This paper derives the optimal fit to a pixel's count rate in the case of an
ideal detector read out nondestructively in the presence of both read and
photon noise. The approach is general for any readout scheme, provides
closed-form expressions for all quantities, and has a computational cost that
is linear in the number of resultants (groups of reads). I also derive the bias
of the fit from estimating the covariance matrix and show how to remove it to
first order. The ramp-fitting algorithm I describe provides the Ο2 value
of the fit of a line to the accumulated counts, enabling hypothesis testing for
cosmic ray hits using the entire ramp. I show that this approach can be
substantially more sensitive than one that only uses the difference between
sequential resultants, especially for long ramps and for jumps that occur in
the middle of a group of reads. It can also be implemented for a computational
cost that is linear in the number of resultants. I provide and describe a pure
Python implementation of these algorithms that can process a 10-resultant ramp
on a 4096Γ4096 detector in β8 seconds with bias removal, or in
β20 seconds including iterative cosmic ray detection and removal, on a
single core of a 2020 Macbook Air. This Python implementation, together with
tests and a tutorial notebook, are available at
https://github.com/t-brandt/fitramp.Comment: 30 pages, 9 figures. Python implementation available at
https://github.com/t-brandt/fitram