ezmsg.sigproc.streamstamp#
Stamp segment and config_id on a stream whose source does not.
A source should set segment itself,
changing it on the first message that does not continue the previous one, and
config_id, changing it when its layout
changes. Place StreamStamp right after a source that does not, so that every
stateful stage downstream resets across a gap instead of filtering through it, and
compares one int per message instead of inspecting the layout.
Classes
- class StreamStamp(*args, settings=None, **kwargs)[source]#
Bases:
BaseTransformerUnit[StreamStampSettings,AxisArray,AxisArray,StreamStampTransformer]- Parameters:
settings (Settings | None)
- SETTINGS#
alias of
StreamStampSettings
- class StreamStampSettings(tolerance: float | None)[source]#
Bases:
Settings- Parameters:
tolerance (float | None)
- tolerance: float | None#
Largest difference, in seconds, between a chunk’s offset and where the previous chunk ended that still counts as continuous.
There is no default because it depends on the source. Two chunks’ offsets can each be off by the source’s timestamp jitter, so allow about twice that. Err on the large side: a timing slip of a sample or two costs a filter far less than the reset a reported gap causes downstream.
Noneturns detection off: every message keeps thesegmentit arrived with, though it still gets aconfig_id. Can be changed while running.
- class StreamStampTransformer(*args, **kwargs)[source]#
Bases:
BaseStatefulTransformer[StreamStampSettings,AxisArray,AxisArray,StreamStampState]Start a new
segmentwherever the stream’s offsets show a gap, and stamp aconfig_id.Each chunk’s stream-axis offset is compared with where the previous chunk ended; a jump forward or backward of more than
toleranceseconds starts a new segment, and so does a change of the upstreamsegmentor of the stream’s layout (e.g. its sample rate). The outputsegmentis this transformer’s own counter, starting at 0, not the upstream one.Only gaps between chunks are seen: a chunk’s
LinearAxiscannot describe a gap within it. Split such chunks first (seeezmsg.baseproc.find_gaps()).Gap detection needs a
LinearAxison the stream dimension. A message whose stream axis is aCoordinateAxiskeeps thesegmentit arrived with.A message that declares a
config_idkeeps it. Any other getscompute_config_id()of its layout, computed only when the layout changes.