The linearity correction as it currently exists is confusing, and has an implementation that prevents easy creation and updating of linearity values.
DM-23023 will be the implementation ticket for these changes.
1) Allow a linearity correction to override what is declared by the lsst.afw.cameraGeom.amplifier.getLinearityType() value. If a linearity correction is supplied by the user, that should be used.
2) Allow linearity corrections to be persisted in a useful format. Currently, only lookup tables exist as an on-disk objects, the rest existing as cameraGeom values. This means there are no clear targets for linearity generation, nor for the overrides necessary to test new linearity models. The proposal is that the linearity correction will "look like" a detector, and support an iterable containing getLinearityType, getLinearityCoeffs properties that can be passed along with an optional lookup table to the linearity correction.
3) Squared and LookupTable corrections do not change.
4) Add generic polynomial correction method. Upcoming linearity measurement code in cp_pipe will be able to fit arbitrary polynomials:
corrected = measured * (1 + a2 * measured + a3 * measured^2 + ...)
This matches the form of the Squared and LookupTable LinearityTypes (corrected = measured * f(measured)), allowing higher order terms. The set of [a2, a3, ...] will be stored in the amplifier.linearityCoeffs vector.
a0 must be equal to zero, as any deviation from this is a bias level offset. Similarly, a1 must be equal to one, as changes in this are identical to gain changes.
5) amplifier.linearityThreshold, amplifier.linearityMaximum, and amplifier.linearityUnits have never been supported, and should be deprecated. linearityMaximum should be handled with the suspectLevel value, and Threshold has been defined to always be zero. With the above definition the correction, the linearityUnits must be identical between pre- and post- corrected values, and therefore are in DN.
6) Reduce the potential confusion by suggesting strongly that all cameras with no linearity correction convert to use lsst.afw.cameraGeom.amplifier.getLinearityType() == "None". This will use lsst.afw.cameraGeom.NullLinearityType, resulting in no linearity correction. This will replace the current default of "Proportional". "Proportional" will be assumed to be equal to "None", but will be explicitly checked.