ezmsg.sigproc.util.startup#
Data-primed filter start-up: build the filter state from the first samples of a stream.
Module Attributes
Fraction of a pole's initial contribution left when its settling length has passed. |
Functions
- hold_for_startup(held, message, axis, n)[source]#
Collect messages until they hold
nsamples onaxis.Appends
messagetoheld. Returns None while fewer thannsamples are held; then emptiesheldand returns everything as one message carrying the first held message’s axes and the latest message’s attrs, segment and config_id.
- prime_with_reflection(run, message, axis, n_pad)[source]#
Prime a stateful processor from the start of
messageand discard what it emits.Builds up to
n_padsamples of synthetic pre-history by odd reflection of the first samples about the first one,2 * x[0] - x[n_pad:0:-1](the paddingscipy.signal.filtfilt()uses), stamps them with the times just beforemessageand passes them torun, whose output is dropped.n_padis cut to whatmessageholds (one fewer than its length); with nothing to reflect,runis not called.
- release_held(held, axis)[source]#
Empty a non-empty
heldand return its messages as one, ashold_for_startup()releases them.A processor’s
flushcalls this to emit a start-up buffer that never filled.
- settle_samples(poles, order, tol=0.001)[source]#
Samples until a filter’s state is (nearly) independent of its initial conditions.
orderfor a filter with all poles at the origin (an FIR: its state is exactly the lastorderinputs), otherwiseceil(log(tol) / log(max|pole|)), the length over which the slowest pole decays totol.inffor a pole on or outside the unit circle.
- startup_n_pad(n, message, axis, max_dur)[source]#
Cap a pad length
n(samples) atmax_durseconds ofmessage’s stream (None: no cap).
Classes
- class StartupMode(*values)[source]#
Bases:
OptionsEnumWhat a filter assumes about the signal before the first sample it sees.
- ZERO = 'Zero pre-history'#
- CONSTANT = "Constant pre-history at the first sample's value"#
- FIRST_CHUNK = 'Prime the state from a reflection of the first message'#
- BUFFERED = 'Hold output until enough samples arrive to prime the state, then release them'#