Hide keyboard shortcuts

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/>. 

21 

22import unittest 

23import os 

24 

25from astropy import units as u 

26 

27import lsst.geom 

28import lsst.utils 

29import lsst.pex.exceptions 

30 

31import jointcalTestBase 

32 

33 

34# for MemoryTestCase 

35def setup_module(module): 

36 lsst.utils.tests.init() 

37 

38 

39class JointcalTestDECAM(jointcalTestBase.JointcalTestBase, lsst.utils.tests.TestCase): 

40 

41 @classmethod 

42 def setUpClass(cls): 

43 try: 

44 cls.data_dir = lsst.utils.getPackageDir('testdata_jointcal') 

45 except LookupError: 

46 raise unittest.SkipTest("testdata_jointcal not setup") 

47 try: 

48 lsst.utils.getPackageDir('obs_decam') 

49 except LookupError: 

50 raise unittest.SkipTest("obs_decam not setup") 

51 

52 def setUp(self): 

53 # See Readme for an explanation of this empirical value. 

54 self.dist_rms_absolute = 63e-3*u.arcsecond 

55 

56 do_plot = False 

57 

58 # center of the decam validation_data catalog 

59 center = lsst.geom.SpherePoint(150.1191666, 2.20583333, lsst.geom.degrees) 

60 radius = 3*lsst.geom.degrees 

61 

62 input_dir = os.path.join(self.data_dir, 'decam') 

63 all_visits = [176837, 176846] 

64 # Skipping ccd=13,14 because they mangle the results (14 is missing in one visit, 13 is bad). 

65 ccdnums = '^'.join(str(x) for x in (10, 11, 12, 15, 16, 17, 18)) 

66 other_args = ['ccdnum=' + ccdnums, ] 

67 

68 self.setUp_base(center, radius, 

69 input_dir=input_dir, 

70 all_visits=all_visits, 

71 other_args=other_args, 

72 do_plot=do_plot, 

73 log_level="DEBUG") 

74 

75 test_config = os.path.join(lsst.utils.getPackageDir('jointcal'), 'tests/config/decam-config.py') 

76 self.configfiles.append(test_config) 

77 

78 def test_jointcalTask_2_visits(self): 

79 self.config = lsst.jointcal.jointcal.JointcalConfig() 

80 self.config.astrometryModel = "simple" 

81 self.config.photometryModel = "simpleFlux" 

82 

83 # See Readme for an explanation of these empirical values. 

84 # NOTE: the photometry and astrometry refstars numbers are different 

85 # here because the SDSS catalogs have some sources with bad fluxes; 

86 # those are rejected for photometric calibration, but not astrometric. 

87 relative_error = 19e-3*u.arcsecond 

88 pa1 = 0.14 

89 metrics = {'collected_astrometry_refStars': 8871, 

90 'collected_photometry_refStars': 8860, 

91 'selected_astrometry_refStars': 1604, 

92 'selected_photometry_refStars': 1604, 

93 'associated_astrometry_fittedStars': 6749, 

94 'associated_photometry_fittedStars': 6749, 

95 'selected_astrometry_fittedStars': 2709, 

96 'selected_photometry_fittedStars': 2709, 

97 'selected_astrometry_ccdImages': 14, 

98 'selected_photometry_ccdImages': 14, 

99 'astrometry_final_chi2': 2838.0, 

100 'astrometry_final_ndof': 5562, 

101 'photometry_final_chi2': 4810.5, 

102 'photometry_final_ndof': 2910, 

103 } 

104 

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

106 

107 def setup_jointcalTask_2_visits_constrainedAstrometry_no_photometry(self): 

108 """Set default values for the constrainedAstrometry tests, and make 

109 the differences between each test and the defaults more obvious. 

110 """ 

111 self.config = lsst.jointcal.jointcal.JointcalConfig() 

112 self.config.astrometryModel = "constrained" 

113 self.config.doPhotometry = False 

114 self.jointcalStatistics.do_photometry = False 

115 

116 # See Readme for an explanation of these empirical values. 

117 relative_error = 17e-3*u.arcsecond 

118 pa1 = None 

119 metrics = {'collected_astrometry_refStars': 8871, 

120 'selected_astrometry_refStars': 1604, 

121 'associated_astrometry_fittedStars': 6749, 

122 'selected_astrometry_fittedStars': 2709, 

123 'selected_astrometry_ccdImages': 14, 

124 'astrometry_final_chi2': 3040.84, 

125 'astrometry_final_ndof': 5748, 

126 } 

127 return relative_error, pa1, metrics 

128 

129 @unittest.skip("DM-14439 : This test produces different chi2/ndof on centos6/7/Ubuntu and macOS.") 

130 def test_jointcalTask_2_visits_constrainedAstrometry_no_photometry(self): 

131 relative_error, pa1, metrics = self.setup_jointcalTask_2_visits_constrainedAstrometry_no_photometry() 

132 

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

134 

135 def test_jointcalTask_2_visits_constrainedAstrometry_no_rank_update(self): 

136 """Demonstrate that skipping the rank update doesn't significantly affect astrometry. 

137 """ 

138 relative_error, pa1, metrics = self.setup_jointcalTask_2_visits_constrainedAstrometry_no_photometry() 

139 self.config.astrometryDoRankUpdate = False 

140 

141 metrics['astrometry_final_chi2'] = 3015.61 

142 metrics['astrometry_final_ndof'] = 5738 

143 

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

145 

146 @unittest.skip("DM-14439 : This test produces different chi2/ndof on centos6 and centos7/macOS.") 

147 def test_jointcalTask_2_visits_constrainedAstrometry_4sigma_outliers(self): 

148 """4 sigma outlier rejection means a fewer available sources, resulting 

149 in a smaller ndof and chi2. 

150 """ 

151 relative_error, pa1, metrics = self.setup_jointcalTask_2_visits_constrainedAstrometry_no_photometry() 

152 self.config.outlierRejectSigma = 4 

153 metrics['astrometry_final_chi2'] = 1506.7 

154 metrics['astrometry_final_ndof'] = 3682 

155 

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

157 

158 def setup_jointcalTask_2_visits_constrainedPhotometry_no_astrometry(self): 

159 """Set default values for the constrainedPhotometry tests, and make 

160 the differences between each test and the defaults more obvious. 

161 """ 

162 self.config = lsst.jointcal.jointcal.JointcalConfig() 

163 self.config.photometryModel = "constrainedFlux" 

164 self.config.doAstrometry = False 

165 self.jointcalStatistics.do_astrometry = False 

166 

167 self.other_args.extend(['--config', 'writeChi2FilesInitialFinal=True']) 

168 

169 # See Readme for an explanation of these empirical values. 

170 pa1 = 0.11 

171 metrics = {'collected_photometry_refStars': 4865, 

172 'selected_photometry_refStars': 661, 

173 'associated_photometry_fittedStars': 6749, 

174 'selected_photometry_fittedStars': 2044, 

175 'selected_photometry_ccdImages': 14, 

176 'photometry_final_chi2': 3066.22, 

177 'photometry_final_ndof': 1998, 

178 } 

179 

180 return pa1, metrics 

181 

182 @unittest.skip("DM-14439 : This test produces different chi2/ndof on Linux and macOS.") 

183 def test_jointcalTask_2_visits_constrainedPhotometry_no_astrometry_fluxErr_0(self): 

184 pa1, metrics = self.setup_jointcalTask_2_visits_constrainedPhotometry_no_astrometry() 

185 

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

187 

188 @unittest.skip("DM-14439 : This test produces different chi2/ndof on Linux and macOS.") 

189 def test_jointcalTask_2_visits_constrainedPhotometry_flagged_selector(self): 

190 pa1, metrics = self.setup_jointcalTask_2_visits_constrainedPhotometry_no_astrometry() 

191 self.config.sourceSelector.name = 'flagged' 

192 # Reduce warnings due to flaggedSourceSelector having fewer sources than astrometrySourceSelector. 

193 self.config.minMeasuredStarsPerCcd = 40 

194 

195 # See Readme for an explanation of these empirical values. 

196 metrics = {'collected_photometry_refStars': 4865, 

197 'selected_photometry_refStars': 551, 

198 'associated_photometry_fittedStars': 860, 

199 'selected_photometry_fittedStars': 593, 

200 'selected_photometry_ccdImages': 14, 

201 'photometry_final_chi2': 817.124, 

202 'photometry_final_ndof': 607, 

203 } 

204 

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

206 

207 @unittest.skip("DM-14439 : This test produces different chi2/ndof on Linux and macOS.") 

208 def test_jointcalTask_2_visits_constrainedPhotometry_no_rank_update(self): 

209 pa1, metrics = self.setup_jointcalTask_2_visits_constrainedPhotometry_no_astrometry() 

210 self.config.photometryDoRankUpdate = False 

211 

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

213 

214 @unittest.skip("DM-14439 : This test produces different chi2/ndof on Linux and macOS.") 

215 def test_jointcalTask_2_visits_constrainedPhotometry_fluxErr_3(self): 

216 pa1, metrics = self.setup_jointcalTask_2_visits_constrainedPhotometry_no_astrometry() 

217 self.config.fluxError = 0.03 

218 metrics['photometry_final_chi2'] = 1818.92 

219 metrics['photometry_final_ndof'] = 2010 

220 

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

222 

223 

224class MemoryTester(lsst.utils.tests.MemoryTestCase): 

225 pass 

226 

227 

228if __name__ == "__main__": 228 ↛ 229line 228 didn't jump to line 229, because the condition on line 228 was never true

229 lsst.utils.tests.init() 

230 unittest.main()