mixsea.helpers.psd

mixsea.helpers.psd(g, dx, axis=1, ffttype='p', detrend=True, window='hamming', tser_window=None, tser_overlap=None)[source]

Compute power spectral density.

Adapted from Jen MacKinnon.

Parameters:
  • g (array-like) – Real or complex input data of size [M * 1], [1 * M] or [M * N]

  • dx (float) – Distance or time between entries in g

  • axis (int, optional) – Axis along which to fft: 0 = columns, 1 = rows (default)

  • ffttype (str, optional) – Flag for fft type

    • ‘p’ for periodic boundary conditions = pure fft (default)

    • ‘c’ or ‘s’ if the input is a sum of cosines or sines only in which case the input is extended evenly or oddly before ffting.

    • ‘t’ for time series, or any other non-exactly periodic series in which the data should be windowed and filtered before computing the periodogram. In this case you may also specify:

      • tser_window: an integer that gives the length of each window the

      series should be broken up into for filtering and computing the periodogram. Default is length(g).

      • tser_overlap: an integer equal to the lengh of points overlap

      between sucessive windows. Default = tser_window/2, which means 50% overlap.

  • detrend (bool, optional) – Detrend along dim by removing a linear fit using scipy.detrend(). Defaults to True.

  • window (str, optional) – Window type. Default ‘hamming’. See scipy.signal.get_window() for window options.

Returns:

  • Pcw (array-like) – Clockwise power spectral density

  • Pccw (array-like) – Counter-clockwise power spectral density

  • Ptot (array-like) – Total = ccw + cw psd one-sided spectra

  • omega (array-like) – Vector of wavenumbers. For plotting use frequency f = omega/(2*pi).