File correlator_core.h¶
FileList > correlator > correlator_core.h
Go to the source code of this file
The one FFT cross-correlator, with coherent integrate-and-dump. More...
#include "doppler/clib_common.h"#include "doppler/dp_parallel.h"#include "doppler/dp_state.h"#include "doppler/f32_buffer/f32_buffer_core.h"#include "doppler/fft/fft_core.h"#include "doppler/fft2d/fft2d_core.h"#include "doppler/cvt/cvt_core.h"#include "doppler/detection/detection_core.h"#include "doppler/dp_tlm/dp_tlm_core.h"#include "doppler/jm_perf.h"
Classes¶
| Type | Name |
|---|---|
| struct | det_peak_t One listed peak of a surface: a cell and its value, in the surface's own units (a magnitude on a coherent surface, a power on a non-coherent one). What det_peak_list() ( correlator_private.h ) returns, and what the acquisition engine keeps per dwell. |
| struct | dp_correlator_fold_t A C reducer: called once per map, in h order, by dp_correlator_execute_fold() . |
| struct | dp_correlator_handoff_t Wire-ready hand-off record built from one dp_correlator_hit_t hit. |
| struct | dp_correlator_hit_t One detection, from any detector or search flavor's dp_correlator_push() . |
| struct | dp_correlator_part_t One tile's share of a decided surface (docs/design/acq-surface.md §13): the surface is cut into window_bins chunks of whole rows, and the per-cell passes after the fan the magnitude, the CFAR reference, the mask copy, each scan of the peak list run per chunk into one of these, merged serially in tile order. The merge is bit-identical at any thread count because the chunks never move. |
| struct | dp_correlator_search The search flavors' policy: everything the two search constructors add on top of the four layers (docs/design/archive/correlator-step3.md section 7, 3.4b). Held by dp_correlator_state_t::search , allocated once at create; NULL in every other flavor. |
| struct | dp_correlator_shape_t What the engine knows about the SHAPE of the repeated preamble, beyond its samples (doppler#1470). |
| struct | dp_correlator_state_t Correlator state, every flavor. |
| struct | dp_correlator_tlm_t Telemetry attachment: a borrowed context + this engine's probe ids (docs/design/async-dsss-receiver.md §2.4). NULL ctx (the default) means detached — the one probe site is then a single predicted-not-taken branch per decided dwell. Never in a state blob; preserved across dp_correlator_set_state() like the borrowed code. |
Public Types¶
| Type | Name |
|---|---|
| enum | det_noise_mode_t How a detector flavor aggregates the noise floor from the correlation magnitudes over the flat bins noise_lo to noise_hi, inclusive. |
| enum | dp_correlator_flavor_t Which constructor built a correlator. |
| enum | dp_correlator_framing_t How dp_correlator_create() frames its input: maps or detections from whole frames, or a search over a stream. |
| typedef struct dp_correlator_search | dp_correlator_search_t The search flavors' policy: everything the two search constructors add on top of the four layers (docs/design/archive/correlator-step3.md section 7, 3.4b). Held by dp_correlator_state_t::search , allocated once at create; NULL in every other flavor. |
| typedef void(* | dp_correlator_surface_sink_fn A surface sink: called once per decided dwell (every decim -th) with the dwell's surface in test-statistic units, row-majorrows xcols (Doppler rows by code-phase columns), and the dwell'ssamples_consumed . The pointer is the engine's and is valid only for the call. Seedp_correlator_set_surface_sink() . |
Public Functions¶
| Type | Name |
|---|---|
| size_t | dp_correlator_bank_detect (const dp_correlator_state_t * state, const float _Complex * x, size_t x_len, size_t L_d, size_t L_r, int g_min, int g_max, float t_candidate, float t_confirm, const float _Complex * rates, size_t rates_len, float * out, int32_t * out1, uint32_t * out2, uint32_t * out3, uint32_t * out4, size_t max_out, int * status, const char ** why) Detect on a coarse carrier grid, refine each candidate at its own cell on a fine one, and keep what confirms. |
| size_t | dp_correlator_bank_detect_max_out (dp_correlator_state_t * state, size_t x_len) Capacity dp_correlator_bank_detect() needs: one record per map cell. |
| size_t | dp_correlator_bank_fold (const dp_correlator_state_t * state, const float _Complex * x, size_t x_len, size_t L, int g_min, int g_max, const float _Complex * rates, size_t rates_len, const dp_correlator_fold_t * fold) Run one frame through a bank of carrier and rate hypotheses and hand each map to a reducer. |
| size_t | dp_correlator_bank_power_max (const dp_correlator_state_t * state, const float _Complex * x, size_t x_len, size_t L, int g_min, int g_max, const float _Complex * rates, size_t rates_len, float * out, uint32_t * out1, size_t max_out, int * status, const char ** why) The strongest power at every cell over a bank, and which hypothesis it came from. |
| size_t | dp_correlator_bank_power_max_max_out (dp_correlator_state_t * state, size_t x_len) Capacity dp_correlator_bank_power_max() needs: one map. |
| size_t | dp_correlator_block_prompt (dp_correlator_state_t * state, size_t tile, size_t col, float _Complex * out, size_t n_out) One cell's column of the last whole block: the per-epoch complex correlations at a code phase, the despread stream at epoch rate. |
| size_t | dp_correlator_block_raw (dp_correlator_state_t * state, float _Complex * out, size_t n_out) The last whole block's raw samples, as pushed. |
| void | dp_correlator_build_handoff (const dp_correlator_state_t * state, const dp_correlator_hit_t * hit, size_t code_len, dp_correlator_handoff_t * out) Convert one dp_correlator_push() hit into a wire-ready hand-off record. |
| int | dp_correlator_carrier_freq_ok (double carrier_freq_hz, double sample_rate_hz) Whether carrier_freq_hz is a carrier the code can be coupled to atsample_rate_hz: 0 (uncoupled), or finite and above half the sample rate. |
| double _Complex | dp_correlator_cell_corr (const dp_correlator_state_t * state, const float _Complex * x, size_t col, double f_hz, double t0) One epoch's correlation against the replica at ONE code phase and ONE frequency: the engine's surface, evaluated at a single cell, on raw samples. |
| void | dp_correlator_cell_corr_grid (const dp_correlator_state_t * state, const float _Complex * x, size_t n_epochs, size_t col, const double * f_hz, size_t n_f, double t0, double _Complex * out) dp_correlator_cell_corr() at many frequencies over consecutive epochs, in one pass: the cells a caller scores once the code phase is settled and only the Doppler is left to search. |
| int | dp_correlator_configure_search_raw (dp_correlator_state_t * state, size_t doppler_bins, size_t n_noncoh, const char ** why) Pin the search grid directly, bypassing both auto-sizing searches — the advanced escape hatch (mirrors Dll's/Costas's configure_lock_raw()). |
| size_t | dp_correlator_consumed (const dp_correlator_state_t * state) Input samples the last dp_correlator_push() took. |
| dp_correlator_state_t * | dp_correlator_create (const float _Complex * ref, size_t ny, size_t nx, dp_correlator_framing_t framing, size_t doppler_rows, int detect, size_t dwell, size_t ny_out, size_t nx_out, int col_out, float threshold, size_t noise_lo, size_t noise_hi, int noise_mode, double sample_rate, double chip_rate, double symbol_rate, size_t reps, double cn0_dbhz, double doppler_uncertainty, double pfa, double pd, double doppler_rate, size_t rate_hypotheses, size_t code_only_epochs, int nthreads, const char ** why) Build the flavor the knobs name: the one constructor the Python class Correlator calls. |
| dp_correlator_state_t * | dp_correlator_create_1d (const float _Complex * ref, size_t ref_len, size_t dwell, int nthreads, size_t n_out) Allocate a 1-D FFT correlator with coherent integrate-and-dump. Pre-computes conj(FFT(ref)) once at construction so each execute() call costs only two FFTs and n complex multiplies. ref may be freed after this returns. Withdwell == 1 every call produces output; with larger values the accumulator absorbsdwell frames before dumping. |
| dp_correlator_state_t * | dp_correlator_create_2d (const float _Complex * ref, size_t ny, size_t nx, size_t dwell, int nthreads, size_t ny_out, size_t nx_out, int col_out) Allocate a 2-D FFT correlator with coherent integrate-and-dump. Two-dimensional extension of dp_correlator_create_1d() . The reference is a flat row-major ny×nx CF32 array; its conjugate spectrum is pre-computed once so each execute() call costs two 2-D FFTs plus ny*nx complex multiplies. The Python wrapper requires ref to be a 2-D ndarray with shape (ny, nx); it passes a flat view to C. |
| dp_correlator_state_t * | dp_correlator_create_burst (const float _Complex * tmpl, size_t n, size_t reps, double fs, double cn0_dbhz, double doppler_uncertainty, double pfa, double pd, int noise_mode, double doppler_rate, size_t rate_hypotheses) Create a burst-mode acquisition engine for a repeated preamble: coherent multi-repetition combining, up to reps deep. |
| dp_correlator_state_t * | dp_correlator_create_continuous (const uint8_t * code, size_t code_len, double sample_rate, double chip_rate, double symbol_rate, double cn0_dbhz, double doppler_uncertainty, double pfa, double pd, int noise_mode, size_t code_only_epochs, double doppler_rate) Create a continuous-mode acquisition engine: always wideband window-tiling, allowing a block-coherent depth inside the tiles to accommodate waveforms with code-only windows. |
| dp_correlator_state_t * | dp_correlator_create_delay_doppler (const float _Complex * code, size_t code_len, size_t ny, size_t dwell, int nthreads, size_t ny_out) Allocate the delay-Doppler flavor: a code correlator that maps a raw stream of ny code periods onto (Doppler, delay). |
| dp_correlator_state_t * | dp_correlator_create_detector_1d (const float _Complex * ref, size_t ref_len, size_t dwell, size_t noise_lo, size_t noise_hi, det_noise_mode_t noise_mode, float threshold, int nthreads) Allocate a 1-D streaming detector: the 2-D detector at one row (docs/design/correlator.md section 2), so its hits are the 2-D one's at ny = 1, each with row 0 and the lag in col. |
| dp_correlator_state_t * | dp_correlator_create_detector_2d (const float _Complex * ref, size_t ny, size_t nx, size_t dwell, size_t noise_lo, size_t noise_hi, det_noise_mode_t noise_mode, float threshold, int nthreads) Allocate a 2-D streaming detector: the 2-D correlator with the stream and detection layers. |
| void | dp_correlator_destroy (dp_correlator_state_t * state) Destroy and free a correlator, any flavor. |
| double | dp_correlator_dsl_db (dp_correlator_state_t * state) The search's Doppler-offset sidelobe level, dB: 20*log10 of the largest lag of the code's periodic ambiguity outside the mainlobe, at any Doppler offset the grid's tiles can put between an emitter and a tile, relative to the emitter's own peak ( dp_correlator_shape_t::dsl ). |
| size_t | dp_correlator_execute (dp_correlator_state_t * state, const float _Complex * in, size_t n_in, float _Complex * out, size_t max_out, const char ** why) Correlate one 2-D frame and optionally dump the coherent accumulator. Runs the 2-D pipeline: FFT2 → pointwise multiply with ref_spec → accumulate the cross-spectrum; on dump, IFFT2 → normalise (÷ ny*nx). Accumulating in the frequency domain and inverting once is exactly the per-frame inverse summed, by linearity of the IFFT — valid because the dwell is coherent (a complex sum); a non-coherent (magnitude) integration could not defer the inverse. |
| size_t | dp_correlator_execute_all (dp_correlator_state_t * state, const float _Complex * in, size_t n_in, float _Complex * out, size_t max_out, const char ** why) Every map of a batch, unreduced: row h of the (H, n_out) result is the map of frame h (in C, map h is at out + h * n_out ). |
| size_t | dp_correlator_execute_all_max_out (const dp_correlator_state_t * state, size_t n_in) Samples dp_correlator_execute_all() writes for n_in input samples: H * n_out, H = n_in / (ny * nx). |
| size_t | dp_correlator_execute_coherent (dp_correlator_state_t * state, const float _Complex * in, size_t n_in, float _Complex * out, size_t max_out, const char ** why) The coherent sum of a batch's maps, inverted once. |
| size_t | dp_correlator_execute_coherent_max_out (const dp_correlator_state_t * state) Samples dp_correlator_execute_coherent() writes: n_out. |
| size_t | dp_correlator_execute_fold (dp_correlator_state_t * state, const float _Complex * in, size_t n_in, const dp_correlator_fold_t * fold) Make the map of every frame in a batch and hand each to a reducer. |
| size_t | dp_correlator_execute_max_out (dp_correlator_state_t * state) Maximum output samples per execute call ( dp_correlator_state_t::n_out __ ny_out*nx_out normally, or ny when a singledp_correlator_state_t::col_out was selected). |
| size_t | dp_correlator_execute_peaks (dp_correlator_state_t * state, const float _Complex * in, size_t n_in, float * out, uint32_t * out1, uint32_t * out2, float * out3, size_t max_out, const char ** why) One record per map of a batch: its peak power, where the peak is, and its mean power. |
| size_t | dp_correlator_execute_peaks_max_out (const dp_correlator_state_t * state, size_t n_in) Records dp_correlator_execute_peaks() writes for n_in samples: H. |
| size_t | dp_correlator_execute_power_max (dp_correlator_state_t * state, const float _Complex * in, size_t n_in, float * out, uint32_t * out1, size_t max_out, const char ** why) The largest power over a batch's maps, cell by cell, and the map it came from. |
| size_t | dp_correlator_execute_power_max_max_out (const dp_correlator_state_t * state) Values per output dp_correlator_execute_power_max() writes: n_out. |
| size_t | dp_correlator_execute_power_sum (dp_correlator_state_t * state, const float _Complex * in, size_t n_in, float * out, size_t max_out, const char ** why) The power of a batch's maps, summed cell by cell: each output cell is the sum over h of that cell's |map_h|^2 , summed in h order in float. |
| size_t | dp_correlator_execute_power_sum_max_out (const dp_correlator_state_t * state) Powers dp_correlator_execute_power_sum() writes: n_out. |
| dp_correlator_flavor_t | dp_correlator_flavor (const dp_correlator_state_t * state) Which constructor built state: whatdp_correlator_create() chose from its knobs, so a caller can ask before reading a member only some flavors serve. |
| double | dp_correlator_gate_stat (const dp_correlator_state_t * state) The gate a dwell's statistic must clear to be a hit, in the units of dp_correlator_hit_t::test_stat : threshold on the coherent path (one look),eta_nc on the non-coherent one. A dwell hits when its strongest cell's statistic exceeds this, and every listed peak's statistic does too. Both statistics are linear in the cell's amplitude, so a list consumer can compare a peak's excess over another's against it in the same units. Configuration: fixed by the thresholds the grid was sized with. |
| int | dp_correlator_get_carrier_freq_hz (const dp_correlator_state_t * state, double * out) RF carrier the Doppler is coupled to, Hz (0.0 = uncoupled); set with set_carrier_freq_hz(). |
| int | dp_correlator_get_chip_rate (const dp_correlator_state_t * state, double * out) Chip rate, Hz. |
| int | dp_correlator_get_cn0_dbhz (const dp_correlator_state_t * state, double * out) Carrier-to-noise density the search was sized for, dB-Hz; NaN for no design point (the burst search only). |
| int | dp_correlator_get_code_bins (const dp_correlator_state_t * state, size_t * out) One period of the reference in samples: the length of every forward transform and of a raw epoch. |
| int | dp_correlator_get_coherent_bins (const dp_correlator_state_t * state, size_t * out) The block-coherent depth D inside every window tile: epochs per block and Doppler rows per tile. 1 without a code-only window. |
| int | dp_correlator_get_col_out (const dp_correlator_state_t * state, int * out) The one lag a dump emits per row, or -1 for every lag. |
| int | dp_correlator_get_count (const dp_correlator_state_t * state, size_t * out) Frames accumulated toward the next dump (0 ... dwell - 1). |
| int | dp_correlator_get_doppler_bins (const dp_correlator_state_t * state, size_t * out) Doppler hypotheses searched, window tiles times the coherent depth: the count to fold a hit's row over (bin_to_signed(row, doppler_bins) * doppler_res_hz is the signed Doppler). |
| int | dp_correlator_get_doppler_rate (const dp_correlator_state_t * state, double * out) Doppler rate the coherent depth is bounded against, Hz/s (0 = no bound); with rate_hypotheses > 1, the span of the hypotheses. |
| int | dp_correlator_get_doppler_res_hz (const dp_correlator_state_t * state, double * out) Doppler bin width, Hz. |
| int | dp_correlator_get_doppler_span_hz (const dp_correlator_state_t * state, double * out) Native unambiguous Doppler half-range, Hz: sample_rate / (2 * code_bins). |
| int | dp_correlator_get_doppler_step (const dp_correlator_state_t * state, double * out) Doppler bin width of the delay-Doppler map, cycles per sample. |
| int | dp_correlator_get_dwell (const dp_correlator_state_t * state, size_t * out) Integration depth: a dump every dwell frames. |
| int | dp_correlator_get_epochs_per_symbol (const dp_correlator_state_t * state, double * out) (chip_rate / sf) / symbol_rate: code epochs per data symbol; 0 when symbol_rate is 0. |
| int | dp_correlator_get_eta (const dp_correlator_state_t * state, float * out) Raw per-cell Rayleigh amplitude threshold. |
| int | dp_correlator_get_eta_nc (const dp_correlator_state_t * state, float * out) Non-coherent CFAR threshold (order-N_nc Marcum). |
| int | dp_correlator_get_keep_surface (const dp_correlator_state_t * state, int * out) Whether every decided dwell's surface is kept for dp_correlator_surface() : 1 or 0. |
| int | dp_correlator_get_lag_bins (const dp_correlator_state_t * state, size_t * out) Code-phase columns of the surface: code_bins unless code_bins is not 7-smooth, then the next power of two (an exact interpolation). surface_chip_phase() gives each column in chips. |
| int | dp_correlator_get_max_peaks (const dp_correlator_state_t * state, size_t * out) The peak list's capacity per dwell (1 = the classic gated maximum); set with set_max_peaks(). |
| int | dp_correlator_get_n (const dp_correlator_state_t * state, size_t * out) Frame length in samples: the reference's length, ny * nx. |
| int | dp_correlator_get_n_held (const dp_correlator_state_t * state, size_t * out) Picks of the last decided dwell held as same-code-phase twins rather than listed (docs/design/async-dsss-receiver.md section 7.1). |
| int | dp_correlator_get_n_noncoh (const dp_correlator_state_t * state, size_t * out) Non-coherent looks per detection (1 = pure coherent). |
| int | dp_correlator_get_n_peaks (const dp_correlator_state_t * state, size_t * out) Picks in the last decided dwell, held twins included. |
| int | dp_correlator_get_noise_hi (const dp_correlator_state_t * state, size_t * out) Last noise (CFAR reference) bin, inclusive. |
| int | dp_correlator_get_noise_lo (const dp_correlator_state_t * state, size_t * out) First noise (CFAR reference) bin, inclusive. |
| int | dp_correlator_get_nx (const dp_correlator_state_t * state, size_t * out) Samples a reference row: the correlation's native lag count. |
| int | dp_correlator_get_nx_out (const dp_correlator_state_t * state, size_t * out) Lags a dump writes per row: nx unless padded (nx_out), which interpolates the lag axis. The one padding name at any row count. |
| int | dp_correlator_get_ny (const dp_correlator_state_t * state, size_t * out) Rows of the reference: 1 for a 1-D one; the delay-Doppler map's Doppler rows (doppler_rows). |
| int | dp_correlator_get_ny_out (const dp_correlator_state_t * state, size_t * out) Rows a dump writes: ny unless padded (ny_out), which interpolates the Doppler or row axis. |
| int | dp_correlator_get_pd (const dp_correlator_state_t * state, double * out) Target detection probability. |
| int | dp_correlator_get_pd_burst (const dp_correlator_state_t * state, double * out) Predicted Pd of one burst of reps repetitions at cn0_dbhz: the number the sizer meets pd with. NaN with no design cn0_dbhz or with n_noncoh > 1. |
| int | dp_correlator_get_pd_predicted (const dp_correlator_state_t * state, double * out) Predicted Pd at cn0_dbhz and the chosen grid, averaged over the straddle priors (slow-time scalloping, intra-segment rotation, code-phase sample offset): what the Monte-Carlo characterization measures, not the on- grid best case. |
| int | dp_correlator_get_peak_conc (const dp_correlator_state_t * state, float * out) Concentration of the last dwell's strongest peak: its main lobe's power over its code-phase column's, across every Doppler row and tile. Near 1 for a clean single emitter; about 0.5 when a data transition splits it into twins (docs/design/async-dsss-receiver.md section 2.4). |
| int | dp_correlator_get_pfa_cell (const dp_correlator_state_t * state, double * out) Sidak per-cell false-alarm probability over the searched cells. |
| int | dp_correlator_get_psl_db (const dp_correlator_state_t * state, double * out) The preamble's peak sidelobe level, dB: its periodic autocorrelation's largest lag outside the mainlobe, relative to the peak (-inf for a perfect sequence such as Zadoff-Chu). |
| int | dp_correlator_get_rate_hypotheses (const dp_correlator_state_t * state, size_t * out) Doppler-rate hypotheses searched: as given, or the engine's choice when built with 0; 1 is none. |
| int | dp_correlator_get_reps (const dp_correlator_state_t * state, size_t * out) Preamble repetitions a burst holds: the coherence ceiling. |
| int | dp_correlator_get_ring_cap (const dp_correlator_state_t * state, size_t * out) Input ring capacity in complex samples. |
| int | dp_correlator_get_sample_rate (const dp_correlator_state_t * state, double * out) Sample rate the search runs at, Hz: the constructor's sample_rate. |
| int | dp_correlator_get_sf (const dp_correlator_state_t * state, size_t * out) Chips per code period: len(ref). |
| void | dp_correlator_get_state (const dp_correlator_state_t * state, void * blob) Serialize the frame count and spectrum accumulator into blob . |
| int | dp_correlator_get_straddle_loss (const dp_correlator_state_t * state, double * out) Mean amplitude derating of the correlation peak from grid straddle, a diagnostic; 20*log10(straddle_loss) is the loss in dB. |
| int | dp_correlator_get_surface_at (const dp_correlator_state_t * state, size_t * out) samples_consumed of the dwell whose surface surface() returns (0 until one has been captured). |
| int | dp_correlator_get_surface_rows (const dp_correlator_state_t * state, size_t * out) Rows of the surface surface() returns: the Doppler axis in surface units; its columns are lag_bins. |
| int | dp_correlator_get_symbol_rate (const dp_correlator_state_t * state, double * out) Data-symbol rate the search was built with, Hz (0 = no known data clock): a diagnostic, never sizing. |
| int | dp_correlator_get_threads (const dp_correlator_state_t * state, int * out) Workers the search fans its tiles across, the calling thread included; 1 = serial. Set with set_threads(). |
| int | dp_correlator_get_threshold (const dp_correlator_state_t * state, float * out) The gate on the test statistic: a detector's as given (0 fires on every dump); a search's derived from pfa (the coherent path's gate). |
| int | dp_correlator_get_underpowered (const dp_correlator_state_t * state, bool * out) True when the search cannot meet pd at cn0_dbhz and its geometry: pd_predicted < pd for the continuous search, pd_burst < pd for the burst search. It still builds a best-effort grid, and construction warns (UserWarning). |
| int | dp_correlator_last_corr_status (const dp_correlator_state_t * state) Whether this flavor has a last correlation vector to read: Python's Correlator.last_corr asks it before it builds the view. |
| size_t | dp_correlator_period_samples (size_t code_len) The samples one code period should be searched at: the smallest power of two that holds at least two samples a chip. |
| uint64_t | dp_correlator_position (const dp_correlator_state_t * state) The engine's stream position: every sample its pushes have taken, framed ones and the carry, since create, reset, a regrid or set_state's restore. |
| double | dp_correlator_psl_db (const dp_correlator_state_t * state) The preamble's peak sidelobe level, dB: 20*log10 of the largest periodic-autocorrelation lag outside the mainlobe, relative to the peak ( dp_correlator_shape_t::psl ). |
| size_t | dp_correlator_push (dp_correlator_state_t * state, const float _Complex * in, size_t n_in, dp_correlator_hit_t * result, size_t max_results) Stream an arbitrary-length CF32 chunk through a detector or a search flavor; return its detections. |
| size_t | dp_correlator_push_max_out (const dp_correlator_state_t * state, size_t n_in) The most hits dp_correlator_push() can return for n_in more samples: a result array this long is never short. |
| size_t | dp_correlator_rate_hypotheses_for (double f_epoch, double span, size_t depth) The fewest rate hypotheses over [-span, +span] that leave the residualspan/(n - 1) within what a block ofdepth epochs tolerates,f_epoch^2/(2*depth^2) __ the drift rule behind the depth cap, inverted. At least 2 for a positive span; 1 for none; at mostDP_CORRELATOR_RATE_HYPS_MAX . |
| double | dp_correlator_rate_hypothesis (double span, size_t n, size_t h) Rate hypothesis h ofn over[-span, +span] , Hz/s:-span + 2*span*h/(n - 1) ; 0 forn <= 1 . |
| double _Complex | dp_correlator_rate_phasor (double rate, double t) The de-chirp phasor exp(-j*pi*rate*t^2) for a rate in Hz/s at timet seconds from the block's middle. |
| void | dp_correlator_reset (dp_correlator_state_t * state) Restart the correlator's running state, keeping how it was built. |
| size_t | dp_correlator_run (dp_correlator_state_t * state, const void * state_in, void * state_out, const float _Complex * in, size_t n_in, dp_correlator_hit_t * result, size_t max_results) Pure run: inject state_in , streamin , emit hits, exportstate_out —(state_in, input) -> (state_out, output) over an engine treated as immutable config + scratch.state_in /state_out may alias. Either may be NULL (NULL in = fresh; NULL out = discard). |
| size_t | dp_correlator_search_period (size_t code_len, double sample_rate, double chip_rate) The samples one code period is searched at, for a caller feeding sample_rate: its own period when that is already fast, elsedp_correlator_period_samples() . |
| int | dp_correlator_set_carrier_freq_hz (dp_correlator_state_t * state, double carrier_freq_hz) Couple the code clock to the carrier: the chip rate dilates by doppler_hz / carrier_freq_hz , and the engine accounts for it. |
| int | dp_correlator_set_keep_surface (dp_correlator_state_t * state, int keep) Ask to keep, or stop keeping, every decided dwell's surface for dp_correlator_surface() : 1 normalises each one into the gate's units at its decision; 0 (the default) keeps none unless a sink is attached (dp_correlator_surface() states the rule). |
| int | dp_correlator_set_max_peaks (dp_correlator_state_t * state, size_t n, const char ** why) How many peaks a dwell may report: the peak list's capacity. |
| int | dp_correlator_set_peak_zone (dp_correlator_state_t * state, int all_doppler, double half_chips, const char ** why) The exclusion zone each listed peak marks before the next is sought: how far it reaches along Doppler and along the lags. |
| int | dp_correlator_set_ref (dp_correlator_state_t * state, const float _Complex * ref) Replace the reference and recompute its spectrum. |
| int | dp_correlator_set_state (dp_correlator_state_t * state, const void * blob) Restore a mid-dwell correlator from dp_correlator_get_state() 's blob. |
| int | dp_correlator_set_surface_sink (dp_correlator_state_t * state, dp_correlator_surface_sink_fn fn, void * ctx, uint32_t decim) Attach (or detach) a C surface sink: every decim-th decided dwell's surface, in test-statistic units, handed tofn on the pushing thread (docs/design/async-dsss-receiver.md §2.4). |
| int | dp_correlator_set_telemetry (dp_correlator_state_t * state, dp_tlm_t * tlm, const char * prefix, uint32_t decim, const char ** why) Attach (or detach) a telemetry context and register the engine's probes on it (docs/design/async-dsss-receiver.md §2.4). |
| int | dp_correlator_set_threads (dp_correlator_state_t * state, int n) Set how many threads the searcher fans its stages across (docs/design/acq-surface.md §13, §18.3: persistent workers). |
| int | dp_correlator_set_threshold (dp_correlator_state_t * state, float threshold) Change a detector flavor's threshold without rebuilding it. |
| double | dp_correlator_sidelobe_ratio (dp_correlator_state_t * state, const dp_correlator_hit_t * from, const dp_correlator_hit_t * to) How far up the sidelobes of the emitter behind one hit can reach at another hit's cell, relative to that emitter's own peak. |
| size_t | dp_correlator_state_bytes (const dp_correlator_state_t * state) Size in bytes of this correlator's state blob. |
| int | dp_correlator_state_check (const dp_correlator_state_t * state, const void * blob) Whether dp_correlator_set_state() would accept blob , without writing anything. |
| int | dp_correlator_state_position (const dp_correlator_state_t * state, const void * blob, uint64_t * position) The stream position a blob records __dp_correlator_position() of the engine it would restore read without restoring it. |
| size_t | dp_correlator_surface (dp_correlator_state_t * state, float * out, size_t n_out) The last decided dwell's surface, in the gate's own units. |
| size_t | dp_correlator_surface_chip_phase (dp_correlator_state_t * state, double * out, size_t n_out) The surface's code-phase axis: the chip phase of each column. |
| size_t | dp_correlator_surface_complex (dp_correlator_state_t * state, float _Complex * out, size_t n_out) The last decided dwell's surface, complex: amplitude and carrier phase per cell, before the magnitude the gate reads. |
| size_t | dp_correlator_surface_doppler_hz (dp_correlator_state_t * state, double * out, size_t n_out) The surface's Doppler axis: the frequency of each row, in Hz. |
Public Static Functions¶
| Type | Name |
|---|---|
| double | dp_correlator_bin_doppler_hz (const dp_correlator_state_t * state, size_t doppler_bin) A hit's signed Doppler, Hz: its row folded over dp_correlator_grid_bins() by numpy's fftfreq convention (dp_fftfreq_index) and scaled by the grid's resolution. |
| size_t | dp_correlator_grid_bins (const dp_correlator_state_t * state) The Doppler grid a hit's row indexes:window_bins * coherent_bins bins. |
Macros¶
| Type | Name |
|---|---|
| define | CORRELATOR_STATE_MAGIC [**DP\_FOURCC**](dp__state_8h.md#define-dp_fourcc) ('C','O','R','L')State-blob magic ('CORL'); set_state() rejects any other. |
| define | CORRELATOR_STATE_VERSION 4uState-blob layout version; set_state() rejects any other. 2: the search's extra block carries keep_surface (#2022); 3: and the peak zone ( dp_correlator_set_peak_zone() , doppler#3067); 4: and the thread request (dp_correlator_set_threads() , #3055). |
| define | DP_CORRELATOR_CN0_NONE NANThe design C/N0 that means "none given" (doppler#1484): a burst engine then sizes for the whole preamble, its pd_predicted is NaN and it is neverunderpowered . |
| define | DP_CORRELATOR_DELAY_LOSS_NODES 4 |
| define | DP_CORRELATOR_MAX_PEAKS 64u |
| define | DP_CORRELATOR_N_NONCOH_SAFETY_CEILING 256uInternal safety-valve ceiling on auto-selected non-coherent looks not a public knob (no caller-facing equivalent of the retired max_noncoh parameter). |
| define | DP_CORRELATOR_RATE_HYPS_MAX 64u |
| define | DP_CORRELATOR_SAME_PHASE_CHIPS 1.0 |
| define | DP_CORRELATOR_SIDELOBE_DOPPLER_PTS 9 |
| define | DP_CORRELATOR_SIDELOBE_LAG_PTS 5 |
| define | DP_CORRELATOR_SIDELOBE_SLOTS 32 |
Detailed Description¶
One object, built by flavor (docs/design/correlator.md section 2):
| constructor | flavor |
|---|---|
| dp_correlator_create_1d() | a 1-D reference, one row |
| dp_correlator_create_2d() | a (ny, nx) reference |
| dp_correlator_create_delay_doppler() | a code, mapped to (Doppler, delay) |
| dp_correlator_create_detector_2d() | a streaming 2-D detector |
| dp_correlator_create_detector_1d() | a streaming 1-D detector |
| dp_correlator_create_continuous() | a continuous DSSS search |
| dp_correlator_create_burst() | a burst preamble search |
The methods are shared. The 1-D flavor is the 2-D one at ny = 1, which the single-row path below serves, so a length-n correlation and a one-row 2-D correlation are the same bits (test_corr_equiv), and so are the two detectors' hits (test_detector_equiv). The map flavors serve execute and its batch family; the detector and search flavors serve push, and each refuses the other's (SIZE_MAX). The search flavors are the acquisition engine (the search flavors' section, at the end).
All buffers are ny×nx row-major flat arrays of length ny*nx. The correlation theorem extends naturally:
R_xh[i,j] = IFFT2( FFT2(x) · conj(FFT2(h)) ) / (ny*nx)
The reference spectrum is pre-computed at create time. The int-dump semantics are identical to the 1-D case: coherently sum dwell frames, then dump.
Single-row-reference fast path. When ref is nonzero only in row 0 (the DSSS acquisition/detection shape: a code replica with no Doppler content of its own) and ny_out == ny (no row-axis interpolation), ref_spec[u,v] is independent of u — the row axis of the 2-D transform pair cancels to an exact identity (DFT orthogonality: sum_u exp(2*pi*i*u*(i-i)/ny) = nyiffi==i', else 0), for *any* row content.dp_correlator_executethen reduces exactly toR(i,j) = IFFT_nx(FFT_nx(row_i) · conj(FFT_nx(ref_row0)))(j) / nx, applied independently per row — sodp_correlator_create_2ddetects this shape and runsnyindependent length-nx1-D FFTs instead of a full(ny,nx)2-D FFT, skipping the row-axis work that would otherwise cancel to a no-op. Any other reference shape, orny_out > ny`, uses the general 2-D path unchanged.
Lifecycle:
enum { NY = 4, NX = 8 };
float _Complex ref[NY * NX] = { 1.0f }; // row-major 2-D reference
float _Complex frame[NY * NX] = { 1.0f }; // one frame, fed four times
float _Complex out[NY * NX];
dp_correlator_state_t *c
= dp_correlator_create_2d (ref, NY, NX, 4, 1, 0, 0, -1);
size_t dumps = 0;
for (int i = 0; i < 4; i++)
dumps += dp_correlator_execute (c, frame, NY * NX, out, NY * NX, NULL)
!= 0;
printf ("dumps: %zu, peak %.1f\n", dumps, crealf (out[0])); // 1, on i == 3
dp_correlator_destroy (c);
Public Types Documentation¶
enum det_noise_mode_t¶
How a detector flavor aggregates the noise floor from the correlation magnitudes over the flat bins noise_lo to noise_hi, inclusive.
enum det_noise_mode_t {
DET_NOISE_MEAN = 0,
DET_NOISE_MEDIAN = 1,
DET_NOISE_MIN = 2,
DET_NOISE_MAX = 3
};
The test statistic is peak_mag / noise_est. A zero noise_est (e.g., when all bins in the range are zero) yields test_stat = 0, and so does a NaN one (a NaN anywhere in the range is a NaN mean, median, min or max).
enum dp_correlator_flavor_t¶
Which constructor built a correlator.
enum dp_correlator_flavor_t {
DP_CORRELATOR_1D = 1,
DP_CORRELATOR_2D = 2,
DP_CORRELATOR_DELAY_DOPPLER = 3,
DP_CORRELATOR_DETECTOR_1D = 4,
DP_CORRELATOR_DETECTOR_2D = 5,
DP_CORRELATOR_SEARCH_CONTINUOUS = 6,
DP_CORRELATOR_SEARCH_BURST = 7
};
Fixed at create and the state blob's first field: a blob restores only into a correlator of its own flavor. Python's Correlator.flavor reads it by name, through the correlator_flavor enum table in just-makeit.toml.
enum dp_correlator_framing_t¶
How dp_correlator_create() frames its input: maps or detections from whole frames, or a search over a stream.
enum dp_correlator_framing_t {
DP_CORRELATOR_FRAMING_NONE = 0,
DP_CORRELATOR_FRAMING_CONTINUOUS = 1,
DP_CORRELATOR_FRAMING_BURST = 2
};
typedef dp_correlator_search_t¶
The search flavors' policy: everything the two search constructors add on top of the four layers (docs/design/archive/correlator-step3.md section 7, 3.4b). Held by dp_correlator_state_t::search , allocated once at create; NULL in every other flavor.
typedef dp_correlator_surface_sink_fn¶
A surface sink: called once per decided dwell (every decim -th) with the dwell's surface in test-statistic units, row-majorrows xcols (Doppler rows by code-phase columns), and the dwell'ssamples_consumed . The pointer is the engine's and is valid only for the call. Seedp_correlator_set_surface_sink() .
typedef void(* dp_correlator_surface_sink_fn) (void *ctx, const float *surface, size_t rows, size_t cols, uint64_t samples_consumed);
Public Functions Documentation¶
function dp_correlator_bank_detect¶
Detect on a coarse carrier grid, refine each candidate at its own cell on a fine one, and keep what confirms.
size_t dp_correlator_bank_detect (
const dp_correlator_state_t * state,
const float _Complex * x,
size_t x_len,
size_t L_d,
size_t L_r,
int g_min,
int g_max,
float t_candidate,
float t_confirm,
const float _Complex * rates,
size_t rates_len,
float * out,
int32_t * out1,
uint32_t * out2,
uint32_t * out3,
uint32_t * out4,
size_t max_out,
int * status,
const char ** why
)
The bank searches on L_d and resolves on L_r (docs/design/corr2d-hypotheses.md section 6):
- Detect. dp_correlator_bank_power_max() over carriers
g_min..g_maxon the1 / (L_d nx)grid, with every rate. - Candidates. Every cell whose power exceeds
t_candidateand is at least each of its 8 neighbors, both axes circular (a delay lag and a Doppler bin both wrap). - Refine. For a candidate found by coarse carrier g_d and rate r, the map value at its cell under every fine carrier g_r from
m g_d - (m - 1)tom g_d + (m - 1), m =L_r / L_d: the carriers between its coarse neighbors, on the1 / (L_r nx)grid. On the fast path and the delay-Doppler map with a native delay axis each is a time-domain correlation at the cell's lag and a slow-time DFT at its Doppler row, in double, with no FFT:2 ny nxmultiply-adds a carrier. Any other object makes that hypothesis's map and reads the cell. The best g_r wins, the lowest on a tie. - Confirm. A candidate whose refined power exceeds
t_confirmis a record.
Records come out in cell order (row-major), one entry of each output per record: out the refined power, out1 g_r on the fine grid, out2 the rate r, out3 the row and out4 the column, the cell as execute() lays out the map. Measured at 64 x 512 against an oracle that corrects the exact offset, L_d = 2 with L_r = 4 holds L = 4's sensitivity within 0.16 dB, for about half the bank (the design page). L_d = L_r is the one-stage bank. Thresholds are powers in the map's own units; the caller sets them for its noise, as for any detector.
Parameters:
stateAs dp_correlator_bank_fold();g_minandg_maxare on the coarse grid.L_dThe search grid; at least 1.L_rThe resolution grid; a multiple ofL_d.t_candidateCandidate threshold, on the coarse power.t_confirmConfirm threshold, on the refined power.outRefined powers.out1Refined carriers, on the1 / (L_r nx)grid.out2Rates.out3Rows.out4Columns.max_outCapacity of each output; at leastn_out.statusWhere the refusal's cause goes (just-makeit#2584); may be NULL.DP_ERR_MEMORYwhen memory ran out (Python: MemoryError),DP_ERR_UNSUPPORTEDoff the flavors that serve the call,DP_ERR_INVALIDfor a refused argument. Untouched on success.whyWhere the refusal's sentence goes, naming the argument it refused; may be NULL. A static string, never freed. Off the flavors that serve the call it stays NULL (the binding then raises the declared "only" sentence; just-makeit#2574).
Returns:
Python: the tuple (power, g, rate, row, col), one entry per confirmed record (possibly none): float32 refined power, int32 refined carrier, uint32 rate, row and column, always new arrays (this call takes no out=); out of memory is a MemoryError, and anything else below a ValueError. C: the record count (0 included), or SIZE_MAX with nothing written for anything dp_correlator_bank_fold() refuses, L_d == 0, an L_r that L_d does not divide, a refined carrier past int32, max_out below n_out, or memory for the detector's work or the refine's scratch.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> rng = np.random.default_rng(0)
>>> ny, nx, d = 8, 32, 5
>>> code = rng.choice([-1.0, 1.0], nx).astype(np.complex64)
>>> m = np.arange(ny * nx)
>>> x = (np.tile(np.roll(code, d), ny) # 1.25 bins: between L_d = 2
... * np.exp(2j * np.pi * 1.25 / nx * m)).astype(np.complex64)
>>> dd = Correlator(code, doppler_rows=ny)
>>> no_rates = np.empty(0, np.complex64)
>>> coarse, _ = dd.bank_power_max(x, 2, -4, 4, no_rates)
>>> t = 0.5 * coarse.max()
>>> power, g, rate, row, col = dd.bank_detect(x, 2, 4, -4, 4, t, t,
... no_rates)
>>> len(power), int(g[0]), int(col[0]) # g on the 1/(4 nx) grid
(1, 5, 5)
>>> round(float(power[0] / coarse.max()), 3) # the straddle recovered
1.233
function dp_correlator_bank_detect_max_out¶
Capacity dp_correlator_bank_detect() needs: one record per map cell.
Parameters:
stateThe correlator.x_lenThe frame's length (the bound does not depend on it).
Returns:
n_out.
function dp_correlator_bank_fold¶
Run one frame through a bank of carrier and rate hypotheses and hand each map to a reducer.
size_t dp_correlator_bank_fold (
const dp_correlator_state_t * state,
const float _Complex * x,
size_t x_len,
size_t L,
int g_min,
int g_max,
const float _Complex * rates,
size_t rates_len,
const dp_correlator_fold_t * fold
)
A bank is what a frame batch of corrected copies would compute, without the copies: carrier g corrects an offset of g / (L * nx) cycles/sample, for every g from g_min to g_max, and each rate r weights the slow-time samples by the r-th ny-long vector of rates. Map h, for h = (g - g_min) * R + r (R = rates_len / ny, or 1 with no rates), is what a fresh dwell-1 object's execute() returns for the frame with period i multiplied by element i of rate vector r and by exp(-j 2 pi g n / (L nx)), where n counts samples WITHIN period i (0 .. nx-1), up to float rounding.
The correction restarts at every period on purpose: the phase a carrier adds between periods is slow-time Doppler, which the slow-time FFT measures, so a signal stays on its own absolute Doppler row under every carrier hypothesis (docs/design/corr2d-hypotheses.md, rule 4).
Every path runs a bank, and only the single-row fast path and the delay-Doppler map share work: whole bins (g a multiple of L) are a roll of the row spectrum, each fraction g mod L mixes and transforms the rows once for every whole bin that shares it. On the delay-Doppler map the one map then runs in the order its rule picks for the bank's carriers per fraction and its rates (docs/design/acq-surface.md §18.1): rows first inverts each carrier's rows once for all its rates and pays a slow-time FFT per rate; slow first shares each fraction's slow time across its whole-bin carriers and pays their rows per rate. On the 2-D map, whose rows are its periods, a rate scales the carrier's rows. The general 2-D path and a known column run each hypothesis's corrected frame through their own frame code, which is the definition with nothing shared.
Maps reach fold in h order, so a reducer's tie rule is the batch's. The stages split across the object's workers exactly as execute() does, and every map is bit-identical for any worker count. The dwell accumulator, count and the state blob are never read or written.
Parameters:
stateA map flavor (1-D, 2-D or delay-Doppler).xOne frame,x_lensamples.x_lenMust be exactlyny * nx.LFractions per whole bin; at least 1.g_minLowest carrier, in units of1 / (L * nx)cycles/sample.g_maxHighest carrier; at leastg_min.ratesPer-period weights, R vectors of ny, or NULL withrates_len0 (one unit vector).rates_lenA whole multiple of ny, 0 included.foldThe reducer, called once per map.
Returns:
The number of maps, (g_max - g_min + 1) * R; or SIZE_MAX, with nothing folded, for a frame of another length, L == 0, g_min > g_max, a rates_len that is not a whole number of ny-long vectors, a count past 2^32, or scratch that cannot be allocated.
#include "doppler/correlator/correlator_core.h"
#include <stdio.h>
static void count_maps (void *ctx, size_t h, const float _Complex *map,
size_t n_out)
{
(void)h, (void)map, (void)n_out;
++*(size_t *)ctx;
}
int main (void)
{
float _Complex code[8] = { 1, -1, 1, 1, -1, 1, -1, -1 }, x[4 * 8] = { 0 };
dp_correlator_state_t *dd = dp_correlator_create_delay_doppler (code, 8, 4, 1, 1, 0);
size_t maps = 0;
dp_correlator_fold_t f = { count_maps, &maps };
size_t h = dp_correlator_bank_fold (dd, x, 4 * 8, 4, -4, 4, NULL, 0, &f);
printf ("%zu %zu\n", h, maps); // 9 carriers, one rate: 9 maps
dp_correlator_destroy (dd);
return !(h == 9 && maps == 9);
}
function dp_correlator_bank_power_max¶
The strongest power at every cell over a bank, and which hypothesis it came from.
size_t dp_correlator_bank_power_max (
const dp_correlator_state_t * state,
const float _Complex * x,
size_t x_len,
size_t L,
int g_min,
int g_max,
const float _Complex * rates,
size_t rates_len,
float * out,
uint32_t * out1,
size_t max_out,
int * status,
const char ** why
)
dp_correlator_bank_fold() with the POWER_MAX reducer: at each cell, out holds the largest |map_h|^2 over every hypothesis h, and out1 that h, (g - g_min) * R + r, the lowest h on a tie. Every argument and refusal is dp_correlator_bank_fold()'s; in addition max_out below n_out is refused with nothing written.
Parameters:
stateThe map; a detector is refused.xOne frame,x_lensamples.x_lenMust be exactlyny * nx.LFractions per whole bin; at least 1.g_minLowest carrier, in units of1 / (L * nx)cycles/sample.g_maxHighest carrier; at leastg_min.ratesPer-period weights, R vectors of ny, or empty (NULL withrates_len0 in C) for one unit vector.rates_lenA whole multiple of ny, 0 included.outn_outpowers.out1n_outhypothesis indices.max_outCapacity of each output; at leastn_out.statusWhere the refusal's cause goes (just-makeit#2584); may be NULL.DP_ERR_MEMORYwhen memory ran out (Python: MemoryError),DP_ERR_UNSUPPORTEDoff the flavors that serve the call,DP_ERR_INVALIDfor a refused argument. Untouched on success.whyWhere the refusal's sentence goes, naming the argument it refused; may be NULL. A static string, never freed. Off the flavors that serve the call it stays NULL (the binding then raises the declared "only" sentence; just-makeit#2574).
Returns:
Python: the tuple (power, index), each (n_out,): float32 powers and uint32 hypothesis indices, always new arrays (this call takes no out=); out of memory is a MemoryError, any other refusal a ValueError. C: n_out, or SIZE_MAX with nothing written.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> rng = np.random.default_rng(0)
>>> ny, nx, d = 8, 32, 5 # code delayed by 5 samples
>>> code = rng.choice([-1.0, 1.0], nx).astype(np.complex64)
>>> m = np.arange(ny * nx)
>>> x = (np.tile(np.roll(code, d), ny) # on a carrier 1.5 bins off
... * np.exp(2j * np.pi * 1.5 / nx * m)).astype(np.complex64)
>>> dd = Correlator(code, doppler_rows=ny)
>>> no_rates = np.empty(0, np.complex64)
>>> pw, h = dd.bank_power_max(x, 2, -4, 4, no_rates) # g / (2 nx), -4..4
>>> cell = int(np.argmax(pw))
>>> cell % nx, int(h[cell]) - 4 # (delay, g = h + g_min)
(5, 3)
function dp_correlator_bank_power_max_max_out¶
Capacity dp_correlator_bank_power_max() needs: one map.
Parameters:
stateThe correlator.x_lenThe frame's length (one map whatever it is).
Returns:
n_out.
function dp_correlator_block_prompt¶
One cell's column of the last whole block: the per-epoch complex correlations at a code phase, the despread stream at epoch rate.
size_t dp_correlator_block_prompt (
dp_correlator_state_t * state,
size_t tile,
size_t col,
float _Complex * out,
size_t n_out
)
The block-coherent engine gathers every tile's correlation row for coherent_bins epochs before its slow-time transform (file doc, docs/design/acq-surface.md §4). This copies the coherent_bins values at column col of tile tile into out, in epoch order: each epoch's complex prompt at that code phase, rolled to the tile's centre frequency and shifted to the block's middle by the tile's code-rate hypothesis, so the phase is continuous along the column for an emitter at the tile's centre and rotates at its offset from it. At an emitter's cell this is what a despreader produces, one value per epoch, phase included (docs/design/async-dsss-receiver-measurements.md §12.21). Valid once a block is whole, until the next epoch is pushed.
Parameters:
stateMust be non-NULL.tileTile index,0 … window_bins-1(native FFT order, the order the surface's rows are cut in).colCode-phase column,0 … lag_bins-1.outAt leastcoherent_binscomplex floats.n_outCapacity ofout. SIZE_MAX (refused) on every flavor but the continuous search (docs/design/correlator.md section 4); 0 is "nothing yet".
Returns:
Values written (coherent_bins), or 0 at coherent_bins == 1 (no block is gathered), while a block is partial, for an index out of range, or when out is too small.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> from doppler.wfm import PN, mls_poly
>>> code = np.asarray(PN(poly=mls_poly(5), seed=1,
... length=5).generate(31)).astype(np.uint8)
>>> s0 = np.repeat(np.where(code & 1, -1.0, 1.0), 4).astype(
... np.complex64)
>>> ref = np.where(code & 1, -1, 1).astype(np.complex64)
>>> b = Correlator(ref, framing="continuous", sample_rate=4e6, chip_rate=1e6, cn0_dbhz=60.0,
... doppler_uncertainty=40e3, code_only_epochs=7)
>>> b.coherent_bins # (7 + 1) // 2
4
>>> blk = np.tile(np.roll(s0, 17), b.coherent_bins).astype(np.complex64)
>>> _ = b.push(blk)
>>> p = np.empty(b.coherent_bins, dtype=np.complex64)
>>> b.block_prompt(0, 17, p) == b.coherent_bins
True
>>> bool(np.abs(p).min() > 0.99 * np.abs(p).max()) # every epoch's prompt
True
>>> b.block_prompt(0, 17, np.empty(1, dtype=np.complex64)) # too small
0
function dp_correlator_block_raw¶
The last whole block's raw samples, as pushed.
size_t dp_correlator_block_raw (
dp_correlator_state_t * state,
float _Complex * out,
size_t n_out
)
Copies the coherent_bins * code_bins samples the block-coherent engine gathered for its last whole block into out, epoch by epoch in stream order — the samples dp_correlator_push() consumed, untouched. Kept for the tile-edge re-ask (search_resolve_tile_alias()); exposed so a tracker can re-correlate them at any code phase, rate or symbol boundary the engine's own grid does not have — a symbol-rate despreader at the tracked timing runs on exactly this (docs/design/async-dsss-receiver-measurements.md §12.21). Valid once a block is whole, until the next epoch is pushed.
Parameters:
stateMust be non-NULL.outAt leastcoherent_bins * code_binscomplex floats.n_outCapacity ofout. SIZE_MAX (refused) on every flavor but the continuous search (docs/design/correlator.md section 4); 0 is "nothing yet".
Returns:
Samples written (coherent_bins * code_bins), or 0 at coherent_bins == 1, while a block is partial, or when out is too small.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> from doppler.wfm import PN, mls_poly
>>> code = np.asarray(PN(poly=mls_poly(5), seed=1,
... length=5).generate(31)).astype(np.uint8)
>>> s0 = np.repeat(np.where(code & 1, -1.0, 1.0), 4).astype(
... np.complex64)
>>> ref = np.where(code & 1, -1, 1).astype(np.complex64)
>>> b = Correlator(ref, framing="continuous", sample_rate=4e6, chip_rate=1e6, cn0_dbhz=60.0,
... doppler_uncertainty=40e3, code_only_epochs=7)
>>> blk = np.tile(np.roll(s0, 17), b.coherent_bins).astype(np.complex64)
>>> _ = b.push(blk)
>>> raw = np.empty(b.coherent_bins * b.code_bins, dtype=np.complex64)
>>> b.block_raw(raw) == raw.size
True
>>> bool(np.array_equal(raw, blk)) # the samples as pushed
True
function dp_correlator_build_handoff¶
Convert one dp_correlator_push() hit into a wire-ready hand-off record.
void dp_correlator_build_handoff (
const dp_correlator_state_t * state,
const dp_correlator_hit_t * hit,
size_t code_len,
dp_correlator_handoff_t * out
)
Two convention inversions live here, ported verbatim from dsss_receiver_core.c's own (pre-existing, now-shared) handoff logic:
- Chip phase:
hit'scolis a correlation LAG (0 … lag_bins-1); a code-tracking loop'sinit_chipwants the code's own instantaneous phase instead — the mirror-image inversionphase = fmod(code_len - col * code_len / lag_bins, code_len), folded non-negative. - Doppler:
stateis assumed built via dp_correlator_create_continuous() (window_binstiles ofcoherent_binseach, the only mode this function supports), sohit'srowindexes the uniform grid ofwindow_bins * coherent_binsbins, mapped to a signed bin bydp_fftfreq_index()— the SAME helper the search uses — and scaled bystate->search->doppler_res_hz. - The dwell's dilation (doppler#1254): a hit is decided on a non-coherent sum over
n_noncohlooks, and the code phase it reports is that sum's peak the phase at the MIDDLE of the dwell, not at its end, when the chip clock is dilated by the same Doppler the hit reports (a physically-coupled carrier,doppler_hz / carrier_freq_hzchips per chip). The seed a code loop wants is the phase at the next sample, so with the carrier set (dp_correlator_set_carrier_freq_hz()) the phase is advanced by the drift over HALF the dwell,doppler_hz_est / carrier_freq_hz * n_noncoh * coherent_bins * code_len / 2chips (a coherent block's epochs are aligned to its middle by the same setting, so the block's peak is its middle too). At the specification's 20 ppm the continuous engine's dwell at 45 dB-Hz is 15 epochs (0.15 chip, inside any code loop's pull-in) and at the 40 dB-Hz floor 88 epochs 0.9 chip, measured directly, past the refine Dll's; without this the floor's hand-offs never refined. Uncoupled (0.0): no advance.
Parameters:
stateThe enginehitcame from (non-NULL, built via dp_correlator_create_continuous()).hitOne hit from dp_correlator_push() (non-NULL).code_lenSpreading-code length (chips): a hit's lag, in columns of the engine'slag_bins-column period, becomes a phase in these units (code_len / lag_binschips a column). For a code engine it is the code's length; a burst engine built from a code held k samples a chip passes the code's length too.outWritten on return (non-NULL).
function dp_correlator_carrier_freq_ok¶
Whether carrier_freq_hz is a carrier the code can be coupled to atsample_rate_hz: 0 (uncoupled), or finite and above half the sample rate.
Every coupled stage divides a Doppler by the carrier: the hand-off's dilation, a coherent block's epoch alignment, a code loop's rate aid. A seed a receiver accepts has a Doppler below half its sample rate (dp_async_dsss_receiver_seed_ok()), so a carrier above that keeps |doppler / carrier| < 1, the physical v/c, when the hand-off is taken from a seed. The acquisition search itself does not yet bound the Doppler it reports to that range (doppler#2112 item 7); a hit past it is refused as a seed rather than used, so the bound holds at the receiver even where the search does not enforce it. A tiny carrier sent doppler / carrier to inf, so the seed phase came out NaN, and the receiver aborted building its code loop from it (doppler#2103). The one rule for every site that takes the divisor: dp_correlator_set_carrier_freq_hz() and the DSSS receivers' creates.
Parameters:
carrier_freq_hzCandidate carrier, Hz; 0 means uncoupled.sample_rate_hzSample rate of the stream, Hz.
Returns:
1 if the carrier is taken, 0 otherwise (a NaN is not).
function dp_correlator_cell_corr¶
One epoch's correlation against the replica at ONE code phase and ONE frequency: the engine's surface, evaluated at a single cell, on raw samples.
double _Complex dp_correlator_cell_corr (
const dp_correlator_state_t * state,
const float _Complex * x,
size_t col,
double f_hz,
double t0
)
sum_m x[m] * conj(ref[(m - col) mod nx]) * exp(-j 2 pi f (t0 + m)/fs) over the code_bins samples of x. The mixer phase is referenced to t0, so epochs evaluated at consecutive t0 combine COHERENTLY: sum the returned values across epochs and the result is a depth-len cell of the slow-time surface at f_hz, with no intra-epoch rotation loss.
It is what a caller does once acquisition has SETTLED the code phase and the Doppler: evaluate the same statistic elsewhere without searching the grid again. The engine's tile-alias check uses it; burst_capture's refine uses it to score each candidate repetition (doppler#1502).
Parameters:
stateThe engine whose replica,code_binsandfsare used.xOne epoch,code_binssamples.colCode phase, samples, in [0, code_bins).f_hzMixer frequency, Hz.t0Time of the first sample ofx, in samples, on the caller's reference.
Returns:
The complex correlation.
function dp_correlator_cell_corr_grid¶
dp_correlator_cell_corr() at many frequencies over consecutive epochs, in one pass: the cells a caller scores once the code phase is settled and only the Doppler is left to search.
void dp_correlator_cell_corr_grid (
const dp_correlator_state_t * state,
const float _Complex * x,
size_t n_epochs,
size_t col,
const double * f_hz,
size_t n_f,
double t0,
double _Complex * out
)
Element e * n_f + j of out is dp_correlator_cell_corr() of epoch e (x + e*code_bins, at t0 + e*code_bins) at the j-th frequency, to within 1e-5 of the epoch's sum |x * ref|, the most either can reach (measured 2.9e-6 at a 510-sample epoch): a coherent peak 100 dB above the difference.
How: evaluated one cell at a time, every frequency repeats the whole despread-and-mix of the epoch. Here the replica is multiplied once per call by a mixer at the frequencies' centre, so each sample costs one multiply, summed over B equal blocks per epoch with the first and second moments of the time within each block. What is left of a frequency is a residual of at most r cycles per epoch either side of the centre; B = ceil(48 r) blocks keep it turning under 1/96 of a cycle either side of a block's centre, and it is applied per block from the moments as a second-order expansion, whose remainder is the error above. So the cost per epoch is code_bins + 3 * B * n_f against n_f * code_bins, and burst_capture's refine, which scores every Doppler cell of every candidate period, is the reason it exists (doppler#1538).
Frequencies spread more than one cycle per epoch either side of their centre fall back to dp_correlator_cell_corr() per cell.
Parameters:
stateThe engine whose replica,code_binsandfsare used.xn_epochs * code_binscontiguous samples.n_epochsEpochs to evaluate.colCode phase, samples, in [0, code_bins).f_hzn_fmixer frequencies, Hz, in any order.n_fNumber of frequencies.t0Time of the first sample ofx, in samples, on the caller's reference.outWritten withn_epochs * n_fcorrelations, epoch-major.
function dp_correlator_configure_search_raw¶
Pin the search grid directly, bypassing both auto-sizing searches — the advanced escape hatch (mirrors Dll's/Costas's configure_lock_raw()).
int dp_correlator_configure_search_raw (
dp_correlator_state_t * state,
size_t doppler_bins,
size_t n_noncoh,
const char ** why
)
Resizes every buffer/plan that depends on the grid (the slow-time FFT, the code correlator, the reference, and every per-frame scratch buffer), re-derives the threshold ladder for the pinned grid from the same physics dp_correlator_create_burst()/dp_correlator_create_continuous() used, and clears in-flight accumulation (ring contents, the non-coherent power accumulator, dwell bookkeeping) — call between push() calls, never a substitute for one.
Parameters:
stateAllocated engine (non-NULL).doppler_binsCoherent depth to pin, in[1, reps].n_noncohNon-coherent look count to pin, in[1, DP_CORRELATOR_N_NONCOH_SAFETY_CEILING].whyWhere the refusal's sentence goes, naming the argument it refused; may be NULL. A static string, never freed. Off the flavors that serve the call it stays NULL (the binding then raises the declared "only" sentence; just-makeit#2574).
Returns:
0 on success; DP_ERR_UNSUPPORTED on a map or detector flavor (no search record); DP_ERR_INVALID if either argument is out of range (or n_noncoh > 1 on an engine with rate hypotheses, which do not compose with non-coherent looks); DP_ERR_MEMORY if an allocation fails (the engine is left usable at its prior grid).
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> from doppler.wfm import PN, mls_poly
>>> code = np.asarray(PN(poly=mls_poly(5), seed=1,
... length=5).generate(31)).astype(np.uint8)
>>> s0 = np.repeat(np.where(code & 1, -1.0, 1.0), 4).astype(
... np.complex64)
>>> ref = np.where(code & 1, -1, 1).astype(np.complex64)
>>> a = Correlator(ref, framing="continuous", sample_rate=4e6, chip_rate=1e6, cn0_dbhz=50.0)
>>> a.configure_search_raw(doppler_bins=1, n_noncoh=4) # pin the grid
>>> a.doppler_bins, a.n_noncoh
(1, 4)
>>> burst = np.tile(np.roll(s0, 17), 4).astype(np.complex64)
>>> h = a.push(burst)
>>> int(h["row"][0]), int(h["col"][0]) # detects at the pinned grid
(0, 18)
function dp_correlator_consumed¶
Input samples the last dp_correlator_push() took.
Equal to its n_in unless result filled up; then the caller resumes at in + consumed. 0 after create, reset, set_ref and set_state, and always 0 for a map flavor.
Parameters:
stateMust be non-NULL.
Returns:
Samples of the last push's input consumed (including any kept as the carry).
function dp_correlator_create¶
Build the flavor the knobs name: the one constructor the Python class Correlator calls.
dp_correlator_state_t * dp_correlator_create (
const float _Complex * ref,
size_t ny,
size_t nx,
dp_correlator_framing_t framing,
size_t doppler_rows,
int detect,
size_t dwell,
size_t ny_out,
size_t nx_out,
int col_out,
float threshold,
size_t noise_lo,
size_t noise_hi,
int noise_mode,
double sample_rate,
double chip_rate,
double symbol_rate,
size_t reps,
double cn0_dbhz,
double doppler_uncertainty,
double pfa,
double pd,
double doppler_rate,
size_t rate_hypotheses,
size_t code_only_epochs,
int nthreads,
const char ** why
)
A C caller names the flavor it wants and calls that flavor's own constructor; this one is the binding's entry point (docs/design/correlator.md section 3). It reads the knobs, picks the flavor, and calls that constructor with them:
| framing | ref rows | doppler_rows | detect | flavor |
|---|---|---|---|---|
NONE |
1 | 0 | 0 | dp_correlator_create_1d() |
NONE |
1 | 0 | 1 | dp_correlator_create_detector_1d() |
NONE |
> 1 | 0 | 0 | dp_correlator_create_2d() |
NONE |
> 1 | 0 | 1 | dp_correlator_create_detector_2d() |
NONE |
1 | > 0 | 0 | dp_correlator_create_delay_doppler() |
CONTINUOUS |
1 | 0 | any | dp_correlator_create_continuous() |
BURST |
1 | 0 | any | dp_correlator_create_burst() |
A one-row reference is the 1-D flavor: dp_correlator_create_1d() is dp_correlator_create_2d() at one row, and nx_out is its padded length.
A value the flavor would not honor is refused, never ignored: a knob the flavor does not read must hold its default, which is the value named with it below. A search honors detect = 1, so it may be either. The refusal returns NULL and points why at a sentence that names the knob.
The continuous search's reference is NRZ chips as samples: exactly +1 (chip 0) or -1 (chip 1), with no imaginary part, the mapping of dp_bin_to_nrz(); any other sample is refused, so a shaped or noisy reference is never quantized silently.
The class Correlator calls it with the knobs as keywords, and the flavor follows from them; a refusal is a ValueError carrying the sentence why points at. The C call, why included, is the guide's (docs/guide/correlator.md, "From C").
Parameters:
refRow-majornyxnxreference, CF32; borrowed.nyRows ofref(1 for a 1-D reference).nxSamples a row.framingMaps and detections, or a search; default NONE.doppler_rowsDoppler rows of the delay-Doppler map, the code periods one frame holds; 0 (default) for no map.detect1 for detections from push(); default 0 (maps).dwellFrames integrated a dump; default 1.ny_outPadded Doppler rows; 0 (default) for native.nx_outPadded lags; 0 (default) for native.col_outThe one lag to emit; -1 (default) for every lag.thresholdDetection threshold on peak / noise; default 0.noise_loFirst noise bin; default 0.noise_hiLast noise bin; default SIZE_MAX, the last bin.noise_modeThe noise statistic, a det_noise_mode_t; default DET_NOISE_MEAN.sample_rateSamples a second; 0 (default) is not given, which a search refuses.chip_rateChips a second; 0 (default) is not given, which the continuous search refuses.symbol_rateData symbols a second, read by the continuous search for a diagnostic only; 0 (default) is no known data clock.repsPreamble repetitions a burst; default 1.cn0_dbhzDesign-point C/N0, dB-Hz; default DP_CORRELATOR_CN0_NONE (NaN, none). The continuous search needs a finite one.doppler_uncertaintyHalf-width of the Doppler search, Hz; default 0.pfaFalse-alarm probability a search; default 1e-3.pdDetection probability at the design point; default 0.9.doppler_rateDoppler rate bound, Hz/s; default 0.rate_hypothesesRate hypotheses of the burst search; default 1.code_only_epochsCode-only epochs of the continuous search; default 1.nthreadsWorker threads of a map or detector; default 1. A search sizes its own pool and refuses any other value here: its count is set after create with dp_correlator_set_threads().whyWhere a refusal's sentence goes; may be NULL. A static string, never freed.
Returns:
The correlator, or NULL: refused (why says which knob) or out of memory.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> ref = np.zeros(8, np.complex64); ref[0] = 1.0
>>> Correlator(ref).flavor # a 1-D map
'1d'
>>> Correlator(ref, detect=1).flavor # a streaming detector
'detector_1d'
>>> Correlator(np.ones((4, 8), np.complex64)).flavor
'2d'
>>> Correlator(ref, doppler_rows=4).flavor # a delay-Doppler map
'delay_doppler'
>>> Correlator(ref).execute(ref).shape # one dump of nx lags
(8,)
>>> from doppler.wfm import PN, mls_poly
>>> code = np.asarray(PN(poly=mls_poly(5), seed=1, length=5).generate(31),
... np.uint8)
>>> s0 = np.repeat(np.where(code & 1, -1.0, 1.0), 4).astype(np.complex64)
>>> b = Correlator(s0, framing="burst", reps=8, sample_rate=4e6,
... cn0_dbhz=60.0) # a burst search: 8 repetitions
>>> b.flavor
'burst'
>>> h = b.push(np.tile(np.roll(s0, 17), 24))[0]
>>> int(h["row"]), int(h["col"]) # (Doppler bin, delay in samples)
(0, 17)
function dp_correlator_create_1d¶
Allocate a 1-D FFT correlator with coherent integrate-and-dump. Pre-computes conj(FFT(ref)) once at construction so each execute() call costs only two FFTs and n complex multiplies. ref may be freed after this returns. Withdwell == 1 every call produces output; with larger values the accumulator absorbsdwell frames before dumping.
dp_correlator_state_t * dp_correlator_create_1d (
const float _Complex * ref,
size_t ref_len,
size_t dwell,
int nthreads,
size_t n_out
)
It is dp_correlator_create_2d() at ny = 1, nx = ref_len: the single-row path, so the same bits (test_corr_equiv). Its frame and its map are both 1-D: execute() takes ref_len samples and a dump writes n_out.
Parameters:
refReference signal, CF32, lengthref_len.ref_lenReference / FFT length in samples.dwellIntegration depth; must be >= 1 (0 is refused). Pass 1 for immediate output on every call.nthreadsAccepted for API compatibility; ignored.n_outInverse/output length; 0 => native (n). Must be >= n. A larger value zero-pads the cross-spectrum before the inverse, returning the band-limited (Dirichlet) interpolation of the correlation on a finer length-n_out grid — same peak, sub-bin lag resolution. Native is bit-exact and allocates no extra buffer.
Returns:
Heap-allocated state (free with dp_correlator_destroy()), or NULL on a dwell of 0, an n_out below ref_len, or allocation failure.
>>> from doppler.correlation import Correlator
>>> import numpy as np
>>> ref = np.zeros(4, dtype=np.complex64); ref[0] = 1.0
>>> corr = Correlator(ref=ref, dwell=1, nthreads=1)
>>> corr.n, corr.dwell, corr.count
(4, 1, 0)
function dp_correlator_create_2d¶
Allocate a 2-D FFT correlator with coherent integrate-and-dump. Two-dimensional extension of dp_correlator_create_1d() . The reference is a flat row-major ny×nx CF32 array; its conjugate spectrum is pre-computed once so each execute() call costs two 2-D FFTs plus ny*nx complex multiplies. The Python wrapper requiresref to be a 2-D ndarray with shape (ny, nx); it passes a flat view to C.
dp_correlator_state_t * dp_correlator_create_2d (
const float _Complex * ref,
size_t ny,
size_t nx,
size_t dwell,
int nthreads,
size_t ny_out,
size_t nx_out,
int col_out
)
Parameters:
refReference image, 2-D (ny, nx) CF32 ndarray in Python.nyNumber of rows in the reference and input frames.nxNumber of columns in the reference and input frames.dwellIntegration depth; must be >= 1.nthreadsWorkers for the single-row-reference fast path's per-row stage: 1 runs serially (no threads), N runs N workers (the caller included), <= 0 uses every online core. The count is capped atny, one row per worker at most. The output is bit-identical whatever the count. The general 2-D path and thecol_outpath run serially and ignore it.ny_outInverse/output rows; 0 => native (ny). Must be >= ny. A larger output zero-pads the cross-spectrum before the inverse, returning the band-limited (Dirichlet) interpolation of the correlation on a finer (ny_out, nx_out) grid — same peak, sub-bin resolution. Native is bit-exact and allocates no extra buffers.nx_outInverse/output columns; 0 => native (nx). Must be >= nx.col_outEmit ONLY this correlation lag, or < 0 for the whole map. When set, a dump writesnyvalues one per row instead of ny*nx_out, computed as the time-domain sum over p ofconj(ref(p)) * row((p + col_out) mod nx), which is what R(i, col_out) expands to once the 1/nx cancels. No transform runs in either direction, so the cost per row is O(nx) rather than O(nx log nx). Requires the single-row-reference fast path (a caller that knows its lag is by construction correlating against a code replica) and the NATIVE output grid: an interpolated column is a fractional lag, which no time-domain sum produces. create() returns NULL ifcol_out>= 0 with a reference the fast path rejects, withny_outornx_outdecoupled, or with a lag outside 0 .. nx-1.
Returns:
Heap-allocated state, or NULL on failure.
>>> from doppler.correlation import Correlator
>>> import numpy as np
>>> ref = np.zeros((4, 4), dtype=np.complex64); ref[0, 0] = 1.0
>>> c = Correlator(ref=ref, dwell=1, nthreads=1)
>>> c.ny, c.nx, c.dwell, c.count
(4, 4, 1, 0)
function dp_correlator_create_burst¶
Create a burst-mode acquisition engine for a repeated preamble: coherent multi-repetition combining, up to reps deep.
dp_correlator_state_t * dp_correlator_create_burst (
const float _Complex * tmpl,
size_t n,
size_t reps,
double fs,
double cn0_dbhz,
double doppler_uncertainty,
double pfa,
double pd,
int noise_mode,
double doppler_rate,
size_t rate_hypotheses
)
Takes the preamble as its SAMPLES: one period of n complex samples at fs, repeated up to reps times. A PN code is one such preamble pass its chips mapped by dp_bin_to_nrz() and held spc samples each, at fs = chip_rate * spc. The engine sees one chip = one sample: sf = n, spc = 1, chip_rate = fs, the native Doppler span is +/- fs/(2n), and col is the delay into the repetition, in samples for a preamble whose ambiguity function is a ridge (Zadoff-Chu: one native bin of Doppler moves the peak u^-1 mod n samples), the delay plus that shift whenever the Doppler is not resolved before correlation. It converts cn0_dbhz to a per-sample amplitude SNR (snr = sqrt(10^(cn0_dbhz/10) / fs)), and picks the smallest coherent depth coherent_bins in [1, reps] whose burst Pd pd_burst meets pd at the Sidak threshold (minimum latency for a strong signal). pd_burst treats the preamble as exactly reps periods at a uniform offset against the stream-aligned dwells, and credits every dwell it spans (doppler#1498). If no depth meets pd the engine takes the one with the most burst Pd and is underpowered; it does NOT add non-coherent looks. A burst has one frame of preamble, so looks beyond it add noise to the statistic and move the hit samples_consumed is stamped at the end of the LAST accumulated look, so a consumer resolving the preamble's position sees an anchor up to n_noncoh*coherent_bins periods late (doppler#1181). Intended for an unmodulated burst or preamble window a continuous, data-modulated signal should use dp_correlator_create_continuous() instead (coherent combining under continuous data is a structural aliasing mislock, not a tunable SNR trade-off see the file doc comment).
cn0_dbhz is the DESIGN (minimum) C/N0 and is optional: NaN (DP_CORRELATOR_CN0_NONE) means none was given, and the engine then integrates the whole preamble (coherent_bins = reps; 1 in a tiled search, where a depth multiplies the buffers and the latency and only a stated C/N0 asks for one) with the threshold set by pfa alone. pd is a sizing target only when a design C/N0 is given; without one pd_predicted and pd_burst are NAN and underpowered is never set.
A tighter doppler_uncertainty narrows the scanned Doppler band, lowering the per-cell threshold (more sensitive). When doppler_uncertainty exceeds the native span fs/(2n), engages the wideband window-tiling mechanism (see the file doc comment): 2*ceil((du - span)/(2*span)) + 1 windows, with a coherent depth chosen inside each (1 with no design C/N0). Use dp_correlator_configure_search_raw() to pin the grid directly instead of relying on this auto-sizer.
What a code once knew analytically, the preamble's own correlation gives numerically, from one FFT at construction (dp_correlator_shape_t):
- the peak zone (the twin rule's reach and the exclusion around each listed peak) is the autocorrelation's first null, the lag of the first local minimum of |R(k)| one chip of samples for a code;
- the delay straddle the Pd model averages is the band-limited autocorrelation over a half-sample offset.
For a PN code the numeric model is the more accurate one: against a rectangular-chip signal it stays conservative (never optimistic) and sits 0.01-0.08 below the measured Pd at spc 2-4, where the analytic triangle sat 0.03-0.21 below (doppler#1470).
The within-repetition rotation loss keeps the engine's sinc model: it is the zero-delay cut of the ambiguity function, which a periodic preamble's envelope does not move measured within 0.007 dB of sinc for RRC-shaped QPSK at 4.7 dB peak-to-average.
tmpl is scaled to unit RMS (a copy the caller's buffer is only read), so peak_mag and noise_est come out in the signal's units whatever the preamble's amplitude. C/N0 is the preamble's mean power.
What hypotheses change, when rate_hypotheses is n > 1:
* Depth. The drift bound is applied to the RESIDUAL rate, the farthest a true rate can sit from a hypothesis, R/(n - 1), so coherent_bins can grow by up to sqrt(n - 1) at a fixed span.
* False alarms. A dwell now offers n looks at each cell: the per-cell Pfa is split over n times the cells the dwell's maximum ranges over (every searched row of the Doppler-interpolated surface, times code_bins), and the gate is the larger count's. Each hypothesis is CFAR-tested against its own surface and the dwell takes the strongest; dp_correlator_hit_t:: doppler_rate_hz_s names the winner.
* Cost. A dwell does n slow-time passes (and a recompute of the winner when it was not the last): about n times the per-dwell cost.
* Pd. The model prices a rate ON a hypothesis. Between two, the coherent gain falls with the residual; the depth bound limits that to half a slow-time row, and validate_acq_rate_pd measures it (a rate half a spacing from every hypothesis, the worst case, against a rate drawn uniformly).
The count is config, not running state, and it is a reject key of the state blob: a blob from an engine with another count is refused, not reinterpreted.
Parameters:
tmplOne period of the preamble,nsamples; not all zero, every sample finite.nSamples per repetition (>= 1).repsMax coherent repetitions, the coherence ceiling (>= 1).fsSample rate in Hz (> 0); 1 for normalized units.cn0_dbhzDesign carrier-to-noise density in dB-Hz, of the preamble's mean power: any finite value (at fs = 1 the per-sample SNR, usually negative), or DP_CORRELATOR_CN0_NONE (NaN) for no design point size for the whole preamble.doppler_uncertaintyOne-sided Doppler search half-range in Hz; 0 uses the full native span +/- fs/(2n). A value greater than the native span engages wideband mode (see the file doc comment above): the uncertainty is tiled with parallel frequency-window hypotheses and a coherent depth is chosen inside every tile (1 with no design C/N0); the surface iswindow_bins * coherent_binsrows.pfaTarget system (max-of-N) false-alarm probability (0,1).pdTarget detection probability (0,1); a sizing target only whencn0_dbhzis given.noise_modeCFAR mode index: 0=mean, 1=median, 2=min, 3=max.doppler_rateDoppler rate in Hz/s (>= 0) the coherent depth is bounded against: at mostf_epoch/sqrt(2*doppler_rate)repetitions (f_epoch = fs/n, the repetition rate), so the carrier's drift over one block stays inside half a slow-time row (doppler#1482). 0 is no bound: the depth is sized up toreps. Withrate_hypotheses> 1 it is the SPAN of the rates searched, below.rate_hypothesesDoppler-rate hypotheses to search (0, or >= 1 and at most DP_CORRELATOR_RATE_HYPS_MAX); 1 searches none anddoppler_rateonly caps the depth. Above 1 the engine COMPENSATES the rate:doppler_rateis the span[-R, +R]and the coherent block is searched atrate_hypothesesrates evenly spaced across it,a_h = -R + 2 R h / (n - 1). For each the slow-time axis is multiplied byexp(-j pi a_h t^2),tthe epoch's time from the block's middle, before the slow-time transform so the Doppler an engine reports is the carrier's at the block's middle, where a hand-off wants it, and a signal whose rate sits within half a spacing of a hypothesis integrates as a still one (see below). A block of one or two epochs cannot see a rate every hypothesis is then the same surface so an engine sized to D <= 2 searches ONE look (the gate of an engine without hypotheses), runs once, and reports a rate of 0. Needs a non-zerodoppler_rate:it is the span. 0 is AUTO: the engine picks the smallestnwhose residualR/(n - 1)no longer limits the depth the sizer would choose with no drift bound at all (priced at thatn), or DP_CORRELATOR_RATE_HYPS_MAX if none does; the choice is the engine'srate_hyps. Burst only, and needs a non-zerodoppler_ratelike anyn > 1.
Returns:
Heap-allocated state, or NULL on bad arguments (including a rate_hypotheses above DP_CORRELATOR_RATE_HYPS_MAX, or 0 or above 1 with doppler_rate == 0) / allocation failure.
// 127-sample Zadoff-Chu preamble at 1 MS/s, up to 8 repetitions
float _Complex zc[127];
for (int k = 0; k < 127; k++)
zc[k] = cexpf (-I * (float)(M_PI * 5.0 * k * (k + 1) / 127.0));
dp_correlator_state_t *a = dp_correlator_create_burst (zc, 127, 8, 1.0e6, 50.0, 0.0, 1e-3,
0.9, 0, 0.0, 1);
dp_correlator_destroy (a);
function dp_correlator_create_continuous¶
Create a continuous-mode acquisition engine: always wideband window-tiling, allowing a block-coherent depth inside the tiles to accommodate waveforms with code-only windows.
dp_correlator_state_t * dp_correlator_create_continuous (
const uint8_t * code,
size_t code_len,
double sample_rate,
double chip_rate,
double symbol_rate,
double cn0_dbhz,
double doppler_uncertainty,
double pfa,
double pd,
int noise_mode,
size_t code_only_epochs,
double doppler_rate
)
Builds the single-row oversampled BPSK reference from code, infers sf = code_len, converts cn0_dbhz to a per-sample amplitude SNR, and ALWAYS tiles window_bins = 2*ceil((doppler_uncertainty - span) / (2*span)) + 1 parallel frequency-window hypotheses, with span = chip_rate/(2*sf) one native span (see the file doc comment's "Wideband
window-tiling mode") unconditionally, so window_bins = 1 when doppler_uncertainty is no wider than one native span. A continuous, data-modulated signal's own bit transitions make coherent multi-epoch combining across DATA a structural aliasing mislock (see docs/design/acq-surface.md §9), so the depth is bounded by what a waveform's code-only window holds: coherent_bins = D = min((code_only_epochs+1)/2, f_epoch/sqrt(2*doppler_rate)), at least 1, rounded down to a 7-smooth length (dp_fft_smooth_floor(): 94 runs as 90), run in non-overlapping D-epoch blocks inside every tile (file doc, docs/design/acq-surface.md §4). With code_only_epochs = 1 it is 1 and the engine is exactly the epoch-by-epoch search. Sensitivity margin beyond the depth comes from auto-selected non-coherent looks over blocks (up to the internal DP_CORRELATOR_N_NONCOH_SAFETY_CEILING).
Parameters:
codePN chips (0/1), lengthcode_len.code_lenNumber of chips supplied (= sf, the spreading factor).sample_rateThe rate of the samples pushed, Hz. One code period is thenn = sample_rate * code_len / chip_ratesamples, which must be a whole number of at leastcode_len:the search's transforms are n points long, so a smooth n (a power of two, dp_correlator_period_samples()) is what makes them fast. When n is a multiple ofcode_leneach chip is held n / code_len samples; otherwise each sample takes the chip its centre falls in, and the correlation shape is measured from that replica.chip_rateChip rate in Hz (> 0).symbol_rateContinuous data-symbol rate in Hz; <= 0 means no known clock. Diagnostic only (exposed via dp_correlator_search_t::epochs_per_symbol), doesn't feed sizing: this engine never coherently combines regardless of the data-modulation clock.cn0_dbhzCarrier-to-noise density in dB-Hz: any finite value. A continuous engine needs one its non-coherent looks cannot be chosen without a target.doppler_uncertaintyOne-sided Doppler search half-range in Hz; 0 uses the full native span +/- chip_rate/(2*sf) (still window-tiled, at window_bins=1).pfaTarget system (max-of-N) false-alarm probability (0,1).pdTarget detection probability (0,1).noise_modeCFAR mode index: 0=mean, 1=median, 2=min, 3=max.code_only_epochsWhole code-only epochs a waveform's code-only window holds at any chip phase (docs/design/async-dsss-receiver.md §2.1:floor(W_symbols * chips_per_symbol / sf) - 1); 1 (>= 1) means no window and a depth of 1.doppler_rateDoppler rate in Hz/s the depth is bounded against (>= 0); 0 leaves the window as the only bound.
Returns:
Heap-allocated state, or NULL on bad arguments / allocation failure.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> from doppler.wfm import PN, mls_poly
>>> code = np.asarray(PN(poly=mls_poly(5), seed=1,
... length=5).generate(31)).astype(np.uint8)
>>> s0 = np.repeat(np.where(code & 1, -1.0, 1.0), 4).astype(
... np.complex64)
>>> burst = np.tile(np.roll(s0, 17), 23).astype(np.complex64)
>>> ref = np.where(code & 1, -1, 1).astype(np.complex64)
>>> a = Correlator(ref, framing="continuous", sample_rate=4e6, chip_rate=1e6, cn0_dbhz=50.0)
>>> h = a.push(burst)
>>> int(h["row"][0]), int(h["col"][0]) # detects (Doppler-window bin, code phase)
(0, 18)
>>> (a.code_bins, a.lag_bins) # 124 samples, read on 128 columns
(124, 128)
>>> round(18 * a.code_bins / a.lag_bins, 2) # column 18, in samples
17.44
>>> a.coherent_bins # no window given: one epoch
1
>>> b = Correlator(ref, framing="continuous", sample_rate=4e6, chip_rate=1e6, cn0_dbhz=50.0,
... code_only_epochs=7)
>>> b.coherent_bins # (7 + 1) // 2: a whole block fits
4
function dp_correlator_create_delay_doppler¶
Allocate the delay-Doppler flavor: a code correlator that maps a raw stream of ny code periods onto (Doppler, delay).
dp_correlator_state_t * dp_correlator_create_delay_doppler (
const float _Complex * code,
size_t code_len,
size_t ny,
size_t dwell,
int nthreads,
size_t ny_out
)
Input to dp_correlator_execute() is the raw stream ny periods of code_len samples, back to back, no reshaping or reference padding by the caller. Each period (row) is correlated against code exactly as the 2-D map's single-row fast path does (FFT, multiply by conj(FFT(code)), coherent dwell accumulation of the product spectrum, inverse scaled by 1/nx), and on the dump the slow-time FFT runs down every delay column. The library's one delay-Doppler map computes it (docs/design/acq-surface.md §18) in the order its rule picks: here the rows first, each row inverted as it is accumulated, which is what makes the row stage fused. In numpy terms, for one frame x (dwell 1): The output is ny_out x nx row-major: rows are Doppler bins, centered (zero Doppler on row ny_out / 2), columns are delay lags. A signal of amplitude a that is the code delayed by d samples and rotated by f cycles/sample peaks at column d and row ny_out/2 + f / doppler_step, where dp_correlator_state_t::doppler_step is 1 / (ny_out * nx) cycles/sample (times the sample rate for Hz). Its peak is a * dwell * ny * sum(abs(code)**2): the 1/nx of the row inverse cancels the row correlation's own gain of nx, and the slow-time FFT is unnormalized, as numpy's is, so it sums the ny rows coherently.
ny_out > ny zero-pads the slow-time samples after the ny rows: the ny_out-point DFT then samples the same Doppler response on a grid ny_out/ny times finer (band-limited interpolation). The pad adds no energy, so the peak at a bin center is unchanged and a Doppler between native bins is found at its fractional row.
Both stages fan out over nthreads workers the rows, then the columns each worker on its own FFT plans, and the result is bit-identical for every thread count.
Parameters:
codeThe code replica,code_lensamples (one period).code_lenSamples per period, nx; must be >= 1.nyPeriods per frame, the slow-time length; must be >= 1.dwellFrames coherently accumulated per dump; must be >= 1.nthreadsWorkers: 1 serial, N for N (the caller included), <= 0 every online core; capped at the most chunks a stage can use,max(ny, ceil(code_len / 16)).ny_outDoppler bins in the map; 0 meansny. Must be >=ny.
Returns:
Heap-allocated state (free with dp_correlator_destroy()), or NULL if code is NULL, code_len or ny is 0, dwell is 0, or ny_out is below ny.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> rng = np.random.default_rng(0)
>>> ny, nx, d, k = 16, 64, 5, 3 # delay 5, Doppler 3 bins
>>> code = np.exp(2j * np.pi * rng.random(nx)).astype(np.complex64)
>>> n = np.arange(ny * nx)
>>> f = k / (ny * nx) # cycles/sample
>>> x = (np.tile(np.roll(code, d), ny)
... * np.exp(2j * np.pi * f * n)).astype(np.complex64)
>>> dd = Correlator(code, doppler_rows=ny, dwell=2)
>>> out = np.empty(dd.execute_max_out(), np.complex64)
>>> for _ in range(2): # one preallocated map per dump
... m = dd.execute(x, out=out)
>>> m is not None and m.base is out
True
>>> row, col = np.unravel_index(np.argmax(np.abs(out)), (ny, nx))
>>> int(row) - ny // 2, int(col) # (Doppler bins, delay)
(3, 5)
>>> dd.doppler_step == 1 / (ny * nx)
True
function dp_correlator_create_detector_1d¶
Allocate a 1-D streaming detector: the 2-D detector at one row (docs/design/correlator.md section 2), so its hits are the 2-D one's at ny = 1, each with row 0 and the lag in col.
dp_correlator_state_t * dp_correlator_create_detector_1d (
const float _Complex * ref,
size_t ref_len,
size_t dwell,
size_t noise_lo,
size_t noise_hi,
det_noise_mode_t noise_mode,
float threshold,
int nthreads
)
After every dump the peak-to-noise test statistic is compared against threshold, and a hit is emitted when it passes; 0.0 fires on every dump. The ring capacity is next_pow_two(max(n, 512)) complex samples.
Parameters:
refReference signal, CF32 ndarray of length ref_len.ref_lenReference / FFT length in complex samples.dwellInt-dump depth; must be >= 1.noise_loLower noise bin index (inclusive, 0-based).noise_hiUpper noise bin index (inclusive, < n). A value at or beyond the window clamps to n - 1, so the default sentinel selects the full window.noise_modeNoise aggregation: "mean", "median", "min", or "max".thresholdTest-stat gate; 0.0 = always emit.nthreadsAccepted for API compatibility; ignored.
Returns:
Heap-allocated state, or NULL when the arguments are refused (an empty reference, dwell 0) or the stream's ring cannot be made. Out of memory for the detection buffers aborts, by the library's dp_x* convention (clib_common.h).
>>> from doppler.correlation import Correlator
>>> import numpy as np
>>> ref = np.zeros(8, dtype=np.complex64); ref[0] = 1.0
>>> det = Correlator(ref=ref, detect=1, dwell=1, noise_lo=1, noise_hi=7,
... noise_mode="mean", threshold=0.0)
>>> det.n, det.dwell, det.ring_cap
(8, 1, 512)
function dp_correlator_create_detector_2d¶
Allocate a 2-D streaming detector: the 2-D correlator with the stream and detection layers.
dp_correlator_state_t * dp_correlator_create_detector_2d (
const float _Complex * ref,
size_t ny,
size_t nx,
size_t dwell,
size_t noise_lo,
size_t noise_hi,
det_noise_mode_t noise_mode,
float threshold,
int nthreads
)
Input frames are flat row-major CF32 arrays of length ny*nx, cut from the stream by the ring's framer. On every dump the peak's flat index is decomposed into (row, col), and a dp_correlator_hit_t is emitted when test_stat > threshold. The Python class accepts a (ny, nx) CF32 ndarray for both ref and the push input. The ring capacity is next_pow_two(max(ny*nx, 512)) complex samples.
Parameters:
ref2-D reference image, (ny, nx) CF32 ndarray in Python.nyNumber of rows in the reference and input frames.nxNumber of columns in the reference and input frames.dwellInt-dump depth; must be >= 1.noise_loLower flat-index noise bin (inclusive, 0-based).noise_hiUpper flat-index noise bin (inclusive, < ny*nx). A value at or beyond the window clamps to ny*nx - 1, so the default sentinel selects the full window.noise_modeNoise aggregation: "mean", "median", "min", or "max".thresholdTest-stat gate; 0.0 = always emit.nthreadsWorkers for the single-row-reference fast path (1 serial, <= 0 every online core); the general 2-D path ignores it.
Returns:
Heap-allocated state, or NULL when the arguments are refused (an empty axis, dwell 0) or the stream's ring cannot be made. Out of memory for the detection buffers aborts, by the library's dp_x* convention (clib_common.h), as the map's plans do.
>>> from doppler.correlation import Correlator
>>> import numpy as np
>>> ref = np.zeros((4, 4), dtype=np.complex64); ref[0, 0] = 1.0
>>> det = Correlator(ref=ref, detect=1, dwell=1, noise_lo=1, noise_hi=15,
... noise_mode="mean", threshold=0.0)
>>> det.ny, det.nx, det.n, det.dwell
(4, 4, 16, 1)
function dp_correlator_destroy¶
Destroy and free a correlator, any flavor.
Parameters:
stateMay be NULL.
function dp_correlator_dsl_db¶
The search's Doppler-offset sidelobe level, dB: 20*log10 of the largest lag of the code's periodic ambiguity outside the mainlobe, at any Doppler offset the grid's tiles can put between an emitter and a tile, relative to the emitter's own peak ( dp_correlator_shape_t::dsl ).
What it predicts: one emitter's peak list carries peaks up to this far below its own, more than a mainlobe from its own lag, in the tiles it is not in and they stay there dwell after dwell, being the code's, not the noise's. A list consumer that skips the strongest peak (a rank, an exclusion) must not take one for a second emitter. It is at least dp_correlator_psl_db(), which is its zero-offset case, and equals it on a single-tile grid searched at one Doppler. -16.95 dB for the receivers' Gold-1023 search at two samples a chip over +-5 kHz (five 3 kHz tiles), against a -23.9 dB psl. Configuration, not state: fixed at construction, kept by a grid pinned later, and not serialized. Computed on the first call and cached in state (hence non-const).
Parameters:
stateMust be non-NULL. NaN on a map or detector flavor (no search record).
Returns:
Doppler-offset sidelobe level in dB, or -INFINITY when there is none.
#include "doppler/correlator/correlator_core.h"
#include "doppler/gold/gold_core.h"
#include <stdio.h>
int main (void)
{
uint8_t code[1023];
dp_gold_state_t *g = dp_gold_create (934, 350, 567, 73, 10);
dp_gold_generate (g, 1023, code, 1023); // the specification Gold-1023 code
dp_gold_destroy (g);
dp_correlator_state_t *a = dp_correlator_create_continuous (
code, 1023, 2 * 3.069e6, 3.069e6, 2700.0, 47.0, 5000.0, 1e-3, 0.9,
0, 1, 0.0);
printf ("%.1f %.1f\n", dp_correlator_psl_db (a), dp_correlator_dsl_db (a));
// -23.9 -16.9
dp_correlator_destroy (a);
return 0;
}
function dp_correlator_execute¶
Correlate one 2-D frame and optionally dump the coherent accumulator. Runs the 2-D pipeline: FFT2 → pointwise multiply with ref_spec → accumulate the cross-spectrum; on dump, IFFT2 → normalise (÷ ny*nx). Accumulating in the frequency domain and inverting once is exactly the per-frame inverse summed, by linearity of the IFFT — valid because the dwell is coherent (a complex sum); a non-coherent (magnitude) integration could not defer the inverse.
size_t dp_correlator_execute (
dp_correlator_state_t * state,
const float _Complex * in,
size_t n_in,
float _Complex * out,
size_t max_out,
const char ** why
)
Layout. A frame is ny*nx complex samples in row-major order: row i is samples i*nx .. (i+1)*nx - 1. For the 2-D map that is a (ny, nx) image; for the delay-Doppler map it is the raw stream, ny code periods of nx = code_len samples back to back. The map a dump produces is flat, n_out = ny_out * nx_out values (ny values with col_out), also row-major: reshape it to (ny_out, nx_out). On the delay-Doppler map, axis 0 is Doppler (centered, zero Doppler on row ny_out / 2) and axis 1 is delay (the lag, in samples).
Ownership. In Python, a call that dumps returns a new array when no out= is given, and a view of out= when one is (a 1-D array holding at least n_out values; it is written on a dump only, and the next dump overwrites it). A call that does not dump returns None and touches neither.
Parameters:
stateAllocated 2-D correlator (non-NULL).inInput frame, flat row-major CF32, length ny*nx.n_inNumber of input samples; must equal ny*nx; else REFUSED.outOutput buffer for the correlation map (CF32, length n_out: ny_out*nx_out, or ny withcol_out); written only on a dump call.max_outCapacity ofoutin elements. Emission stops there, so the return value is the number actually written.whyWhere the refusal's sentence goes, naming the argument it refused; may be NULL. A static string, never freed. Off the flavors that serve the call it stays NULL (the binding then raises the declared "only" sentence; just-makeit#2574).
Returns:
Python: the map on a dump, None otherwise; a frame that is not ny*nx samples is REFUSED with nothing read, written or counted, as a ValueError (#1925). C: n_out on a dump (or max_out if smaller), 0 otherwise, and SIZE_MAX for the refused frame.
>>> from doppler.correlation import Correlator
>>> import numpy as np
>>> ref = np.zeros((2, 2), dtype=np.complex64); ref[0, 0] = 1.0
>>> c = Correlator(ref=ref, dwell=2)
>>> x = np.ones((2, 2), dtype=np.complex64)
>>> c.execute(x) is None # frame 1 — no dump
True
>>> c.execute(x).tolist() # frame 2 — dump
[(2+0j), (2+0j), (2+0j), (2+0j)]
function dp_correlator_execute_all¶
Every map of a batch, unreduced: row h of the (H, n_out) result is the map of frame h (in C, map h is at out + h * n_out ).
size_t dp_correlator_execute_all (
dp_correlator_state_t * state,
const float _Complex * in,
size_t n_in,
float _Complex * out,
size_t max_out,
const char ** why
)
Python: x is the H frames back to back, a flat array of H * ny * nx samples (H >= 1): frame h is the samples from h * ny * nx up to, not including, (h + 1) * ny * nx. With no out= each call returns a new array; with out= it returns a view of it, and the next call into the same out= overwrites that view. out= is a 2-D complex64 array of shape (rows, n_out) with at least H rows (a shorter one is refused); the result is its first H rows. The object's dwell is untouched.
Parameters:
stateMust be non-NULL.inH frames back to back (CF32).n_inA nonzero multiple of ny * nx.outH * n_out values (CF32).max_outCapacity ofout; at least dp_correlator_execute_all_max_out().whyWhere the refusal's sentence goes, naming the argument it refused; may be NULL. A static string, never freed. Off the flavors that serve the call it stays NULL (the binding then raises the declared "only" sentence; just-makeit#2574).
Returns:
Python: the (H, n_out) array; a refused batch (empty, not a whole number of frames, or an out= with fewer than H rows) is a ValueError with nothing written. C: H * n_out, or SIZE_MAX for the refused batch.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> rng = np.random.default_rng(0)
>>> ny, nx = 8, 32
>>> code = np.exp(2j * np.pi * rng.random(nx)).astype(np.complex64)
>>> dd = Correlator(code, doppler_rows=ny)
>>> frames = np.concatenate([np.tile(np.roll(code, d), ny)
... for d in (3, 11)]) # delays 3 and 11
>>> maps = dd.execute_all(frames)
>>> maps.shape
(2, 256)
>>> [int(np.argmax(np.abs(m))) % nx for m in maps] # each map's delay
[3, 11]
>>> dd.count # the dwell never moved
0
function dp_correlator_execute_all_max_out¶
Samples dp_correlator_execute_all() writes forn_in input samples: H * n_out, H = n_in / (ny * nx).
Parameters:
stateMust be non-NULL.n_inInput samples about to be passed. 0 on a detector or search flavor, which execute_all() refuses.
Returns:
The capacity execute_all needs for n_in samples: H * n_out values (C: SIZE_MAX if that overflows).
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> rng = np.random.default_rng(0)
>>> ny, nx = 8, 32
>>> code = np.exp(2j * np.pi * rng.random(nx)).astype(np.complex64)
>>> dd = Correlator(code, doppler_rows=ny)
>>> frames = np.concatenate([np.tile(np.roll(code, d), ny)
... for d in (3, 11)]) # delays 3 and 11
>>> dd.execute_all_max_out(len(frames)) # 2 maps of 8 x 32
512
function dp_correlator_execute_coherent¶
The coherent sum of a batch's maps, inverted once.
size_t dp_correlator_execute_coherent (
dp_correlator_state_t * state,
const float _Complex * in,
size_t n_in,
float _Complex * out,
size_t max_out,
const char ** why
)
Python: x is the H frames back to back, a flat array of H * ny * nx samples (H >= 1).
The frames' product spectra are summed and the sum is inverted, as a dwell does: the result is bit-identical to what a fresh object with dwell = H dumps for the same frames, and equal to the sum of the H maps up to rounding. The object's own dwell is untouched.
Parameters:
stateMust be non-NULL.inH frames back to back (CF32).n_inA nonzero multiple of ny * nx.outn_out values (CF32).max_outCapacity ofout; at least n_out.whyWhere the refusal's sentence goes, naming the argument it refused; may be NULL. A static string, never freed. Off the flavors that serve the call it stays NULL (the binding then raises the declared "only" sentence; just-makeit#2574).
Returns:
Python: the one map, a new (n_out,) array; a refused batch is a ValueError with nothing written. C: n_out, or SIZE_MAX for the refused batch.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> rng = np.random.default_rng(0)
>>> ny, nx = 8, 32
>>> code = np.exp(2j * np.pi * rng.random(nx)).astype(np.complex64)
>>> dd = Correlator(code, doppler_rows=ny)
>>> frames = np.concatenate([np.tile(np.roll(code, d), ny)
... for d in (3, 11)]) # delays 3 and 11
>>> x = np.tile(code, ny)
>>> total = dd.execute_coherent(np.concatenate([x, -x]))
>>> bool(np.abs(total).max() < 1e-3) # x and -x cancel
True
function dp_correlator_execute_coherent_max_out¶
Samples dp_correlator_execute_coherent() writes: n_out.
Parameters:
stateMust be non-NULL.
Returns:
n_out, fixed at create().
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> rng = np.random.default_rng(0)
>>> ny, nx = 8, 32
>>> code = np.exp(2j * np.pi * rng.random(nx)).astype(np.complex64)
>>> dd = Correlator(code, doppler_rows=ny)
>>> frames = np.concatenate([np.tile(np.roll(code, d), ny)
... for d in (3, 11)]) # delays 3 and 11
>>> dd.execute_coherent_max_out()
256
function dp_correlator_execute_fold¶
Make the map of every frame in a batch and hand each to a reducer.
size_t dp_correlator_execute_fold (
dp_correlator_state_t * state,
const float _Complex * in,
size_t n_in,
const dp_correlator_fold_t * fold
)
The one loop every typed batch call runs on. Maps are made as described above and passed to fold->fold(fold->ctx, h, map, n_out) for h = 0 .. H-1, in that order, from the calling thread.
Parameters:
stateMust be non-NULL.inH frames, each ny * nx samples (CF32), back to back.n_inSamples inin:a nonzero multiple of ny * nx.foldThe reducer; must be non-NULL.
Returns:
H, or SIZE_MAX (nothing folded) when n_in is 0 or not a multiple of the frame.
#include "doppler/correlator/correlator_core.h"
#include <stdio.h>
// A reducer: the energy of each map, one value per frame.
static void
energy (void *ctx, size_t h, const float _Complex *m, size_t n_out)
{
double e = 0.0;
for (size_t k = 0; k < n_out; k++)
e += crealf (m[k]) * crealf (m[k]) + cimagf (m[k]) * cimagf (m[k]);
((double *)ctx)[h] = e;
}
int
main (void)
{
const float _Complex code[4] = { 1.0f, 1.0f, -1.0f, 1.0f };
dp_correlator_state_t *dd
= dp_correlator_create_delay_doppler (code, 4, 2, 1, 1, 0);
float _Complex frames[3 * 2 * 4]; // 3 frames of ny x nx = 2 x 4
for (size_t k = 0; k < 3 * 2 * 4; k++)
frames[k] = code[k % 4] * (float)(1 + k / 8); // frame h is (h+1) x
double e[3];
dp_correlator_fold_t f = { energy, e };
size_t H = dp_correlator_execute_fold (dd, frames, 3 * 2 * 4, &f);
printf ("%zu maps, energy ratios %.0f %.0f\n", H, e[1] / e[0],
e[2] / e[0]); // 3 maps, energy ratios 4 9
dp_correlator_destroy (dd);
return !(H == 3 && e[1] > 3.99 * e[0] && e[1] < 4.01 * e[0]);
}
function dp_correlator_execute_max_out¶
Maximum output samples per execute call ( dp_correlator_state_t::n_out __ ny_out*nx_out normally, or ny when a singledp_correlator_state_t::col_out was selected).
Parameters:
stateMust be non-NULL.
0 on a detector or search flavor, which execute() refuses.
Returns:
n_out, fixed at create().
function dp_correlator_execute_peaks¶
One record per map of a batch: its peak power, where the peak is, and its mean power.
size_t dp_correlator_execute_peaks (
dp_correlator_state_t * state,
const float _Complex * in,
size_t n_in,
float * out,
uint32_t * out1,
uint32_t * out2,
float * out3,
size_t max_out,
const char ** why
)
Python: x is the H frames back to back, a flat array of H * ny * nx samples (H >= 1).
Entry h of each output describes map h: out its largest |map|^2, out1 and out2 the row and column of that cell (the first in row-major order on a tie), and out3 the mean |map|^2 over its n_out cells. A map is ny_out x nx_out; with col_out it is ny x 1, and the column reported is col_out. The peak-to-mean of each map is out over out3, entry by entry: a statistic of each map, which the same statistic of a pointwise maximum over maps does not give.
Parameters:
stateMust be non-NULL.inH frames back to back (CF32).n_inA nonzero multiple of ny * nx.outH peak powers (float).out1H peak rows (uint32).out2H peak columns (uint32).out3H mean powers (float).max_outCapacity of each output; at least H.whyWhere the refusal's sentence goes, naming the argument it refused; may be NULL. A static string, never freed. Off the flavors that serve the call it stays NULL (the binding then raises the declared "only" sentence; just-makeit#2574).
Returns:
Python: the tuple (peak, row, col, mean), each (H,): float32 peak power, uint32 row and column, float32 mean power, always new arrays (this call takes no out=); a refused batch is a ValueError. C: H, or SIZE_MAX with nothing written.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> rng = np.random.default_rng(0)
>>> ny, nx = 8, 32
>>> code = np.exp(2j * np.pi * rng.random(nx)).astype(np.complex64)
>>> dd = Correlator(code, doppler_rows=ny)
>>> frames = np.concatenate([np.tile(np.roll(code, d), ny)
... for d in (3, 11)]) # delays 3 and 11
>>> peak, row, col, mean = dd.execute_peaks(frames)
>>> row.tolist(), col.tolist() # zero Doppler is row ny / 2
([4, 4], [3, 11])
>>> bool(np.all(peak / mean > 100)) # each map's own peak-to-mean
True
function dp_correlator_execute_peaks_max_out¶
Records dp_correlator_execute_peaks() writes forn_in samples: H.
Parameters:
stateMust be non-NULL.n_inInput samples about to be passed. 0 on a detector or search flavor, which execute_peaks() refuses.
Returns:
n_in / (ny * nx).
const float _Complex code[4] = { 1.0f, 1.0f, -1.0f, 1.0f };
dp_correlator_state_t *dd = dp_correlator_create_delay_doppler (code, 4, 2, 1, 1,
0);
size_t h = dp_correlator_execute_peaks_max_out (dd, 3 * 2 * 4); // 3 frames
dp_correlator_destroy (dd);
return h != 3;
function dp_correlator_execute_power_max¶
The largest power over a batch's maps, cell by cell, and the map it came from.
size_t dp_correlator_execute_power_max (
dp_correlator_state_t * state,
const float _Complex * in,
size_t n_in,
float * out,
uint32_t * out1,
size_t max_out,
const char ** why
)
Python: x is the H frames back to back, a flat array of H * ny * nx samples (H >= 1).
Each cell of out is the largest |map_h|^2 that cell takes over the maps, and the same cell of out1 is the h it came from. A tie goes to the lowest h: a later map replaces the running maximum only when it is strictly greater.
Parameters:
stateMust be non-NULL.inH frames back to back (CF32); H at most 2^32.n_inA nonzero multiple of ny * nx.outn_out powers (float).out1n_out map indices (uint32).max_outCapacity of each ofoutandout1; at least n_out.whyWhere the refusal's sentence goes, naming the argument it refused; may be NULL. A static string, never freed. Off the flavors that serve the call it stays NULL (the binding then raises the declared "only" sentence; just-makeit#2574).
Returns:
Python: the tuple (power, index), each (n_out,): float32 powers and uint32 map indices, always new arrays (this call takes no out=); a refused batch, or H above 2**32, is a ValueError. C: n_out, or SIZE_MAX with nothing written.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> rng = np.random.default_rng(0)
>>> ny, nx = 8, 32
>>> code = np.exp(2j * np.pi * rng.random(nx)).astype(np.complex64)
>>> dd = Correlator(code, doppler_rows=ny)
>>> frames = np.concatenate([np.tile(np.roll(code, d), ny)
... for d in (3, 11)]) # delays 3 and 11
>>> power, index = dd.execute_power_max(frames)
>>> int(index[4 * nx + 3]), int(index[4 * nx + 11]) # which map peaks
(0, 1)
function dp_correlator_execute_power_max_max_out¶
Values per output dp_correlator_execute_power_max() writes: n_out.
Parameters:
stateMust be non-NULL.
Returns:
n_out, fixed at create().
const float _Complex code[4] = { 1.0f, 1.0f, -1.0f, 1.0f };
dp_correlator_state_t *dd = dp_correlator_create_delay_doppler (code, 4, 2, 1, 1,
0);
size_t n = dp_correlator_execute_power_max_max_out (dd); // 2 x 4 = 8
dp_correlator_destroy (dd);
return n != 8;
function dp_correlator_execute_power_sum¶
The power of a batch's maps, summed cell by cell: each output cell is the sum over h of that cell's |map_h|^2 , summed in h order in float.
size_t dp_correlator_execute_power_sum (
dp_correlator_state_t * state,
const float _Complex * in,
size_t n_in,
float * out,
size_t max_out,
const char ** why
)
Python: x is the H frames back to back, a flat array of H * ny * nx samples (H >= 1).
Unlike the coherent sum, phase does not cancel: frames x and -x sum to twice one map's power, where their coherent sum is zero.
Parameters:
stateMust be non-NULL.inH frames back to back (CF32).n_inA nonzero multiple of ny * nx.outn_out powers (float).max_outCapacity ofout; at least n_out.whyWhere the refusal's sentence goes, naming the argument it refused; may be NULL. A static string, never freed. Off the flavors that serve the call it stays NULL (the binding then raises the declared "only" sentence; just-makeit#2574).
Returns:
Python: the (n_out,) float32 powers, a new array; a refused batch is a ValueError with nothing written. C: n_out, or SIZE_MAX for the refused batch.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> rng = np.random.default_rng(0)
>>> ny, nx = 8, 32
>>> code = np.exp(2j * np.pi * rng.random(nx)).astype(np.complex64)
>>> dd = Correlator(code, doppler_rows=ny)
>>> frames = np.concatenate([np.tile(np.roll(code, d), ny)
... for d in (3, 11)]) # delays 3 and 11
>>> x = np.tile(code, ny)
>>> power = dd.execute_power_sum(np.concatenate([x, -x]))
>>> one = np.abs(dd.execute_all(x)[0]) ** 2
>>> bool(np.allclose(power, 2 * one)) # x and -x do not cancel
True
function dp_correlator_execute_power_sum_max_out¶
Powers dp_correlator_execute_power_sum() writes: n_out.
Parameters:
stateMust be non-NULL.
Returns:
n_out, fixed at create().
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> rng = np.random.default_rng(0)
>>> ny, nx = 8, 32
>>> code = np.exp(2j * np.pi * rng.random(nx)).astype(np.complex64)
>>> dd = Correlator(code, doppler_rows=ny)
>>> frames = np.concatenate([np.tile(np.roll(code, d), ny)
... for d in (3, 11)]) # delays 3 and 11
>>> dd.execute_power_sum_max_out()
256
function dp_correlator_flavor¶
Which constructor built state: whatdp_correlator_create() chose from its knobs, so a caller can ask before reading a member only some flavors serve.
Parameters:
stateMust be non-NULL.
Returns:
The flavor, fixed at create.
function dp_correlator_gate_stat¶
The gate a dwell's statistic must clear to be a hit, in the units of dp_correlator_hit_t::test_stat :threshold on the coherent path (one look),eta_nc on the non-coherent one. A dwell hits when its strongest cell's statistic exceeds this, and every listed peak's statistic does too. Both statistics are linear in the cell's amplitude, so a list consumer can compare a peak's excess over another's against it in the same units. Configuration: fixed by the thresholds the grid was sized with.
Parameters:
stateMust be non-NULL. NaN on a map or detector flavor (no search record).
Returns:
The gate, in dp_correlator_hit_t::test_stat units.
function dp_correlator_get_carrier_freq_hz¶
RF carrier the Doppler is coupled to, Hz (0.0 = uncoupled); set with set_carrier_freq_hz().
Served by the continuous search (framing='continuous'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_chip_rate¶
Chip rate, Hz.
Served by the continuous search (framing='continuous'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_cn0_dbhz¶
Carrier-to-noise density the search was sized for, dB-Hz; NaN for no design point (the burst search only).
Served by a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_code_bins¶
One period of the reference in samples: the length of every forward transform and of a raw epoch.
Served by a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_coherent_bins¶
The block-coherent depth D inside every window tile: epochs per block and Doppler rows per tile. 1 without a code-only window.
Served by the continuous search (framing='continuous'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_col_out¶
The one lag a dump emits per row, or -1 for every lag.
Served by the 1-D or 2-D map (framing='none', detect=False, doppler_rows=0); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_count¶
Frames accumulated toward the next dump (0 ... dwell - 1).
Served by a map or a detector (framing='none'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_doppler_bins¶
Doppler hypotheses searched, window tiles times the coherent depth: the count to fold a hit's row over (bin_to_signed(row, doppler_bins) * doppler_res_hz is the signed Doppler).
Served by a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_doppler_rate¶
Doppler rate the coherent depth is bounded against, Hz/s (0 = no bound); with rate_hypotheses > 1, the span of the hypotheses.
Served by the burst search (framing='burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_doppler_res_hz¶
Doppler bin width, Hz.
Served by a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_doppler_span_hz¶
Native unambiguous Doppler half-range, Hz: sample_rate / (2 * code_bins).
Served by a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_doppler_step¶
Doppler bin width of the delay-Doppler map, cycles per sample.
Served by the delay-Doppler map (doppler_rows > 0); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_dwell¶
Integration depth: a dump every dwell frames.
Served by a map or a detector (framing='none'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_epochs_per_symbol¶
(chip_rate / sf) / symbol_rate: code epochs per data symbol; 0 when symbol_rate is 0.
Served by the continuous search (framing='continuous'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_eta¶
Raw per-cell Rayleigh amplitude threshold.
Served by a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_eta_nc¶
Non-coherent CFAR threshold (order-N_nc Marcum).
Served by a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_keep_surface¶
Whether every decided dwell's surface is kept for dp_correlator_surface() : 1 or 0.
The continuous search only (docs/design/correlator.md section 4): any other flavor keeps no surface and refuses the read, and Python's read raises AttributeError.
Parameters:
stateMust be non-NULL.outReceives 1 if kept, else 0; untouched on a refusal.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the continuous search.
function dp_correlator_get_lag_bins¶
Code-phase columns of the surface: code_bins unless code_bins is not 7-smooth, then the next power of two (an exact interpolation). surface_chip_phase() gives each column in chips.
Served by the continuous search (framing='continuous'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_max_peaks¶
The peak list's capacity per dwell (1 = the classic gated maximum); set with set_max_peaks().
Served by a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_n¶
Frame length in samples: the reference's length, ny * nx.
Served by the 1-D map or a detector (detect=True); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_n_held¶
Picks of the last decided dwell held as same-code-phase twins rather than listed (docs/design/async-dsss-receiver.md section 7.1).
Served by the continuous search (framing='continuous'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_n_noncoh¶
Non-coherent looks per detection (1 = pure coherent).
Served by a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_n_peaks¶
Picks in the last decided dwell, held twins included.
Served by the continuous search (framing='continuous'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_noise_hi¶
Last noise (CFAR reference) bin, inclusive.
Served by a detector (detect=True) or a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_noise_lo¶
First noise (CFAR reference) bin, inclusive.
Served by a detector (detect=True) or a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_nx¶
Samples a reference row: the correlation's native lag count.
Served by a map or a detector (framing='none'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_nx_out¶
Lags a dump writes per row: nx unless padded (nx_out), which interpolates the lag axis. The one padding name at any row count.
Served by the 1-D or 2-D map (framing='none', detect=False, doppler_rows=0); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_ny¶
Rows of the reference: 1 for a 1-D one; the delay-Doppler map's Doppler rows (doppler_rows).
Served by a map or a detector (framing='none'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_ny_out¶
Rows a dump writes: ny unless padded (ny_out), which interpolates the Doppler or row axis.
Served by a map (framing='none', detect=False); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_pd¶
Target detection probability.
Served by a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_pd_burst¶
Predicted Pd of one burst of reps repetitions at cn0_dbhz: the number the sizer meets pd with. NaN with no design cn0_dbhz or with n_noncoh > 1.
Served by the burst search (framing='burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_pd_predicted¶
Predicted Pd at cn0_dbhz and the chosen grid, averaged over the straddle priors (slow-time scalloping, intra-segment rotation, code-phase sample offset): what the Monte-Carlo characterization measures, not the on- grid best case.
Served by a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_peak_conc¶
Concentration of the last dwell's strongest peak: its main lobe's power over its code-phase column's, across every Doppler row and tile. Near 1 for a clean single emitter; about 0.5 when a data transition splits it into twins (docs/design/async-dsss-receiver.md section 2.4).
Served by the continuous search (framing='continuous'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_pfa_cell¶
Sidak per-cell false-alarm probability over the searched cells.
Served by a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_psl_db¶
The preamble's peak sidelobe level, dB: its periodic autocorrelation's largest lag outside the mainlobe, relative to the peak (-inf for a perfect sequence such as Zadoff-Chu).
Served by the burst search (framing='burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_rate_hypotheses¶
Doppler-rate hypotheses searched: as given, or the engine's choice when built with 0; 1 is none.
Served by the burst search (framing='burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_reps¶
Preamble repetitions a burst holds: the coherence ceiling.
Served by the burst search (framing='burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_ring_cap¶
Input ring capacity in complex samples.
Served by a detector (detect=True) or a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_sample_rate¶
Sample rate the search runs at, Hz: the constructor's sample_rate.
Served by a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_sf¶
Chips per code period: len(ref).
Served by the continuous search (framing='continuous'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_state¶
Serialize the frame count and spectrum accumulator into blob .
Parameters:
stateMust be non-NULL.blobDestination; at least dp_correlator_state_bytes() bytes.
function dp_correlator_get_straddle_loss¶
Mean amplitude derating of the correlation peak from grid straddle, a diagnostic; 20*log10(straddle_loss) is the loss in dB.
Served by a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_surface_at¶
samples_consumed of the dwell whose surface surface() returns (0 until one has been captured).
Served by the continuous search (framing='continuous'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_surface_rows¶
Rows of the surface surface() returns: the Doppler axis in surface units; its columns are lag_bins.
Served by the continuous search (framing='continuous'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_symbol_rate¶
Data-symbol rate the search was built with, Hz (0 = no known data clock): a diagnostic, never sizing.
Served by the continuous search (framing='continuous'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_threads¶
Workers the search fans its tiles across, the calling thread included; 1 = serial. Set with set_threads().
Served by a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_threshold¶
The gate on the test statistic: a detector's as given (0 fires on every dump); a search's derived from pfa (the coherent path's gate).
Served by a detector (detect=True) or a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_get_underpowered¶
True when the search cannot meet pd at cn0_dbhz and its geometry: pd_predicted < pd for the continuous search, pd_burst < pd for the burst search. It still builds a best-effort grid, and construction warns (UserWarning).
Served by a search (framing='continuous' or 'burst'); any other flavor refuses it, and Python's read raises AttributeError (docs/design/correlator.md section 4).
Parameters:
stateMust be non-NULL.outReceives the value when served.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED off the flavors that serve it.
function dp_correlator_last_corr_status¶
Whether this flavor has a last correlation vector to read: Python's Correlator.last_corr asks it before it builds the view.
Both detectors serve it (section 4); there, the view reads None until a push() has produced a result. Any other flavor refuses, and Python's read raises AttributeError.
Parameters:
stateMust be non-NULL.
Returns:
DP_OK on a detector, DP_ERR_UNSUPPORTED on any other flavor.
function dp_correlator_period_samples¶
The samples one code period should be searched at: the smallest power of two that holds at least two samples a chip.
The search's fast-time transform is one code period long, so its length decides its speed: 2 * 1023 = 2,046 = 2 * 3 * 11 * 31 runs 5x slower than 2,048 (docs/design/async-dsss-receiver.md). An object that resamples its input for the search resamples to chip_rate * dp_correlator_period_samples(code_len) / code_len, and builds the engine at that rate. Two samples a chip is the least a code loop's early and late taps need.
Parameters:
code_lenChips in one code period (>= 1).
Returns:
The period in samples, a power of two: 2048 for 1023 or 1024 chips, 64 for 31; 0 for code_len 0 or one whose period would not fit a size_t.
function dp_correlator_position¶
The engine's stream position: every sample its pushes have taken, framed ones and the carry, since create, reset, a regrid or set_state's restore.
The timebase dp_correlator_hit_t::samples_consumed is counted in. Read at the start of a push, it is where that push's input begins, so a hit from that push ended at x + (hit.samples_consumed - position): the hand-off a tracker resumes from. A caller's own count of what it has fed is a different timebase configure_search_raw() and set_state() reset or restore the engine and not the caller's count and subtracting the two reads outside x.
float _Complex pre[124]; // a 31-chip code at 4x
for (size_t i = 0; i < 124; i++)
pre[i] = (i / 4) % 3 ? 1.0f : -1.0f;
dp_correlator_state_t *a = dp_correlator_create_burst (pre, 124, 16, 4.0e6, 45.0,
0.0, 1e-3, 0.9, 0, 0.0, 1);
float _Complex x[300] = { 0 };
uint64_t before = dp_correlator_position (a); // 0
dp_correlator_hit_t hit;
if (dp_correlator_push (a, x, 300, &hit, 1) == 1)
printf ("hit ended at x + %llu\n",
(unsigned long long)(hit.samples_consumed - before));
uint64_t after = dp_correlator_position (a); // 300: framed and carried
dp_correlator_destroy (a);
if (before != 0 || after != 300)
return 1;
Parameters:
stateMust be non-NULL. 0 on a map or detector flavor (no search record).
Returns:
Samples taken since create, reset, a regrid or a restore: those framed plus the carry still pending.
function dp_correlator_psl_db¶
The preamble's peak sidelobe level, dB: 20*log10 of the largest periodic-autocorrelation lag outside the mainlobe, relative to the peak ( dp_correlator_shape_t::psl ).
What it predicts: a detection's sidelobes sit this far below it, at delays outside the peak zone where the peak list's exclusion does not reach. So a burst that clears the threshold by more than -psl_db also lists its own sidelobe as a second peak (with max_peaks > 1), and a strong burst's sidelobe can mask a weak one there. A code's is its periodic floor, 20*log10(1/31) = -29.8 dB for a 31-chip m-sequence; a perfect sequence (Zadoff-Chu, a Frank-type chirp) has none and reads -INFINITY. Configuration, not state: it is fixed at construction and not serialized.
Parameters:
stateMust be non-NULL. NaN on a map or detector flavor (no search record).
Returns:
Peak sidelobe level in dB (<= 0), or -INFINITY.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> from doppler.cvt import bin_to_nrz
>>> from doppler.wfm import PN
>>> chips = (np.asarray(PN(poly=0, seed=1, length=5).generate(31)) & 1
... ).astype(np.uint8)
>>> nrz = np.zeros(31, dtype=np.float32)
>>> _ = bin_to_nrz(chips, nrz)
>>> pre = np.repeat(nrz, 4).astype(np.complex64) # 4 samples a chip
>>> a = Correlator(pre, framing="burst", reps=4, sample_rate=4.0e6, cn0_dbhz=61.0)
>>> round(a.psl_db, 2) # an m-sequence: 1/31
-29.83
>>> k = np.arange(127)
>>> zc = np.exp(-1j * np.pi * 5 * k * (k + 1) / 127).astype(np.complex64)
>>> Correlator(zc, framing="burst", reps=8, sample_rate=1.0e6, cn0_dbhz=53.0).psl_db
-inf
function dp_correlator_push¶
Stream an arbitrary-length CF32 chunk through a detector or a search flavor; return its detections.
size_t dp_correlator_push (
dp_correlator_state_t * state,
const float _Complex * in,
size_t n_in,
dp_correlator_hit_t * result,
size_t max_results
)
Takes the input in order and frames it. A detector runs each complete n-sample frame (n = ny*nx) through the correlator and, on every dump, computes the test statistic peak_mag / noise_est: each dump that passes the threshold is one hit, row and col its cell (on one row, col is the lag). A search gates each decided dwell on its CFAR threshold and lists up to max_peaks hits a dwell, each with its Doppler bin (row), code phase (col), C/N0 estimate and hand-off fields (dp_correlator_hit_t). A chunk that ends mid-frame keeps the rest as the carry, so the hits do not depend on how the stream is split into calls.
In Python the hits are one structured array of dp_correlator_hit_t records, a field per member, sized from dp_correlator_push_max_out(): a push never loses input to a full list. A map flavor refuses it.
Parameters:
stateA detector or search flavor (non-NULL).inCF32 input chunk of arbitrary length.n_inNumber of input samples inin.resultCaller-supplied array of at leastmax_resultshits; filled on return.max_resultsCapacity ofresult(maximum detections to emit). A fullresultnever loses input: a detector's frame yields at most one detection (a search's at most max_peaks), and onceresultis full the push takes the rest of its input only if the rest completes no frame (it is then the carry); otherwise it takes nothing more, stopping on the boundary of its last frame. dp_correlator_consumed() says how many samples it took, and the caller offers the rest again. Input that runs out mid-frame is the carry, held inside (fewer than n samples). With room 0 the push is full from the start, so a resume loop needs room for at least one; with that, a push of any input takes at least one sample.
Returns:
Python: the hits, a structured array, empty when no dump or dwell passed the gate. C: the number of hits written to result, or SIZE_MAX (nothing taken, nothing changed) when state is a map flavor.
>>> from doppler.correlation import Correlator
>>> import numpy as np
>>> ref = np.zeros((4, 4), dtype=np.complex64); ref[0, 0] = 1.0
>>> det = Correlator(ref=ref, detect=1, dwell=1, noise_lo=1, noise_hi=15,
... noise_mode="mean", threshold=0.0)
>>> h = det.push(np.ones((4, 4), dtype=np.complex64))[0]
>>> row, col = int(h["row"]), int(h["col"])
>>> peak, noise, stat = (float(h[f]) for f in ("peak_mag", "noise_est",
... "test_stat"))
>>> row, col, round(peak, 4), round(noise, 4), round(stat, 4)
(0, 0, 1.0, 1.0, 1.0)
>>> det1 = Correlator(ref=ref[0], detect=1, dwell=1, noise_lo=1, noise_hi=3,
... noise_mode="mean", threshold=0.0)
>>> h = det1.push(np.ones(4, dtype=np.complex64))[0]
>>> lag = int(h["col"]) # one row: the lag is the column
>>> peak, noise, stat = (float(h[f]) for f in ("peak_mag", "noise_est",
... "test_stat"))
>>> lag, round(peak, 4), round(noise, 4), round(stat, 4)
(0, 1.0, 1.0, 1.0)
A burst search over a PN preamble, 4 samples a chip, finds the burst's
delay; any repeated preamble works, a Zadoff-Chu sequence included:
>>> from doppler.wfm import PN, mls_poly
>>> code = np.asarray(PN(poly=mls_poly(5), seed=1, length=5).generate(31),
... np.uint8)
>>> s0 = np.repeat(np.where(code & 1, -1.0, 1.0), 4).astype(np.complex64)
>>> b = Correlator(s0, framing="burst", reps=8, sample_rate=4e6,
... cn0_dbhz=60.0)
>>> h = b.push(np.tile(np.roll(s0, 17), 24))[0]
>>> int(h["row"]), int(h["col"]) # (Doppler bin, delay in samples)
(0, 17)
>>> k = np.arange(127)
>>> zc = np.exp(-1j * np.pi * 5 * k * (k + 1) / 127).astype(np.complex64)
>>> z = Correlator(zc, framing="burst", reps=8, sample_rate=1.0)
>>> z.code_bins # samples a repetition
127
>>> h = z.push(np.tile(np.roll(zc, 40), 10))[0]
>>> int(h["row"]), int(h["col"])
(0, 40)
function dp_correlator_push_max_out¶
The most hits dp_correlator_push() can return forn_in more samples: a result array this long is never short.
The frames n_in completes, counting the carry the last push left, times what one frame can make: one hit for a detector (one per dump), max_peaks for a search (a frame that ends a dwell lists up to that many). A bound, not a count: most frames end no dump. 0 on a map flavor, which push() refuses. SIZE_MAX if the product would overflow.
Parameters:
stateMust be non-NULL.n_inSamples the next push() will be given.
Returns:
The bound, in hits.
function dp_correlator_rate_hypotheses_for¶
The fewest rate hypotheses over [-span, +span] that leave the residualspan/(n - 1) within what a block ofdepth epochs tolerates,f_epoch^2/(2*depth^2) __ the drift rule behind the depth cap, inverted. At least 2 for a positive span; 1 for none; at mostDP_CORRELATOR_RATE_HYPS_MAX .
Parameters:
f_epochEpoch rate, Hz (fs/nfor a burst engine).spanRate span, Hz/s (>= 0).depthBlock depth in epochs (>= 1).
Returns:
The hypothesis count; 1 when span is not positive and finite, f_epoch is not positive and finite, or depth is 0.
function dp_correlator_rate_hypothesis¶
Rate hypothesis h ofn over[-span, +span] , Hz/s:-span + 2*span*h/(n - 1) ; 0 forn <= 1 .
The engine's grid, exported so a composing object searches the SAME rates and not a restatement of them (dp_burst_capture's refine).
Parameters:
spanHalf-width of the rate search, Hz/s.nNumber of hypotheses on the grid.hHypothesis index, 0 .. n - 1 (not range-checked).
Returns:
The rate of hypothesis h, Hz/s.
function dp_correlator_rate_phasor¶
The de-chirp phasor exp(-j*pi*rate*t^2) for a rate in Hz/s at timet seconds from the block's middle.
What the engine multiplies a block's slow-time axis by, and what refine multiplies its per-period correlations by: one definition of the centring and the sign.
Parameters:
rateDoppler rate hypothesis, Hz/s.tTime from the block's middle, seconds.
Returns:
exp(-j*pi*rate*t^2), unit magnitude.
function dp_correlator_reset¶
Restart the correlator's running state, keeping how it was built.
What each flavor drops; the reference, its spectrum, the FFT plans and every knob stay:
- a map: zeroes the accumulator and the integration counter, a fresh dwell cycle;
- a detector: that, plus the carry (the partial frame held between pushes) and the last dump's fields, so it matches a fresh detector built with the same arguments; last_corr reads None until the next dump;
- a search: drains the input ring and clears the non-coherent power accumulator and the dwell bookkeeping, so the next push() begins a fresh search; the grid and thresholds are untouched.
Parameters:
stateMust be non-NULL.
>>> from doppler.correlation import Correlator
>>> import numpy as np
>>> ref = np.zeros((2, 2), dtype=np.complex64); ref[0, 0] = 1.0
>>> c = Correlator(ref=ref, dwell=3)
>>> _ = c.execute(np.ones((2, 2), dtype=np.complex64))
>>> c.count
1
>>> c.reset()
>>> c.count
0
function dp_correlator_run¶
Pure run: inject state_in , streamin , emit hits, exportstate_out —(state_in, input) -> (state_out, output) over an engine treated as immutable config + scratch.state_in /state_out may alias. Either may be NULL (NULL in = fresh; NULL out = discard).
size_t dp_correlator_run (
dp_correlator_state_t * state,
const void * state_in,
void * state_out,
const float _Complex * in,
size_t n_in,
dp_correlator_hit_t * result,
size_t max_results
)
The run is one dp_correlator_push(), so it stops where a push stops: once result is full, or before a frame that ends a dwell when fewer than min(max_peaks, max_results) slots are left. It may then leave part of in untaken. dp_correlator_consumed(state) says how much it took; the caller calls again with state_out as the next state_in and the rest, in + consumed, and the two runs together equal one over the whole input. A refused state_in runs nothing and returns 0, with dp_correlator_consumed() reading 0.
Parameters:
stateEngine (config + scratch); its running state is replaced bystate_in, or reset when that is NULL.state_inBlob from dp_correlator_get_state(), or NULL for fresh.state_outDestination blob (dp_correlator_state_bytes() bytes), or NULL to discard.inInput cf32 samples.n_inNumber of input samples.resultOutput hits.max_resultsCapacity ofresult.
Returns:
Number of events written (0 … max_results).
function dp_correlator_search_period¶
The samples one code period is searched at, for a caller feeding sample_rate: its own period when that is already fast, elsedp_correlator_period_samples() .
The caller's period, sample_rate * code_len / chip_rate, is kept when it is a whole number of samples (to a part in 1e9) and at least code_len: searching the samples as they come needs no resampler. Its length need not be fast for the FFT: one with a larger prime (2 * 1,023 = 2 * 3 * 11 * 31) is read on a padded lag grid, lag_bins columns, the next power of two. Otherwise a fractional period (11 MSa/s over 5 Mcps for 1,023 chips is 2,250.6) it is the power of two dp_correlator_period_samples() derives, and the caller resamples to chip_rate * period / code_len. 4 samples a chip of a 7-chip code keeps 28; 2 a chip of 1,023 chips keeps 2,046 (read on 2,048 lag columns); 11 MSa/s over 5 Mcps takes 2,048.
Parameters:
code_lenChips in one code period (>= 1).sample_rateThe caller's sample rate, Hz (> 0).chip_rateChip rate, Hz (> 0).
Returns:
The period in samples; 0 for an argument outside the domain.
function dp_correlator_set_carrier_freq_hz¶
Couple the code clock to the carrier: the chip rate dilates by doppler_hz / carrier_freq_hz , and the engine accounts for it.
A physically-coupled Doppler moves the code as well as the carrier 100 chips/s at 20 ppm of 5 Mcps and the engine's two long integrations both smear over it (doppler#1256, #1254):
* Inside a coherent block of D epochs every tile's epoch correlations are shifted along the code axis by the drift the tile's own frequency implies, f_tile / carrier chips per chip, aligned to the block's middle (a linear phase on each epoch's product). The one delay-Doppler map applies it at the block's end, read on a slow-time grid 4 times finer and rounded. The bound is 0.09 dB, the worst over 33 tones and three dilations (docs/design/acq-surface.md §18.1); the engine measures 0.020-0.026 dB on its equivalence test's carrier scenes. dp_correlator_block_prompt() applies it exactly. A change of carrier mid-block applies to the whole block. Measured at the specification's 20 ppm with D = 154 (3.1 chips of drift across the block): without it the block's peak is 13 dB down and 3 chips wide and the depth detects nothing at 34 dB-Hz; with it the block reads as a still one.
* The hand-off (dp_correlator_build_handoff()) advances the hit's code phase by the drift over half the dwell the non-coherent sum's peak is the phase at the dwell's middle, the seed is wanted at its end: 0.9 chip at the 40 dB-Hz floor, past a refine loop's pull-in.
A mutator's value (#2022): it rides in the state blob (v8), and a restore takes it through this setter's rebuild, so a resumed engine carries it on. Setting it rebuilds the map's fine grid and every tile's ramp tables when they move (the regrid that re-applies the thread request). Default 0.0 (uncoupled) is the engine exactly as it ran without it.
Parameters:
stateMust be non-NULL.carrier_freq_hzRF carrier, Hz; 0.0 = uncoupled. Refused (DP_ERR_UNSUPPORTED) on every flavor but the continuous search (docs/design/correlator.md section 4).
Returns:
DP_OK, DP_ERR_INVALID for a carrier outside dp_correlator_carrier_freq_ok() at this engine's sample rate, or DP_ERR_MEMORY when the rebuild cannot allocate (the engine is left as it was).
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> from doppler.wfm import Gold
>>> code = np.asarray(Gold().generate(1023)).astype(np.uint8)
>>> ref = np.where(code & 1, -1, 1).astype(np.complex64)
>>> a = Correlator(ref, framing="continuous", sample_rate=1e7, chip_rate=5e6, symbol_rate=2700.0,
... cn0_dbhz=45.0, doppler_uncertainty=50e3)
>>> a.carrier_freq_hz
0.0
>>> a.set_carrier_freq_hz(2.5e9)
>>> a.carrier_freq_hz
2500000000.0
function dp_correlator_set_keep_surface¶
Ask to keep, or stop keeping, every decided dwell's surface for dp_correlator_surface() : 1 normalises each one into the gate's units at its decision; 0 (the default) keeps none unless a sink is attached (dp_correlator_surface() states the rule).
Python's writable Correlator.keep_surface; dp_correlator_set_surface_sink() sets it too, and a search flavor's other setters leave it as it is. The continuous search only (docs/design/correlator.md section 4): any other flavor refuses it and keeps nothing.
Parameters:
stateMust be non-NULL.keepNon-zero to keep (stored as 1), 0 not to.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED on any flavor but the continuous search.
function dp_correlator_set_max_peaks¶
How many peaks a dwell may report: the peak list's capacity.
One (the default) is the classic detector the maximum of the surface, gated. More is the list of docs/design/async-dsss-receiver.md §7.1: every peak above the same gate, strongest first, each with an exclusion zone of one Doppler bin by the reference's first autocorrelation null around it (one chip for a PN code; one emitter's main lobe, so its own shoulders are not the next peak), and the two-epoch rule for a peak at an already-listed code phase a data transition inside the epoch splits one emitter into twins at its own code phase on other tiles, so such a peak is held for one dwell and listed only if it was there, at the same tile, on the previous one. Each listed peak is one dp_correlator_hit_t from dp_correlator_push(), all of a dwell's sharing its samples_consumed and noise_est. A held twin takes a slot of the n for that dwell but is not reported. The threshold does not change: a second peak is another draw from the same cells against the same union bound. Clears the held candidates.
Parameters:
stateMust be non-NULL.n1 … DP_CORRELATOR_MAX_PEAKS.whyWhere the refusal's sentence goes, naming the argument it refused; may be NULL. A static string, never freed. Off the flavors that serve the call it stays NULL (the binding then raises the declared "only" sentence; just-makeit#2574).
Returns:
0; DP_ERR_UNSUPPORTED off a search (a map or detector lists no peaks); DP_ERR_INVALID (state untouched) when n is out of range.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> code = (np.arange(31) * 5 % 2).astype(np.uint8)
>>> ref = np.where(code & 1, -1, 1).astype(np.complex64)
>>> a = Correlator(ref, framing="continuous", sample_rate=2e6, chip_rate=1e6, symbol_rate=1e3,
... cn0_dbhz=50.0, doppler_uncertainty=50e3)
>>> a.max_peaks
1
>>> a.set_max_peaks(8)
>>> a.max_peaks
8
function dp_correlator_set_peak_zone¶
The exclusion zone each listed peak marks before the next is sought: how far it reaches along Doppler and along the lags.
int dp_correlator_set_peak_zone (
dp_correlator_state_t * state,
int all_doppler,
double half_chips,
const char ** why
)
By default a listed peak masks one native Doppler row (its interp surface rows either side) by the template's correlation mainlobe across the lags (shape.zone), so the next peak may sit at the same lag in another Doppler row: a second emitter at that code phase, or the first one's own slow-time sidelobes, its alias in a neighbouring roll, or the spread its data puts on its own lag inside a coherent dwell. One strong emitter can then take every slot of the list with its own lag, and a weaker one elsewhere is never listed (doppler#3067).
all_doppler = 1 makes the zone cover every Doppler bin of every roll at the peak's lags, so an emitter is listed once a dwell, at its strongest cell. half_chips > 0 sets the zone's half-width across the lags in the search's chips: the most whole lag columns within it, floor(half_chips * lag_bins / sf), so the zone is never wider than asked (sf is a code's chips a period on the continuous search; on the burst search it is the template's samples, so a "chip" there is a sample); <= 0 keeps the mainlobe's. The receiver asks for (1, DP_CORRELATOR_SAME_PHASE_CHIPS / 2), half the width its pick treats as one signal (§7.2 rule 1): the zone is a lag, and with a carrier set the pick's key carries each hit on by its own Doppler's dilation, off the lag grid, so only a zone inside the key never masks what the pick keeps. A half_chips under one lag column (0.5 chip below two lag columns a chip) marks the peak's own lag alone. A caller that never calls this gets today's list exactly. The two-epoch twin rule (async-dsss-receiver.md §7.1) keeps the mainlobe's width whatever this sets, so a peak past a narrower zone but inside the mainlobe an emitter's shoulder off the lag grid is still held a dwell as a twin.
Both values are mutators' (#2022): they travel in the state blob and a restore applies them.
Parameters:
stateMust be non-NULL.all_doppler1 = every Doppler bin of every roll; 0 = one row.half_chipsHalf-width across the lags, chips; <= 0 = the template's mainlobe. Finite.whyWhere the refusal's sentence goes; may be NULL. A static string, never freed.
Returns:
0; DP_ERR_UNSUPPORTED off a search (only a search lists peaks); DP_ERR_INVALID (state untouched) when all_doppler is not 0 or 1 or half_chips is not finite.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> code = (np.arange(31) * 5 % 2).astype(np.uint8)
>>> ref = np.where(code & 1, -1, 1).astype(np.complex64)
>>> a = Correlator(ref, framing="continuous", sample_rate=2e6, chip_rate=1e6, symbol_rate=1e3,
... cn0_dbhz=50.0, doppler_uncertainty=50e3)
>>> a.set_max_peaks(8)
>>> a.set_peak_zone(1, 1.0)
function dp_correlator_set_ref¶
Replace the reference and recompute its spectrum.
Also resets accumulator and counter on success. The object's fast-path mode (see the file doc comment) is fixed at create() time and never changes here: on a fast-path object, ref must still be nonzero only in row 0, or the call is rejected and the object's existing reference and spectrum are left completely untouched (never a silent partial update) — a caller that needs a genuinely different reference shape must build a new dp_correlator_state_t. A general-path object accepts any (ny,nx) ref and always succeeds. A detector flavor resets first (see dp_correlator_reset()), so it is reset even when the reference is then refused.
Parameters:
stateMust be non-NULL.refNew reference, flat row-major CF32, length ny*nx. Served by the 1-D and 2-D maps and both detectors (docs/design/ correlator.md section 4); the delay-Doppler map and the searches refuse it, touching nothing. A detector is reset first, so it is reset even when its new reference is then refused (DP_ERR_INVALID).
Returns:
0 on success; DP_ERR_UNSUPPORTED on the delay-Doppler map or a search; DP_ERR_INVALID if state is fast-path and ref is no longer single-row.
function dp_correlator_set_state¶
Restore a mid-dwell correlator from dp_correlator_get_state() 's blob.
Parameters:
stateMust be non-NULL, created with the same (ny, nx) and reference (the reference is not in the blob).blobSource blob of dp_correlator_state_bytes() bytes.
Returns:
DP_OK, or DP_ERR_INVALID (state untouched) when the header's magic, version, endianness or size does not match, when the blob's flavor, ny, ny_out, fast_path, col_out or nx_out differs from state's (a blob of one flavor never restores into another), when its frame count is not below state's dwell, or, for a detector flavor, when noise_lo, noise_hi or noise_mode differs, the framer's child blob is refused, the frames that blob has handed out are not the dwell's position (frames mod dwell must equal the count, as every push, reset and set_ref keeps it), or the last peak is not a cell of the map. Everything is checked before anything is written.
function dp_correlator_set_surface_sink¶
Attach (or detach) a C surface sink: every decim-th decided dwell's surface, in test-statistic units, handed tofn on the pushing thread (docs/design/async-dsss-receiver.md §2.4).
int dp_correlator_set_surface_sink (
dp_correlator_state_t * state,
dp_correlator_surface_sink_fn fn,
void * ctx,
uint32_t decim
)
Sets keep_surface, so dp_correlator_surface() reads the same dwell afterwards. While a sink is attached every decided dwell's surface is computed and handed over whatever keep_surface reads: a dp_correlator_set_state() (whose blob carries keep_surface, not the sink, which is the caller's and stays attached) or dp_correlator_set_keep_surface(0) leaves it firing. Detach with fn NULL. The pointer handed to fn is the engine's and is valid only for the call: copy or write it out there. This is how a long run records the surface decimated in time without a copy per dwell it does not keep.
Parameters:
stateMust be non-NULL.fnThe sink, or NULL to detach.ctxPassed through tofn.decimHand over every decim-th dwell; 0 reads as 1.
Returns:
DP_OK; DP_ERR_UNSUPPORTED, with nothing attached, off a search (a map or a detector decides no dwell).
function dp_correlator_set_telemetry¶
Attach (or detach) a telemetry context and register the engine's probes on it (docs/design/async-dsss-receiver.md §2.4).
int dp_correlator_set_telemetry (
dp_correlator_state_t * state,
dp_tlm_t * tlm,
const char * prefix,
uint32_t decim,
const char ** why
)
Registers ten probes, emitted once per DECIDED dwell (a coherent dump, or the dwell that completes n_noncoh looks) and further thinned by decim: "<prefix>.stat" (the dwell's test statistic — the strongest cell against the CFAR reference, in the units the gate is set in), "<prefix>.gate" (that gate: threshold on the coherent path, eta_nc on the non-coherent one — plotted together they show exactly where a hit fired), "<prefix>.noise" (the CFAR reference noise_est), "<prefix>.peak" (the strongest cell's raw value), "<prefix>.row" and "<prefix>.col" (its native Doppler row and code-phase column — a surface coordinate, not a physical unit; dp_correlator_surface_doppler_hz() and dp_correlator_surface_chip_phase() convert), "<prefix>.n_peaks" (picks in the dwell, held twins included), "<prefix>.n_held" (picks held as same-code-phase twins rather than listed, §7.1), "<prefix>.conc" (the strongest pick's concentration — see peak_conc: its main lobe's power over its whole column's, near 1 for one clean emitter even when it straddles two tiles, about 0.5 when a data transition splits it into twins two or more tiles away, lower still when a coherent block straddles data — the discriminator between one emitter's splatter and a second emitter) and "<prefix>.hit" (1 when the gate fired). Passing NULL detaches. Setup path, never hot; the context is borrowed and must outlive the attachment (SPSC rules in dp_tlm/dp_tlm_core.h).
Parameters:
stateMust be non-NULL.tlmTelemetry context to attach, or NULL to detach.prefixProbe-name prefix, e.g. "acq" or "ch0.acq".decimEmit every decim-th decided dwell; >= 1. Refused (DP_ERR_UNSUPPORTED) on every flavor but the continuous search (docs/design/correlator.md section 4).whyWhere the refusal's sentence goes, naming the argument it refused; may be NULL. A static string, never freed. Off the flavors that serve the call it stays NULL (the binding then raises the declared "only" sentence; just-makeit#2574).
Returns:
DP_OK; DP_ERR_INVALID for an overlong prefix, a decim of 0, or a probe table without room for all ten probes; DP_ERR_MEMORY when the dry run's scratch context cannot be allocated. A refusal registers nothing on tlm and leaves the previous attachment (or detachment) exactly as it was.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> from doppler.telemetry import Telemetry
>>> from doppler.wfm import PN, mls_poly
>>> code = np.asarray(
... PN(poly=mls_poly(9), seed=1, length=9).generate(511), np.uint8)
>>> ref = np.where(code & 1, -1, 1).astype(np.complex64)
>>> a = Correlator(ref, framing="continuous", sample_rate=2e6, chip_rate=1e6, cn0_dbhz=50.0)
>>> tlm = Telemetry(1 << 12)
>>> a.set_telemetry(tlm, "acq")
>>> sorted(tlm.probe_names)[:3]
['acq.col', 'acq.conc', 'acq.gate']
>>> x = np.zeros(a.n_noncoh * 511 * 2 * 3, dtype=np.complex64)
>>> _ = a.push(x)
>>> len(tlm.read()) % 10 # ten records per decided dwell
0
function dp_correlator_set_threads¶
Set how many threads the searcher fans its stages across (docs/design/acq-surface.md §13, §18.3: persistent workers).
A continuous engine is created asking for the machine's online cores, except with one tile at a depth of one epoch, which runs serially; a burst engine runs serially until asked. Its workers start at its first push, so an engine set to one thread before it is pushed never starts any. This sets the count: 0 auto-selects the online core count, 1 runs everything on the calling thread, n runs on n workers (the caller included). At a depth of one epoch (D = 1) the count is capped at window_bins: every per-epoch fan hands out one tile a task, so a worker past that only wakes and waits. At D > 1 every stage fans finer than tiles (epochs, capture bins, rows, chunks of rows), so the count is taken whole, and each worker holds its own FFT plans and scratch: memory grows with the count. The request is kept, and every regrid re-applies it, so an engine narrowed to one tile and widened again runs on the request, not on the 1 the narrow grid ran on. The workers are created here, once, and parked between pushes; nothing is created per push after the first. The surface is bit-identical at every count every output row and every decide chunk is computed whole by one worker, and the chunk count is the grid's so this changes the cost of a push and nothing about its result. The request travels in the state blob (a mutator's value, #2022): dp_correlator_set_state() applies it through this call, so the target resolves it as it would here: 0 becomes the target's own online cores, an explicit n is taken whole, and either is capped at the target's tiles only at D = 1. Setup path, never hot; not while another thread is inside push().
Parameters:
stateMust be non-NULL.nThread count; 0 = online cores, 1 = serial. Refused (DP_ERR_UNSUPPORTED) on a map or detector flavor (no search record).
Returns:
DP_OK. The count a push runs on is threads.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> from doppler.wfm import PN, mls_poly
>>> code = np.asarray(
... PN(poly=mls_poly(9), seed=1, length=9).generate(511), np.uint8)
>>> ref = np.where(code & 1, -1, 1).astype(np.complex64)
>>> a = Correlator(ref, framing="continuous", sample_rate=2e6, chip_rate=1e6, cn0_dbhz=50.0,
... doppler_uncertainty=4000.0)
>>> a.threads >= 1 # the online cores (capped at D = 1)
True
>>> a.set_threads(1)
>>> a.threads
1
function dp_correlator_set_threshold¶
Change a detector flavor's threshold without rebuilding it.
The value is part of the state blob, so set_state restores it. A search flavor refuses it: its gate is sized from Pfa and Pd at create, together with the raw and non-coherent thresholds it implies.
Parameters:
stateMust be non-NULL.thresholdNew threshold; 0.0 = always fire.
Returns:
DP_OK, or DP_ERR_UNSUPPORTED (nothing changed) for a map or search flavor.
function dp_correlator_sidelobe_ratio¶
How far up the sidelobes of the emitter behind one hit can reach at another hit's cell, relative to that emitter's own peak.
double dp_correlator_sidelobe_ratio (
dp_correlator_state_t * state,
const dp_correlator_hit_t * from,
const dp_correlator_hit_t * to
)
One emitter puts its code's cross-ambiguity on every cell of the surface. This computes that row the way the surface itself is made: one period of the replica, carrying from's Doppler less the cell's tile centre and delayed by from's lag (a phase ramp, so a lag between two samples is exact), its spectrum times the replica's conjugate, zero-padded to lag_bins and inverted (dp_fft_pad_spectrum()), read at to's column. The emitter's own peak is the same product's zero lag at its residual from its own tile's centre. The ratio is the most it can be over what the hits do not pin down:
from'slag is known to half a lag column either side of its column: five points across that are read;from'sDoppler is known to half a native row either side: nine points across that row are read, its own residual moving with each;- a cell on a tile edge, or on the combined axis's wrap, is read in every tile it touches.
The cell's fast-time mixing frequency is its tile's centre (a multiple of the epoch rate, chip_rate / sf; DC on a single-tile engine): within a tile the slow-time transform only lowers a sidelobe that sits off the emitter's own row, and no credit is taken for that. The value is a SAMPLED maximum, not a proven bound: the cross-ambiguity varies on a one-sample scale, and between the five lag and nine Doppler points it reads, it can sit higher than any of them. What holds it is measurement: native/validation/acq_emitter_floor.c holds every cell of a clean emitter's tile and the two beside it under it, on the scale rule 2 uses (the emitter's statistic on its own lag): least margin +0.61 dB over 6,129 cells, on the Gold-1023 floor. With a data transition inside the epoch it does not bound the surface (a cell reads 20.4 dB above it: the model is one clean period, doppler#2734), and async_dsss_near_far.c takes no sidelobe over the operating range, where the gate covers that. It is the code's worst sidelobe (dp_correlator_dsl_db()) only at the worst cells: most cells sit well below it, which is the room a weak emitter beside a strong one needs. Times from's statistic on its own lag (dp_correlator_hit_t::test_stat_peak), it is the statistic from's sidelobe can read at to.
Cost: the first read against a hit, in a tile, sweeps that hit's whole row there: 5 inverse transforms of code_bins (the lag points), then per lag and Doppler point one forward of code_bins and one inverse of lag_bins (45), every complex exponential a resynced recurrence. Every column is kept, so later reads against the same hit and tile, any cell, are lookups: DP_CORRELATOR_SIDELOBE_SLOTS (hit, tile) rows, keyed on the hit's cell and the tile, round-robin when full, and emptied by every regrid (each slot was read on the grid it was filled on). A pick reads many cells against its few stronger hits, dwell after dwell, so nearly every read is a lookup. The plans, buffers and cache are made on the first call and kept on state.
Parameters:
stateThe engine both hits came from (non-NULL).fromThe hit whose emitter's sidelobes are bounded.toThe hit whose cell they are bounded at.
Returns:
The ratio, from 0 to 1.
function dp_correlator_state_bytes¶
Size in bytes of this correlator's state blob.
Parameters:
stateMust be non-NULL.
Returns:
Header + flavor, ny, ny_out, fast_path, col_out, nx_out and frame count (u64 each) + the ny*nx complex-float accumulator; a detector flavor adds 5 u64, 4 f32 and the framer's child blob.
function dp_correlator_state_check¶
Whether dp_correlator_set_state() would acceptblob , without writing anything.
DP_OK exactly when set_state would accept it, and DP_ERR_INVALID exactly when it would refuse it: both read the blob through one check. What lets a composition check this child before it restores any other, so a refusal of either changes nothing (carrier_acq's 'CAQR' does).
Parameters:
stateMust be non-NULL.blobCandidate blob of dp_correlator_state_bytes() bytes.
Returns:
DP_OK or DP_ERR_INVALID; state is never written.
function dp_correlator_state_position¶
The stream position a blob records __dp_correlator_position() of the engine it would restore read without restoring it.
int dp_correlator_state_position (
const dp_correlator_state_t * state,
const void * blob,
uint64_t * position
)
What lets a composition check its child's blob against its own count before it writes anything, so a refusal never has to be undone (an undo is a second set_state, and set_state can fail). Accepts exactly the blobs dp_correlator_set_state() checks and accepts before its carrier rebuild, through the same check.
float _Complex pre[124]; // a 31-chip code at 4x
for (size_t i = 0; i < 124; i++)
pre[i] = (i / 4) % 3 ? 1.0f : -1.0f;
dp_correlator_state_t *a = dp_correlator_create_burst (pre, 124, 16, 4.0e6, 45.0,
0.0, 1e-3, 0.9, 0, 0.0, 1);
float _Complex x[300] = { 0 };
dp_correlator_hit_t hit;
(void)dp_correlator_push (a, x, 300, &hit, 1);
void *blob = dp_xmalloc (dp_correlator_state_bytes (a));
uint64_t at = 0;
dp_correlator_get_state (a, blob);
int ok = dp_correlator_state_position (a, blob, &at); // DP_OK, 300
int same = at == dp_correlator_position (a);
free (blob);
dp_correlator_destroy (a);
if (ok != DP_OK || at != 300 || !same)
return 1;
Parameters:
stateThe engine the blob would be restored into.blobA blob from dp_correlator_get_state().positionOut: the blob's position. Unchanged on a refusal.
Returns:
DP_OK, or DP_ERR_INVALID where dp_correlator_set_state() would refuse the blob as invalid.
function dp_correlator_surface¶
The last decided dwell's surface, in the gate's own units.
Copies the surface the last dwell was decided on into out, row-major surface_rows (Doppler: tiles, or interpolated slow-time rows) by lag_bins (code phase), every cell divided by the same CFAR reference the gate used — so a cell reads as its own test statistic, to a float rounding (the SIMD build's fast-math may take a reciprocal in this loop and a divide in the gate's), and the gate (threshold, or eta_nc on the non-coherent path) is a flat plane on a plot.
A surface is kept while keep_surface is set OR a sink is attached (dp_correlator_set_surface_sink()); this is the one statement of that rule. Set either, push, then read. surface_at says which dwell it is; a time-decimated record is the caller reading every k-th dwell, or a sink with decim.
Parameters:
stateMust be non-NULL.outAt leastsurface_rows * lag_binsfloats.n_outCapacity ofout. SIZE_MAX (refused) on every flavor but the continuous search (docs/design/correlator.md section 4); 0 is "nothing yet".
Returns:
Cells written (surface_rows * lag_bins), or 0 when no dwell has been decided while a surface was kept, or out is too small.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> from doppler.wfm import PN, mls_poly
>>> code = np.asarray(
... PN(poly=mls_poly(9), seed=1, length=9).generate(511), np.uint8)
>>> ref = np.where(code & 1, -1, 1).astype(np.complex64)
>>> a = Correlator(ref, framing="continuous", sample_rate=2e6, chip_rate=1e6, cn0_dbhz=50.0)
>>> a.keep_surface = 1
>>> x = np.zeros(a.n_noncoh * 511 * 2, dtype=np.complex64)
>>> _ = a.push(x)
>>> s = np.empty(a.surface_rows * a.lag_bins, dtype=np.float32)
>>> a.surface(s) == s.size
True
>>> a.code_bins, a.lag_bins # 1022 is 2 x 7 x 73: read on 1024 lags
(1022, 1024)
>>> s.reshape(a.surface_rows, a.lag_bins).shape == (a.surface_rows, 1024)
True
function dp_correlator_surface_chip_phase¶
The surface's code-phase axis: the chip phase of each column.
size_t dp_correlator_surface_chip_phase (
dp_correlator_state_t * state,
double * out,
size_t n_out
)
One value per surface column, in chips, the same mapping dp_correlator_build_handoff() applies to a hit's col — so a plotted peak sits at the chip phase the DetectionEvent would carry.
Parameters:
stateMust be non-NULL.outAt leastlag_binsdoubles.n_outCapacity ofout. SIZE_MAX (refused) on every flavor but the continuous search (docs/design/correlator.md section 4); 0 is "nothing yet".
Returns:
Values written (lag_bins), or 0 if out is too small.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> from doppler.wfm import PN, mls_poly
>>> code = np.asarray(
... PN(poly=mls_poly(9), seed=1, length=9).generate(511), np.uint8)
>>> ref = np.where(code & 1, -1, 1).astype(np.complex64)
>>> a = Correlator(ref, framing="continuous", sample_rate=2e6, chip_rate=1e6, cn0_dbhz=50.0)
>>> c = np.empty(a.lag_bins, dtype=np.float64)
>>> a.surface_chip_phase(c) == a.lag_bins
True
>>> bool(c[0] == 0.0 and c[1] == 511 - 511 / 1024)
True
function dp_correlator_surface_complex¶
The last decided dwell's surface, complex: amplitude and carrier phase per cell, before the magnitude the gate reads.
size_t dp_correlator_surface_complex (
dp_correlator_state_t * state,
float _Complex * out,
size_t n_out
)
Copies the coherent sum the last dwell was decided on into out, row-major surface_rows x lag_bins like dp_correlator_surface(), in the correlation's own units rather than the gate's. A cell's phase is the carrier at the block's middle, relative to its tile's centre; its neighbours along the code axis are complex early and late arms, so a tracker can form the coherent discriminator Re(conj(P) (L - E)) / |P|^2, which the magnitude surface cannot (docs/design/async-dsss-receiver-measurements.md §12.21). Coherent path only: a non-coherent dwell (n_noncoh > 1) is a power sum with no phase, and reads 0.
Parameters:
stateMust be non-NULL.outAt leastsurface_rows * lag_binscomplex floats.n_outCapacity ofout. SIZE_MAX (refused) on a map or detector flavor (no search record); 0 is "nothing yet".
Returns:
Cells written (surface_rows * lag_bins), or 0 when no dwell has been decided, the path is non-coherent, or out is too small.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> from doppler.wfm import PN, mls_poly
>>> code = np.asarray(PN(poly=mls_poly(5), seed=1,
... length=5).generate(31)).astype(np.uint8)
>>> s0 = np.repeat(np.where(code & 1, -1.0, 1.0), 4).astype(
... np.complex64)
>>> ref = np.where(code & 1, -1, 1).astype(np.complex64)
>>> a = Correlator(ref, framing="continuous", sample_rate=4e6, chip_rate=1e6, cn0_dbhz=70.0)
>>> a.n_noncoh # one look: the dwell is the coherent dump
1
>>> _ = a.push(np.roll(s0, 17).astype(np.complex64))
>>> sc = np.empty(a.surface_rows * a.lag_bins, dtype=np.complex64)
>>> a.surface_complex(sc) == sc.size
True
>>> int(np.argmax(np.abs(sc)) % a.lag_bins) # the peak's lag column
18
function dp_correlator_surface_doppler_hz¶
The surface's Doppler axis: the frequency of each row, in Hz.
size_t dp_correlator_surface_doppler_hz (
dp_correlator_state_t * state,
double * out,
size_t n_out
)
One value per surface row, the fold and scale a hit's doppler_hz_est uses (dp_fftfreq_index() times doppler_res_hz, on the interpolated grid where the slow-time axis is interpolated), so a plot of dp_correlator_surface() carries the same axis a DetectionEvent reports on.
Parameters:
stateMust be non-NULL.outAt leastsurface_rowsdoubles.n_outCapacity ofout. SIZE_MAX (refused) on every flavor but the continuous search (docs/design/correlator.md section 4); 0 is "nothing yet".
Returns:
Values written (surface_rows), or 0 if out is too small.
>>> import numpy as np
>>> from doppler.correlation import Correlator
>>> from doppler.wfm import PN, mls_poly
>>> code = np.asarray(
... PN(poly=mls_poly(9), seed=1, length=9).generate(511), np.uint8)
>>> ref = np.where(code & 1, -1, 1).astype(np.complex64)
>>> a = Correlator(ref, framing="continuous", sample_rate=2e6, chip_rate=1e6, cn0_dbhz=50.0,
... doppler_uncertainty=4000.0)
>>> f = np.empty(a.surface_rows, dtype=np.float64)
>>> a.surface_doppler_hz(f) == a.surface_rows
True
>>> bool(f[0] == 0.0 and f.min() < 0.0 < f.max())
True
Public Static Functions Documentation¶
function dp_correlator_bin_doppler_hz¶
A hit's signed Doppler, Hz: its row folded over dp_correlator_grid_bins() by numpy's fftfreq convention (dp_fftfreq_index) and scaled by the grid's resolution.
static inline double dp_correlator_bin_doppler_hz (
const dp_correlator_state_t * state,
size_t doppler_bin
)
The one conversion from a bin to Hz; dp_correlator_build_handoff() and every composing object call it rather than restating the fold.
function dp_correlator_grid_bins¶
The Doppler grid a hit's row indexes:window_bins * coherent_bins bins.
One bin in a native search; the window-tile count once a doppler_uncertainty wider than the native span is tiled; tiles times the block depth on a continuous engine with code-only epochs. Every consumer that folds a row must fold it over THIS, not over coherent_bins: a capture that did read every tiled hit as 0 Hz (doppler#1512). 0 on a map or detector flavor, which has no Doppler grid.
Macro Definition Documentation¶
define CORRELATOR_STATE_MAGIC¶
State-blob magic ('CORL'); set_state() rejects any other.
define CORRELATOR_STATE_VERSION¶
State-blob layout version; set_state() rejects any other. 2: the search's extra block carries keep_surface (#2022); 3: and the peak zone ( dp_correlator_set_peak_zone() , doppler#3067); 4: and the thread request (dp_correlator_set_threads() , #3055).
define DP_CORRELATOR_CN0_NONE¶
The design C/N0 that means "none given" (doppler#1484): a burst engine then sizes for the whole preamble, its pd_predicted is NaN and it is neverunderpowered .
NaN, because every finite value is a real design point including a negative one: at fs = 1 (normalized units) the C/N0 IS the per-sample SNR in dB, which is negative wherever acquisition is hard. It used to be 0, which made exactly 0 dB unreachable and a negative per-sample SNR unstatable. Test with isnan(), never ==.
define DP_CORRELATOR_DELAY_LOSS_NODES¶
Quadrature nodes the Pd model averages the delay straddle over.
define DP_CORRELATOR_MAX_PEAKS¶
The largest max_peaks dp_correlator_set_max_peaks() accepts: the bindings' push result arrays (1024) are at least this many, so one dwell can always be reported whole.
define DP_CORRELATOR_N_NONCOH_SAFETY_CEILING¶
Internal safety-valve ceiling on auto-selected non-coherent looks not a public knob (no caller-facing equivalent of the retiredmax_noncoh parameter).
The semi-analytical Pd model both auto-sizers ascend against turns non-monotonic and unreliable past a few hundred looks (this project's own geometry found ~256 empirically see docs/design/async-dsss-receiver.md). Hitting this ceiling without meeting pd leaves dp_correlator_search_t::underpowered set, same as any other infeasible operating point no separate bookkeeping needed.
define DP_CORRELATOR_RATE_HYPS_MAX¶
Most Doppler-rate hypotheses an engine searches. Each one costs a full slow-time pass per dwell, so this bounds the cost of a typo, not a design: the residual rate falls as 1/(R-1), and a few dozen hypotheses already take a rate span out to depths no preamble repeats to.
define DP_CORRELATOR_SAME_PHASE_CHIPS¶
Two code phases closer than this many chips, circularly, are one signal: the receiver's pick (rules 1 and 3, docs/design/async-dsss-receiver.md §7.2), the pool's duplicate test, and the peak zone the receiver asks its search for (dp_correlator_set_peak_zone()) all read this one value. The test itself is dp_correlator_same_code_phase() (correlation_core.h), which the pick and the duplicate test call:
#include "doppler/correlation/correlation_core.h"
#include <stdio.h>
int main (void)
{
// one chip apart is one signal; a chip and a half is two
int one = dp_correlator_same_code_phase (100.0, 101.0, 1023.0);
int two = dp_correlator_same_code_phase (100.0, 101.5, 1023.0);
// across chip 0: 0.6 chips apart, circularly
int wrap = dp_correlator_same_code_phase (0.4, 1022.8, 1023.0);
printf ("%d %d %d\n", one, two, wrap); // 1 0 1
return !(one && !two && wrap);
}
define DP_CORRELATOR_SIDELOBE_DOPPLER_PTS¶
dp_correlator_sidelobe_ratio()'s Doppler points: across the emitter's native row, its own bin's width.
define DP_CORRELATOR_SIDELOBE_LAG_PTS¶
dp_correlator_sidelobe_ratio()'s lag points: across the emitter's own lag column, one column (code_bins / lag_bins samples) wide.
define DP_CORRELATOR_SIDELOBE_SLOTS¶
(hit, tile) rows dp_correlator_sidelobe_ratio() keeps every column of: room for a pick's few stronger emitters on the tiles their cells touch.
The documentation for this class was generated from the following file native/inc/doppler/correlator/correlator_core.h