freq_map¶
MATLAB equivalent:
sidFreqMap
freq_map ¶
Time-varying frequency response map via segmented spectral analysis.
freq_map ¶
freq_map(y: ndarray | list, u: ndarray | list | None = None, *, segment_length: int | None = None, overlap: int | None = None, algorithm: str = 'bt', sample_time: float = 1.0, window_size: int | None = None, frequencies: ndarray | None = None, sub_segment_length: int | None = None, sub_overlap: int | None = None, window: str | ndarray = 'hann', nfft: int | None = None) -> FreqMapResult
Estimate a time-varying frequency response map.
Estimates G(omega, t) by applying spectral analysis to overlapping segments of input-output data. For a linear time-invariant (LTI) system the map is constant along time; for a linear time-varying (LTV) system it reveals how the transfer function, noise spectrum, and coherence evolve.
Two inner estimation algorithms are supported:
'bt'(default) -- Blackman-Tukey correlogram via :func:sid.freq_bt.'welch'-- Welch averaged periodogram.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y
|
ndarray or list of ndarray, shape (N, ny) or (N, ny, L)
|
Output data. A 1-D array is treated as a single-channel signal.
For multiple trajectories pass a 3-D array |
required |
u
|
ndarray, list of ndarray, or None
|
Input data. Same shape conventions as y. Pass |
None
|
segment_length
|
int
|
Number of samples per outer segment L. Must be >= 4.
Default: |
None
|
overlap
|
int
|
Overlap P between segments, |
None
|
algorithm
|
str
|
|
'bt'
|
sample_time
|
float
|
Sample time in seconds. Must be positive. Default is |
1.0
|
window_size
|
int
|
(BT only) Hann lag window size M.
Default: |
None
|
frequencies
|
(ndarray, shape(nf))
|
(BT only) Frequency vector in rad/sample, in |
None
|
sub_segment_length
|
int
|
(Welch only) Sub-segment length within each outer segment.
Default: |
None
|
sub_overlap
|
int
|
(Welch only) Sub-segment overlap.
Default: |
None
|
window
|
str or ndarray
|
(Welch only) |
'hann'
|
nfft
|
int
|
(Welch only) FFT length.
Default: |
None
|
Returns:
| Type | Description |
|---|---|
FreqMapResult
|
Frozen dataclass with fields:
|
Raises:
| Type | Description |
|---|---|
SidError
|
If |
SidError
|
If |
SidError
|
If |
SidError
|
If |
SidError
|
If |
SidError
|
If data is too short for even one segment
(code: |
Examples:
Time-varying frequency map (Blackman-Tukey):
>>> import numpy as np
>>> import sid
>>> N = 4000; rng = np.random.default_rng(0)
>>> u = rng.standard_normal(N)
>>> from scipy.signal import lfilter
>>> y = lfilter([1], [1, -0.9], u) + 0.1 * rng.standard_normal(N)
>>> result = sid.freq_map(y, u, segment_length=512)
Time-varying spectrum (time-series, Welch):
Notes
Algorithm (outer segmentation + inner estimator):
- Validate and orient data; detect time-series / SISO / MIMO.
- Divide the data into K overlapping segments of length L
with stride
L - P. - For each segment, apply either the Blackman-Tukey or Welch inner estimator.
- Stack the per-segment results into 2-D / 4-D arrays indexed by
(frequency, segment).
Specification: SPEC.md S6 -- Time-Varying Frequency Response Map
See Also
sid.freq_bt : Blackman-Tukey spectral analysis (inner estimator). sid.map_plot : Surface / image plot of a FreqMapResult. sid.spectrogram : Short-time FFT spectrogram.
Changelog
2026-04-08 : First version (Python port) by Pedro Lourenco.