photon_transfer#
- msfc_ccd.noise.photon_transfer(images, axis, threshold=5, fraction_saturated=0.001)[source]#
Compute the photon transfer curve of each tap from a sequence of flats.
The images must be a sequence of uniformly illuminated images, or flats, gathered using the same illumination and exposure length. For each pair of adjacent images along axis, the signal is the mean of the two images and the variance is half the variance of their difference, computed over the active pixels outside the masked rows,
where_masked().Differencing the two images removes everything the two images have in common, including the pattern of the illumination and the variation in response from pixel to pixel, and leaves only the shot noise and the readout noise. The shot noise has a variance, in electrons, equal to the signal, so the variance in data numbers is
\[\sigma^2 = \frac{S}{g} + \sigma_r^2,\]where \(S\) is the signal, \(g\) is the gain, and \(\sigma_r\) is the readout noise. Gathering pairs at several levels of illumination traces out the photon transfer curve, and
msfc_ccd.gain.photon_transfer()uses it to measure the gain.The result has one fewer element along axis than the input, since it is defined for each pair of adjacent images.
A pixel at the top of the range of the analog-to-digital converter has lost part of its noise, so an image with more than fraction_saturated of its pixels there raises an error. A few such pixels, from cosmic rays or hot pixels, are rejected along with the other spikes.
- Parameters:
images (AbstractTapData) – A sequence of flats from each tap, such as the
tapsof a sequence of images.axis (str) – The logical axis along which the images are a sequence of flats.
threshold (float) – Pixels in the difference image further than this many standard deviations from the median are rejected, as in
readout(), to remove cosmic rays.fraction_saturated (float) – The largest fraction of the pixels of an image which may be at the top of the range of the analog-to-digital converter.
- Raises:
TypeError – If images is not the images from each tap.
ValueError – If there are fewer than two images along axis, or more than fraction_saturated of the pixels of an image are at the top of the range of the analog-to-digital converter.
- Return type:
Examples
Compute the signal and the variance of a pair of images of a diffuse LED source.
import numpy as np import named_arrays as na import msfc_ccd # Load two consecutive images with the same illumination path = na.ScalarArray( ndarray=np.array([ msfc_ccd.samples.path_led_esis1, msfc_ccd.samples.path_led_esis1_next, ]), axes="time", ) images = msfc_ccd.fits.open(path) # Compute the signal and the variance of each tap ptc = msfc_ccd.noise.photon_transfer(images.taps, "time") ptc.inputs.ndarray
\[ \begin{align}\begin{aligned}[[[15641.277],~ [11731.57]],~\\ [[24187.898],~ [19075.661]]] \; \mathrm{DN}\end{aligned}\end{align} \]ptc.outputs.ndarray
\[ \begin{align}\begin{aligned}[[[6199.7545],~ [4692.9026]],~\\ [[9578.508],~ [7612.1268]]] \; \mathrm{DN^{2}}\end{aligned}\end{align} \]