hispecdrp.primitives.ramp_fitting.fitramp_Brandt

Functions

fit_ramps(diffs, Cov, sig[, countrateguess, ...])

Function fit_ramps.

getramps(countrate, sig, readtimes[, nramps])

Function getramps: make some synthetic ramps

mask_jumps(diffs, Cov, sig[, ...])

Function mask_jumps implements a likelihood-based, iterative jump detection algorithm.

Classes

Covar(read_times[, pedestal])

class Covar holding read and photon noise components of alpha and beta and the time intervals between the resultant midpoints

Ramp_Result()

class Covar(read_times, pedestal=False)[source]

Bases: object

class Covar holding read and photon noise components of alpha and beta and the time intervals between the resultant midpoints

calc_bias(countrates, sig, cvec, da=1e-07)[source]

Calculate the bias in the best-fit count rate from estimating the covariance matrix. This calculation is derived in the paper.

Parameters:
  • countrates (array_like) – Array of count rates at which the bias is desired.

  • sig (float) – Single read noise.

  • cvec (array_like) – Weight vector on resultant differences for initial estimation of count rate for the covariance matrix. Will be renormalized inside this function.

  • da (float, default 1e-7) – Fraction of the count rate plus sig**2 to use for finite difference estimate of the derivative.

Returns:

bias (array_like) – Bias of the best-fit count rate from using cvec plus the observed resultants to estimate the covariance matrix.

class Ramp_Result[source]

Bases: object

fill_masked_reads(diffs2use)[source]

Replace countrates, uncertainties, and chi squared values that are NaN because resultant differences were doubly omitted. For these cases, revert to the corresponding values in with fewer omitted resultant differences to get the correct values without double-coundint omissions.

Parameters:

diffs2use (array_like) – A 2D array matching self.countrate_oneomit in shape with zero for resultant differences that were masked and one for differences that were not masked.

Notes

This function replaces the relevant entries of self.countrate_twoomit, self.chisq_twoomit, self.uncert_twoomit, self.countrate_oneomit, and self.chisq_oneomit in place. It does not return a value.

fit_ramps(diffs, Cov, sig, countrateguess=None, diffs2use=None, detect_jumps=False, resetval=0, resetsig=inf, rescale=True, dn_scale=10)[source]

Function fit_ramps. Fits ramps to read differences using the covariance matrix for the read differences as given by the diagonal elements and the off-diagonal elements.

Parameters:
  • diffs (array_like, shape (ndiffs, npix)) – Resultant differences.

  • Cov (Covar) – Class holding the covariance matrix information.

  • sig (array_like, shape (npix)) – Read noise.

  • countrateguess (array_like, shape (npix), optional) – Count rates to be used to estimate the covariance matrix. Default is None.

  • diffs2use (array_like, shape (ndiffs, npix), optional) – Boolean mask of whether to use each resultant difference for each pixel. Default is None.

  • detect_jumps (bool, optional) – Run the jump detection machinery. Default is False.

  • resetval (float or array_like, shape (npix), optional) – Priors on the reset values. Default is 0.

  • resetsig (float or array_like, shape (npix), optional) – Uncertainties on the reset values. Default is np.inf.

  • rescale (bool, optional) – Scale the covariance matrix internally. Default is True.

Returns:

Ramp_Result – Class holding detailed ramp information.

getramps(countrate, sig, readtimes, nramps=10)[source]

Function getramps: make some synthetic ramps

Parameters:
  • countrate (float or array_like) – Electrons per unit time.

  • sig (float) – Single-read read noise in electrons.

  • readtimes (list or list of lists) – Times of reads. If a list of lists, times are averaged together to produce a resultant.

  • nramps (int, optional) – Number of ramps desired. Default is 10.

Returns:

counts (ndarray, shape (nreads, nramps)) – Electrons in each read.

mask_jumps(diffs, Cov, sig, threshold_oneomit=20.25, threshold_twoomit=23.8, diffs2use=None)[source]

Function mask_jumps implements a likelihood-based, iterative jump detection algorithm.

Parameters:
  • diffs (array_like) – Resultant differences.

  • Cov (Covar) – Class holding the covariance matrix information. Must be based on differences alone (without the pedestal).

  • sig (array_like, shape (npix)) – Read noise.

  • threshold_oneomit (float, optional) – Minimum chi-squared improvement to exclude a single resultant difference. Default is 20.25.

  • threshold_twoomit (float, optional) – Minimum chi-squared improvement to exclude two sequential resultant differences. Default is 23.8.

  • diffs2use (array_like, shape same as diffs, optional) – Mask array indicating which resultant differences are okay (1) or contaminated (0). Default is None.

Returns:
  • diffs2use (array_like, shape same as diffs) – Mask array of resultant differences after jump detection.

  • countrates (array_like) – Count rates after masking pixels and resultants in diffs2use.