Skip to content

Commit

Permalink
Record filter names in CoaddInputs.
Browse files Browse the repository at this point in the history
  • Loading branch information
TallJimbo committed Nov 28, 2017
1 parent 67b1ea0 commit 24a6fea
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions python/lsst/pipe/tasks/coaddInputRecorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def addCalExp(self, calExp, ccdId, nGoodPix):
self._setExposureInfoInRecord(exposure=calExp, record=record)
if self.task.config.saveCcdWeights:
record.setD(self.task.ccdWeightKey, 1.0) # No weighting or overlap when warping
self.set(self.task.ccdFilterKey, calExp.getFilter().getName())

def finish(self, coaddTempExp, nGoodPix=None):
"""Finish creating the CoaddInputs for a CoaddTempExp.
Expand Down Expand Up @@ -176,6 +177,10 @@ def __init__(self, *args, **kwargs):
if self.config.saveCcdWeights:
self.ccdWeightKey = self.ccdSchema.addField("weight", type=float,
doc="Weight for this visit in the coadd")
self.visitFilterKey = self.visitSchema.addField("filter", type=str, size=32,
doc="Filter associated with this visit.")
self.ccdFilterKey = self.ccdSchema.addField("filter", type=str, size=32,
doc="Filter associated with this visit.")

def makeCoaddTempExpRecorder(self, visitId, num=0):
"""Return a CoaddTempExpInputRecorder instance to help with saving a CoaddTempExp's inputs.
Expand Down Expand Up @@ -210,6 +215,7 @@ def addVisitToCoadd(self, coaddInputs, coaddTempExp, weight):
outputVisitRecord = coaddInputs.visits.addNew()
outputVisitRecord.assign(inputVisitRecord)
outputVisitRecord.setD(self.visitWeightKey, weight)
outputVisitRecord.set(self.visitFilterKey, coaddTempExp.getFilter().getName())
for inputCcdRecord in tempExpInputs.ccds:
if inputCcdRecord.getL(self.ccdVisitKey) != inputVisitRecord.getId():
self.log.warn("CoaddInputs for coaddTempExp with id %d contains CCDs with visit=%d. "
Expand All @@ -219,4 +225,5 @@ def addVisitToCoadd(self, coaddInputs, coaddTempExp, weight):
outputCcdRecord.assign(inputCcdRecord)
if self.config.saveCcdWeights:
outputCcdRecord.setD(self.ccdWeightKey, weight)
outputCcdRecord.set(self.ccdFilterKey, coaddTempExp.getFilter().getName())
return inputVisitRecord
2 changes: 2 additions & 0 deletions python/lsst/pipe/tasks/mocks/mockObservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def __init__(self, **kwds):
self.ccdKey = self.schema.addField("ccd", type=np.int32, doc="CCD number")
self.visitKey = self.schema.addField("visit", type=np.int32, doc="visit number")
self.pointingKey = lsst.afw.table.CoordKey.addFields(self.schema, "pointing", "center of visit")
self.filterKey = self.schema.addField("filter", type=str, doc="Bandpass filter name", size=16)
self.rng = np.random.RandomState(self.config.seed)

def run(self, butler, n, tractInfo, camera, catalog=None):
Expand Down Expand Up @@ -123,6 +124,7 @@ def run(self, butler, n, tractInfo, camera, catalog=None):
record = catalog.addNew()
record.setI(self.ccdKey, detector.getId())
record.setI(self.visitKey, visit)
record.set(self.filterKey, 'r')
record.set(self.pointingKey, position)
record.setWcs(self.buildWcs(position, pa, detector))
record.setCalib(calib)
Expand Down
1 change: 1 addition & 0 deletions tests/nopytest_test_coadds.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ def testCoaddInputs(self, tract=0):
self.assertEqual(obsRecord.getId(), ccdRecord.getId())
self.assertEqual(obsRecord.getWcs(), ccdRecord.getWcs())
self.assertEqual(obsRecord.getBBox(), ccdRecord.getBBox())
self.assertEqual(obsRecord.get("filter"), ccdRecord.get("filter"))
self.comparePsfs(obsRecord.getPsf(), ccdRecord.getPsf())
self.assertIsNotNone(coaddInputs.visits.find(ccdRecord.getL(ccdVisitKey)))
for visitRecord in coaddInputs.visits:
Expand Down

0 comments on commit 24a6fea

Please sign in to comment.