Coverage for tests/test_jointcal_decam.py : 26%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# This file is part of jointcal.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
22import unittest
23import os
25from astropy import units as u
27import lsst.geom
28import lsst.utils
29import lsst.pex.exceptions
31import jointcalTestBase
34# for MemoryTestCase
35def setup_module(module):
36 lsst.utils.tests.init()
39class JointcalTestDECAM(jointcalTestBase.JointcalTestBase, lsst.utils.tests.TestCase):
41 @classmethod
42 def setUpClass(cls):
43 try:
44 cls.data_dir = lsst.utils.getPackageDir('testdata_jointcal')
45 except lsst.pex.exceptions.NotFoundError:
46 raise unittest.SkipTest("testdata_jointcal not setup")
48 def setUp(self):
49 # See Readme for an explanation of this empirical value.
50 self.dist_rms_absolute = 63e-3*u.arcsecond
52 do_plot = False
54 # center of the decam validation_data catalog
55 center = lsst.geom.SpherePoint(150.1191666, 2.20583333, lsst.geom.degrees)
56 radius = 3*lsst.geom.degrees
58 input_dir = os.path.join(self.data_dir, 'decam')
59 all_visits = [176837, 176846]
60 # Skipping ccd=13,14 because they mangle the results (14 is missing in one visit, 13 is bad).
61 ccdnums = '^'.join(str(x) for x in (10, 11, 12, 15, 16, 17, 18))
62 other_args = ['ccdnum=' + ccdnums, ]
64 self.setUp_base(center, radius,
65 input_dir=input_dir,
66 all_visits=all_visits,
67 other_args=other_args,
68 do_plot=do_plot,
69 log_level="DEBUG")
71 test_config = os.path.join(lsst.utils.getPackageDir('jointcal'), 'tests/config/decam-config.py')
72 self.configfiles.append(test_config)
74 def test_jointcalTask_2_visits(self):
75 self.config = lsst.jointcal.jointcal.JointcalConfig()
76 self.config.astrometryModel = "simple"
77 self.config.photometryModel = "simpleFlux"
79 # See Readme for an explanation of these empirical values.
80 # NOTE: the photometry and astrometry refstars numbers are different
81 # here because the SDSS catalogs have some sources with bad fluxes;
82 # those are rejected for photometric calibration, but not astrometric.
83 relative_error = 19e-3*u.arcsecond
84 pa1 = 0.14
85 metrics = {'collected_astrometry_refStars': 8871,
86 'collected_photometry_refStars': 8860,
87 'selected_astrometry_refStars': 1604,
88 'selected_photometry_refStars': 1604,
89 'associated_astrometry_fittedStars': 6749,
90 'associated_photometry_fittedStars': 6749,
91 'selected_astrometry_fittedStars': 2709,
92 'selected_photometry_fittedStars': 2709,
93 'selected_astrometry_ccdImages': 14,
94 'selected_photometry_ccdImages': 14,
95 'astrometry_final_chi2': 2838.0,
96 'astrometry_final_ndof': 5562,
97 'photometry_final_chi2': 4810.5,
98 'photometry_final_ndof': 2910,
99 }
101 self._testJointcalTask(2, relative_error, self.dist_rms_absolute, pa1, metrics=metrics)
103 def setup_jointcalTask_2_visits_constrainedAstrometry_no_photometry(self):
104 """Set default values for the constrainedAstrometry tests, and make
105 the differences between each test and the defaults more obvious.
106 """
107 self.config = lsst.jointcal.jointcal.JointcalConfig()
108 self.config.astrometryModel = "constrained"
109 self.config.doPhotometry = False
110 self.jointcalStatistics.do_photometry = False
112 # See Readme for an explanation of these empirical values.
113 relative_error = 17e-3*u.arcsecond
114 pa1 = None
115 metrics = {'collected_astrometry_refStars': 8871,
116 'selected_astrometry_refStars': 1604,
117 'associated_astrometry_fittedStars': 6749,
118 'selected_astrometry_fittedStars': 2709,
119 'selected_astrometry_ccdImages': 14,
120 'astrometry_final_chi2': 3040.84,
121 'astrometry_final_ndof': 5748,
122 }
123 return relative_error, pa1, metrics
125 @unittest.skip("DM-14439 : This test produces different chi2/ndof on centos6/7/Ubuntu and macOS.")
126 def test_jointcalTask_2_visits_constrainedAstrometry_no_photometry(self):
127 relative_error, pa1, metrics = self.setup_jointcalTask_2_visits_constrainedAstrometry_no_photometry()
129 self._testJointcalTask(2, relative_error, self.dist_rms_absolute, pa1, metrics=metrics)
131 def test_jointcalTask_2_visits_constrainedAstrometry_no_rank_update(self):
132 """Demonstrate that skipping the rank update doesn't significantly affect astrometry.
133 """
134 relative_error, pa1, metrics = self.setup_jointcalTask_2_visits_constrainedAstrometry_no_photometry()
135 self.config.astrometryDoRankUpdate = False
137 metrics['astrometry_final_chi2'] = 3015.61
138 metrics['astrometry_final_ndof'] = 5738
140 self._testJointcalTask(2, relative_error, self.dist_rms_absolute, pa1, metrics=metrics)
142 @unittest.skip("DM-14439 : This test produces different chi2/ndof on centos6 and centos7/macOS.")
143 def test_jointcalTask_2_visits_constrainedAstrometry_4sigma_outliers(self):
144 """4 sigma outlier rejection means a fewer available sources, resulting
145 in a smaller ndof and chi2.
146 """
147 relative_error, pa1, metrics = self.setup_jointcalTask_2_visits_constrainedAstrometry_no_photometry()
148 self.config.outlierRejectSigma = 4
149 metrics['astrometry_final_chi2'] = 1506.7
150 metrics['astrometry_final_ndof'] = 3682
152 self._testJointcalTask(2, relative_error, self.dist_rms_absolute, pa1, metrics=metrics)
154 def setup_jointcalTask_2_visits_constrainedPhotometry_no_astrometry(self):
155 """Set default values for the constrainedPhotometry tests, and make
156 the differences between each test and the defaults more obvious.
157 """
158 self.config = lsst.jointcal.jointcal.JointcalConfig()
159 self.config.photometryModel = "constrainedFlux"
160 self.config.doAstrometry = False
161 self.jointcalStatistics.do_astrometry = False
163 self.other_args.extend(['--config', 'writeChi2FilesInitialFinal=True'])
165 # See Readme for an explanation of these empirical values.
166 pa1 = 0.11
167 metrics = {'collected_photometry_refStars': 4865,
168 'selected_photometry_refStars': 661,
169 'associated_photometry_fittedStars': 6749,
170 'selected_photometry_fittedStars': 2044,
171 'selected_photometry_ccdImages': 14,
172 'photometry_final_chi2': 3066.22,
173 'photometry_final_ndof': 1998,
174 }
176 return pa1, metrics
178 @unittest.skip("DM-14439 : This test produces different chi2/ndof on Linux and macOS.")
179 def test_jointcalTask_2_visits_constrainedPhotometry_no_astrometry_fluxErr_0(self):
180 pa1, metrics = self.setup_jointcalTask_2_visits_constrainedPhotometry_no_astrometry()
182 self._testJointcalTask(2, None, None, pa1, metrics=metrics)
184 @unittest.skip("DM-14439 : This test produces different chi2/ndof on Linux and macOS.")
185 def test_jointcalTask_2_visits_constrainedPhotometry_flagged_selector(self):
186 pa1, metrics = self.setup_jointcalTask_2_visits_constrainedPhotometry_no_astrometry()
187 self.config.sourceSelector.name = 'flagged'
188 # Reduce warnings due to flaggedSourceSelector having fewer sources than astrometrySourceSelector.
189 self.config.minMeasuredStarsPerCcd = 40
191 # See Readme for an explanation of these empirical values.
192 metrics = {'collected_photometry_refStars': 4865,
193 'selected_photometry_refStars': 551,
194 'associated_photometry_fittedStars': 860,
195 'selected_photometry_fittedStars': 593,
196 'selected_photometry_ccdImages': 14,
197 'photometry_final_chi2': 817.124,
198 'photometry_final_ndof': 607,
199 }
201 self._testJointcalTask(2, None, None, pa1, metrics=metrics)
203 @unittest.skip("DM-14439 : This test produces different chi2/ndof on Linux and macOS.")
204 def test_jointcalTask_2_visits_constrainedPhotometry_no_rank_update(self):
205 pa1, metrics = self.setup_jointcalTask_2_visits_constrainedPhotometry_no_astrometry()
206 self.config.photometryDoRankUpdate = False
208 self._testJointcalTask(2, None, None, pa1, metrics=metrics)
210 @unittest.skip("DM-14439 : This test produces different chi2/ndof on Linux and macOS.")
211 def test_jointcalTask_2_visits_constrainedPhotometry_fluxErr_3(self):
212 pa1, metrics = self.setup_jointcalTask_2_visits_constrainedPhotometry_no_astrometry()
213 self.config.fluxError = 0.03
214 metrics['photometry_final_chi2'] = 1818.92
215 metrics['photometry_final_ndof'] = 2010
217 self._testJointcalTask(2, None, None, pa1, metrics=metrics)
220class MemoryTester(lsst.utils.tests.MemoryTestCase):
221 pass
224if __name__ == "__main__": 224 ↛ 225line 224 didn't jump to line 225, because the condition on line 224 was never true
225 lsst.utils.tests.init()
226 unittest.main()