spec2d

kgpy.fft.power.spec2d(data, sub_image_size=16, retain_dc=False)

This is a port of CCK’s spec2d.pro to Python 3. Ported to Python by NCG, 2020-07-30

Compute the power spectra of a 2D array by dividing into many overlapping sub-images and averaging their power spectra. This impproves the estiate at the expense of spectral resolution. This is a 2d analog of powerspec, which uses Welch’s method with a Hanning window. Any sub-image containing NaN is ignored by np.nanmean

Parameters:
  • data (numpy.ndarray) – 2D array of data

  • sub_image_size (int) – size of the square sub-image to analyze. Default is 16, min is 4

  • retain_dc (bool) – if True, then retain the DC offset when calculating the power spectrum. Ordinarily, the DC offset is subtracted before calculating the spectrum, because the Hanning window tends to make the offset bleed into the nearest neighbor of pixel (0, 0) of the 2D power spectrum.

Returns: