Class Spectrogram
Contains the definition of SAUL’s Spectrogram class.
- class saul.spectral.spectrogram.Spectrogram[source]
A class for calculating and plotting spectrograms of waveforms.
Attributes
- method
See
__init__()- Type:
- win_dur
See
__init__(); only defined ifmethod='scipy'ormethod='multitaper'
- time_bandwidth_product
See
__init__(); only defined ifmethod='multitaper'- Type:
- number_of_tapers
See
__init__(); only defined ifmethod='multitaper'- Type:
- gamma
See
__init__(); only defined ifmethod='s_transform'- Type:
- max_fs
See
__init__(); only defined ifmethod='s_transform'
- data_kind
Input waveform data kind; e.g.,
'infrasound'or'seismic'(inferred from channel code)- Type:
Methods
- __init__(tr_or_st, method='scipy', win_dur=8, time_bandwidth_product=4, number_of_tapers=7, gamma=1, max_fs=10, units='infer')[source]
Create a
Spectrogramobject.The spectrogram of the input waveform is estimated in this method (only a single waveform may be provided). Three spectral estimation approaches are supported: The method implemented by SciPy (
scipy.signal.spectrogram()), the multitaper method (mtspec.spectrogram()), and the \(S\) transform (implemented in the Stockwell package). The input arguments (below) relevant for each method are marked with a [P] for the SciPy method, an [M] for the multitaper method, and an [S] for the \(S\) transform. Arguments corresponding to the non-selected method are ignored.- Parameters:
method (str) – Either
'scipy'[P],'multitaper'[M], or's_transform'[S]win_dur (int or float) – [P] [M] Segment length in seconds. This usually must be adjusted, within the constraints of the total signal duration, to ensure that the longest-period signals of interest are included
time_bandwidth_product (float) – [M] Time-bandwidth product
number_of_tapers (int) – [M] Number of tapers to use
max_fs (int or float) – [S] Maximum allowed sampling rate in hertz. If an input signal has a sampling rate higher than this, it will be downsampled before the \(S\) transform is computed (this saves computation time and memory)
units (str or None) – Units of the input waveform; either
'infer'to guess from input response information, a string explicitly defining the units (see_VALID_UNIT_OPTIONSinsaul.waveform.unitsfor supported options), orNonefor unknown units (e.g., counts)
- plot(db_lim='smart', use_period=False, log_y=False)[source]
Plot the calculated spectrogram.
- Parameters:
- copy()[source]
Return a deep copy of the
Spectrogramobject.