lsurf.detectors.SphericalDetector

class lsurf.detectors.SphericalDetector(center, radius, name='Spherical Detector', use_gpu=True)[source]

Spherical detector centered at a point.

Detects all rays that pass within a certain radius of the center point. Good for collecting rays from all directions without directional bias.

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

  • radius (float) – Detection radius in meters.

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

  • use_gpu (bool, optional) – Whether to use GPU acceleration when available. Default is True.

center

Detector center position.

Type:

ndarray, shape (3,)

radius

Detection radius.

Type:

float

use_gpu

GPU acceleration flag.

Type:

bool

name

Detector name.

Type:

str

accumulated_result

All accumulated detections since last clear().

Type:

DetectorResult

Notes

Detection is based on the closest approach distance between each ray and the center point. A ray is detected if this distance is less than or equal to the detection radius.

The arrival time is computed assuming the ray travels through air (n approx 1.0) from its current position to the detection point.

Examples

>>> detector = SphericalDetector(
...     center=(0, 0, 100),
...     radius=10.0,
...     use_gpu=True
... )
>>> result = detector.detect(reflected_rays)
>>> print(f"Detected {result.num_rays} rays")
__init__(center, radius, name='Spherical Detector', use_gpu=True)[source]

Initialize spherical detector.

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

  • radius (float) – Detection radius in meters.

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

  • use_gpu (bool, optional) – Whether to use GPU acceleration. Default is True.

Methods

__init__(center, radius[, name, use_gpu])

Initialize spherical detector.

clear()

Clear all recorded detections.

detect(rays[, current_time, accumulate])

Detect rays that pass within detection radius.

get_arrival_angles(reference_direction)

Get angles between ray directions and reference direction.

get_arrival_times()

Get array of all arrival times.

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, radius, name='Spherical Detector', use_gpu=True)[source]

Initialize spherical detector.

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

  • radius (float) – Detection radius in meters.

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

  • use_gpu (bool, optional) – Whether to use GPU acceleration. Default is True.

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 pass within detection radius.

For each ray, find the closest approach to center. If within radius, record a detection event.

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

clear()[source]

Clear all recorded detections.

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

__repr__()[source]

Return string representation.

__len__()[source]

Return number of detected rays.

get_arrival_times()[source]

Get array of all arrival times.

Returns:

times – Arrival times in seconds for all detected rays.

Return type:

ndarray, shape (N,)

get_arrival_angles(reference_direction)[source]

Get angles between ray directions and reference direction.

Parameters:

reference_direction (ndarray, shape (3,)) – Reference vector for angle calculation.

Returns:

angles – Angles in radians.

Return type:

ndarray, shape (N,)

get_intensities()[source]

Get array of all detected intensities.

Returns:

intensities – Intensity values for all detected rays.

Return type:

ndarray, shape (N,)

get_wavelengths()[source]

Get array of all detected wavelengths.

Returns:

wavelengths – Wavelengths in meters.

Return type:

ndarray, shape (N,)

get_positions()[source]

Get array of all detection positions.

Returns:

positions – 3D positions where rays were detected.

Return type:

ndarray, shape (N, 3)

get_total_intensity()[source]

Get sum of all detected intensities.

Returns:

Total detected intensity.

Return type:

float