Skip to content

Commit

Permalink
Check linearity residual fit for too-few points.
Browse files Browse the repository at this point in the history
  • Loading branch information
czwa committed Nov 2, 2023
1 parent df35531 commit 23d02b9
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions python/lsst/cp/pipe/linearity.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,15 +551,20 @@ def run(self, inputPtc, dummy, camera, inputDims,

# The residuals that we record are the final residuals compared to
# a linear model, after everything has been (properly?) linearized.
postLinearFit, _, _, _ = irlsFit(
[0.0, 100.0],
inputAbscissa[mask],
linearizeModel[mask],
funcPolynomial,
)
residuals = linearizeModel - (postLinearFit[0] + postLinearFit[1] * inputAbscissa)
# We set masked residuals to nan.
residuals[~mask] = np.nan
if mask.sum() < 2:
self.log.warning("Amp %s in detector %s has not enough points in linear ordinate "
"for residuals. Skipping!", ampName, detector.getName())
residuals = np.full_like(linearizeModel, np.nan)
else:
postLinearFit, _, _, _ = irlsFit(
[0.0, 100.0],
inputAbscissa[mask],
linearizeModel[mask],
funcPolynomial,
)
residuals = linearizeModel - (postLinearFit[0] + postLinearFit[1] * inputAbscissa)
# We set masked residuals to nan.
residuals[~mask] = np.nan

linearizer.fitResiduals[ampName] = residuals

Expand Down

0 comments on commit 23d02b9

Please sign in to comment.