ezmsg.sigproc.spectrum#
Functions
- spectrum(axis=None, out_axis='freq', window=WindowFunction.HANNING, transform=SpectralTransform.REL_DB, output=SpectralOutput.POSITIVE, norm='forward', do_fftshift=True, nfft=None)[source]#
Calculate a spectrum on a data slice.
- Returns:
A
SpectrumTransformerobject that expects anAxisArrayvia .(axis_array) (__call__) containing continuous data and returns anAxisArraywith data of spectral magnitudes or powers.- Parameters:
axis (str | None)
out_axis (str | None)
window (WindowFunction)
transform (SpectralTransform)
output (SpectralOutput)
norm (str | None)
do_fftshift (bool)
nfft (int | None)
- Return type:
Classes
- class OptionsEnum(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
Enum
- class SpectralOutput(*values)[source]#
Bases:
OptionsEnumThe expected spectral contents.
- FULL = 'Full Spectrum'#
- POSITIVE = 'Positive Frequencies'#
- NEGATIVE = 'Negative Frequencies'#
- class SpectralTransform(*values)[source]#
Bases:
OptionsEnumAdditional transformation functions to apply to the spectral result.
- RAW_COMPLEX = 'Complex FFT Output'#
- REAL = 'Real Component of FFT'#
- IMAG = 'Imaginary Component of FFT'#
- REL_POWER = 'Relative Power'#
- REL_DB = 'Log Power (Relative dB)'#
- class Spectrum(*args, settings=None, **kwargs)[source]#
Bases:
BaseTransformerUnit[SpectrumSettings,AxisArray,AxisArray,SpectrumTransformer]- Parameters:
settings (Settings | None)
- SETTINGS#
alias of
SpectrumSettings
- class SpectrumSettings(axis=None, out_axis='freq', window=WindowFunction.HAMMING, transform=SpectralTransform.REL_DB, output=SpectralOutput.POSITIVE, norm='forward', do_fftshift=True, nfft=None)[source]#
Bases:
SettingsSettings for
Spectrum. See :obj:`spectrumfor a description of the parameters.- Parameters:
axis (str | None)
out_axis (str | None)
window (WindowFunction)
transform (SpectralTransform)
output (SpectralOutput)
norm (str | None)
do_fftshift (bool)
nfft (int | None)
- axis: str | None = None#
The name of the axis on which to calculate the spectrum. Note: The axis must have an .axes entry of type LinearAxis, not CoordinateAxis.
- out_axis: str | None = 'freq'#
The name of the new axis. Defaults to “freq”. If none; don’t change dim name
- window: WindowFunction = 'Hamming'#
The
WindowFunctionto apply to the data slice prior to calculating the spectrum.
- transform: SpectralTransform = 'Log Power (Relative dB)'#
The
SpectralTransformto apply to the spectral magnitude.
- output: SpectralOutput = 'Positive Frequencies'#
The
SpectralOutputformat.
- norm: str | None = 'forward'#
Normalization mode. Default “forward” is best used when the inverse transform is not needed, for example when the goal is to get spectral power. Use “backward” (equivalent to None) to not scale the spectrum which is useful when the spectra will be manipulated and possibly inverse-transformed. See numpy.fft.fft for details.
- do_fftshift: bool = True#
Whether to apply fftshift to the output. Default is True. This value is ignored unless output is SpectralOutput.FULL.
- nfft: int | None = None#
The number of points to use for the FFT. If None, the length of the input data is used.
- __init__(axis=None, out_axis='freq', window=WindowFunction.HAMMING, transform=SpectralTransform.REL_DB, output=SpectralOutput.POSITIVE, norm='forward', do_fftshift=True, nfft=None)#
- Parameters:
axis (str | None)
out_axis (str | None)
window (WindowFunction)
transform (SpectralTransform)
output (SpectralOutput)
norm (str | None)
do_fftshift (bool)
nfft (int | None)
- Return type:
None
- class SpectrumTransformer(*args, **kwargs)[source]#
Bases:
BaseStatefulTransformer[SpectrumSettings,AxisArray,AxisArray,SpectrumState]
- class WindowFunction(*values)[source]#
Bases:
OptionsEnumWindowing function prior to calculating spectrum.
- NONE = 'None (Rectangular)'#
None.
- HAMMING = 'Hamming'#
- HANNING = 'Hanning'#
- BARTLETT = 'Bartlett'#
- BLACKMAN = 'Blackman'#
- class OptionsEnum(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Bases:
Enum
- class WindowFunction(*values)[source]#
Bases:
OptionsEnumWindowing function prior to calculating spectrum.
- NONE = 'None (Rectangular)'#
None.
- HAMMING = 'Hamming'#
- HANNING = 'Hanning'#
- BARTLETT = 'Bartlett'#
- BLACKMAN = 'Blackman'#
- class SpectralTransform(*values)[source]#
Bases:
OptionsEnumAdditional transformation functions to apply to the spectral result.
- RAW_COMPLEX = 'Complex FFT Output'#
- REAL = 'Real Component of FFT'#
- IMAG = 'Imaginary Component of FFT'#
- REL_POWER = 'Relative Power'#
- REL_DB = 'Log Power (Relative dB)'#
- class SpectralOutput(*values)[source]#
Bases:
OptionsEnumThe expected spectral contents.
- FULL = 'Full Spectrum'#
- POSITIVE = 'Positive Frequencies'#
- NEGATIVE = 'Negative Frequencies'#
- class SpectrumSettings(axis=None, out_axis='freq', window=WindowFunction.HAMMING, transform=SpectralTransform.REL_DB, output=SpectralOutput.POSITIVE, norm='forward', do_fftshift=True, nfft=None)[source]#
Bases:
SettingsSettings for
Spectrum. See :obj:`spectrumfor a description of the parameters.- Parameters:
axis (str | None)
out_axis (str | None)
window (WindowFunction)
transform (SpectralTransform)
output (SpectralOutput)
norm (str | None)
do_fftshift (bool)
nfft (int | None)
- axis: str | None = None#
The name of the axis on which to calculate the spectrum. Note: The axis must have an .axes entry of type LinearAxis, not CoordinateAxis.
- out_axis: str | None = 'freq'#
The name of the new axis. Defaults to “freq”. If none; don’t change dim name
- window: WindowFunction = 'Hamming'#
The
WindowFunctionto apply to the data slice prior to calculating the spectrum.
- transform: SpectralTransform = 'Log Power (Relative dB)'#
The
SpectralTransformto apply to the spectral magnitude.
- output: SpectralOutput = 'Positive Frequencies'#
The
SpectralOutputformat.
- norm: str | None = 'forward'#
Normalization mode. Default “forward” is best used when the inverse transform is not needed, for example when the goal is to get spectral power. Use “backward” (equivalent to None) to not scale the spectrum which is useful when the spectra will be manipulated and possibly inverse-transformed. See numpy.fft.fft for details.
- do_fftshift: bool = True#
Whether to apply fftshift to the output. Default is True. This value is ignored unless output is SpectralOutput.FULL.
- nfft: int | None = None#
The number of points to use for the FFT. If None, the length of the input data is used.
- __init__(axis=None, out_axis='freq', window=WindowFunction.HAMMING, transform=SpectralTransform.REL_DB, output=SpectralOutput.POSITIVE, norm='forward', do_fftshift=True, nfft=None)#
- Parameters:
axis (str | None)
out_axis (str | None)
window (WindowFunction)
transform (SpectralTransform)
output (SpectralOutput)
norm (str | None)
do_fftshift (bool)
nfft (int | None)
- Return type:
None
- class SpectrumTransformer(*args, **kwargs)[source]#
Bases:
BaseStatefulTransformer[SpectrumSettings,AxisArray,AxisArray,SpectrumState]
- class Spectrum(*args, settings=None, **kwargs)[source]#
Bases:
BaseTransformerUnit[SpectrumSettings,AxisArray,AxisArray,SpectrumTransformer]- Parameters:
settings (Settings | None)
- SETTINGS#
alias of
SpectrumSettings
- spectrum(axis=None, out_axis='freq', window=WindowFunction.HANNING, transform=SpectralTransform.REL_DB, output=SpectralOutput.POSITIVE, norm='forward', do_fftshift=True, nfft=None)[source]#
Calculate a spectrum on a data slice.
- Returns:
A
SpectrumTransformerobject that expects anAxisArrayvia .(axis_array) (__call__) containing continuous data and returns anAxisArraywith data of spectral magnitudes or powers.- Parameters:
axis (str | None)
out_axis (str | None)
window (WindowFunction)
transform (SpectralTransform)
output (SpectralOutput)
norm (str | None)
do_fftshift (bool)
nfft (int | None)
- Return type: