libtcspc.ScanHistograms¶
- final class libtcspc.ScanHistograms(num_elements, num_bins, max_per_bin, reset_event_type=None, *, buffer_provider=None, overflow='error', emit_concluding=False, reset_after_scan=False, clear_every_scan=False, numeric_traits=None)[source]¶
Bases:
NodeProcessor that accumulates an array of histograms over a scan.
Each
BinIncrementClusterEventupdates the next element of the histogram array; aHistogramArrayProgressEventis emitted per cluster, and aHistogramArrayEventupon completion of each scan. A round ends on areset_event_type; if concluding events are enabled, aConcludingHistogramArrayEventis emitted on each reset.- Parameters:
num_elements (int or Param[int]) – Number of histograms (elements) in the array.
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 array. If
None, a defaultRecyclingBucketSourceis used.overflow (str) – Overflow behavior:
"error"(default),"stop","saturate", or"reset".emit_concluding (bool) – If
True, emit aConcludingHistogramArrayEventon each reset. DefaultFalse.reset_after_scan (bool) – If
True, reset after each completed scan. DefaultFalse.clear_every_scan (bool) – If
True, clear the array at the start of each scan. DefaultFalse.numeric_traits (NumericTraits or None) – Numeric traits specifying
bin_index_typeandbin_type. Defaults toNumericTraits().
Notes
Events handled:
BinIncrementClusterEvent: update the next element of the histogram array and emit aHistogramArrayProgressEvent; emit aHistogramArrayEventwhen a scan completes.reset_event_type(if given): end the current round and start a new one; ifemit_concludingis set, aConcludingHistogramArrayEventis emitted first.All other event types: pass through unchanged.
On bin overflow: handled per
overflow(when"saturate", aWarningEventis emitted).End of input: pass through; an incomplete scan 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 array as a bare NumPy array.See also
- tcspc::scan_histograms()
The underlying C++ factory function.
ExtractBucketExtract a histogram-array bucket as a bare NumPy array.