Skip to content

Commit

Permalink
Update warps to new photoCalib nJy definition
Browse files Browse the repository at this point in the history
  • Loading branch information
parejkoj committed Dec 25, 2018
1 parent f310332 commit 35b8426
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
12 changes: 7 additions & 5 deletions python/lsst/pipe/tasks/makeCoaddTempExp.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ def getCalibratedExposure(self, dataRef, bgSubtracted):
mi += background.getImage()
del mi

# TODO: this is needed until DM-10153 is done and Calib is gone
referenceFlux = 1e23 * 10**(48.6 / -2.5) * 1e9
if self.config.doApplyUberCal:
if self.config.useMeasMosaic:
from lsst.meas.mosaic import applyMosaicResultsExposure
Expand All @@ -476,23 +478,23 @@ def getCalibratedExposure(self, dataRef, bgSubtracted):
except dafPersist.NoResults as e:
raise MissingExposureError('Mosaic calibration not found: %s ' % str(e)) from e
fluxMag0 = exposure.getCalib().getFluxMag0()[0]
photoCalib = afwImage.PhotoCalib(1.0/fluxMag0,
fluxMag0Err/fluxMag0**2,
photoCalib = afwImage.PhotoCalib(referenceFlux/fluxMag0,
referenceFlux*fluxMag0Err/fluxMag0**2,
exposure.getBBox())
else:
photoCalib = dataRef.get("jointcal_photoCalib")
skyWcs = dataRef.get("jointcal_wcs")
exposure.setWcs(skyWcs)
else:
fluxMag0 = exposure.getCalib().getFluxMag0()
photoCalib = afwImage.PhotoCalib(1.0/fluxMag0[0],
fluxMag0[1]/fluxMag0[0]**2,
photoCalib = afwImage.PhotoCalib(referenceFlux/fluxMag0[0],
referenceFlux*fluxMag0[1]/fluxMag0[0]**2,
exposure.getBBox())

exposure.maskedImage = photoCalib.calibrateImage(exposure.maskedImage,
includeScaleUncertainty=self.config.includeCalibVar)
exposure.maskedImage /= photoCalib.getCalibrationMean()
exposure.setCalib(afwImage.Calib(1/photoCalib.getCalibrationMean()))
exposure.setCalib(afwImage.Calib(photoCalib.getInstFluxAtZeroMagnitude()))
# TODO: The images will have a calibration of 1.0 everywhere once RFC-545 is implemented.
# exposure.setCalib(afwImage.Calib(1.0))
return exposure
Expand Down
7 changes: 5 additions & 2 deletions tests/test_makeCoaddTempExp.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ def setUp(self):
# mask at least one pixel
self.exposure.maskedImage.mask[5, 5] = 3
# set the Calib and Wcs objects of this exposure.
self.exposure.getCalib().setFluxMag0(1/meanCalibration, calibrationErr/meanCalibration**2)
# TODO: this is needed until DM-10153 is done and Calib is gone
referenceFlux = 1e23 * 10**(48.6 / -2.5) * 1e9
self.exposure.getCalib().setFluxMag0(referenceFlux/meanCalibration,
referenceFlux*calibrationErr/meanCalibration**2)
self.exposure.setWcs(self.skyWcs)

# set to True in a test to raise NoResults for get('calexp')
Expand Down Expand Up @@ -114,7 +117,7 @@ def _checkCalibratedExposure(self, doApplyUberCal, includeCalibVar):
result = task.getCalibratedExposure(self.dataRef, True)
self.assertMaskedImagesEqual(result.maskedImage, expect)
# TODO: once RFC-545 is implemented, this should be 1.0
self.assertEqual(result.getCalib().getFluxMag0()[0], 1/photoCalib.getCalibrationMean())
self.assertEqual(result.getCalib().getFluxMag0()[0], photoCalib.getInstFluxAtZeroMagnitude())

targetWcs = self.jointcalSkyWcs if doApplyUberCal else self.skyWcs
self.assertEqual(result.getWcs(), targetWcs)
Expand Down

0 comments on commit 35b8426

Please sign in to comment.