carriers

package
v0.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package carriers holds protocol-neutral carrier-discovery primitives: finding candidate carriers in a power spectrum and snapping them onto the standard land-mobile channel rasters. It sits below both internal/hunt (the live sweeper) and internal/siglab (the offline wideband survey) so the two share one implementation of the peak detector and channel-grid logic rather than drifting copies — the import direction is carriers ← {hunt, siglab}, never the reverse.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InferGrid

func InferGrid(freqs []uint32) (stepHz, phaseHz uint32)

InferGrid picks the channel raster (step, phase in Hz) that best explains the candidate frequencies. For each standard step it treats the residuals (f mod step) as points on a circle and measures their concentration (mean resultant length); the raster fits when the residuals pile up at one phase. It returns the coarsest step whose residuals are tightly clustered — the coarsest raster the channels genuinely sit on — and that cluster's phase.

With too few candidates, or no step clustering tightly, it falls back to the finest standard step at phase 0: a lone carrier (the 440.125 MHz repro) then still snaps to the nearest 6.25 kHz point, correcting the FFT-bin offset.

func SnapHz

func SnapHz(f, step, phase, maxCorrectionHz uint32) uint32

SnapHz snaps f to the nearest point on the (step, phase) grid, but only when that point is within maxCorrectionHz of f — so a small FFT-bin quantization error is corrected to the true channel centre while a carrier that genuinely sits off the raster (e.g. an analog channel on a different plan) is left where it is. maxCorrectionHz == 0, or step == 0, disables snapping.

Types

type Peak

type Peak struct {
	FreqHz    uint32
	PowerDbFS float32
	SNRDb     float32
}

Peak is a candidate carrier found in a spectrum frame: its absolute frequency, its power, and how far it stands above the estimated noise floor.

func DetectPeaks

func DetectPeaks(frame spectrum.Frame, opts PeakOptions) []Peak

DetectPeaks finds candidate carriers in a spectrum frame. It estimates a robust noise floor (low-quartile of the bin powers), keeps local maxima that stand ThresholdDb above it, drops the DC bin and the band-edge guard bins, and enforces a minimum carrier spacing (stronger peak wins). Bin indices are mapped to absolute Hz using the frame's center and sample rate. Returned peaks are sorted by descending SNR.

type PeakOptions

type PeakOptions struct {
	// ThresholdDb is the minimum power above the estimated noise floor for a
	// local maximum to count as a carrier. 0 ⇒ a sensible default (10 dB).
	ThresholdDb float32
	// MinSpacingHz is the minimum separation between reported peaks; when two
	// maxima fall closer than this the stronger one wins. 0 ⇒ 6.25 kHz (the
	// tightest trunking channel step).
	MinSpacingHz uint32
	// GuardBins drops this many bins at each band edge (rolloff) from
	// consideration. 0 ⇒ a default proportional to the FFT size.
	GuardBins int
}

PeakOptions tune the carrier detector.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL