prysm.detector#
Detector-related simulations.
- class prysm.detector.Detector(dark_current, read_noise, bias, fwc, conversion_gain, bits, exposure_time, prnu=None, dcnu=None)#
Bases:
object
Basic model of a detector, no fuss.
Initialize a new camera model.
- Parameters:
dark_current (float) – e-/sec, charge accumulated with no light reaching the sensor.
read_noise (float) – e-, random gaussian noise associated with readout
bias (float) – e-, uniform value added to readout to avoid negative numbers
fwc (float) – e-, maximum number of electrons that can be held by one pixel
conversion_gain (float) – e-/DN gain converting e- to DN,
bits (int) – number of bits for the ADC, multiples of 2 in 8..16 are contemporary
exposure_time (float) – exposure time, seconds
prnu (numpy.ndarray, optional) – relative pixel response nonuiformity, a fixed map that the input field is multiplied by. ones_like is perfectly uniform.
dcnu (numpy.ndarray, optional) – dark current nonuniformity, a fixed map that the dark current is multiplied by. ones_like is perfectly uniform.
- expose(aerial_img, frames=1)#
Form an exposure of an aerial image.
- Parameters:
aerial_img (numpy.ndarray) – aerial image, with units of e-/sec. Should include any QE as part of its Z scaling
frames (int) – number of images to expose, > 1 is functionally equivalent to calling with frames=1 in a loop, but the random values are all drawn at once which can much improve performance in GPU-based modeling.
- Returns:
of shape (frames, aerial_img.shape), if frames=1 the first dim is squeezed, and output shape is same as input shape. dtype=uint8 if nbits <= 8, else uint16 for <= 16, etc not scaled to fill containers, i.e. a 12-bit image will have peak DN of 4095 in a container that can reach 65535.
has units of DN.
- Return type:
numpy.ndarray
- prysm.detector.olpf_ft(fx, fy, width_x, width_y)#
Analytic FT of an optical low-pass filter, two or four pole.
- Parameters:
fx (numpy.ndarray) – x spatial frequency, in cycles per micron
fy (numpy.ndarray) – y spatial frequency, in cycles per micron
width_x (float) – x diameter of the pixel, in microns
width_y (float) – y diameter of the pixel, in microns
- Returns:
FT of the OLPF
- Return type:
numpy.ndarray
- prysm.detector.pixel_ft(fx, fy, width_x, width_y)#
Analytic FT of a rectangular pixel aperture.
- Parameters:
fx (numpy.ndarray) – x spatial frequency, in cycles per micron
fy (numpy.ndarray) – y spatial frequency, in cycles per micron
width_x (float) – x diameter of the pixel, in microns
width_y (float) – y diameter of the pixel, in microns
- Returns:
FT of the pixel
- Return type:
numpy.ndarray
- prysm.detector.pixel(x, y, width_x, width_y)#
Spatial representation of a pixel.
- Parameters:
x (numpy.ndarray) – x coordinates
y (numpy.ndarray) – y coordinates
width_x (float) – x diameter of the pixel, in microns
width_y (float) – y diameter of the pixel, in microns
- Returns:
spatial representation of the pixel
- Return type:
numpy.ndarray
- prysm.detector.bindown(array, factor, mode='avg')#
Bin (resample) an array.
- Parameters:
array (numpy.ndarray) – array of values
factor (int or sequence of int) – binning factor. If an integer, broadcast to each axis of array, else unique factors may be used for each axis.
mode (str, {'avg', 'sum'}) – sum or avg, how to adjust the output signal
- Returns:
ndarray binned by given number of samples
- Return type:
numpy.ndarray
Notes
For each axis of array, shape must be an integer multiple of factor.
array may be ND, a scalar factor will broadcast to all dimensions.
To bin an image cube e.g. of shape (3, m, n), use bindown(img, [1, factor, factor])
- Raises:
ValueError – invalid mode
- prysm.detector.tile(array, factor, scaling='sum')#
Tile (repeat) an array by factor.
- Parameters:
array (numpy.ndarray) – array of values
factor (int or sequence of int) – binning factor. If an integer, broadcast to each axis of array, else unique factors may be used for each axis.
scaling (str, {'avg', 'sum'}) – sum or avg, how to adjust the output signal
- Returns:
ndarray binned by given number of samples
- Return type:
numpy.ndarray
Notes
This function is the adjoint operation for bindown.
It works with ND arrays, with the same rules as bindown.
In 2D, it is equivalent to array.repeat(factor, axis=0).repeat(factor, axis=1) (and is more generally equivalent for higher dimensionality, but it runs about ndim times faster (twice as fast in 2D, 3x in 3D, etc).
The return may be a view into the argument and is mutated after calling tile at the user’s risk