lsurf.detectors.PlanarDetector

class lsurf.detectors.PlanarDetector(center, normal, width, height, name='Planar Detector')[source]

Planar detector with finite rectangular size.

Detects rays that intersect a rectangular plane at a specific position and orientation. Useful for imaging applications and beam profiling.

Parameters:
  • center (tuple of float) – Center position of detector plane (x, y, z) in meters.

  • normal (tuple of float) – Normal vector (defines which direction detector faces).

  • width (float) – Width of detector (in local u direction) in meters.

  • height (float) – Height of detector (in local v direction) in meters.

  • name (str, optional) – Detector name. Default is “Planar Detector”.

center

Detector center position.

Type:

ndarray, shape (3,)

normal

Unit normal vector.

Type:

ndarray, shape (3,)

width

Detector width.

Type:

float

height

Detector height.

Type:

float

u

Local x-axis direction (width direction).

Type:

ndarray, shape (3,)

v

Local y-axis direction (height direction).

Type:

ndarray, shape (3,)

name

Detector name.

Type:

str

accumulated_result

All accumulated detections since last clear().

Type:

DetectorResult

Notes

The local coordinate system is constructed with: - normal: direction the detector faces - u: perpendicular to normal (width direction) - v: perpendicular to both normal and u (height direction)

Only rays traveling toward the front face of the detector (opposite to the normal direction) are detected.

Examples

>>> detector = PlanarDetector(
...     center=(0, 0, 50),
...     normal=(0, 0, -1),  # Facing -z direction
...     width=0.1,
...     height=0.1
... )
>>> result = detector.detect(rays)
__init__(center, normal, width, height, name='Planar Detector')[source]

Initialize planar detector.

Parameters:
  • center (tuple of float) – Center position of detector plane.

  • normal (tuple of float) – Normal vector (detector faces in this direction).

  • width (float) – Detector width in meters.

  • height (float) – Detector height in meters.

  • name (str, optional) – Detector name.

Methods

__init__(center, normal, width, height[, name])

Initialize planar detector.

clear()

Clear all recorded detections.

detect(rays[, current_time, accumulate])

Detect rays that intersect the detector plane within bounds.

get_arrival_angles(reference_direction)

Get angles between ray directions and reference direction.

get_arrival_times()

Get array of all arrival times.

get_image([bins_u, bins_v])

Generate intensity image from detection events.

get_intensities()

Get array of all detected intensities.

get_positions()

Get array of all detection positions.

get_total_intensity()

Get sum of all detected intensities.

get_wavelengths()

Get array of all detected wavelengths.

Attributes

accumulated_result

All accumulated detections since last clear().

events

list of DetectionEvent objects.

__init__(center, normal, width, height, name='Planar Detector')[source]

Initialize planar detector.

Parameters:
  • center (tuple of float) – Center position of detector plane.

  • normal (tuple of float) – Normal vector (detector faces in this direction).

  • width (float) – Detector width in meters.

  • height (float) – Detector height in meters.

  • name (str, optional) – Detector name.

property accumulated_result: DetectorResult

All accumulated detections since last clear().

property events: list[DetectionEvent]

list of DetectionEvent objects.

For new code, use accumulated_result instead.

Type:

Backward compatibility

detect(rays, current_time=0.0, accumulate=True)[source]

Detect rays that intersect the detector plane within bounds.

Parameters:
  • rays (RayBatch) – Ray batch to test.

  • current_time (float, optional) – Current simulation time. Default is 0.0.

  • accumulate (bool, optional) – Whether to accumulate results. Default is True.

Returns:

Newly detected rays.

Return type:

DetectorResult

Notes

Only detects rays that: - Are traveling toward the front face (opposite to normal) - Intersect the plane in the forward direction - Hit within the width x height bounds

clear()[source]

Clear all recorded detections.

Resets the detector to its initial state with no recorded events.

get_image(bins_u=100, bins_v=100)[source]

Generate intensity image from detection events.

Parameters:
  • bins_u (int, optional) – Number of bins in u direction. Default is 100.

  • bins_v (int, optional) – Number of bins in v direction. Default is 100.

Returns:

  • u_centers (ndarray, shape (bins_u,)) – Bin centers in u direction (meters).

  • v_centers (ndarray, shape (bins_v,)) – Bin centers in v direction (meters).

  • image (ndarray, shape (bins_v, bins_u)) – Intensity image (sum of intensities per bin).

Return type:

tuple[ndarray[tuple[Any, …], dtype[float64]], ndarray[tuple[Any, …], dtype[float64]], ndarray[tuple[Any, …], dtype[float64]]]

__repr__()[source]

Return string representation.

__len__()[source]

Return number of detected rays.

get_arrival_times()[source]

Get array of all arrival times.

get_arrival_angles(reference_direction)[source]

Get angles between ray directions and reference direction.

get_intensities()[source]

Get array of all detected intensities.

get_wavelengths()[source]

Get array of all detected wavelengths.

get_positions()[source]

Get array of all detection positions.

get_total_intensity()[source]

Get sum of all detected intensities.