Skip to content

← spectral package

Spectrogram

Calculate a spectrogram (periodogram) of the given data (that is, a time/frequency representation).

The node will compute a new data array with a typically coarser time axis than the original data, and an additional frequency axis, thus yielding an estimate how the spectral content in the data changes over time. This is done using the Short-Time Fourier Transform (STFT). This node estimates the spectrum over multiple successive (and usually overlapping) sub-windows. The parameters of this node allow to trade off time vs. frequency detail, as well as increase the step size along time and/or frequency. See also the tooltips of these parameters to see how they affect the result. This node operates on short segments of data, so in the case of streaming data the data must first be segmented into windows, i.e., using the Segmentation or Moving Window node. This node will then compute a time/frequency representation for each segment it receives. It will not work on continuous streaming data, since each packet received would contain too few samples to perform a spectrogram on. This node can also be used on "offline" (non-streaming) data, in which case the spectrogram will be computed over the entire dataset at once. More Info... Version 1.2.0

Ports/Properties

data

Data to process.

verbose name
Data
default value
None
port type
DataPort
value type
Packet (can be None)
data direction
INOUT

segment_samples

Length of the sub-windows for spectral estimation. This node will extract successive windows from the given data of this length, which are overlapped according to the overlap samples parameter. Longer windows will give a higher-resolution spectrum, but at the same time the result will increase the smoothness (i.e., blurriness) along the time axis. The tradeoff between time resolution and frequency resolution that can be adjusted via this parameter is fundamental. If unspecified, defaults to 0.5 seconds of data (or equivalent in samples) based on the sampling rate. If specified in seconds, the specified value will be converted to samples at runtime based on the sampling rate of the incoming data.

verbose name
Sub-Window Length
default value
None
port type
FloatPort
value type
float (can be None)

unit

Unit in which the sub-window length is expressed.

verbose name
Unit Used For Sub-Window Length.
default value
samples
port type
EnumPort
value type
str (can be None)

overlap_samples

Overlap between successive sub-windows, expressed as a fraction of the sub-window length. This determines by how much successive sub-windows are overlapped. Using a higher value will yield finer stepping in time without a change in temporal or frequency detail (since the time axis will be correspondingly more smooth to counter the finer stepping). If unspecified, defaults to half of the sub-window length. If the sub-window length is expressed in samples, this value can also be expressed in samples.

verbose name
Overlap Between Sub-Windows
default value
None
port type
FloatPort
value type
float (can be None)

fft_size

Length of the FFT used, in samples. Using a higher number will yield a finer stepping along the frequency axis, without a change in frequency or temporal detail (the frequency axis will be correspondingly more smooth to counter the finer stepping). If not given, it defaults to the sub-window length.

verbose name
Fft Size
default value
None
port type
IntPort
value type
int (can be None)

window

Type of window function to apply to sub-windows. Different functions have different spectral and temporal localization characteristics. One of the simplest well-behaved windows is the Hann window (the default).

verbose name
Window Function For Sub-Windows
default value
hann
port type
EnumPort
value type
str (can be None)

detrend

Sub-window detrending method. In the Welch method, linear trends or constant offsets can be removed from each window prior to spectral estimation.

verbose name
Sub-Window Detrending
default value
off
port type
EnumPort
value type
str (can be None)

onesided

Return one-sided spectrum. If disabled, a two-sided (meaning: symmetric about the middle) spectrum will be computed, which is redundant for real-valued data, but required for complex-valued data (for complex data, the spectrum is always two-sided.

verbose name
Onesided Spectrum For Real-Valued Data
default value
True
port type
BoolPort
value type
bool (can be None)

scaling

Scaling of the spectrum. In density mode, the result is divided by the frequency; this yields the power-spectral density, and is the default. However, this will incur a falloff towards higher frequencies which may be addressed separately using the frequency normalization node.

verbose name
Spectral Scaling Mode
default value
density
port type
EnumPort
value type
str (can be None)

use_caching

Enable caching. This will significantly speed up re-use of the same data. For offline data only.

verbose name
Use Caching
default value
False
port type
BoolPort
value type
bool (can be None)

set_breakpoint

Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

verbose name
Set Breakpoint (Debug Only)
default value
False
port type
BoolPort
value type
bool (can be None)

metadata

User-definable meta-data associated with the node. Usually reserved for technical purposes.

verbose name
Metadata
default value
{}
port type
DictPort
value type
dict (can be None)