Skip to content

Commit

Permalink
Convert linarizer array to int type
Browse files Browse the repository at this point in the history
  • Loading branch information
plazas committed Mar 17, 2020
1 parent 81dd812 commit 40eb018
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions python/lsst/cp/pipe/ptc.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,8 +657,8 @@ def calculateLinearityResidualAndLinearizers(self, exposureTimeVector, meanSigna
# Use linear part to get time at wich signal is maxAduForLookupTableLinearizer ADU
tMax = (self.config.maxAduForLookupTableLinearizer - parsFit[0])/parsFit[1]
timeRange = np.linspace(0, tMax, self.config.maxAduForLookupTableLinearizer)
signalIdeal = parsFit[0] + parsFit[1]*timeRange
signalUncorrected = self.funcPolynomial(parsFit, timeRange)
signalIdeal = (parsFit[0] + parsFit[1]*timeRange).astype(int)
signalUncorrected = (self.funcPolynomial(parsFit, timeRange)).astype(int)
linearizerTableRow = signalIdeal - signalUncorrected # LinearizerLookupTable has corrections

# Use quadratic and linear part of fit to produce c0 for LinearizeSquared
Expand Down
18 changes: 15 additions & 3 deletions tests/test_ptc.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def ptcFitQuadAndCubic(self, order):
numberAmps = len(self.ampNames)
numberAduValues = config.maxAduForLookupTableLinearizer

lookupTableArray = np.zeros((numberAmps, numberAduValues), dtype=np.float32)
lookupTableArray = np.zeros((numberAmps, numberAduValues), dtype=np.int)
returnedDataset = task.fitPtcAndNonLinearity(localDataset, lookupTableArray, ptcFitType='POLYNOMIAL')

# check that the linearizer table has been filled out properly
Expand All @@ -131,7 +131,7 @@ def ptcFitQuadAndCubic(self, order):
signalIdeal = timeRange*self.flux
signalUncorrected = task.funcPolynomial(np.array([0.0, self.flux, self.k2NonLinearity]),
timeRange)
linearizerTableRow = signalIdeal - signalUncorrected
linearizerTableRow = signalIdeal.astype(int) - signalUncorrected.astype(int)
self.assertEqual(len(linearizerTableRow), len(lookupTableArray[i, :]))
for j in np.arange(len(linearizerTableRow)):
self.assertAlmostEqual(linearizerTableRow[j], lookupTableArray[i, :][j], places=6)
Expand Down Expand Up @@ -200,11 +200,23 @@ def test_ptcFitAstier(self):

numberAmps = len(self.ampNames)
numberAduValues = config.maxAduForLookupTableLinearizer
lookupTableArray = np.zeros((numberAmps, numberAduValues), dtype=np.float32)
lookupTableArray = np.zeros((numberAmps, numberAduValues), dtype=np.int)

returnedDataset = task.fitPtcAndNonLinearity(localDataset, lookupTableArray,
ptcFitType='ASTIERAPPROXIMATION')

# check that the linearizer table has been filled out properly
for i in np.arange(numberAmps):
tMax = (config.maxAduForLookupTableLinearizer)/self.flux
timeRange = np.linspace(0., tMax, config.maxAduForLookupTableLinearizer)
signalIdeal = timeRange*self.flux
signalUncorrected = task.funcPolynomial(np.array([0.0, self.flux, self.k2NonLinearity]),
timeRange)
linearizerTableRow = signalIdeal.astype(int) - signalUncorrected.astype(int)
self.assertEqual(len(linearizerTableRow), len(lookupTableArray[i, :]))
for j in np.arange(len(linearizerTableRow)):
self.assertAlmostEqual(linearizerTableRow[j], lookupTableArray[i, :][j], places=6)

# check entries in localDataset, which was modified by the function
for ampName in self.ampNames:
self.assertAlmostEqual('ASTIERAPPROXIMATION', localDataset.ptcFitType[ampName])
Expand Down

0 comments on commit 40eb018

Please sign in to comment.