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

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

# This file is part of jointcal. 

# 

# Developed for the LSST Data Management System. 

# This product includes software developed by the LSST Project 

# (https://www.lsst.org). 

# See the COPYRIGHT file at the top-level directory of this distribution 

# for details of code ownership. 

# 

# This program is free software: you can redistribute it and/or modify 

# it under the terms of the GNU General Public License as published by 

# the Free Software Foundation, either version 3 of the License, or 

# (at your option) any later version. 

# 

# This program is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

# GNU General Public License for more details. 

# 

# You should have received a copy of the GNU General Public License 

# along with this program. If not, see <https://www.gnu.org/licenses/>. 

 

import unittest 

import os 

 

from astropy import units as u 

 

import lsst.afw.geom 

import lsst.utils 

import lsst.pex.exceptions 

 

import jointcalTestBase 

 

 

# for MemoryTestCase 

def setup_module(module): 

lsst.utils.tests.init() 

 

 

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

 

@classmethod 

def setUpClass(cls): 

try: 

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

os.environ['ASTROMETRY_NET_DATA_DIR'] = os.path.join(cls.data_dir, 'decam_and_index') 

except lsst.pex.exceptions.NotFoundError: 

raise unittest.SkipTest("testdata_jointcal not setup") 

 

def setUp(self): 

# See Readme for an explanation of this empirical value. 

self.dist_rms_absolute = 62.5e-3*u.arcsecond 

 

do_plot = False 

 

# center of the decam validation_data catalog 

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

radius = 3*lsst.afw.geom.degrees 

 

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

all_visits = [176837, 176846] 

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

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

other_args = ['ccdnum=' + ccdnums, ] 

 

self.setUp_base(center, radius, 

input_dir=input_dir, 

all_visits=all_visits, 

other_args=other_args, 

do_plot=do_plot, 

log_level="DEBUG") 

 

def test_jointcalTask_2_visits(self): 

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

self.config.astrometryModel = "simple" 

self.config.photometryModel = "simpleFlux" 

self.config.sourceSelector['astrometry'].badFlags.append("base_PixelFlags_flag_interpolated") 

 

# See Readme for an explanation of these empirical values. 

relative_error = 19e-3*u.arcsecond 

pa1 = 0.14 

metrics = {'collected_astrometry_refStars': 4866, 

'collected_photometry_refStars': 4865, 

'selected_astrometry_refStars': 661, 

'selected_photometry_refStars': 661, 

'associated_astrometry_fittedStars': 6749, 

'associated_photometry_fittedStars': 6749, 

'selected_astrometry_fittedStars': 2044, 

'selected_photometry_fittedStars': 2044, 

'selected_astrometry_ccdImages': 14, 

'selected_photometry_ccdImages': 14, 

'astrometry_final_chi2': 1974.13, 

'astrometry_final_ndof': 3822, 

'photometry_final_chi2': 3453.16, 

'photometry_final_ndof': 2079, 

} 

 

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

 

def setup_jointcalTask_2_visits_constrainedAstrometry_no_photometry(self): 

"""Help keep the two constrainedAstrometry tests consistent and make 

the difference between them more obvious.""" 

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

self.config.astrometryModel = "constrained" 

self.config.doPhotometry = False 

self.config.sourceSelector['astrometry'].badFlags.append("base_PixelFlags_flag_interpolated") 

self.jointcalStatistics.do_photometry = False 

 

# See Readme for an explanation of these empirical values. 

relative_error = 17e-3*u.arcsecond 

pa1 = None 

metrics = {'collected_astrometry_refStars': 4866, 

'selected_astrometry_refStars': 661, 

'associated_astrometry_fittedStars': 6749, 

'selected_astrometry_fittedStars': 2044, 

'selected_astrometry_ccdImages': 14, 

'astrometry_final_chi2': 2072.89, 

'astrometry_final_ndof': 3970, 

} 

return relative_error, pa1, metrics 

 

def test_jointcalTask_2_visits_constrainedAstrometry_no_photometry(self): 

relative_error, pa1, metrics = self.setup_jointcalTask_2_visits_constrainedAstrometry_no_photometry() 

 

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

 

def test_jointcalTask_2_visits_constrainedAstrometry_no_rank_update(self): 

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

""" 

relative_error, pa1, metrics = self.setup_jointcalTask_2_visits_constrainedAstrometry_no_photometry() 

self.config.astrometryDoRankUpdate = False 

 

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. 

""" 

relative_error, pa1, metrics = self.setup_jointcalTask_2_visits_constrainedAstrometry_no_photometry() 

self.config.outlierRejectSigma = 4 

metrics['astrometry_final_chi2'] = 1506.7 

metrics['astrometry_final_ndof'] = 3682 

 

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

 

def setup_jointcalTask_2_visits_constrainedPhotometry_no_astrometry(self): 

"""Help keep the constrainedPhotometry tests consistent and make 

the differences between them more obvious. 

""" 

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

self.config.photometryModel = "constrainedFlux" 

self.config.sourceSelector['astrometry'].badFlags.append("base_PixelFlags_flag_interpolated") 

self.config.doAstrometry = False 

self.jointcalStatistics.do_astrometry = False 

 

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

 

# See Readme for an explanation of these empirical values. 

pa1 = 0.11 

metrics = {'collected_photometry_refStars': 4865, 

'selected_photometry_refStars': 661, 

'associated_photometry_fittedStars': 6749, 

'selected_photometry_fittedStars': 2044, 

'selected_photometry_ccdImages': 14, 

'photometry_final_chi2': 3066.22, 

'photometry_final_ndof': 1998, 

} 

 

return pa1, metrics 

 

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

def test_jointcalTask_2_visits_constrainedPhotometry_no_astrometry_fluxErr_0(self): 

pa1, metrics = self.setup_jointcalTask_2_visits_constrainedPhotometry_no_astrometry() 

 

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

 

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

def test_jointcalTask_2_visits_constrainedPhotometry_flagged_selector(self): 

pa1, metrics = self.setup_jointcalTask_2_visits_constrainedPhotometry_no_astrometry() 

self.config.sourceSelector.name = 'flagged' 

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

self.config.minMeasuredStarsPerCcd = 40 

 

# See Readme for an explanation of these empirical values. 

metrics = {'collected_photometry_refStars': 4865, 

'selected_photometry_refStars': 551, 

'associated_photometry_fittedStars': 860, 

'selected_photometry_fittedStars': 593, 

'selected_photometry_ccdImages': 14, 

'photometry_final_chi2': 817.124, 

'photometry_final_ndof': 607, 

} 

 

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

 

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

def test_jointcalTask_2_visits_constrainedPhotometry_no_rank_update(self): 

pa1, metrics = self.setup_jointcalTask_2_visits_constrainedPhotometry_no_astrometry() 

self.config.photometryDoRankUpdate = False 

 

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

 

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

def test_jointcalTask_2_visits_constrainedPhotometry_fluxErr_3(self): 

pa1, metrics = self.setup_jointcalTask_2_visits_constrainedPhotometry_no_astrometry() 

self.config.fluxError = 0.03 

metrics['photometry_final_chi2'] = 1818.92 

metrics['photometry_final_ndof'] = 2010 

 

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

 

 

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

pass 

 

 

217 ↛ 218line 217 didn't jump to line 218, because the condition on line 217 was never trueif __name__ == "__main__": 

lsst.utils.tests.init() 

unittest.main()