Skip to content

Commit

Permalink
Merge branch 'tickets/DM-38827' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
czwa committed May 17, 2023
2 parents a4cd419 + 9d32895 commit f9245e7
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions python/lsst/cp/pipe/makeBrighterFatterKernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ def run(self, inputPtc, dummy, camera, inputDims):

# Use the PTC covariances as the cross-correlations. These
# are scaled before the kernel is generated, which performs
# the conversion.
# the conversion. The input covariances are in (x, y) index
# ordering, as is the aMatrix.
bfk.rawXcorrs = inputPtc.covariances # ADU^2
bfk.badAmps = inputPtc.badAmps
bfk.shape = (inputPtc.covMatrixSide*2 + 1, inputPtc.covMatrixSide*2 + 1)
Expand Down Expand Up @@ -372,12 +373,13 @@ def averageCorrelations(self, xCorrList, name):
The averaged cross-correlation.
"""
meanXcorr = np.zeros_like(xCorrList[0])
xCorrList = np.transpose(xCorrList)
xCorrList = np.array(xCorrList)

sctrl = afwMath.StatisticsControl()
sctrl.setNumSigmaClip(self.config.nSigmaClip)
for i in range(np.shape(meanXcorr)[0]):
for j in range(np.shape(meanXcorr)[1]):
meanXcorr[i, j] = afwMath.makeStatistics(xCorrList[i, j],
meanXcorr[i, j] = afwMath.makeStatistics(xCorrList[:, i, j],
afwMath.MEANCLIP, sctrl).getValue()

# To match previous definitions, pad by one element.
Expand Down Expand Up @@ -409,11 +411,11 @@ def quadraticCorrelations(self, xCorrList, fluxList, name):

for i in range(np.shape(meanXcorr)[0]):
for j in range(np.shape(meanXcorr)[1]):
# Fit corrlation_i(x, y) = a0 + a1 * (flux_i)^2 The
# i,j indices are inverted to apply the transposition,
# as is done in the averaging case.
# Fit corrlation_i(x, y) = a0 + a1 * (flux_i)^2 We do
# not want to transpose, so use (i, j) without
# inversion.
linearFit, linearFitErr, chiSq, weights = irlsFit([0.0, 1e-4], fluxList,
xCorrList[:, j, i], funcPolynomial,
xCorrList[:, i, j], funcPolynomial,
scaleResidual=False)
meanXcorr[i, j] = linearFit[1] # Discard the intercept.
self.log.info("Quad fit meanXcorr[%d,%d] = %g", i, j, linearFit[1])
Expand Down

0 comments on commit f9245e7

Please sign in to comment.