Dsp Spectrum
dsp_spectrumCompute one-sided FFT amplitude spectra and power spectral density with windowing, Welch averaging, peak detection, and ADC metrics (SNR, SINAD, THD, SFDR, ENOB) from samples or CSV files.
Instructions
One-sided spectrum of a sampled record: amplitude spectrum (an on-bin sine of amplitude A reads A, coherent-gain corrected) and power spectral density (unit^2/Hz), by FFT with a rectangular, hann, hamming, blackman or flattop window, optional Welch averaging (segment_length, overlap_percent), a peak list with parabolic interpolation of frequency and amplitude, and with adc_metrics the single-tone SNR, SINAD, THD (harmonics 2..N), SFDR and ENOB with their definitions. Samples: JSON list in 'samples' or a CSV file (value, or time,value, with an optional header line; 'column' picks one column of a wider file, e.g. the output of dsp_filter_apply) in 'samples_file'; 'unit' (e.g. 'g') is carried to the results; sample_rate with unit unless the file has a time column. Returns bin width, ENBW, leakage/resolution warnings and the spectrum table as CSV (rows bounded, max-hold decimated).
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "dsp_spectrum"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| unit | No | Unit of the samples, e.g. 'g' (standard gravity), 'm/s^2', 'V'; carried to the amplitude, rms and power values; blank = dimensionless | |
| peaks | No | Maximum number of peaks to list, 0..100 (default 5) | |
| column | No | Value column of samples_file, by header name or number (1 = first), e.g. 'output' of dsp_filter_apply; blank = the single value column | |
| window | No | rectangular, hann, hamming, blackman or flattop (default hann) | hann |
| samples | No | Samples as JSON text, e.g. '[0.1, 0.5, -0.2]' (at most 4194304 values). Or use samples_file | |
| harmonics | No | Highest harmonic number counted in THD (2..50, default 5) | |
| table_rows | No | Maximum rows of the spectrum table, 16..20000 (default 2048) | |
| adc_metrics | No | Compute SNR, SINAD, THD, SFDR, ENOB assuming a single tone (default false) | |
| remove_mean | No | Subtract each segment's mean before windowing (default false) | |
| sample_rate | No | Sample rate with unit, e.g. '48 kHz'; optional when the file has a time column | |
| samples_file | No | Path of a CSV/TXT file: one column of values, or two columns time(s),value; numbers only, optional header line | |
| segment_length | No | Welch segment length in samples (8..N); 0 = one FFT of the whole record | |
| overlap_percent | No | Welch overlap in percent, 0 to below 100 (default 50); used with segment_length | |
| peak_threshold_db | No | Only peaks within this many dB below the highest one (default 60) | |
| full_scale_amplitude | No | Converter full-scale peak amplitude in the unit of the samples, for ENOB at less than full scale; 0 = tone assumed at full scale |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | ||
| data | No | Non-quantity payload (reports, listings) | |
| error | No | ||
| value | No | Primary quantity result | |
| values | No | All named quantity results (includes the primary) | |
| warnings | No | ||
| artifacts | No | ||
| provenance | Yes | What produced the result and from which inputs. | |
| review_status | No | unreviewed |