corgidrp.pump_trap_calibration#
Analysis of trap-pumped images for calibration. Assumes trap-pumped full frames as input. Some of the trap-finding and parameter-fitting code adapted from code from Nathan Bush, and his code was used for his paper, the basis for this code: Nathan Bush, David Hall, and Andrew Holland, J. of Astronomical Telescopes, Instruments, and Systems, 7(1), 016003 (2021). https://doi.org/10.1117/1.JATIS.7.1.016003 - Kevin Ludwick, UAH, 6/2022
- MMB Changes for corgi-drp:
Removed everything meta and replaced with functions from detector.py
Replaced II&T get_relgains function with corgidrp function -> Now
requires a NonLinearityCorrection object to work. Defaults to None - Removed image slicing - Removed non-linearity correction - Input dataset is now a Dataset object from corgidrp.data - output is now a corgi.drp.TrapCalibration object
Exceptions#
Exception class for tpumpanalysis. |
Functions#
|
Probability function 1, one trap. |
|
Probability function 1, two traps. |
|
Probability function 2, one trap. |
|
One trap for probability function 1, one for probability function 2. |
|
Probability function 2, two traps. |
|
Probability function 3, one trap. |
|
Probability function 3, two traps. |
|
One trap for probability function 2, one for probability function 3. |
|
Performs non-uniform illumination correction by taking sections of the |
|
Calculates the release time constant (tau) based on the input temperature, |
|
Calculates the standard deviation of the release time constant via error propagation. |
|
Identifies dipoles in an image stack based on threshold amplitude and categorizes them. |
|
For a given temperature, scheme, and pixel, this function examines data |
|
For a given temperature, scheme, and pixel, this function examines data |
|
This function fits the cross section for holes (cs) for a given trap |
|
This function analyzes trap-pumped frames and outputs the location of |
|
A function that converts a trap dictionary into a corgidrp.data.TrapCalibration |
|
Partially rebuild the trap_dictionary from the trap_pump_array to help with testing |
Module Contents#
- exception corgidrp.pump_trap_calibration.TPumpAnException[source]#
Bases:
ExceptionException class for tpumpanalysis.
- corgidrp.pump_trap_calibration.P1(time_data, offset, tauc, tau, num_pumps=2000)[source]#
Probability function 1, one trap.
- Parameters:
time_data (array) – Phase times in seconds.
offset (float) – Offset in the fitting of data for amplitude vs phase time.
tauc (float) – Capture time constant. Units: e-.
tau (float) – Release time constant. Units: seconds.
num_pumps (int) – Number of cycles for trap pumping. Must be greater than 0.
- Returns:
Expected amplitude values for the given phase times.
- Return type:
array
- corgidrp.pump_trap_calibration.P1_P1(time_data, offset, tauc, tau, tauc2, tau2, num_pumps=2000)[source]#
Probability function 1, two traps.
- Parameters:
time_data (array) – Phase times in seconds.
offset (float) – Offset in the fitting of data for amplitude vs phase time.
tauc (float) – Capture time constant for the first trap. Units: e-.
tau (float) – Release time constant for the first trap. Units: seconds.
tauc2 (float) – Capture time constant for the second trap. Units: e-.
tau2 (float) – Release time constant for the second trap. Units: seconds.
num_pumps (int) – Number of cycles for trap pumping. Must be greater than 0.
- Returns:
Expected amplitude values for the given phase times.
- Return type:
array
- corgidrp.pump_trap_calibration.P2(time_data, offset, tauc, tau, num_pumps=2000)[source]#
Probability function 2, one trap.
- Parameters:
time_data (array) – Phase times in seconds.
offset (float) – Offset in the fitting of data for amplitude vs phase time.
tauc (float) – Capture time constant. Units: e-.
tau (float) – Release time constant. Units: seconds.
num_pumps (int) – Number of cycles for trap pumping. Must be greater than 0.
- Returns:
Expected amplitude values for the given phase times.
- Return type:
array
- corgidrp.pump_trap_calibration.P1_P2(time_data, offset, tauc, tau, tauc2, tau2, num_pumps=2000)[source]#
One trap for probability function 1, one for probability function 2.
- Parameters:
time_data (array) – Phase times in seconds.
offset (float) – Offset in the fitting of data for amplitude vs phase time.
tauc (float) – Capture time constant for the first trap. Units: e-.
tau (float) – Release time constant for the first trap. Units: seconds.
tauc2 (float) – Capture time constant for the second trap. Units: e-.
tau2 (float) – Release time constant for the second trap. Units: seconds.
num_pumps (int) – Number of cycles for trap pumping. Must be greater than 0.
- Returns:
Expected amplitude values for the given phase times.
- Return type:
array
- corgidrp.pump_trap_calibration.P2_P2(time_data, offset, tauc, tau, tauc2, tau2, num_pumps=2000)[source]#
Probability function 2, two traps.
- Parameters:
time_data (array) – Phase times in seconds.
offset (float) – Offset in the fitting of data for amplitude vs phase time.
tauc (float) – Capture time constant for the first trap. Units: e-.
tau (float) – Release time constant for the first trap. Units: seconds.
tauc2 (float) – Capture time constant for the second trap. Units: e-.
tau2 (float) – Release time constant for the second trap. Units: seconds.
num_pumps (int) – Number of cycles for trap pumping. Must be greater than 0.
- Returns:
Expected amplitude values for the given phase times.s
- Return type:
array
- corgidrp.pump_trap_calibration.P3(time_data, offset, tauc, tau, num_pumps=2000)[source]#
Probability function 3, one trap.
- Parameters:
time_data (array) – Phase times in seconds.
offset (float) – Offset in the fitting of data for amplitude vs phase time.
tauc (float) – Capture time constant. Units: e-.
tau (float) – Release time constant. Units: seconds.
num_pumps (int) – Number of cycles for trap pumping. Must be greater than 0.
- Returns:
Expected amplitude values for the given phase times.
- Return type:
array
- corgidrp.pump_trap_calibration.P3_P3(time_data, offset, tauc, tau, tauc2, tau2, num_pumps=2000)[source]#
Probability function 3, two traps.
- Parameters:
time_data (array) – Phase times in seconds.
offset (float) – Offset in the fitting of data for amplitude vs phase time.
tauc (float) – Capture time constant for the first trap. Units: e-.
tau (float) – Release time constant for the first trap. Units: seconds.
tauc2 (float) – Capture time constant for the second trap. Units: e-.
tau2 (float) – Release time constant for the second trap. Units: seconds.
num_pumps (int) – Number of cycles for trap pumping. Must be greater than 0.
- Returns:
Expected amplitude values for the given phase times.
- Return type:
array
- corgidrp.pump_trap_calibration.P2_P3(time_data, offset, tauc, tau, tauc2, tau2, num_pumps=2000)[source]#
One trap for probability function 2, one for probability function 3.
- Parameters:
time_data (array) – Phase times in seconds.
offset (float) – Offset in the fitting of data for amplitude vs phase time.
tauc (float) – Capture time constant for the first trap. Units: e-.
tau (float) – Release time constant for the first trap. Units: seconds.
tauc2 (float) – Capture time constant for the second trap. Units: e-.
tau2 (float) – Release time constant for the second trap. Units: seconds.
num_pumps (int) – Number of cycles for trap pumping. Must be greater than 0.
- Returns:
Expected amplitude values for the given phase times.
- Return type:
array
- corgidrp.pump_trap_calibration.illumination_correction(img, binsize, ill_corr)[source]#
Performs non-uniform illumination correction by taking sections of the image and performing local illumination subtraction.
This function was copied and pasted from trip_id.py in the II&T pipeline.
- Parameters:
img (2-D array) – Image to be corrected.
binsize (int) – Number of pixels over which to average for subtraction. If None, acts as if ill_corr is False.
ill_corr (bool) – If True, subtracts the local median of the square region of side length equal to binsize from each pixel. If False, simply subtracts from each pixel the median of the whole image region.
- Returns:
- A tuple containing:
corrected_img (2-D array): Corrected image. local_ill (2-D array): Frame with pixel values equal to the amount that was subtracted from each.
- Return type:
tuple
- corgidrp.pump_trap_calibration.tau_temp(temp_data, E, cs)[source]#
Calculates the release time constant (tau) based on the input temperature, energy level, and capture cross section for holes.
This function was copied and pasted from the trip_fitting.py in the II&T pipeline.
This function computes the release time constant (tau, in seconds) using the input temperature data, energy level, and capture cross section for holes. For more details, refer to the Appendix in “2020 Bush et al.pdf”.
- Parameters:
temp_data (float) – Temperature in Kelvin.
E (float) – Energy level in electron volts (eV).
cs (float) – Capture cross section for holes, either in units of 1e-19 m^2 or 1e-15 cm^2.
- Returns:
The release time constant (tau) in seconds.
- Return type:
float
- corgidrp.pump_trap_calibration.sig_tau_temp(temp_data, E, cs, sig_E, sig_cs)[source]#
Calculates the standard deviation of the release time constant via error propagation.
This function computes the standard deviation of the release time constant (sig_tau, in seconds) through error propagation, based on the input temperature, energy level, capture cross section for holes, and their respective standard deviations. For more details, refer to the Appendix in “2020 Bush et al.pdf”.
This function was copied and pasted from the trip_fitting.py in the II&T pipeline.
- Parameters:
temp_data (float) – Temperature in Kelvin.
E (float) – Energy level in electron volts (eV).
cs (float) – Capture cross section for holes, either in units of 1e-19 m^2 or 1e-15 cm^2.
sig_E (float) – Standard deviation of the energy level (eV).
sig_cs (float) – Standard deviation of the capture cross section for holes.
- Returns:
The standard deviation of the release time constant (sig_tau) in seconds.
- Return type:
float
- corgidrp.pump_trap_calibration.trap_id(cor_img_stack, ill_corr_min, ill_corr_max, timings, thresh_factor, length_limit)[source]#
Identifies dipoles in an image stack based on threshold amplitude and categorizes them.
This function analyzes a stack of trap-pumped images taken at different phase times to identify dipoles by detecting adjacent pixels that exceed a threshold amplitude above and below the mean. The threshold must be met at a sufficient number of phase times. The function then categorizes the bright pixel of each dipole into one of three categories: ‘above’, ‘below’, or ‘both’.
The function was copied and pasted from trap_id.py in the II&T pipeline.
- Parameters:
cor_img_stack (3-D array) – Stack of trap-pumped images taken at different phase times. Each frame should have the same dimensions. Units can be in electrons (e-) or digital numbers (DN), but they are input as electrons when this function is called in tpump_analysis().
ill_corr_min (2-D array) – Frame with pixel values equal to the minimum median taken over phase times that was subtracted during illumination_correction(). If ill_corr was False, the median was global over the whole image region. If ill_corr was True, the median was over a local square of side length binsize pixels in illumination_correction().
ill_corr_max (2-D array) – Frame with pixel values equal to the maximum median taken over phase times that was subtracted during illumination_correction(). The conditions are the same as described for ill_corr_min.
timings (array-like) – Array of the phase times corresponding to the ordering of the frames in cor_img_stack. Units are in seconds.
thresh_factor (float) – Number of standard deviations from the mean that a dipole must exceed to be considered for a trap. If too high, dipoles with increasing amplitude over time are identified, which is not characteristic of an actual trap. If too low, the resulting dipoles may have amplitudes that are too noisy or low.
length_limit (int) – Minimum number of frames in which a dipole must meet the threshold to be considered a true trap.
- Returns:
- A dictionary with keys for each bright pixel of an ‘above’ dipole,
formatted as: {
- (row, col): {
‘amps_above’: array([amp1, amp2, …]), ‘loc_med_min’: float, ‘loc_med_max’: float
} ‘amps_above’ is an array of amplitudes in the same order as the phase time order in timings. ‘loc_med_min’ and ‘loc_med_max’ are the minimum and maximum bias values over all phase times, respectively.
- rc_below (dict): A dictionary with keys for each bright pixel of a ‘below’ dipole,
formatted similarly to rc_above.
- rc_both (dict): A dictionary with keys for each bright pixel that is both an ‘above’
and ‘below’ dipole, formatted as: {
- (row, col): {
‘amps_both’: array([amp1, amp2, …]), ‘loc_med_min’: float, ‘loc_med_max’: float, ‘above’: {
’amp’: array([amp1a, amp2a, …]), ‘t’: array([t1a, t2a, …])
}, ‘below’: {
’amp’: array([amp1b, amp2b, …]), ‘t’: array([t1b, t2b, …])
}
} ‘amps’ and ‘t’ under ‘above’ and ‘below’ are arrays identified specifically with their respective dipoles. ‘amps_both’ contains all amplitudes for that pixel in the same order as timings.
- Return type:
rc_above (dict)
- corgidrp.pump_trap_calibration.trap_fit(scheme, amps, times, num_pumps, fit_thresh, tau_min, tau_max, tauc_min, tauc_max, offset_min, offset_max, both_a=None)[source]#
For a given temperature, scheme, and pixel, this function examines data for amplitude vs phase time and fits for release time constant (tau) and the probability for capture (pc). It tries fitting for a single trap in the pixel, and if the goodness of fit is not high enough (if less than fit_thresh), then the function attempts to fit for two traps in the pixel. The exception is the case where a ‘both’ type pixel is input; then only a two-trap fit is attempted. The function assumes the full time-dependent form for capture probability.
The function was copied and pasted from trap_fitting.py in the II&T pipeline.
- Parameters:
scheme (int) – The scheme under consideration. Only certain probability functions are valid for different schemes. Values: {1, 2, 3, 4}.
amps (array) – Amplitudes of bright pixel of the dipole. Units: e-.
times (array) – Phase times in the same order as amps. Units: seconds.
num_pumps (int) – Number of cycles for trap pumping. Must be greater than 0.
fit_thresh (float) – Minimum value required for adjusted coefficient of determination (adjusted R^2) for curve fitting for the release time constant (tau) using data for dipole amplitude vs phase time. The closer to 1, the better the fit. Must be between 0 and 1.
tau_min (float) – Lower bound value for tau (release time constant) for curve fitting. Units: seconds. Must be greater than or equal to 0.
tau_max (float) – Upper bound value for tau (release time constant) for curve fitting. Units: seconds. Must be greater than tau_min.
tauc_min (float) – Lower bound value for tauc (capture time constant) for curve fitting. Units: e-. Must be greater than or equal to 0.
tauc_max (float) – Upper bound value for tauc (capture time constant) for curve fitting. Units: e-. Must be greater than tauc_min.
offset_min (float) – Lower bound value for the offset in the fitting of data for amplitude vs phase time. Acts as a nuisance parameter. Units: e-.
offset_max (float) – Upper bound value for the offset in the fitting of data for amplitude vs phase time. Acts as a nuisance parameter. Units: e-. Must be greater than offset_min.
both_a (dict, optional) – Use None if fitting for a dipole that is of the ‘above’ or ‘below’ kind. Use the dictionary corresponding to rc_both[(row,col)][‘above’] if fitting for a dipole that is of the ‘both’ kind. Defaults to None.
- Returns:
- Dictionary of fit data. Contains:
prob: {1, 2, 3}; denotes probability function that gave the best fit
pc: Constant capture probability, best-fit value
pc_err: Standard deviation of pc
tau: Release time constant, best-fit value
tau_err: Standard deviation of tau
The structure of the returned dictionary varies based on both_a: - If both_a is None and one trap is the best fit:
{prob: [[pc, pc_err, tau, tau_err]]}
- If both_a is None and two traps are the best fit:
- {prob1: [[pc, pc_err, tau, tau_err]],
prob2: [[pc2, pc2_err, tau2, tau2_err]]}
- If both traps are of prob1 type:
{prob1: [[pc, pc_err, tau, tau_err], [pc2, pc2_err, tau2, tau2_err]]}
- If both_a is not None:
- {type1: {1: [[pc, pc_err, tau, tau_err]]},
type2: {2: [[pc2, pc2_err, tau2, tau2_err]]}}
where type1 is either ‘a’ for above or ‘b’ for below, and type2 is whichever of those type1 is not.
- Return type:
dict
- corgidrp.pump_trap_calibration.trap_fit_const(scheme, amps, times, num_pumps, fit_thresh, tau_min, tau_max, pc_min, pc_max, offset_min, offset_max, both_a=None)[source]#
For a given temperature, scheme, and pixel, this function examines data for amplitude vs phase time and fits for release time constant (tau) and the probability for capture (pc). It tries fitting for a single trap in the pixel, and if the goodness of fit is not high enough (if less than fit_thresh), then the function attempts to fit for two traps in the pixel. The exception is the case where a ‘both’ type pixel is input; then only a two-trap fit is attempted. The function assumes a constant for pc rather than its actual time-dependent form.
The function was copied and pasted from trap_fitting.py in the II&T pipeline.
- Parameters:
scheme (int) – The scheme under consideration. Only certain probability functions are valid for different schemes. Values: {1, 2, 3, 4}.
amps (array) – Amplitudes of bright pixel of the dipole. Units: e-.
times (array) – Phase times in the same order as amps. Units: seconds.
num_pumps (int) – Number of cycles for trap pumping. Must be greater than 0.
fit_thresh (float) – Minimum value required for adjusted coefficient of determination (adjusted R^2) for curve fitting for the release time constant (tau) using data for dipole amplitude vs phase time. The closer to 1, the better the fit. Must be between 0 and 1.
tau_min (float) – Lower bound value for tau (release time constant) for curve fitting. Units: seconds. Must be greater than or equal to 0.
tau_max (float) – Upper bound value for tau (release time constant) for curve fitting. Units: seconds. Must be greater than tau_min.
pc_min (float) – Lower bound value for pc (capture probability) for curve fitting. Units: e-. Must be greater than or equal to 0.
pc_max (float) – Upper bound value for pc (capture probability) for curve fitting. Units: e-. Must be greater than pc_min.
offset_min (float) – Lower bound value for the offset in the fitting of data for amplitude vs phase time. Acts as a nuisance parameter. Units: e-.
offset_max (float) – Upper bound value for the offset in the fitting of data for amplitude vs phase time. Acts as a nuisance parameter. Units: e-. Must be greater than offset_min.
both_a (dict, optional) – Use None if fitting for a dipole that is of the ‘above’ or ‘below’ kind. Use the dictionary corresponding to rc_both[(row,col)][‘above’] if fitting for a dipole that is of the ‘both’ kind. Defaults to None.
- Returns:
- Dictionary of fit data. Contains:
prob: {1, 2, 3}; denotes probability function that gave the best fit
pc: Constant capture probability, best-fit value
pc_err: Standard deviation of pc
tau: Release time constant, best-fit value
tau_err: Standard deviation of tau
The structure of the returned dictionary varies based on both_a: - If both_a is None and one trap is the best fit:
{prob: [[pc, pc_err, tau, tau_err]]}
- If both_a is None and two traps are the best fit:
- {prob1: [[pc, pc_err, tau, tau_err]],
prob2: [[pc2, pc2_err, tau2, tau2_err]]}
- If both traps are of prob1 type:
{prob1: [[pc, pc_err, tau, tau_err], [pc2, pc2_err, tau2, tau2_err]]}
- If both_a is not None:
- {type1: {1: [[pc, pc_err, tau, tau_err]]},
type2: {2: [[pc2, pc2_err, tau2, tau2_err]]}}
where type1 is either ‘a’ for above or ‘b’ for below, and type2 is whichever of those type1 is not.
- Return type:
dict
- corgidrp.pump_trap_calibration.fit_cs(taus, tau_errs, temps, cs_fit_thresh, E_min, E_max, cs_min, cs_max, input_T)[source]#
This function fits the cross section for holes (cs) for a given trap by curve-fitting release time constant (tau) vs temperature. Returns fit parameters and the release time constant at the desired input temperature.
- Parameters:
taus (array) – Array of tau values (in seconds).
tau_errs (array) – Array of tau uncertainty values (in seconds), with elements in the same order as that of taus.
temps (array) – Array of temperatures (in Kelvin), with elements in the same order as that of taus.
cs_fit_thresh (float) – The minimum value required for adjusted coefficient of determination (adjusted R^2) for curve fitting for the capture cross section for holes (cs) using data for tau vs temperature. The closer to 1, the better the fit. Must be between 0 and 1.
E_min (float) – Lower bound for E (energy level in release time constant) for curve fitting, in eV. Must be greater than or equal to 0.
E_max (float) – Upper bound for E (energy level in release time constant) for curve fitting, in eV. Must be greater than E_min.
cs_min (float) – Lower bound for cs (capture cross section for holes in release time constant) for curve fitting, in 1e-19 m^2. Must be greater than or equal to 0.
cs_max (float) – Upper bound for cs (capture cross section for holes in release time constant) for curve fitting, in 1e-19 m^2. Must be greater than cs_min.
input_T (float) – Temperature of Roman EMCCD at which to calculate the release time constant (in units of Kelvin). Must be greater than 0.
- Returns:
Energy level (in eV). sig_E (float): Standard deviation error of energy level, in eV. cs (float): Cross section for holes, in cm^2. sig_cs (float): Standard deviation error of cross section for holes, in cm^2. Rsq (float): Adjusted R^2 for the tau vs temperature fit that was done to obtain cs. tau_input_T (float): Tau evaluated at desired temperature of Roman EMCCD, input_T,
in seconds.
- sig_tau_input_T (float): Standard deviation error of tau at desired temperature of
Roman EMCCD, input_T. Found by propagating error by utilizing sig_cs and sig_E, in seconds.
- Return type:
E (float)
- corgidrp.pump_trap_calibration.tpump_analysis(input_dataset, time_head='TPTAU', mean_field=None, length_lim=5, thresh_factor=1.5, k_prob=1, ill_corr=True, tfit_const=True, tau_fit_thresh=0.8, tau_min=7e-07, tau_max=0.013, tauc_min=0, tauc_max=1e-05, pc_min=0, pc_max=2, offset_min=10, offset_max=10, cs_fit_thresh=0.8, E_min=0, E_max=1, cs_min=0, cs_max=50, bins_E=100, bins_cs=10, input_T=180, sample_data=False, verbose=False, bin_size=10, bias_tolerance=10)[source]#
This function analyzes trap-pumped frames and outputs the location of each radiation trap (pixel and sub-electrode location within the pixel), everything needed to determine the release time constant at any temperature (the capture cross section for holes and the energy level), trap densities (i.e., how many traps per pixel for each kind of trap found), and information about the capture time constant (for potential future analysis). This function only works as intended for the EMCCD with its electrodes’ paticular electric potential shape that will be used for trap pumping on the Roman telescope. It can find up to two traps per sub-electrode location per pixel. The function has an option to save a preliminary output that takes a long time to create (the dictionary called ‘temps’) and an option to load that in and start the function at that point.
The frames in the input_dataset should be SCI full frames that: - have had their bias subtracted - have been corrected for nonlinearity - have been divided by EMGAIN
The following parameters from the II&T Trap pumping code are stored in the object calibration file: trap_densities : list
A list of lists, where a list is provided for each type of trap. The trap density for a trap type is the # of traps in a given 2-D bin of E and tau divided by the total number of pixels in the image area. The binning by default is fine enough to distinguish all trap types found in the literarture. Only the bins that contain non-zero entries are returned here. Each trap-type list is of the following format: [trap density, E, cs]. E is the central value of the E bin, and cs is the central value of the cs bin. Stored in a hdu extention named ‘trap_densities’
- bad_fit_counterint
Number of times trap_fit() provided fits of amplitude vs phase time that were below fit_thresh over all schemes and temperature (which would include any preliminary trap identifications that were rejected because they weren’t consistent across all schemes for sub-electrode locations).
- pre_sub_el_countint
Number of times a trap was identified before filtering them through sub-electrode location. The counter is over all schemes and temperatures.
- unused_fit_dataint or None
Number of times traps were identified that were not matched up for sub-electrode location determination.
- unused_temp_fit_dataint
Number of times traps were identified that did not get used in identifying release time constant values across all temperatures
- two_or_less_countint
Number of traps that only appeared at 2 or fewer temperatures.
- noncontinuous_countint
Number of traps that appeared at a noncontinuous series of temperatures.
- Parameters:
input_dataset (corgidrp.data.Dataset) – The input dataset to be analyzed. The dataset should be a stack of trap-pumped frames.
time_head (str) – Keyword corresponding to phase time for each FITS file. The keyword value is assumed to be a float (units of microseconds). Defaults to ‘TPTAU’.
mean_field (float, optional) – The mean electron level that was present in each pixel before trap pumping was performed (excluding EM gain). Only useful if the mean level is less than num_pumps/4 e-. If num_pumps/4 e- or higher, use None.
length_lim (int, optional) – Minimum number of frames for which a dipole needs to meet the threshold to be considered a true trap. Defaults to 5.
thresh_factor (float, optional) – Number of standard deviations from the mean a dipole should stand out to be considered for a trap. Defaults to 1.5.
k_prob (int, optional) – The probability function used for finding the e-/DN factor. If the code fails with an exception, re-run the code with 2. Defaults to 1.
ill_corr (bool, optional) – Whether to run local illumination correction on each trap-pumped frame. Defaults to True.
tfit_const (bool, optional) – Whether to use trap_fit_const() for curve fitting, treating the capture probability as constant. Defaults to True.
tau_fit_thresh (float, optional) – Minimum adjusted R^2 value required for curve fitting for the release time constant (tau). Defaults to 0.8.
tau_min (float, optional) – Lower bound value for tau (release time constant) for curve fitting, in seconds. Defaults to 0.7e-6.
tau_max (float, optional) – Upper bound value for tau (release time constant) for curve fitting, in seconds. Defaults to 1.3e-2.
tauc_min (float, optional) – Lower bound value for tauc (capture time constant) for curve fitting, in seconds. Only used if tfit_const = False. Defaults to 0.
tauc_max (float, optional) – Upper bound value for tauc (capture time constant) for curve fitting, in seconds. Only used if tfit_const = False. Defaults to 1e-5.
pc_min (float, optional) – Lower bound value for pc (capture probability) for curve fitting, in e-. Only used if tfit_const = True. Defaults to 0.
pc_max (float, optional) – Upper bound value for pc (capture probability) for curve fitting, in e-. Only used if tfit_const = True. Defaults to 2.
offset_min (float, optional) – Lower bound for the offset in the curve fit relative to 0 for fitting amplitude vs phase time. Defaults to 10.
offset_max (float, optional) – Upper bound for the offset in the curve fit relative to 0 for fitting amplitude vs phase time. Defaults to 10.
cs_fit_thresh (float, optional) – Minimum adjusted R^2 value required for curve fitting for the capture cross section for holes (cs) using data for tau vs temperature. Defaults to 0.8.
E_min (float, optional) – Lower bound for E (energy level in release time constant) for curve fitting, in eV. Defaults to 0.
E_max (float, optional) – Upper bound for E (energy level in release time constant) for curve fitting, in eV. Defaults to 1.
cs_min (float, optional) – Lower bound for cs (capture cross section for holes in release time constant) for curve fitting, in 1e-19 m^2. Defaults to 0.
cs_max (float, optional) – Upper bound for cs (capture cross section for holes in release time constant) for curve fitting, in 1e-19 m^2. Defaults to 50.
bins_E (int, optional) – Number of bins used for energy level in categorizing traps into 2-D bins of energy level and cross section. Defaults to 100.
bins_cs (int, optional) – Number of bins used for cross section in categorizing traps into 2-D bins of energy level and cross section. Defaults to 10.
input_T (float, optional) – Temperature of Roman EMCCD at which to calculate the release time constant (in units of Kelvin). Defaults to 180.
sample_data (bool, optional) – Whether to run the sample data on Alfresco. Defaults to False.
verbose (bool, optional) – Whether to print out additional information. Defaults to False.
bin_size (int, optional) – Side length of the square of pixels to consider for binning in illumination_correction(). If None, the square root of the smaller dimension (the smaller of the number of rows and number of cols) is used. Defaults to 10. If a value bigger than the smaller dimension is input, then the size of the smaller dimension is used instead. The optimal value for bin_size depends on the trap density, which is unknown, so in principle, this function could be run several times with decreasing bin size until the maximum number of traps have been detected.
bias_tolerance (float, optional) – Used for filtering out legacy frames. Legacy frames have no illumination except for in the last few rows, so the average of a central region of the imaging area should be close to 0 since bias was already subtracted out (and the average takes care of read noise). Even if a legacy frame slips through, it will not cause any harm to the processing since no dipoles would be found in such a frame. Defaults to 10.
- Returns:
An object containing the results of the trap calibration. The trap densities are appended as an extension HDU, and several other parameters are stored as header keywords in the ext_hdr header.
- Return type:
- corgidrp.pump_trap_calibration.create_TrapCalibration_from_trap_dict(trap_dict, input_dataset)[source]#
A function that converts a trap dictionary into a corgidrp.data.TrapCalibration file.
The trap dictionary is defined as follows: A dictionary with a key for each trap for which acceptable fits for the release time constant (tau) for all schemes could be made. It has the following format, and an example entry for a pixel at location (row, col) on the right-hand side (RHS) of electrode 2 containg 1 of possibly two traps is shown. The 0 in the key denotes that this is the first trap found at this pixel and sub-electrode location. If a 2nd trap was found at this same location, another trap with a 1 in the key would be present in trap_dict. trap_dict = {
((row, col), ‘RHSel2’, 0): {‘T’: [160, 162, 164, 166, 168], ‘tau’: [1.51e-6, 1.49e-6, 1.53e-6, 1.50e-6, 1.52e-6], ‘sigma_tau’: [2e-7, 1e-7, 1e-7, 2e-7, 1e-7], ‘cap’: [[cap1, cap1_err, max_amp1, cap2, cap2_err, max_amp2], …], ‘E’: 0.23, ‘sig_E’: 0.02, ‘cs’: 2.6e-15, ‘sig_cs’: 0.3e-15, ‘Rsq’: 0.96, ‘tau at input T’: 1.61e-6, ‘sig_tau at input T’: 2.02e-6}, …}
- ‘T’: temperatures for which values of tau were successfully fit. In K.
‘tau’: the tau values corresponding to these temperatures in the same order. In seconds. ‘sigma_tau’: overall uncetainty in tau taken from the errors in the fits from all the schemes that were used to specify trap location (corresponding to the same order as ‘T’ and ‘tau’). In seconds. ‘cap’: cap1 is either the probability of capture (if trap_fit_const() used) or tauc (capture time constant) if trap_fit() used. cap1_err is the error from fitting. max_amp1 is the maximum amplitude of the dipole from the curve fit for that pixel. Similarly for cap2, cap2_err, and max_amp2, and there can be a 3rd set of parameters if a trap sub-electrode location was determined using 3 schemes. This data may be useful for future analysis. ‘E’: energy level. In eV. ‘sig_E’: standard deviation error of energy level. In eV. ‘cs’: cross section for holes. In cm^2. ‘sig_cs’: standard deviation error of cross section for holes. In cm^2. ‘Rsq’: adjusted R^2 for the tau vs temperature fit that was done to obtain cs. ‘tau at input T’: tau (in seconds) evaluated at desired temperature of Roman EMCCD, input_T. ‘sig_tau at input T’: standard deviation error of tau at desired temperature of Roman EMCCD, input_T. Found by propagating error by utilizing ‘sig_cs’ and ‘sig_E’.
We will recode the string parts of that dictionary specifying the sub-electrode location for a given pixel to a number code. An example of such a string is ‘RHSel2’, which denotes the right-hand side of electrode 2. It can be ‘RHS’, ‘LHS’, or ‘CEN’ for electrodes 1 through 4. So that can be converted to a number code (1: ‘LHS’, 2: ‘CEN’, 3: ‘RHS’), so that ‘RHSel2’ would be 32.
- Parameters:
trap_dict (dict) – A dictionary output by tpump_analysis
input_dataset (list) – A list of corgidrp.data.TPumpData objects.
- Returns:
A trap calibration file.
- Return type:
trap_cal (corgidrp.data.TrapCalibration)