Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-37951: Allow PTC analysis to split each amp into subregions #251

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions python/lsst/ip/isr/ptcDataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ def setAmpValues(self, ampName, inputExpIdPair=[(np.nan, np.nan)], expIdMask=[np
covArrayModel=[], covSqrtWeights=[], aMatrix=[], bMatrix=[], covArrayModelNoB=[],
aMatrixNoB=[], finalVar=[np.nan], finalModelVar=[np.nan], finalMean=[np.nan]):
"""Function to initialize an amp of a PhotonTransferCurveDataset.

Notes
-----
The parameters are all documented in `init`.
Expand All @@ -227,12 +226,13 @@ def setAmpValues(self, ampName, inputExpIdPair=[(np.nan, np.nan)], expIdMask=[np
bMatrix = nanMatrix
if len(aMatrixNoB) == 0:
aMatrixNoB = nanMatrix

self.inputExpIdPairs[ampName] = inputExpIdPair
self.expIdMask[ampName] = expIdMask
self.rawExpTimes[ampName] = rawExpTime
self.rawMeans[ampName] = rawMean
self.rawVars[ampName] = rawVar
# Modifications here for the subregions.
# New data is appended to the existing data
self.inputExpIdPairs[ampName] += inputExpIdPair
self.expIdMask[ampName] += expIdMask
self.rawExpTimes[ampName] += rawExpTime
self.rawMeans[ampName] += rawMean
self.rawVars[ampName] += rawVar
self.photoCharge[ampName] = photoCharge
self.gain[ampName] = gain
self.gainErr[ampName] = gainErr
Expand All @@ -242,10 +242,16 @@ def setAmpValues(self, ampName, inputExpIdPair=[(np.nan, np.nan)], expIdMask=[np
self.ptcFitParsError[ampName] = ptcFitParsError
self.ptcFitChiSq[ampName] = ptcFitChiSq
self.ptcTurnoff[ampName] = ptcTurnoff
self.covariances[ampName] = covArray
self.covariancesSqrtWeights[ampName] = covSqrtWeights
self.covariancesModel[ampName] = covArrayModel
self.covariancesModelNoB[ampName] = covArrayModelNoB
if len(self.covariances[ampName]) == 0:
self.covariances[ampName] = np.array(covArray)
else:
self.covariances[ampName] = np.concatenate((self.covariances[ampName],np.array(covArray)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm concerned about dimensionality here. Doesn't this take the NxN covariances and stack them to create an `(m_subregion*N)xN array?

if len(self.covariancesSqrtWeights[ampName]) == 0:
self.covariancesSqrtWeights[ampName] = np.array(covSqrtWeights)
else:
self.covariancesSqrtWeights[ampName] = np.concatenate((self.covariancesSqrtWeights[ampName],np.array(covSqrtWeights)))
self.covariancesModel[ampName] = np.full_like(self.covariances[ampName], np.nan)
self.covariancesModelNoB[ampName] = np.full_like(self.covariances[ampName], np.nan)
self.aMatrix[ampName] = aMatrix
self.bMatrix[ampName] = bMatrix
self.aMatrixNoB[ampName] = aMatrixNoB
Expand Down Expand Up @@ -526,7 +532,6 @@ def toTable(self):
for i, ampName in enumerate(self.ampNames):
nPadPoints[ampName] = nSignalPoints - len(list(self.covariances.values())[i])
covMatrixSide = self.covMatrixSide

catalog = Table([{'AMPLIFIER_NAME': ampName,
'PTC_FIT_TYPE': self.ptcFitType,
'COV_MATRIX_SIDE': self.covMatrixSide,
Expand Down