hispecdrp.primitives.nonlinear_correction.nonlincorr_numba

Functions

_correct_nonlinearity_numba(ramps, dq_raw, ...)

correct_nonlinearity(ramps, dq_raw, dq, ...)

Apply non-linearity correction to up-the-ramps.

correct_nonlinearity(ramps, dq_raw, dq, coeffs, nonlin_max, nonlin_dq, max_cores=1)[source]

Apply non-linearity correction to up-the-ramps. Correction is done in place. The first read is subtracted before applying the polynomial correction, but it is added back after such that the output ramp still includes the bias. The dq arrays are updated in place to flag any reads that exceed the non-linearity limit.

Parameters:
  • ramps – 3D array of shape (Nreads, Ny, Nx) containing the ramps. Must be floating point.

  • dq_raw – 3D array of shape (Nreads, Ny, Nx) containing the raw DQ flags. Any reads beyong nonlin_max will be flagged as “non linear” and not trustworthy.

  • dq – 2D array of shape (Ny, Nx) containing the DQ flags to be updated with non-linearity flags.

  • coeffs – 3D array of shape (Ncoeffs, Ny, Nx) containing the polynomial coefficients of P(). such that, “corrected ramp (DN)” = P(“measured ramp (DN)”).

  • nonlin_max – The maximum DN value for which the non-linearity correction is good to within 1%.

  • nonlin_dq – 2D array of shape (Ny, Nx) containing the DQ flags from the non-linearity model to be applied to all pixels.

  • max_cores – Maximum number of CPU cores to use. Default is 1.

Returns:
  • ramps – The non-linearity corrected ramps (same as input ramps but modified in place).

  • dq_raw – The updated raw DQ array (same as input dq_raw but modified in place).

  • dq – The updated DQ array (same as input dq but modified in place).