photonscore.correlator

photonscore.correlator

correlator.StartStop

StartStop

class StartStop()

Streaming normal start-stop correlator.

For every photon (stop) the correlator reports its delay relative to the most recent laser pulse (start) that opened the window the photon falls into, i.e. dt = photon - laser[i] where laser[i] <= photon < laser[i + 1].

Unlike the array-at-once helpers in the example notebooks, this class keeps memory between calls: laser and photon tags are enqueued incrementally into ring-buffer queues and correlate consumes only what it can fully resolve, carrying the open window over to the next call. This mirrors the streaming Photonscore.Tag.Correlators.ICorrelator contract on the .NET side.

Both tag streams must be enqueued in non-decreasing time order. Photons that arrive before the first laser pulse are dropped; photons in the still-open last window are buffered until the next laser pulse closes it.

This is the single-/multi-hit dt of the multi-hit ("Dima") correlator; pass order = True to correlate to also get each photon's hit index within its window, recovering the full multi-hit output.

enqueue_reference

def enqueue_reference(tags) -> None

Append laser (start) tags to the input queue.

enqueue_photon

def enqueue_photon(tags) -> None

Append photon (stop) tags to the input queue.

correlate

def correlate(order = False)

Resolve every photon whose laser window is fully known.

Returns the start-stop delays as int64 in photon arrival order. The open window is retained for the next call.

If order is True, also return each photon's hit index within its laser window (0 for the first photon in a window, 1 for the second, ...) as a second int64 array, matching the multi-hit correlator. The result is then the tuple (dt, order).

clear

def clear() -> None

Reset the correlator to its initial, empty state.

correlator.StartStopDiv

StartStopDiv

class StartStopDiv(divisor: int = 1)

Streaming start-stop correlator with a divided stop.

Used when the recorded laser sync is pre-divided, so each recorded interval [laser[i], laser[i + 1]) actually spans divisor real laser periods. The reported delay is folded back into a single period:

period = (laser[i + 1] - laser[i]) // divisor
dt     = (photon - laser[i]) % period

With divisor == 1 this reduces to plain StartStop. The streaming / memory behaviour (and the order flag) is inherited unchanged; only the per-window period differs.

correlator.correlator

correlate_two

def correlate_two(chan_a: np.ndarray, chan_b: np.ndarray) -> np.ndarray