File timing_est_core.h¶
FileList > doppler > timing_est > timing_est_core.h
Go to the source code of this file
Feedforward symbol-timing estimator: a block of matched-filtered samples in, one estimate of the symbol timing out, with no loop. More...
#include "doppler/RateConverter/RateConverter_core.h"#include "doppler/clib_common.h"#include "doppler/dp_state.h"#include "doppler/jm_perf.h"#include "doppler/nco/nco_core.h"#include "doppler/resamp/resamp_core.h"#include "doppler/hbdecim/hbdecim_core.h"#include "doppler/cic/cic_core.h"#include "doppler/fir/fir_core.h"#include "doppler/resample/resample_core.h"
Classes¶
| Type | Name |
|---|---|
| struct | dp_timing_est_state_t SymbolTimingEstimator state. |
| struct | dp_timing_estimate_t One feedforward symbol-timing estimate. |
Public Functions¶
| Type | Name |
|---|---|
| JM_FORCEINLINE void | dp_timing_est_accumulate (dp_timing_est_state_t * state, double power) Add one sample's power to the block in progress and advance the symbol clock by one sample. |
| dp_timing_est_state_t * | dp_timing_est_create (double sps) Create an estimator whose symbol clock runs at sps samples a symbol. |
| dp_timing_est_state_t * | dp_timing_est_create_matched (double sps, int pulse, double beta, size_t span) Create an estimator with a matched filter of its own, for a stream of sps samples a symbol that nothing has filtered. |
| void | dp_timing_est_destroy (dp_timing_est_state_t * state) Destroy a timing_est instance and release all memory. |
| dp_timing_estimate_t | dp_timing_est_estimate (dp_timing_est_state_t * state, const float _Complex * in, size_t n_in) Estimate the symbol timing from one block of matched-filtered samples. |
| dp_timing_estimate_t | dp_timing_est_finish (dp_timing_est_state_t * state) Close the block in progress and return its estimate. |
| void | dp_timing_est_get_state (const dp_timing_est_state_t * state, void * blob) Write the running state into blob: the symbol clock, the sample count, the block in progress and the previous block. |
| void | dp_timing_est_push (dp_timing_est_state_t * state, const float _Complex * in, size_t n_in) Add samples to the block in progress without closing it. |
| void | dp_timing_est_reset (dp_timing_est_state_t * state) Return the symbol clock to zero and forget the previous block and any block in progress; keep sps . |
| int | dp_timing_est_set_state (dp_timing_est_state_t * state, const void * blob) Restore the running state from blob . |
| size_t | dp_timing_est_state_bytes (const dp_timing_est_state_t * state) Bytes in the blob dp_timing_est_get_state() writes. |
Macros¶
| Type | Name |
|---|---|
| define | TIMING_EST_MATCHED_PHASES 1024uArms in the matched flavor's terminal bank: the fixed-rate stage's timing resolution, 1 / 1024 of an output. |
| define | TIMING_EST_MATCHED_SPS 4.0Samples a symbol the matched flavor's converter delivers, and its symbol clock runs at. |
| define | TIMING_EST_STATE_MAGIC [**DP\_FOURCC**](dp__state_8h.md#define-dp_fourcc) ('T', 'M', 'G', 'E')State-blob identity (see dp_state.h ). |
| define | TIMING_EST_STATE_VERSION /* multi line expression */State-blob layout version. |
Detailed Description¶
The power of a matched-filtered data stream is periodic at the symbol rate, with its maximum at the eye center. Over a block this object forms the Fourier coefficient of that power at the symbol rate, and reads the timing from its phase and the estimate's quality from its size (Oerder and Meyr, 1988). phi is the object's SYMBOL CLOCK: a 32-bit phase word advanced once a sample by the NCO's own increment for 1 / sps cycles a sample, so sps may be any real number above 2.
What it promises:
- One estimate a block, in the block's own length. There is no pull-in: the time an estimate takes is the block the caller hands it, whatever the timing was.
- The carrier does not enter. Only
|x|^2is used, so the estimate is the same for any carrier phase and for a frequency offset, which is what lets it run before carrier recovery. (An offset still costs the caller's matched filter amplitude; that loss is the filter's.) - One symbol clock across calls. The clock is not restarted between blocks, so consecutive estimates are comparable, and their difference is the symbol rate's error.
- Nothing is decided. No threshold is applied:
qualityis reported and the caller judges it.
It filters, resamples and decides nothing; the caller owns the matched filter. The reasoning, the predicted variance and what is not yet known are in docs/design/timing-estimator.md.
With a matched filter of its own. dp_timing_est_create_matched() takes the pulse and the input's samples a symbol and puts a matched RateConverter ahead of the clock: its decimating cascade, then its matched terminal stage at a fixed rate to 4 samples a symbol, which nothing steers. dp_timing_est_estimate() then takes the samples as they arrive, for any real number of them a symbol from 4 up. It skips the converter's own start (dp_RateConverter_get_memory()) before the first block counts, and every estimate says where the eye center sits on the INPUT's timeline (eye), which is what lets a second converter on the same samples be set to it.
Lifecycle: create -> (estimate | accumulate.. finish | reset)* -> destroy
Example:
dp_timing_est_state_t *te = dp_timing_est_create (4.0);
float _Complex x[512] = { 0 }; // 128 symbols of your stream
dp_timing_estimate_t e = dp_timing_est_estimate (te, x, 512);
(void)e.tau; // eye center, symbols
dp_timing_est_destroy (te);
Public Functions Documentation¶
function dp_timing_est_accumulate¶
Add one sample's power to the block in progress and advance the symbol clock by one sample.
The form a composing object uses when it has the power but not a block of samples (a matched bank read at several timing hypotheses a symbol hands its |y|^2 here, one hypothesis a call). dp_timing_est_estimate() is this in a loop followed by dp_timing_est_finish().
Parameters:
stateMust be non-NULL.power|x|^2of the sample; not checked.
function dp_timing_est_create¶
Create an estimator whose symbol clock runs at sps samples a symbol.
The bound on sps is the line's own: the power is sampled sps times a symbol and its symbol-rate line sits at 1 / sps cycles a sample, which is below the Nyquist rate only for sps > 2. How close to 2 a given pulse allows is a property of the pulse, not of this object.
Parameters:
spsSamples per symbol of the stream handed to it; finite and above 2 (default: 4.0).
Returns:
Heap-allocated state, or NULL when sps is not finite, is 2 or less, or allocation fails.
Note:
Caller must call dp_timing_est_destroy() when done.
>>> from doppler.estimation import SymbolTimingEstimator
>>> te = SymbolTimingEstimator(sps=4.0)
>>> te.sps
4.0
function dp_timing_est_create_matched¶
Create an estimator with a matched filter of its own, for a stream of sps samples a symbol that nothing has filtered.
dp_timing_est_state_t * dp_timing_est_create_matched (
double sps,
int pulse,
double beta,
size_t span
)
Builds one matched RateConverter for the rate TIMING_EST_MATCHED_SPS / sps, droop compensation on, and runs the symbol clock on its output at TIMING_EST_MATCHED_SPS samples a symbol. The converter's terminal stage is the matched filter and runs at that fixed rate: nothing steers it. dp_timing_est_estimate() then takes the unfiltered samples, and its record's symbols counts the converter outputs the block gave, so a block that ends inside the lead-in reports fewer symbols than it was handed (none, while the lead-in lasts).
Parameters:
spsSamples per symbol of the input; finite, and TIMING_EST_MATCHED_SPS or more (the terminal stage does not interpolate).pulseRC_PULSE_IANDD (rectangle) or RC_PULSE_RRC.betaRoot-raised-cosine roll-off, 0 to 1; ignored for the rectangle.spanOne-sided root-raised-cosine span in symbols, 1 or more; ignored for the rectangle.
Returns:
Heap-allocated state, or NULL when sps is not finite or is below TIMING_EST_MATCHED_SPS, the pulse is neither, beta or span is out of range, or allocation fails.
Note:
Caller must call dp_timing_est_destroy() when done.
>>> import numpy as np
>>> from doppler.estimation import MatchedSymbolTimingEstimator
>>> n = np.arange(4096)
>>> # +1 -1 +1 ... through a root-raised cosine at 8 samples a symbol,
>>> # with a symbol instant at sample 3 and every 8 after it
>>> x = (0.25 * np.cos(np.pi * (n - 3.0) / 8.0)).astype(np.complex64)
>>> te = MatchedSymbolTimingEstimator(sps=8.0, pulse="rrc")
>>> e = te.estimate(x)
>>> bool(abs(e.eye % 8.0 - 3.0) < 0.1), e.symbols
(True, 490.25)
function dp_timing_est_destroy¶
Destroy a timing_est instance and release all memory.
Parameters:
stateMay be NULL.
function dp_timing_est_estimate¶
Estimate the symbol timing from one block of matched-filtered samples.
dp_timing_estimate_t dp_timing_est_estimate (
dp_timing_est_state_t * state,
const float _Complex * in,
size_t n_in
)
The block is the whole call: its length sets the estimate's variance and the time the estimate takes. Consecutive calls stay on one symbol clock, and from the second call that had power the result carries the symbol rate's error.
Parameters:
stateMust be non-NULL.inMatched-filtered samples,spsa symbol.n_inNumber of samples; 0 returns a record of zeros.
Returns:
The block's estimate.
>>> import numpy as np
>>> from doppler.estimation import SymbolTimingEstimator
>>> n = np.arange(4 * 256)
>>> # power peaking a quarter symbol into each symbol, on any carrier
>>> x = np.sqrt(1.0 + 0.5 * np.cos(2 * np.pi * (n / 4 - 0.25)))
>>> x = (x * np.exp(1j * 0.3 * n)).astype(np.complex64)
>>> e = SymbolTimingEstimator(sps=4.0).estimate(x)
>>> round(e.tau, 3), round(e.quality, 3), e.symbols, e.has_rate
(0.25, 0.25, 256.0, 0)
function dp_timing_est_finish¶
Close the block in progress and return its estimate.
A block with no samples returns a record of zeros and changes nothing. A block with no power returns tau 0 and quality 0 and is not kept as the previous block, so the next rate is taken against the last block that had power.
Parameters:
stateMust be non-NULL.
Returns:
The estimate for the samples accumulated since the last finish.
function dp_timing_est_get_state¶
Write the running state into blob: the symbol clock, the sample count, the block in progress and the previous block.
Parameters:
stateMust be non-NULL.blobAt least dp_timing_est_state_bytes() bytes.
function dp_timing_est_push¶
Add samples to the block in progress without closing it.
The streaming half of dp_timing_est_estimate(), which is this followed by dp_timing_est_finish(). A composing object that takes its input a sample or a chunk at a time pushes here and closes the block when it has the length it wants: blk_n counts the clock's samples in the block, sps a symbol on a plain instance and TIMING_EST_MATCHED_SPS on a matched one. On a matched instance the samples go through the converter and its lead-in is skipped, as in dp_timing_est_estimate().
Parameters:
stateMust be non-NULL.inSamples,spsa symbol.n_inNumber of samples; 0 does nothing.
function dp_timing_est_reset¶
Return the symbol clock to zero and forget the previous block and any block in progress; keep sps .
The next estimate is then the first again: its tau is on a clock that starts at the next sample, and it carries no rate.
Parameters:
stateMust be non-NULL.>>> import numpy as np >>> from doppler.estimation import SymbolTimingEstimator >>> n = np.arange(1024) >>> x = np.sqrt(1.0 + 0.5 * np.cos(2 * np.pi * n / 4)).astype(np.complex64) >>> te = SymbolTimingEstimator(sps=4.0) >>> te.estimate(x).has_rate, te.estimate(x).has_rate (0, 1) >>> te.reset() >>> te.estimate(x).has_rate 0
function dp_timing_est_set_state¶
Restore the running state from blob .
Parameters:
stateMust be non-NULL; created with anysps(the blob carries no config, so the resumed clock runs at this object's).blobA blob dp_timing_est_get_state() wrote.
Returns:
DP_OK, or DP_ERR_INVALID for a blob of another kind, version, size or byte order, or one whose fields are not a state this object reaches (a non-finite sum, a negative power, a previous tau outside (-1/2, 1/2], a block longer than the count); the state is then unchanged.
function dp_timing_est_state_bytes¶
Bytes in the blob dp_timing_est_get_state() writes.
Parameters:
stateMust be non-NULL.
Returns:
The blob's size: the envelope and the running fields.
Macro Definition Documentation¶
define TIMING_EST_MATCHED_PHASES¶
Arms in the matched flavor's terminal bank: the fixed-rate stage's timing resolution, 1 / 1024 of an output.
define TIMING_EST_MATCHED_SPS¶
Samples a symbol the matched flavor's converter delivers, and its symbol clock runs at.
define TIMING_EST_STATE_MAGIC¶
State-blob identity (see dp_state.h ).
define TIMING_EST_STATE_VERSION¶
State-blob layout version.
The documentation for this class was generated from the following file native/inc/doppler/timing_est/timing_est_core.h