corgidrp.l2a_to_l2b#

Functions#

add_shot_noise_to_err(input_dataset, kgain, ...)

Propagate the Poisson/shot noise determined from the image signal to the error map. Also

dark_subtraction(input_dataset[, noisemaps, dark, ...])

Perform dark subtraction of a dataset using the corresponding dark frame. The dark frame can be either a synthesized master dark (made for any given EM gain and exposure time)

flat_division(input_dataset, flat_field)

Divide the dataset by the master flat field.

flat_division_pol(input_dataset, flat_fieldPOL0, ...)

Divide the dataset by the master flat field.

frame_select(input_dataset[, bpix_frac, allowed_bpix, ...])

Selects the frames that we want to use for further processing.

convert_to_electrons(input_dataset, k_gain)

Convert the data from ADU to electrons.

em_gain_division(input_dataset)

Convert the data from detected EM electrons to detected electrons by dividing by the EM gain.

cti_correction(input_dataset, pump_trap_cal)

Apply the CTI correction to the dataset.

correct_bad_pixels(input_dataset, bp_mask)

Correct for bad pixels: Bad pixels are identified as part of the data

desmear(input_dataset, detector_params)

EXCAM has no shutter, and so continues to illuminate the detector during

update_to_l2b(input_dataset)

Updates the data level to L2b. Only works on L2a data.

Module Contents#

corgidrp.l2a_to_l2b.add_shot_noise_to_err(input_dataset, kgain, detector_params)[source]#

Propagate the Poisson/shot noise determined from the image signal to the error map. Also includes the effect of read noise. Estimation of photon/poisson/shot noise by interpolation of the photon transfer curve, added excess noise in case of em_gain > 1. Especially useful when a dataset has very few frames so that the shot noise is not accurately obtained by averaging the frames, nor is the read noise effectively mitigated through averaging.

Parameters:
Returns:

shot noise propagated to the image error extensions of the input dataset

Return type:

corgidrp.data.Dataset

corgidrp.l2a_to_l2b.dark_subtraction(input_dataset, noisemaps=None, dark=None, detector_regions=None, outputdir=None)[source]#

Perform dark subtraction of a dataset using the corresponding dark frame. The dark frame can be either a synthesized master dark (made for any given EM gain and exposure time) or for a traditional master dark (average of darks taken at the EM gain and exposure time of the corresponding observation). The function gives preference for the traditional master dark if provided. If the frames are photon-counted (PC) and a PC dark is provided, the subtraction will not happen here but instead in the PC function pc_mean(), later in the pipeline. The master dark is also saved if it is of the synthesized type after it is built. When noisemaps is provided (and dark is not), the dataset may contain frames with multiple distinct EMGAIN and exposure time configurations; a separate synthesized dark is built for each configuration.

Parameters:
  • input_dataset (corgidrp.data.Dataset) – a dataset of Images that need dark subtraction (L2a-level)

  • noisemaps (corgidrp.data.DetectorNoiseMaps) – If not None and if dark input not provided, a synthesized master dark is created using this DetectorNoiseMaps object for the EM gain and exposure time used in the frames in input_dataset. Multiple EMGAIN/EXPTIME configurations within input_dataset are supported in this mode.

  • dark (corgidrp.data.Dark or corgidrp.data.DetectorNoiseMaps) – If dark is of the corgidrp.data.Dark type, dark subtraction will be done with this input whether noisemaps is specified or not.

  • detector_regions – (dict): A dictionary of detector geometry properties. Keys should be as found in detector_areas in detector.py. Defaults to detector_areas in detector.py.

  • outputdir (string) – Filepath for output directory where to save the master dark if it is a synthesized master dark. Defaults to current directory.

Returns:

a dark-subtracted version of the input dataset including error propagation

Return type:

corgidrp.data.Dataset

corgidrp.l2a_to_l2b.flat_division(input_dataset, flat_field)[source]#

Divide the dataset by the master flat field.

Parameters:
Returns:

a version of the input dataset with the flat field divided out

Return type:

corgidrp.data.Dataset

corgidrp.l2a_to_l2b.flat_division_pol(input_dataset, flat_fieldPOL0, flat_fieldPOL45)[source]#

Divide the dataset by the master flat field.

Parameters:
Returns:

a version of the input dataset with the flat field divided out

Return type:

corgidrp.data.Dataset

corgidrp.l2a_to_l2b.frame_select(input_dataset, bpix_frac=1.0, allowed_bpix=0, overexp=False, tt_rms_thres=None, tt_bias_thres=None, discard_bad=True)[source]#

Selects the frames that we want to use for further processing.

Parameters:
  • input_dataset (corgidrp.data.Dataset) – a dataset of Images (L2a-level)

  • bpix_frac (float) – greater than fraction of the image needs to be bad to discard. Default: 1.0 (not used)

  • allowed_bpix (int) – sum of DQ values that are allowed and not counted towards to bpix fraction (e.g., 6 means 2 and 4 are not considered bad). Default is 0 (all nonzero DQ flags are considered bad)

  • overexp (bool) – if True, removes frames where the OVEREXP keyword is True. Default: False

  • tt_rms_thres (float) – maximum allowed RMS tip or tilt in image to be considered good. Default: None (not used)

  • tt_bias_thres (float) – maximum allowed bias in tip/tilt over the course of an image to be consdiered good. Default: None (not used)

  • discard_bad (bool) – if True, drops the bad frames rather than keeping them through processing

Returns:

a version of the input dataset with only the frames we want to use

Return type:

corgidrp.data.Dataset

corgidrp.l2a_to_l2b.convert_to_electrons(input_dataset, k_gain)[source]#

Convert the data from ADU to electrons. TODO: Establish the interaction with the CalDB for obtaining gain calibration

Parameters:
Returns:

a version of the input dataset with the data in electrons

Return type:

corgidrp.data.Dataset

corgidrp.l2a_to_l2b.em_gain_division(input_dataset)[source]#

Convert the data from detected EM electrons to detected electrons by dividing by the EM gain. Update the change in units in the header [detected electrons].

Parameters:

input_dataset (corgidrp.data.Dataset) – a dataset of Images (L2a-level)

Returns:

a version of the input dataset with the data in units “detected electrons”

Return type:

corgidrp.data.Dataset

corgidrp.l2a_to_l2b.cti_correction(input_dataset, pump_trap_cal)[source]#

Apply the CTI correction to the dataset.

Currently a no-op step function.

Parameters:
Returns:

a version of the input dataset with the CTI correction applied

Return type:

corgidrp.data.Dataset

corgidrp.l2a_to_l2b.correct_bad_pixels(input_dataset, bp_mask)[source]#
Correct for bad pixels: Bad pixels are identified as part of the data

calibration. This function replaces bad pixels by NaN values. It also updates its DQ storing the type of bad pixel at each bad pixel location, and it records the fact that the pixel has been replaced by NaN.

Parameters:
Returns:

a version of the input dataset with bad detector pixels and cosmic rays replaced by NaNs

Return type:

corgidrp.data.Dataset

corgidrp.l2a_to_l2b.desmear(input_dataset, detector_params)[source]#

EXCAM has no shutter, and so continues to illuminate the detector during readout. This creates a “smearing” effect into the resulting images. The desmear function corrects for this effect. There are a small number of use cases for not desmearing data (e.g. time-varying raster data).

Parameters:
Returns:

a version of the input dataset with desmear applied

Return type:

corgidrp.data.Dataset

corgidrp.l2a_to_l2b.update_to_l2b(input_dataset)[source]#

Updates the data level to L2b. Only works on L2a data.

Currently only checks that data is at the L2a level

Parameters:

input_dataset (corgidrp.data.Dataset) – a dataset of Images (L2a-level)

Returns:

same dataset now at L2b-level

Return type:

corgidrp.data.Dataset