de_twin.detector.Detector#

class de_twin.detector.Detector(model='DE16', seed=0, *, ht_kv=300.0, **overrides)[source]#

Bases: object

A camera: sensor maps (dark, gain, defects) plus the per-frame noise pipeline.

overrides replace any CameraModel field, e.g. Detector("DE16", read_noise_adu=4, hot_pixel_fraction=0). expose is serialised by an internal lock (it reuses buffers).

Parameters:
__init__(model='DE16', seed=0, *, ht_kv=300.0, **overrides)[source]#
Parameters:

Methods

__init__([model, seed, ht_kv])

dark_current_map(exposure_s)

Dark-current contribution (ADU) for exposure_s, full sensor (hot pixels included).

expected_dark(exposure_s[, request])

Noise-free expected dark frame (float64, output shape); integrating cameras.

expected_gain([request])

Gain map binned to the output shape (float64).

expose(flux, exposure_s[, request, ...])

Simulate one raw frame.

output_shape([request])

(h, w) of the hardware frame: ROI, then binning (integer division, like DE-Server); twice that each way for a super-resolution counting frame.

roi([request])

Resolved hardware ROI: the requested ROI clamped to the sensor (0 size = full).

super_resolution([request])

Whether request reads this camera out at super-resolution: a counting camera, asked for it, unbinned (binning and super-resolution do not combine).

Attributes

bad_pixel_mask

True for hot, dead and bad-column pixels, full sensor.

dark_map

Exposure-independent dark level (offset + fixed pattern), full sensor, ADU.

gain_map

Relative gain (mean 1; 0 for dead pixels), full sensor.

hot_pixels

false counts/s).

roi(request=None)[source]#

Resolved hardware ROI: the requested ROI clamped to the sensor (0 size = full).

No DE alignment is re-applied: DE-Server sends an already aligned ROI and its hw_frame must be reproduced exactly.

Parameters:

request (AcquisitionRequest | None)

Return type:

Roi

output_shape(request=None)[source]#

(h, w) of the hardware frame: ROI, then binning (integer division, like DE-Server); twice that each way for a super-resolution counting frame.

Parameters:

request (AcquisitionRequest | None)

Return type:

tuple[int, int]

super_resolution(request=None)[source]#

Whether request reads this camera out at super-resolution: a counting camera, asked for it, unbinned (binning and super-resolution do not combine).

Parameters:

request (AcquisitionRequest | None)

Return type:

bool

property dark_map: ndarray#

Exposure-independent dark level (offset + fixed pattern), full sensor, ADU.

property gain_map: ndarray#

Relative gain (mean 1; 0 for dead pixels), full sensor.

property bad_pixel_mask: ndarray#

True for hot, dead and bad-column pixels, full sensor.

property hot_pixels: tuple[ndarray, ndarray, ndarray]#

false counts/s).

Type:

(y, x, dark current ADU/s) of the hot pixels (counting cameras

dark_current_map(exposure_s)[source]#

Dark-current contribution (ADU) for exposure_s, full sensor (hot pixels included).

Parameters:

exposure_s (float)

Return type:

ndarray

expected_dark(exposure_s, request=None)[source]#

Noise-free expected dark frame (float64, output shape); integrating cameras.

Parameters:
Return type:

ndarray

expected_gain(request=None)[source]#

Gain map binned to the output shape (float64).

Parameters:

request (AcquisitionRequest | None)

Return type:

ndarray

expose(flux, exposure_s, request=None, frame_index=0, *, ht_kv=None, seed=None)[source]#

Simulate one raw frame.

flux: electrons / sensor pixel / second, a float array of the ROI shape (or of the binned output shape, or a scalar), or None for no beam (dark reference, blanked, retracted…). Returns (frame, info); the frame has output_shape() and the model’s dtype (uint16, or uint8 for counting cameras). info holds dose_e_per_px (mean electrons per sensor pixel), saturated, saturated_pixels, blanked and the resolved geometry. seed replaces the detector’s own for this frame’s noise (a pinned acquisition).

Parameters:
Return type:

tuple[ndarray, dict]