RampFitInterpolator

class romanisim.ramp.RampFitInterpolator(read_pattern, flux_on_readvar_pts=None)

Bases: object

Ramp fitting tool aiding efficient fitting of large number of ramps.

The basic idea is that for a given image, ignoring cosmic rays or saturated pixels, the ramp fitting parameters are just a linear combination of the resultants. The weights of this linear combination are a single parameter family in the flux in the ramp divided by the read variance. So rather than explicitly calculating those weights for each pixel, we can up front calculate them overa grid in the flux over the read variance, and interpolate off that grid for each point. That can all be done in a vectorized way, allowing one to avoid doing something like a matrix inverse for each of a 16 million pixels.

The tool pre-calculates the grid and interpolators it needs at initialization, and then uses the results of that calculation when invoked to get the weights \(k\) or variances. The expectation is that most users just initialize and then call the fit_ramps method.

Construct a RampFitInterpolator for a read_pattern and a grid of flux/read_noise**2.

Parameters:
read_patternlist[list] (int)

list of lists of indices of reads entering each resultant

flux_on_readvar_ptsnp.ndarray (float)

flux / read_noise**2 points at which to compute ramp fitting matrices. if None, a default grid will be used that should cover all reasonable values, from the read variance being 100k larger to 100k smaller than the electrons per second.

Methods Summary

fit_ramps(resultants, read_noise[, fluxest])

Fit ramps for a set of resultants and their read noise.

ki(flux, read_noise)

Compute \(k\), the weights for the linear combination of resultant differences for optimal measurement of ramp pedestal and slope.

variances(flux, read_noise)

Compute the variances of ramp fit parameters.

Methods Documentation

fit_ramps(resultants, read_noise, fluxest=None)

Fit ramps for a set of resultants and their read noise.

Does not handle partial ramps (i.e., broken due to CRs).

Parameters:
resultantsnp.ndarray[n_resultants, nx, ny] (numeric)

Resultants to fit

read_noisefloat or array_like like resultants

read noise in array

fluxestfloat or array_like like resultants

Initial estimate of flux in each ramp, in electrons per second. If None, estimated from the median flux differences between resultants.

Returns:
parnp.ndarray[nx, ny, 2] (float)

the best fit pedestal and slope for each pixel

varnp.ndarray[nx, ny, 3, 2, 2] (float)

the covariance matrix of par, for each of three noise terms: the read noise, Poisson source noise, and total noise.

ki(flux, read_noise)

Compute \(k\), the weights for the linear combination of resultant differences for optimal measurement of ramp pedestal and slope.

Parameters:
fluxarray_like (float)

Estimate of electrons per second in ramp

read_noisearray_like (float)

read_noise in ramp. Must be broadcastable with flux.

Returns:
kiarray_like[…, 2, n_resultant] (float)

\(k\), weights of differences in linear combination of ramp pixels

variances(flux, read_noise)

Compute the variances of ramp fit parameters.

Parameters:
fluxarray_like (float)

Estimate of electrons per second in ramp

read_noisearray_like (float)

read_noise in ramp. Must be broadcastable with flux.

Returns:
variancesarray_like[…, 3, 2, 2] (float)

covariance of ramp fit parameters, for read noise, poisson noise, and the total noise