measure_spectrum()#

InstroSDR.measure_spectrum(
n_samples: int = 1024,
*,
channels: Sequence[str] | None = None,
**kwargs: Any,
) → Measurement | None[source]#

Acquire one block and publish four scalar spectrum features per channel.

Publishes spectrum.peak_power_db, spectrum.peak_freq_hz (Hz), spectrum.mean_power_db, and spectrum.occupied_bw_hz (Hz, the band holding 99% of total power). The spectrum array itself is not published; use compute_psd for it.

Parameters:
  • n_samples (int) – Samples per channel.

  • channels (Sequence[str] | None) – Receive channels to analyze. None means every channel the running stream covers, or ("0",) with no stream running.

  • **kwargs – Tags added to the published value, on top of the instrument’s default tags.

Returns:

Measurement | None – The published features, or None if the read returned no samples.

Raises:

ValueError – If n_samples is not positive.