Qu

spectrum_normalize

Builtin index · Signal processing

result = spectrum_normalize(X, [scaling="amplitude"])

Input: X, scaling · Output: result

What it is

X: a raw_transform-scaled spectrum; scaling= (optional string, "amplitude" or "rms").

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = spectrum_normalize(X, [scaling="amplitude"])
X —X: a raw_transform-scaled spectrum.
scaling string, optional (default "amplitude")scaling= (optional string, "amplitude" or "rms").
result —
Returns a new spectrum with that convention applied โ€” the same conversion fft/rfft(..., scaling=) do at transform time, usable afterward on a spectrum that already went through band_zero or another raw-bin operation. Errors if X is already normalised โ€” spectrum_unnormalize(X) first if you want a different scaling.

Examples

No documentation example calls this form yet. The Signal processing chapter is where one belongs.

How it works

ยง41.2, frequency side -- the twin of signal_slice_time above: address a spectrum in Hz instead of in bin indices, which is the single most error-prone step in DSP code (round(f * N / fs) written out by hand on every script). These deliberately do NOT include a "slice out a band" verb. Slicing bins would leave bin 0 of the result no longer at DC, silently invalidating .freq -- an axis that lies is worse than no axis. band_zero keeps the full axis intact, and .mag/ .freq return plain vectors that can be sliced safely. spectrum_normalize(X, [scaling="amplitude"]) / spectrum_unnormalize(X) -- convert a Spectrum's bins between SpectrumNorm conventions after the fact, rather than only at fft/rfft(..., scaling=) time. Useful for normalizing a spectrum that already went through band_zero or another raw-bin operation, and required before ifft/irfft/band_power will accept a spectrum that came out of scaling= (they refuse a non-raw one rather than silently treat scaled bins as the unnormalised DFT sum -- see reject_scaled_spectrum).

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.