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 21, 2018
1 parent fbb788f commit 83efb67
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 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,22 +478,22 @@ 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)
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
11 changes: 8 additions & 3 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 @@ -104,7 +107,8 @@ def test_getCalibratedExposure(self):

self.assertMaskedImagesEqual(result.maskedImage, expect)
# TODO: once RFC-545 is implemented, this should be 1.0
self.assertEqual(result.getCalib().getFluxMag0()[0], 1/self.exposurePhotoCalib.getCalibrationMean())
self.assertEqual(result.getCalib().getFluxMag0()[0],
self.exposurePhotoCalib.getInstFluxAtZeroMagnitude())
self.assertEqual(result.getWcs(), self.skyWcs)

def test_getCalibratedExposureJointcal(self):
Expand All @@ -116,7 +120,8 @@ def test_getCalibratedExposureJointcal(self):
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/self.jointcalPhotoCalib.getCalibrationMean())
self.assertEqual(result.getCalib().getFluxMag0()[0],
self.jointcalPhotoCalib.getInstFluxAtZeroMagnitude())
self.assertEqual(result.getWcs(), self.jointcalSkyWcs)


Expand Down

0 comments on commit 83efb67

Please sign in to comment.