libtcspc.Histogram¶
- final class libtcspc.Histogram(num_bins, max_per_bin, reset_event_type=None, *, buffer_provider=None, overflow='error', emit_concluding=False, numeric_traits=None)[source]¶
Bases:
NodeProcessor that accumulates a histogram from bin increment events.
Each
BinIncrementEventincrements the corresponding bin; aHistogramEventcarrying a view of the current histogram is emitted on each increment. A round of accumulation ends on areset_event_type; if concluding events are enabled, aConcludingHistogramEventis emitted on each reset.- Parameters:
num_bins (int or Param[int]) – Number of bins in the histogram.
max_per_bin (int or Param[int]) – Maximum count per bin before the overflow policy applies.
reset_event_type (EventType or None) – Event type that resets (starts a new round).
None(the default) means no reset event.buffer_provider (BucketSource or Param[PyBucketSource] or None) – Source of buckets holding the histogram. If
None, a defaultRecyclingBucketSourceis used.overflow (str) – Overflow behavior:
"error"(default),"stop","saturate", or"reset".emit_concluding (bool) – If
True, emit aConcludingHistogramEventon each reset. DefaultFalse.numeric_traits (NumericTraits or None) – Numeric traits specifying
bin_index_typeandbin_type. Defaults toNumericTraits().
Notes
Events handled:
BinIncrementEvent: increment the corresponding bin and emit aHistogramEventcarrying a view of the current histogram.reset_event_type(if given): end the current round and start a new one; ifemit_concludingis set, aConcludingHistogramEventis emitted first.All other event types: pass through unchanged.
On bin overflow: handled per
overflow(when"saturate", aWarningEventis emitted).End of input: pass through; the current histogram is not emitted as a concluding event.
The histogram-carrying output events can be sent directly to a Python sink, where they are delivered as
EventInstancevalues whosedata_bucketattribute reads as a read-only NumPy array. Alternatively, insertExtractBucketto obtain just the histogram as a bare NumPy array.See also
- tcspc::histogram()
The underlying C++ factory function.
ExtractBucketExtract the histogram bucket as a bare NumPy array.