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-27177: Deprecate transitional getFilterLabel API #689

Merged
merged 2 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion python/lsst/pipe/tasks/assembleCoadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ def assembleMetadata(self, coaddExposure, tempExpRefList, weightList):

# Set the coadd FilterLabel to the band of the first input exposure:
# Coadds are calibrated, so the physical label is now meaningless.
coaddExposure.setFilterLabel(afwImage.FilterLabel(tempExpList[0].getFilterLabel().bandLabel))
coaddExposure.setFilter(afwImage.FilterLabel(tempExpList[0].getFilter().bandLabel))
coaddInputs = coaddExposure.getInfo().getCoaddInputs()
coaddInputs.ccds.reserve(numCcds)
coaddInputs.visits.reserve(len(tempExpList))
Expand Down
6 changes: 3 additions & 3 deletions python/lsst/pipe/tasks/coaddInputRecorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,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
record.set(self.task.ccdFilterKey, calExp.getFilterLabel().physicalLabel)
record.set(self.task.ccdFilterKey, calExp.getFilter().physicalLabel)

def finish(self, coaddTempExp, nGoodPix=None):
"""Finish creating the CoaddInputs for a CoaddTempExp.
Expand Down Expand Up @@ -216,7 +216,7 @@ def addVisitToCoadd(self, coaddInputs, coaddTempExp, weight):
outputVisitRecord = coaddInputs.visits.addNew()
outputVisitRecord.assign(inputVisitRecord)
outputVisitRecord.setD(self.visitWeightKey, weight)
outputVisitRecord.set(self.visitFilterKey, coaddTempExp.getFilterLabel().physicalLabel)
outputVisitRecord.set(self.visitFilterKey, coaddTempExp.getFilter().physicalLabel)
for inputCcdRecord in tempExpInputs.ccds:
if inputCcdRecord.getL(self.ccdVisitKey) != inputVisitRecord.getId():
self.log.warning("CoaddInputs for coaddTempExp with id %d contains CCDs with visit=%d. "
Expand All @@ -226,5 +226,5 @@ def addVisitToCoadd(self, coaddInputs, coaddTempExp, weight):
outputCcdRecord.assign(inputCcdRecord)
if self.config.saveCcdWeights:
outputCcdRecord.setD(self.ccdWeightKey, weight)
outputCcdRecord.set(self.ccdFilterKey, coaddTempExp.getFilterLabel().physicalLabel)
outputCcdRecord.set(self.ccdFilterKey, coaddTempExp.getFilter().physicalLabel)
return inputVisitRecord
2 changes: 1 addition & 1 deletion python/lsst/pipe/tasks/dcrAssembleCoadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def prepareDcrInputs(self, templateCoadd, warpRefList, weightList):
If ``lambdaMin`` is missing from the Mapper class of the obs package being used.
"""
sigma2fwhm = 2.*np.sqrt(2.*np.log(2.))
filterLabel = templateCoadd.getFilterLabel()
filterLabel = templateCoadd.getFilter()
tempExpName = self.getTempExpDatasetName(self.warpType)
dcrShifts = []
airmassDict = {}
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/pipe/tasks/hips.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def run(self, pixels, coadd_exposure_handles):
# Make sure the mask planes, filter, and photocalib of the output
# exposure match the (first) input exposure.
exp_hpx_dict[pixel].mask.conformMaskPlanes(coadd_exp.mask.getMaskPlaneDict())
exp_hpx_dict[pixel].setFilterLabel(coadd_exp.getFilterLabel())
exp_hpx_dict[pixel].setFilter(coadd_exp.getFilter())
exp_hpx_dict[pixel].setPhotoCalib(coadd_exp.getPhotoCalib())

if warped.getBBox().getArea() == 0 or not np.any(np.isfinite(warped.image.array)):
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/pipe/tasks/insertFakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ def run(self, fakeCat, image, wcs, photoCalib):
image.setWcs(wcs)
image.setPhotoCalib(photoCalib)

band = image.getFilterLabel().bandLabel
band = image.getFilter().bandLabel
fakeCat = self._standardizeColumns(fakeCat, band)

fakeCat = self.addPixCoords(fakeCat, image)
Expand Down Expand Up @@ -894,7 +894,7 @@ def _generateGSObjectsFromImages(self, exposure, fakeCat):
gsObjects : `generator`
A generator of tuples of `lsst.geom.SpherePoint` and `galsim.GSObject`.
"""
band = exposure.getFilterLabel().bandLabel
band = exposure.getFilter().bandLabel
wcs = exposure.getWcs()
photoCalib = exposure.getPhotoCalib()

Expand Down
2 changes: 1 addition & 1 deletion python/lsst/pipe/tasks/makeCoaddTempExp.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def run(self, calExpList, ccdIdList, skyInfo, visitId=0, dataIdList=None, **kwar
if numGoodPix[warpType] > 0 and not didSetMetadata[warpType]:
coaddTempExp.info.id = exposure.info.id
coaddTempExp.setPhotoCalib(exposure.getPhotoCalib())
coaddTempExp.setFilterLabel(exposure.getFilterLabel())
coaddTempExp.setFilter(exposure.getFilter())
coaddTempExp.getInfo().setVisitInfo(exposure.getInfo().getVisitInfo())
# PSF replaced with CoaddPsf after loop if and only if creating direct warp
coaddTempExp.setPsf(exposure.getPsf())
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/pipe/tasks/multiBand.py
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ def run(self, exposure, sources, skyInfo, exposureId, ccdInputs=None, visitCatal
results = Struct()

if self.config.doMatchSources:
matchResult = self.match.run(sources, exposure.getInfo().getFilterLabel().bandLabel)
matchResult = self.match.run(sources, exposure.getInfo().getFilter().bandLabel)
matches = afwTable.packMatches(matchResult.matches)
matches.table.setMetadata(matchResult.matchMeta)
results.matchResult = matches
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/pipe/tasks/photoCal.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def run(self, exposure, sourceCat, expId=0):
except Exception:
self.fig = pyplot.figure()

filterLabel = exposure.getFilterLabel()
filterLabel = exposure.getFilter()

# Match sources
matchResults = self.match.run(sourceCat, filterLabel.bandLabel)
Expand Down
6 changes: 3 additions & 3 deletions python/lsst/pipe/tasks/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def readCatalog(self, patchRef):
Tuple consisting of band name and a dict of catalogs, keyed by
dataset name
"""
band = patchRef.get(self.config.coaddName + "Coadd_filterLabel", immediate=True).bandLabel
band = patchRef.get(self.config.coaddName + "Coadd_filter", immediate=True).bandLabel
catalogDict = {}
for dataset in self.inputDatasets:
catalog = patchRef.get(self.config.coaddName + "Coadd_" + dataset, immediate=True)
Expand Down Expand Up @@ -1443,7 +1443,7 @@ def _combineExposureMetadata(self, visit, dataRefs, isGen3=True):
for i, dataRef in enumerate(dataRefs):
if isGen3:
visitInfo = dataRef.get(component='visitInfo')
filterLabel = dataRef.get(component='filterLabel')
filterLabel = dataRef.get(component='filter')
summaryStats = dataRef.get(component='summaryStats')
detector = dataRef.get(component='detector')
wcs = dataRef.get(component='wcs')
Expand All @@ -1457,7 +1457,7 @@ def _combineExposureMetadata(self, visit, dataRefs, isGen3=True):
gen2_read_bbox = lsst.geom.BoxI(lsst.geom.PointI(0, 0), lsst.geom.PointI(1, 1))
exp = dataRef.get(datasetType='calexp_sub', bbox=gen2_read_bbox)
visitInfo = exp.getInfo().getVisitInfo()
filterLabel = dataRef.get("calexp_filterLabel")
filterLabel = dataRef.get("calexp_filter")
summaryStats = exp.getInfo().getSummaryStats()
wcs = exp.getWcs()
photoCalib = exp.getPhotoCalib()
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/pipe/tasks/processCcdWithFakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ def run(self, fakeCats, exposure, skyMap, wcs=None, photoCalib=None, exposureIdI
if exposureIdInfo is None:
exposureIdInfo = ExposureIdInfo()

band = exposure.getFilterLabel().bandLabel
band = exposure.getFilter().bandLabel
ccdVisitMagnitudes = self.addVariablity(fakeCat, band, exposure, photoCalib, exposureIdInfo)

self.insertFakes.run(fakeCat, exposure, wcs, photoCalib)
Expand Down
2 changes: 1 addition & 1 deletion tests/assembleCoaddTestUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ def makeCoaddTempExp(self, rawExposure, visitInfo, expId):
tempExp = rawExposure.clone()
tempExp.setWcs(self.wcs)

tempExp.setFilterLabel(self.filterLabel)
tempExp.setFilter(self.filterLabel)
tempExp.setPhotoCalib(self.photoCalib)
tempExp.getInfo().setVisitInfo(visitInfo)
tempExp.getInfo().setDetector(self.detector)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_coaddInputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def makeExposure(self, universalId):
expInfo.setPhotoCalib(lsst.afw.image.makePhotoCalibFromCalibZeroPoint(1.1e12, 2.2e10))
expInfo.setApCorrMap(self.makeApCorrMap())
expInfo.setValidPolygon(lsst.afw.geom.Polygon(lsst.geom.Box2D(bbox).getCorners()))
expInfo.setFilterLabel(lsst.afw.image.FilterLabel(physical="fakeFilter", band="fake"))
expInfo.setFilter(lsst.afw.image.FilterLabel(physical="fakeFilter", band="fake"))
if self.version > 1:
expInfo.setVisitInfo(self.makeVisitInfo())

Expand Down
4 changes: 2 additions & 2 deletions tests/test_hips.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_hips_single(self):

# Check that metadata is correct
self.assertEqual(output.hips_exposures[pixel].getPhotoCalib(), exposure.getPhotoCalib())
self.assertEqual(output.hips_exposures[pixel].getFilterLabel(), exposure.getFilterLabel())
self.assertEqual(output.hips_exposures[pixel].getFilter(), exposure.getFilter())

def test_hips_double(self):
"""Test creating a HIPS image from two neighboring patches."""
Expand Down Expand Up @@ -192,7 +192,7 @@ def _make_noise_exposure(self, patch_info):
exposure.image.array[:, :] = np.random.normal(scale=1.0, size=exposure.image.array.shape)
exposure.setWcs(patch_info.wcs)
exposure.setPhotoCalib(lsst.afw.image.PhotoCalib(calibrationMean=1.0))
exposure.setFilterLabel(lsst.afw.image.FilterLabel(band='i'))
exposure.setFilter(lsst.afw.image.FilterLabel(band='i'))

return exposure

Expand Down
2 changes: 1 addition & 1 deletion tests/test_photoCal.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def setUp(self):
smallExposure = afwImage.ExposureF(os.path.join(testDir, "data", "v695833-e0-c000-a00.sci.fits"))
self.exposure = afwImage.ExposureF(self.bbox)
self.exposure.setWcs(smallExposure.getWcs())
self.exposure.setFilterLabel(afwImage.FilterLabel(band="i", physical="test-i"))
self.exposure.setFilter(afwImage.FilterLabel(band="i", physical="test-i"))
self.exposure.setPhotoCalib(smallExposure.getPhotoCalib())

coordKey = self.srcCat.getCoordKey()
Expand Down