pyoptools.raytrace.surface.detector module

class pyoptools.raytrace.surface.detector.ArrayDetector

Bases: Plane

Class to simulate a CCD-like detector surface.

The ArrayDetector class acts similarly to a real CCD (Charge-Coupled Device) in an optical system. It is designed to capture and store the coordinates of rays that hit the detector surface, effectively simulating the behavior of a CCD detector.

Parameters:
  • size (tuple of float, optional) – A tuple (width, height) representing the physical size of the detector surface in mm. The default size is (10, 10).

  • *args (tuple, optional) – Additional positional arguments passed to the Plane superclass.

  • **kwargs (dict, optional) – Additional keyword arguments passed to the Plane superclass.

size

The physical size of the detector surface, as specified during initialization.

Type:

tuple of float

Examples

Creating an ArrayDetector with a specified size:

>>> detector = ArrayDetector(size=(10, 10))

Notes

  • The ArrayDetector captures the coordinates of rays that hit the detector surface and can be used to simulate the detection process in optical simulations.

  • The size parameter defines the physical dimensions of the detector, which determines the area over which it can detect incoming rays.

  • Refer to the Plane class documentation for additional options and functionality inherited by the ArrayDetector.

get_color_histogram(resolution=(256, 256))

Generate a color histogram of ray impacts per unit area on the detector surface.

This method returns a 3D array representing the number of ray impacts per unit area of the detector, simulating a color image. Each impact contributes to the RGB color channels based on the ray’s wavelength.

Parameters:

resolution (tuple of int, optional) – A tuple (px, py) representing the resolution of the histogram in pixels. px is the number of pixels along the X-axis, and py is the number of pixels along the Y-axis. The default value is (256, 256). The physical size of the detector is determined during the surface’s creation.

Returns:

A 3D numpy array of shape (px, py, 3) where each element contains the accumulated RGB values corresponding to ray impacts at that pixel position.

Return type:

ndarray

Notes

  • The resolution parameter controls the resolution of the histogram.

Increasing the resolution results in a finer grid with more pixels, while decreasing the resolution results in a coarser grid with fewer pixels. - The physical size of the detector, defined during its creation, determines the actual area over which the impacts are distributed. - The method does not currently account for the intensity of the rays, which should be considered in future improvements. - The Z-coordinate of the impact is assumed to be zero, consistent with a planar detector surface. - Rays that hit the detector are recorded in the _hit_list, which stores their impact coordinates and wavelengths.

get_histogram(resolution=(256, 256))

Generate a histogram of ray impacts per unit area on the detector surface.

This method returns a 2D array (histogram) representing the number of ray impacts per unit area of the detector. The histogram provides a pixelated view of how rays are distributed across the detector surface.

Parameters:

resolution (tuple of int, optional) – A tuple (px, py) representing the resolution of the histogram in pixels. px is the number of pixels along the X-axis, and py is the number of pixels along the Y-axis. The default value is (256, 256). The physical size of the detector is determined during the surface’s creation.

Returns:

A 2D numpy array of shape (px, py) where each element represents the number of ray impacts in that pixel area.

Return type:

ndarray

Notes

  • The resolution parameter controls the resolution of the histogram.

Increasing the resolution results in a finer grid with more pixels, while decreasing the resolution results in a coarser grid with fewer pixels. - The physical size of the detector, defined during its creation, determines the actual area over which the impacts are distributed. - The method assumes that the Z-coordinate of all impacts is zero, consistent with a planar detector surface. - Rays that hit the detector are recorded in the _hit_list, which stores their impact coordinates.

size