Skip to content

Commit

Permalink
Merge pull request #131 from lsst/tickets/DM-13757
Browse files Browse the repository at this point in the history
DM-13757: enable jointcal config writing
  • Loading branch information
parejkoj committed Mar 15, 2019
2 parents a3c9d7e + 9fd944d commit 18e75bb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
8 changes: 3 additions & 5 deletions python/lsst/jointcal/jointcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,9 @@ def __init__(self, butler=None, profile_jointcal=False, **kwargs):
# To hold various computed metrics for use by tests
self.job = Job.load_metrics_package(subset='jointcal')

# We don't need to persist config and metadata at this stage.
# In this way, we don't need to put a specific entry in the camera mapper policy file
def _getConfigName(self):
return None

# We don't currently need to persist the metadata.
# If we do in the future, we will have to add appropriate dataset templates
# to each obs package (the metadata template should look like `jointcal_wcs`).
def _getMetadataName(self):
return None

Expand Down
18 changes: 18 additions & 0 deletions tests/test_jointcal_cfht_minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ def setup_module(module):


class JointcalTestCFHTMinimal(jointcalTestBase.JointcalTestBase, lsst.utils.tests.TestCase):
"""
Test with a stripped down CFHT dataset containing 3 stars, so by-hand
calculation of metrics is possible.
See `notebooks/cfht_minimal_direct_calculation.ipynb` for numpy-based
computations of chi2, etc. using this dataset.
"""
@classmethod
def setUpClass(cls):
cls.data_dir = os.path.join(lsst.utils.getPackageDir('jointcal'), 'tests/data')
Expand Down Expand Up @@ -79,6 +86,8 @@ def test_jointcalTask_2_visits_photometry(self):

# The output repo is named after this method.
caller = inspect.stack()[0].function
# we use _runJointcalTask instead of _test here because we aren't doing
# full calulation of PA1: the above chi2 is exact.
self._runJointcalTask(2, caller, metrics=metrics)

# Check that the Hessian/gradient files were written.
Expand All @@ -91,6 +100,15 @@ def test_jointcalTask_2_visits_photometry(self):
self.assertTrue(os.path.exists("photometry_postinit-grad.txt"))
os.remove("photometry_postinit-grad.txt")

# Check that the config was persisted, we can read it, and it matches the settings above
output_dir = os.path.join('.test', self.__class__.__name__, caller)
self.assertTrue(os.path.exists(os.path.join(output_dir, 'config/jointcal.py')))
butler = lsst.daf.persistence.Butler(output_dir)
config = butler.get('jointcal_config')
self.assertEqual(config.photometryModel, self.config.photometryModel)
self.assertEqual(config.doAstrometry, self.config.doAstrometry)
self.assertEqual(config.writeInitMatrix, self.config.writeInitMatrix)

def test_jointcalTask_2_visits_photometry_magnitude(self):
self.config = lsst.jointcal.jointcal.JointcalConfig()
self.config.photometryModel = "simpleMagnitude"
Expand Down

0 comments on commit 18e75bb

Please sign in to comment.