Skip to content

Commit

Permalink
Merge pull request #88 from lsst/tickets/DM-14552
Browse files Browse the repository at this point in the history
DM-14552 Move tests from decam to cfht
  • Loading branch information
parejkoj committed May 23, 2018
2 parents d965ca7 + 0babbf9 commit 7441b25
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 20 deletions.
70 changes: 50 additions & 20 deletions tests/test_jointcal_cfht.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ def test_jointcalTask_2_visits(self):
self.assertTrue(os.path.exists(name), msg='Did not find file %s'%name)
os.remove(name)

def test_jointcalTask_2_visits_constrainedAstrometry_no_photometry(self):
def setup_jointcalTask_2_visits_constrainedAstrometry(self):
"""Help keep the constrainedAstrometry tests consistent and make
the differences between them more obvious.
"""
self.config = lsst.jointcal.jointcal.JointcalConfig()
self.config.astrometryRefObjLoader.retarget(LoadAstrometryNetObjectsTask)
self.config.astrometryModel = "constrained"
Expand All @@ -99,8 +102,6 @@ def test_jointcalTask_2_visits_constrainedAstrometry_no_photometry(self):

# See Readme for an explanation of these empirical values.
dist_rms_relative = 12e-3*u.arcsecond
dist_rms_absolute = 48e-3*u.arcsecond
pa1 = None
metrics = {'collected_astrometry_refStars': 825,
'selected_astrometry_refStars': 350,
'associated_astrometry_fittedStars': 2269,
Expand All @@ -110,9 +111,35 @@ def test_jointcalTask_2_visits_constrainedAstrometry_no_photometry(self):
'astrometry_final_ndof': 2660,
}

self._testJointcalTask(2, dist_rms_relative, dist_rms_absolute, pa1, metrics=metrics)
return dist_rms_relative, metrics

def test_jointcalTask_2_visits_constrainedPhotometry_no_astrometry(self):
def test_jointcalTask_2_visits_constrainedAstrometry_no_photometry(self):
dist_rms_relative, metrics = self.setup_jointcalTask_2_visits_constrainedAstrometry()
self._testJointcalTask(2, dist_rms_relative, self.dist_rms_absolute, None, metrics=metrics)

def test_jointcalTask_2_visits_constrainedAstrometry_no_rank_update(self):
"""Demonstrate that skipping the rank update doesn't affect astrometry.
"""
relative_error, metrics = self.setup_jointcalTask_2_visits_constrainedAstrometry()
self.config.astrometryDoRankUpdate = False

self._testJointcalTask(2, relative_error, self.dist_rms_absolute, None, metrics=metrics)

def test_jointcalTask_2_visits_constrainedAstrometry_4sigma_outliers(self):
"""4 sigma outlier rejection means fewer available sources after the
fitter converges, resulting in a smaller ndof and chi2.
"""
dist_rms_relative, metrics = self.setup_jointcalTask_2_visits_constrainedAstrometry()
self.config.outlierRejectSigma = 4
metrics['astrometry_final_chi2'] = 922.76
metrics['astrometry_final_ndof'] = 2486

self._testJointcalTask(2, dist_rms_relative, self.dist_rms_absolute, None, metrics=metrics)

def setup_jointcalTask_2_visits_constrainedPhotometry(self):
"""Help keep the constrainedPhotometry tests consistent and make
the differences between them more obvious.
"""
self.config = lsst.jointcal.jointcal.JointcalConfig()
self.config.photometryRefObjLoader.retarget(LoadAstrometryNetObjectsTask)
self.config.photometryModel = "constrained"
Expand All @@ -130,32 +157,35 @@ def test_jointcalTask_2_visits_constrainedPhotometry_no_astrometry(self):
'photometry_final_chi2': 2655.86,
'photometry_final_ndof': 1328
}
return pa1, metrics

def test_jointcalTask_2_visits_constrainedPhotometry_no_astrometry(self):
pa1, metrics = self.setup_jointcalTask_2_visits_constrainedPhotometry()

self._testJointcalTask(2, None, None, pa1, metrics=metrics)

def test_jointcalTask_2_visits_constrainedPhotometry_no_rank_update(self):
"""Demonstrate that skipping the rank update doesn't affect photometry.
"""
pa1, metrics = self.setup_jointcalTask_2_visits_constrainedPhotometry()
self.config.photometryDoRankUpdate = False

self._testJointcalTask(2, None, None, pa1, metrics=metrics)

def test_jointcalTask_2_visits_constrainedPhotometry_flagged(self):
"""Test the use of the FlaggedSourceSelector."""
self.config = lsst.jointcal.jointcal.JointcalConfig()
self.config.photometryRefObjLoader.retarget(LoadAstrometryNetObjectsTask)
self.config.photometryModel = "constrained"
pa1, metrics = self.setup_jointcalTask_2_visits_constrainedPhotometry()
self.config.sourceSelector.name = "flagged"
# Reduce warnings due to flaggedSourceSelector having fewer sources than astrometrySourceSelector.
self.config.minMeasuredStarsPerCcd = 30
self.config.minRefStarsPerCcd = 20
self.config.doAstrometry = False
self.config.sourceSelector['astrometry'].badFlags.append("base_PixelFlags_flag_interpolated")
self.jointcalStatistics.do_astrometry = False

# See Readme for an explanation of these empirical values.
pa1 = 0.026
metrics = {'collected_photometry_refStars': 825,
'selected_photometry_refStars': 212,
'associated_photometry_fittedStars': 270,
'selected_photometry_fittedStars': 244,
'selected_photometry_ccdImages': 12,
'photometry_final_chi2': 369.96,
'photometry_final_ndof': 252
}
metrics['selected_photometry_refStars'] = 212
metrics['associated_photometry_fittedStars'] = 270
metrics['selected_photometry_fittedStars'] = 244
metrics['photometry_final_chi2'] = 369.96
metrics['photometry_final_ndof'] = 252

self._testJointcalTask(2, None, None, pa1, metrics=metrics)

Expand Down
1 change: 1 addition & 0 deletions tests/test_jointcal_decam.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def test_jointcalTask_2_visits_constrainedAstrometry_no_rank_update(self):

self._testJointcalTask(2, relative_error, self.dist_rms_absolute, pa1, metrics=metrics)

@unittest.skip("DM-14439 : This test produces different chi2/ndof on centos6 and centos7/macOS.")
def test_jointcalTask_2_visits_constrainedAstrometry_4sigma_outliers(self):
"""4 sigma outlier rejection means a fewer available sources, resulting
in a smaller ndof and chi2.
Expand Down

0 comments on commit 7441b25

Please sign in to comment.