prysm.detector#
Detector-related simulations.
- prysm.detector.apply_lut(img, lut)#
Apply a lookup table to img.
- Parameters:
img (ndarray) – n dimensional array (2D and 3D are both OK) of an unsigned integer dtype
lut (ndarray) – 1 dimensional array whose indices are input values and values are output values
- Returns:
ndarray of the same shape as img the output array must not be modified in place, or lut will be modified as well.
- Return type:
ndarray
- class prysm.detector.Detector(dark_current, read_noise, bias, fwc, conversion_gain, bits, exposure_time, prnu=None, dcnu=None, lut=None)#
Bases:
objectModel of a detector.
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 (ndarray, optional) – relative pixel response nonuiformity, a fixed map that the input field is multiplied by. ones_like is perfectly uniform.
dcnu (ndarray, optional) – dark current nonuniformity, a fixed map that the dark current is multiplied by. ones_like is perfectly uniform.
lut (ndarray, optional) – look-up table of ideal output DN values to output DN values, representing the nonlinearity of the detector
- expose(aerial_img, frames=1)#
Form an exposure of an aerial image.
- Parameters:
aerial_img (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:
ndarray
- prysm.detector.olpf_ft(fx, fy, width_x, width_y)#
Analytic FT of an optical low-pass filter, two or four pole.
- prysm.detector.pixel_ft(fx, fy, width_x, width_y)#
Analytic FT of a rectangular pixel aperture.
- prysm.detector.pixel(x, y, width_x, width_y)#
Spatial representation of a pixel.
- prysm.detector.bindown(array, factor, mode='avg')#
Bin (resample) an array.
- Parameters:
- Returns:
ndarray binned by given number of samples
- Return type:
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:
- Returns:
ndarray binned by given number of samples
- Return type:
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