Skip to content

Commit

Permalink
Merge pull request #198 from lsst/tickets/DM-32135
Browse files Browse the repository at this point in the history
DM-32135: Fix metric output removal code.
  • Loading branch information
erykoff committed Oct 11, 2021
2 parents fa6a221 + 4fa312c commit f95093a
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 2 deletions.
4 changes: 2 additions & 2 deletions python/lsst/jointcal/jointcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,13 @@ def __init__(self, *, config=None):
if not config.doAstrometry:
self.prerequisiteInputs.remove("astrometryRefCat")
self.outputs.remove("outputWcs")
for key in list(self.outputs.keys()):
for key in list(self.outputs):
if "metricvalue_jointcal_astrometry" in key:
self.outputs.remove(key)
if not config.doPhotometry:
self.prerequisiteInputs.remove("photometryRefCat")
self.outputs.remove("outputPhotoCalib")
for key in list(self.outputs.keys()):
for key in list(self.outputs):
if "metricvalue_jointcal_photometry" in key:
self.outputs.remove(key)

Expand Down
66 changes: 66 additions & 0 deletions tests/test_jointcal_hsc.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,72 @@ def check_output(visit, detectors):
check_output(34648, [51, 59, 67])
check_output(34690, [48, 56, 64])

def test_jointcalTask_2_visits_simple_astrometry_no_photometry_gen3(self):
"""Test gen3 butler jointcal, no photometry."""
configOptions = {"astrometryModel": "simple", "doPhotometry": False}
where = f" and visit in ({self.all_visits[0]},{self.all_visits[1]})"

metrics = {'astrometry_collected_refStars': 568,
'astrometry_prepared_refStars': 137,
'astrometry_matched_fittedStars': 2070,
'astrometry_prepared_fittedStars': 989,
'astrometry_prepared_ccdImages': 6,
'astrometry_final_chi2': 835.473,
'astrometry_final_ndof': 1918,
}
self._runGen3Jointcal("lsst.obs.subaru.HyperSuprimeCam", "HSC", whereSuffix=where,
configOptions=configOptions, metrics=metrics)
# TODO DM-28863: this does not currently test anything other than the code
# running without raising and that it writes non-empty output.
butler = Butler(self.repo, collections=['HSC/testdata/jointcal'])

def check_output(visit, detectors):
"""Check that there is something for each detector, and only
entries for the correct detectors."""
dataId = {'visit': visit, 'instrument': 'HSC', 'tract': 9697}

catalog = butler.get('jointcalSkyWcsCatalog', dataId)
for record in catalog:
self.assertIsInstance(record.getWcs(), lsst.afw.geom.SkyWcs,
msg=f"visit {visit}: {record}")
np.testing.assert_array_equal(catalog['id'], detectors)

check_output(34648, [51, 59, 67])
check_output(34690, [48, 56, 64])

def test_jointcalTask_2_visits_simple_photometry_no_astrometry_gen3(self):
"""Test gen3 butler jointcal, no astrometry."""
configOptions = {"doAstrometry": False, "photometryModel": "simpleFlux"}
where = f" and visit in ({self.all_visits[0]},{self.all_visits[1]})"

metrics = {'photometry_collected_refStars': 6485,
'photometry_prepared_refStars': 1609,
'photometry_matched_fittedStars': 2070,
'photometry_prepared_fittedStars': 1731,
'photometry_prepared_ccdImages': 6,
'photometry_final_chi2': 4997.62,
'photometry_final_ndof': 2188
}
self._runGen3Jointcal("lsst.obs.subaru.HyperSuprimeCam", "HSC", whereSuffix=where,
configOptions=configOptions, metrics=metrics)
# TODO DM-28863: this does not currently test anything other than the code
# running without raising and that it writes non-empty output.
butler = Butler(self.repo, collections=['HSC/testdata/jointcal'])

def check_output(visit, detectors):
"""Check that there is something for each detector, and only
entries for the correct detectors."""
dataId = {'visit': visit, 'instrument': 'HSC', 'tract': 9697}

catalog = butler.get('jointcalPhotoCalibCatalog', dataId)
for record in catalog:
self.assertIsInstance(record.getPhotoCalib(), lsst.afw.image.PhotoCalib,
msg=f"visit {visit}: {record}")
np.testing.assert_array_equal(catalog['id'], detectors)

check_output(34648, [51, 59, 67])
check_output(34690, [48, 56, 64])

def test_jointcalTask_10_visits_simple_astrometry_no_photometry(self):
"""Test all 10 visits with different filters.
Testing photometry doesn't make sense for this currently.
Expand Down

0 comments on commit f95093a

Please sign in to comment.