httm.transformations.electron_flux_slices_to_raw

Transformation functions for processing slices contained in a SingleCCDElectronFluxConverter so that they are suitable for writing to a simulated raw FITS file.

add_baseline_to_slice(single_frame_baseline_adu, single_frame_baseline_adu_drift_term, number_of_exposures, video_scale, image_slice)[source]

This transformation adds a scalar random variate, the baseline electron count, to every pixel.

The baseline electron count is also known as the video bias.

To avoid clipping for low numbers of estimated electrons (which may even be negative) the ADC output is biased above zero, and this bias is not perfectly stable.

Because this bias is not perfectly stable, the baseline electron count is modeled as a Gaussian noise term.

The average value \(\mu\) of the baseline electron count is \(\displaystyle{ \frac{\mathtt{single\_frame\_baseline\_adu} \times\mathtt{number\_of\_exposures}}{\mathtt{video\_scale}}}\).

The variance \(\sigma^2\) of the baseline electron count is \(\displaystyle{ \mathtt{single\_frame\_baseline\_adu\_drift\_term}^2 / \mathtt{video\_scale}^2}\).

Parameters:
  • single_frame_baseline_adu (float) – The expected video bias in ADU for a single frame exposure.
  • single_frame_baseline_adu_drift_term (float) – A standard deviation in ADU of the baseline electron count random variate.
  • number_of_exposures (int) – Number of stacked images in the slice
  • video_scale (float) – Constant for converting electron counts to Analogue to Digital Converter Units (ADU). Units: electrons per ADU
  • image_slice (Slice) – input slice
Return type:

Slice

add_pattern_noise_to_slice(pattern_noise, image_slice)[source]

This transformation adds a fixed pattern of noise to a slice.

The fixed pattern noise is different for each slice, for each CCD.

The default values should be zero, because the expected pattern noise is zero.

This transformation is present to accommodate the flight electronics where pattern noise may be present.

Parameters:
  • pattern_noise (numpy.ndarray) – A two dimensional array of floats, representing a fixed pattern disturbance in a slice.
  • image_slice (Slice) – The input slice. Units: ADU
Return type:

Slice

add_readout_noise_to_slice(readout_noise_parameter, number_of_exposures, image_slice)[source]

This transformation a Gaussian random readout noise to every pixel.

This noise comes from the charge sense transistor and the signal processing electronics.

The average value \(\mu\) of the noise is 0.

The variance \(\sigma^2\) is \(\mathtt{readout\_noise\_parameter}^2 \times \mathtt{number\_of\_exposures}\).

Parameters:
  • readout_noise_parameter (float) – noise standard deviation for one image
  • number_of_exposures (int) – number of stacked images in the slice
  • image_slice (Slice) – input slice
Return type:

Slice

add_shot_noise_to_slice(image_slice)[source]

This transformation adds shot noise to every pixel.

Shot noise is a fluctuation in electron counts.

It is modeled as a Gaussian distributed error.

If the expected electron count in the pixel is \(n\) the standard deviation \(\sigma\) of the shot noise is \(\sqrt{n}\) and the expected value \(\mu\) is \(n\).

Parameters:image_slice (Slice) – An image slice which has electrons as its units. Pixel data should be the expected electron counts for each pixel.
Return type:Slice
convert_slice_electrons_to_adu(gain_loss, number_of_exposures, video_scale, clip_level_adu, image_slice)[source]

This functions simulate various nonlinear effects in the measurement of electrons, before finally yielding output in Analogue To Digital Converter Units (ADU).

The other transformation functions handle linear and approximately linear effects. This transformation is more complex and has more parameters because nonlinear effects are not so easily disentangled.

Define the following:

\(\displaystyle{\mathtt{FPE\_MAX\_ADU} := 65535}\)

\(\displaystyle{\mathtt{gain\_loss\_per\_adu} := \frac{\mathtt{gain\_loss}} {\mathtt{number\_of\_exposures}\times\mathtt{FPE\_MAX\_ADU}}}\)

\(\displaystyle{\mathtt{gain\_loss\_per\_electron} := \frac{\mathtt{gain\_loss\_per\_adu}} {\mathtt{video\_scale}}}\)

\(\displaystyle{\mathtt{exposure\_clip\_level} := \mathtt{clip\_level\_adu} \times\mathtt{number\_of\_exposures}}\)

\(\displaystyle{\mathtt{clip}(x,a,b) := \max(a,\min(x,b))}\)

For each pixel \(p\), with units in estimated electrons, this function applies the following transformation:

\(\displaystyle{\mathtt{clip}\left(\frac{p}{\mathtt{video\_scale} \times (1 + \mathtt{gain\_loss\_per\_electron} \times p)}, 0, \mathtt{exposure\_clip\_level}\right)}\)

This transformation affects all pixels, dark, smear or illuminated.

This function is the inverse transform of convert_slice_adu_to_electrons().

Parameters:
  • gain_loss (float) – The relative decrease in video gain over the total ADC range
  • number_of_exposures (int) – The number of exposures the image comprises.
  • video_scale (float) – Constant for converting electron counts to Analogue to Digital Converter Units (ADU). Units: electrons per ADU
  • clip_level_adu (int) – Maximum analog to digital converter output. Units: ADU
  • image_slice (Slice) – Input slice. Units: electrons
Return type:

Slice

introduce_smear_rows_to_slice(smear_ratio, early_dark_pixel_columns, late_dark_pixel_columns, final_dark_pixel_rows, smear_rows, image_slice)[source]

This function takes a slice with empty smear rows and populates them, and adds smear to every image pixel (but not dark pixels). See CCD and Slice Layout for more details.

Smear is estimated by averaging rows in the image pixels and then multiplying by smear_ratio. For most of the frame cycle, a pixel effectively sits in the imaging area of the CCD, collecting photons from a particular point on the sky for the exposure time. During readout, that pixel moves quickly through the imaging area, exposed to each point on the sky along a column for a short time, the parallel clock period. The smear_ratio is the ratio of parallel clock period to the nominal exposure time of a single frame.

This function first adds up all of the rows in the image pixel subarray of the slice. It multiplies that sum by smear_ratio to estimate a smear row. It then replaces the corresponding empty smear rows in the slice with the estimated smear row. Finally, it adds the estimated smear row to each image row.

The pixels in the resulting smear rows should all be nonzero for reasonable input data, but if this transformation has not been applied, they should always contain zeros for a slice of electron flux data.

Parameters:
  • smear_ratio (float) – Dimensionless ratio of smear exposure to nominal exposure
  • early_dark_pixel_columns (int) – The number of dark pixel columns on the left side of the slice
  • late_dark_pixel_columns (int) – The number of dark pixel columns on the right side of the slice
  • final_dark_pixel_rows (int) – The number of dark pixel rows at the top of the slice
  • smear_rows (int) – The number of smear rows
  • image_slice (Slice) – Input slice. Units: electrons
Return type:

Slice

simulate_blooming_on_slice(full_well, blooming_threshold, number_of_exposures, image_slice)[source]

This function simulates blooming along columns in the image pixel array.

Blooming is a diffusion process involving thermal excitation of electrons over the potential barriers between pixels. The height of the potential barrier confining electrons to the pixel decreases as the electron count in the pixel increases. The diffusion rate grows exponentially with decreasing barrier height.

This process is modeled using three parameters:

  • \(\mathtt{full\_well}\), the maximum number of electrons in a pixel. This is the number of electrons sufficient to cause such rapid diffusion that the pixel cannot hold any more.
  • \(\mathtt{blooming\_threshold}\), the number of electrons in the pixel that suffices to drive significant diffusion.
  • \(\mathtt{number\_of\_exposures}\), the number of stacked images in the slice.

Blooming is modeled as a diffusion process.

In a single step of the diffusion process, those pixels with electrons above \(\mathtt{number\_of\_exposures} \times \mathtt{blooming\_threshold}\) electrons diffuse charge to neighboring pixels in the same column.

A single step of the diffusion process is always performed at least once.

The single step is repeated until all pixels are below \(\mathtt{number\_of\_exposures} \times \mathtt{full\_well}\).

This transformation does not have an inverse.

Parameters:
  • full_well (float) – The maximum number of electrons in a pixel.
  • blooming_threshold (float) – The number of electrons in the pixel that suffices to drive significant diffusion.
  • number_of_exposures (int) – The number of stacked images in the slice
  • image_slice (Slice) – Input slice. Units: electrons
Return type:

Slice

simulate_start_of_line_ringing_to_slice(start_of_line_ringing, image_slice)[source]

Every row of electron flux pixels (dark or otherwise) in a CCD slice has been empirically observed to start with a fixed pattern.

This pattern is referred to as the start of line ringing.

This transformation introduces the start of line ringing pattern to each row.

Start of line ringing differs from CCD to CCD and slice to slice.

It is most prominent in the left dark pixel columns.

Parameters:
  • start_of_line_ringing (row: numpy.ndarray) – One dimensional array of floats, representing a fixed pattern disturbance in each row of a slice. If it is shorter than a row, it is padded with zeros, if longer it is truncated.
  • image_slice (Slice units: electrons) – input slice. Units: electrons
Return type:

Slice

simulate_undershoot_on_slice(undershoot_parameter, image_slice)[source]

When a CCD reads out a bright pixel, the pixel to the right of it appears artificially dimmer.

This is undershoot.

This function simulates undershoot for a slice.

It convolves the kernel \(\langle 1, -\mathtt{undershoot\_parameter} \rangle\) with each input row, yielding an output row of the same length.

The convolution is non-cyclic: the input row is implicitly padded with zero at the start to make this true.

This transformation is the (approximate) inverse of remove_undershoot_from_slice().

Parameters:
  • undershoot_parameter (float) – Typically ~0.001, dimensionless
  • image_slice (Slice) – input slice. Units: electrons
Return type:

Slice