mtspec.mtspec

mtspec.multitaper.mtspec(data, delta, time_bandwidth, nfft=None, number_of_tapers=None, quadratic=False, adaptive=True, verbose=False, optional_output=False, statistics=False, rshape=False, fcrit=False)[source]

Wrapper method for the mtspec subroutine in the library by German A. Prieto.

This method estimates the adaptive weighted multitaper spectrum, as in Thomson 1982. This is done by estimating the DPSS (discrete prolate spheroidal sequences), multiplying each of the tapers with the data series, take the FFT, and using the adaptive scheme for a better estimation. It outputs the power spectral density (PSD).

Parameters:
  • datanumpy.ndarray Array with the data.
  • delta – float Sample spacing of the data.
  • time_bandwidth – float Time-bandwidth product. Common values are 2, 3, 4 and numbers in between.
  • nfft – int Number of points for fft. If nfft == None, no zero padding will be applied before the fft
  • number_of_tapers – integer, optional Number of tapers to use. Defaults to int(2*time_bandwidth) - 1. This is maximum senseful amount. More tapers will have no great influence on the final spectrum but increase the calculation time. Use fewer tapers for a faster calculation.
  • quadratic – bool, optional Whether or not to caluclate a quadratic multitaper. Will only work if nfft is False or equal to the sample count. The nfft parameter will overwrite the quadratic paramter. Defaults to False.
  • adaptive – bool, optional Whether to use adaptive or constant weighting of the eigenspectra. Defaults to True(adaptive).
  • verbose – bool, optional Passed to the fortran library. Defaults to False.
  • optional_output – bool, optional Calculates and returns additional output parameters. See the notes in the docstring for further details.
  • statistics – bool, optional Calculates and returns statistics. See the notes in the docstring for further details.
  • rshape – integer/None, optional Determines whether or not to perform the F-test for lines. If rshape is 1 or 2, then don’t put the lines back. If rshape is 2 only check around 60 Hz. See the fortran source code for more informations. Defaults to None (do not perform the F-test).
  • fcrit – float/None, optional The threshold probability for the F-test. If none is given, the mtspec library calculates a default value. See the fortran source code for details. Defaults to None.
Returns:

Returns a list with numpy.ndarray. See the note below.

Note

This method will at return at least two arrays: The calculated spectrum and the corresponding frequencies. If optional_output is true it will also return (in the given order) (multidimensional) arrays containing the eigenspectra, the corresponding eigencoefficients and an array containing the weights for each eigenspectra normalized so that the sum of squares over the eigenspectra is one. If statistics is True is will also return (in the given order) (multidimensional) arrays containing the jackknife 5% and 95% confidence intervals, the F statistics for single line and the number of degrees of freedom for each frequency bin. If both optional_output and statistics are true, the optional_outputs will be returned before the statistics.