photonscore.LINCam

photonscore.LINCam

LINCam.LINCamRemote

Python remote control interface for the LINCam TCSPC camera.

LINCam is a time-correlated single photon counting (TCSPC) camera based on a microchannel plate (MCP) detector with delay-line readout. This module provides a gRPC client to control the LINCam Capture desktop application.

The communication protocol uses a settings diff pattern: write to properties on the local object, call LINCamRemote.sync to push changes to the device and refresh all read-only status fields in one round trip.

Connect and enable the photocathode:

from photonscore.LINCam.LINCamRemote import LINCamRemote

cam = LINCamRemote("localhost:50051")
cam.photocathode_on = True
cam.sync()
print(cam)          # shows live count rates
cam.sync_histograms()
image = cam.hist_2d  # numpy 2-D array

Dependencies: grpc, numpy, photonscore.proto.lincam_v4_remote_pb2 (generated from photonscore/proto/lincam_v4_remote.proto)

LINCamRemote

class LINCamRemote(target: str | None = None)

Remote control handle for a LINCam TCSPC camera.

Wraps the gRPC LINCamRemote service exposed by the LINCam Capture application. All settable parameters are Python properties that stage changes locally; call sync to commit and read back device state.

After construction the object immediately calls sync so that all read-only properties (serial number, count rates, temperatures, …) are populated.

Attributes

  • hist_2d: Last acquired 2-D spatial histogram as a square numpy array. Updated by sync_histograms.
  • hist_dt: Last acquired timing histogram (delta-t) as a 1-D numpy array. Updated by sync_histograms.

sync

def sync()

Push pending settings to the device and refresh all status fields.

Sends the accumulated new_settings diff to the server. The server returns the full current device state which is stored in read_settings. After the call new_settings is reset so the next sync only sends newly staged changes.

sync_histograms

def sync_histograms(
    xy_bins: int | None = 512,
    clear_after: bool = False,
)

Fetch the current 2-D spatial image and timing histogram from the device.

The acquired data is stored in hist_2d (2-D numpy array, shape [xy_bins, xy_bins]) and hist_dt (1-D numpy array with the delta-t histogram).

The xy_bins parameter is rounded down to the nearest supported resolution: 256, 512, 1024, 2048, or 4096 pixels per side.

Arguments

  • xy_bins (int | None): Requested edge length of the square spatial image in pixels. Supported values: 256, 512 (default), 1024, 2048, 4096. Pass None to skip the 2-D image (timing only).
  • clear_after (bool): If True the device resets its internal histogram buffers after the data is returned.

format_cps

def format_cps(cps_hz)

setup_recording

def setup_recording(
    filename: str,
    filenumber: int = 0,
    seconds: int = 0,
    continious: bool = False,
)

Stage file recording parameters (call sync to apply).

After calling this method set is_recording to True and call sync to start saving photon data to disk.

Arguments

  • filename (str): Base path for the output .photons file. The device appends filenumber and a timestamp.
  • filenumber (int): Numeric suffix appended to the filename (default 0).
  • seconds (int): Chunk duration in seconds. 0 means record until is_recording is set to False.
  • continious (bool): If True the device automatically starts a new chunk file when the current one reaches seconds.

is_recording

property

is_recording

bool: Whether the device is currently writing photon data to disk.

device_url

property

device_url

str: IP address and port of the physical LINCam device (e.g. "192.168.1.42:5000").

Setting this tells LINCam Capture which hardware unit to connect to. Takes effect on the next sync.

tdc_start_rise

property

tdc_start_rise

bool: TDC start channel edge polarity — True = rising, False = falling.

tdc_stop_rise

property

tdc_stop_rise

bool: TDC stop channel edge polarity — True = rising, False = falling.

tdc_slopes

property

tdc_slopes

str: Compact slope notation for start and stop channels.

A two-character string where "/" means rising and "\" means falling edge. For example "/\" means start-rising, stop-falling.

Setting this property updates tdc_start_rise and tdc_stop_rise simultaneously.

photocathode_on

property

photocathode_on

bool: Commanded photocathode state.

Setting to True requests the detector to enable the photocathode high voltage. The actual on/off status is reflected in photocathode_on_status after the next sync.

.. warning:

Do not expose the photocathode to ambient light without
appropriate neutral density filters or the protective lens cap.

test_generator

property

test_generator

int: Internal test pulse rate in kHz, or 0 if disabled.

Accepted set values: 0 (off), 10, 100, 1000 kHz. Useful for verifying the timing chain without an external light source.

stop_threshold

property

stop_threshold

int: CFD stop-channel threshold voltage in DAC counts.

stop_zero_cross

property

stop_zero_cross

int: CFD stop-channel zero-crossing voltage in DAC counts.

time_offset

property

time_offset

float: Global timing offset applied to all events, in nanoseconds.

time_binnig

property

time_binnig

int: TDC bin size in picoseconds per channel.

time_gate_on

property

time_gate_on

bool: Whether the timing gate is active.

time_gate_a

property

time_gate_a

float: Timing gate start edge in nanoseconds.

time_gate_b

property

time_gate_b

float: Timing gate stop edge in nanoseconds.

time_gate

property

time_gate

list[float]: Timing gate [start_ns, stop_ns], or disables gate on set failure.

Assign a two-element sequence [a, b] to set both edges and enable the gate. Assign anything else (e.g. None) to disable the gate.

position_transform

property

position_transform

list[float]: View-only 2D transform applied to the histogram images.

A 2x3 affine matrix stored column-major as [m00, m10, m01, m11, m02, m12]. It transforms the XY positions of the displayed and downloaded histogram images (see sync_histograms); recorded photon data is not affected, and other connected clients are not affected. Identity by default; LINCam Capture resets it to identity on restart.

Assign either a 6-element sequence or a ~photonscore.python.transform2d.Transform2D:

from photonscore import Transform2D

# Rotate by 10 degrees about the image center
cam.position_transform = (
  Transform2D().move(2048, 2048).rotate(10).move(-2048, -2048))
cam.sync()

position_transform_device

property

position_transform_device

list[float]: Device-level 2D transform applied in the camera driver.

Same 2x3 affine layout as position_transform, but applied to the photon stream inside the device driver — so it affects recorded photon data and every connected client alike, not just this view. Identity by default; reset on driver restart.

device_connected

property

device_connected

bool: True if LINCam Capture has an active connection to the hardware.

device_sn

property

device_sn

str: Hardware serial number reported by the device.

device_uptime

property

device_uptime

str: Human-readable uptime of the LINCam Capture application.

mcp_cps

property

mcp_cps

float: Total MCP anode count rate in Hz (all photon events, pre-filter).

stop_cps

property

stop_cps

float: CFD stop-channel count rate in Hz.

acquired_cps

property

acquired_cps

float: Net acquired photon count rate in Hz (after all filters/gates).

fpga_temperature

property

fpga_temperature

float: FPGA die temperature in °C.

detector_temperature

property

detector_temperature

float: Detector housing temperature in °C.

photocathode_on_status

property

photocathode_on_status

bool: Actual photocathode high-voltage state as reported by the hardware.

Unlike photocathode_on (the commanded state), this reflects whether the HV is actually present. The overexposure protection circuit can disable it even when photocathode_on is True.