Skip to content

Commit

Permalink
Use common metadata handler.
Browse files Browse the repository at this point in the history
Be pedantic on updateMetadata to avoid issues with ingest.
  • Loading branch information
czwa committed Oct 6, 2020
1 parent fe4d62f commit 044087b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 4 additions & 2 deletions python/lsst/cp/pipe/linearity.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ def run(self, inputPtc, camera, inputDims):
linearityFit = [tableIndex, 0]
tableIndex += 1
elif self.config.linearityType in ['Spline']:
# See discussion in `lsst.ip.isr.linearize.py` before modifying.
numPerBin, binEdges = np.histogram(linearOrdinate, bins=self.config.fitOrder)
with np.errstate(invalid="ignore"):
values = np.histogram(linearOrdinate, bins=self.config.fitOrder,
Expand Down Expand Up @@ -293,9 +294,10 @@ def run(self, inputPtc, camera, inputDims):
self.debugFit('solution', inputOrdinate[fluxMask], linearOrdinate,
linearizeModel[fluxMask], None, ampName)

linearizer.hasLinearity=True
linearizer.hasLinearity = True
linearizer.validate()
linearizer.updateMetadata(setDate=True)
linearizer.updateMetadata(camera=camera, detector=detector, filterName='NONE')
linearizer.updateMetadata(setDate=True, setCalibId=True)
provenance = IsrProvenance(calibType='linearizer')

return pipeBase.Struct(
Expand Down
9 changes: 7 additions & 2 deletions tests/test_ptc.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
from lsst.cp.pipe.utils import (funcPolynomial, makeMockFlats)


class FakeCamera(list):
def getName(self):
return "FakeCam"


class MeasurePhotonTransferCurveTaskTestCase(lsst.utils.tests.TestCase):
"""A test case for the PTC task."""

Expand Down Expand Up @@ -183,13 +188,13 @@ def ptcFitAndCheckPtc(self, order=None, fitType='', doTableArray=False, doFitBoo
localDataset = task.fitPtc(localDataset, ptcFitType=fitType)
# linDataset: Dictionary of `lsst.cp.pipe.ptc.LinearityResidualsAndLinearizersDataset`
linDataset = task.linearity.run(localDataset,
camera=[self.flatExp1.getDetector()],
camera=FakeCamera([self.flatExp1.getDetector()]),
inputDims={'detector': 0})
linDataset = linDataset.outputLinearizer
else:
localDataset = task.fitPtc(localDataset, ptcFitType=fitType)
linDataset = task.linearity.run(localDataset,
camera=[self.flatExp1.getDetector()],
camera=FakeCamera([self.flatExp1.getDetector()]),
inputDims={'detector': 0})
linDataset = linDataset.outputLinearizer

Expand Down

0 comments on commit 044087b

Please sign in to comment.