Coverage for python/lsst/analysis/tools/atools/astrometricRepeatability.py: 23%

83 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-07 03:18 -0700

1# This file is part of analysis_tools. 

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

21from __future__ import annotations 

22 

23__all__ = ( 

24 "StellarAstrometricResidualsRAFocalPlanePlot", 

25 "StellarAstrometricResidualsDecFocalPlanePlot", 

26 "StellarAstrometricResidualStdDevRAFocalPlanePlot", 

27 "StellarAstrometricResidualStdDevDecFocalPlanePlot", 

28 "StellarAstrometricResidualsRASkyPlot", 

29 "StellarAstrometricResidualsDecSkyPlot", 

30) 

31 

32from ..actions.plot import FocalPlanePlot, SkyPlot 

33from ..actions.vector import ( 

34 BandSelector, 

35 ConvertFluxToMag, 

36 ConvertUnits, 

37 DownselectVector, 

38 LoadVector, 

39 RAcosDec, 

40 ResidualWithPerGroupStatistic, 

41 SnSelector, 

42 ThresholdSelector, 

43) 

44from ..interfaces import AnalysisTool 

45 

46 

47class StellarAstrometricResidualsBase(AnalysisTool): 

48 """Plot mean astrometric residuals. 

49 

50 The individual source measurements are grouped together by object index 

51 and the per-group centroid is computed. The residuals between the 

52 individual sources and these centroids are then used to construct a plot 

53 showing the mean residual as a function of the focal-plane or sky position. 

54 """ 

55 

56 def setDefaults(self): 

57 super().setDefaults() 

58 

59 # Apply per-source selection criteria 

60 self.prep.selectors.bandSelector = BandSelector() 

61 

62 self.process.buildActions.mags = ConvertFluxToMag(vectorKey="psfFlux") 

63 self.process.buildActions.residual = ConvertUnits() 

64 self.process.buildActions.residual.inUnit = "degree" 

65 self.process.buildActions.residual.outUnit = "marcsec" 

66 

67 self.process.buildActions.residual.buildAction = ResidualWithPerGroupStatistic() 

68 

69 self.process.buildActions.x = LoadVector(vectorKey="x") 

70 self.process.buildActions.y = LoadVector(vectorKey="y") 

71 

72 self.process.buildActions.detector = LoadVector(vectorKey="detector") 

73 

74 self.process.filterActions.x = DownselectVector(vectorKey="x") 

75 self.process.filterActions.x.selector = ThresholdSelector( 

76 vectorKey="mags", 

77 op="le", 

78 threshold=24, 

79 ) 

80 self.process.filterActions.y = DownselectVector( 

81 vectorKey="y", selector=self.process.filterActions.x.selector 

82 ) 

83 self.process.filterActions.z = DownselectVector( 

84 vectorKey="residual", selector=self.process.filterActions.x.selector 

85 ) 

86 self.process.filterActions.detector = DownselectVector( 

87 vectorKey="detector", selector=self.process.filterActions.x.selector 

88 ) 

89 

90 self.process.buildActions.statMask = SnSelector() 

91 self.process.buildActions.statMask.threshold = 0 

92 self.process.buildActions.statMask.fluxType = "psfFlux" 

93 

94 

95class StellarAstrometricResidualsRASkyPlot(StellarAstrometricResidualsBase): 

96 """Plot mean astrometric residuals in RA as a function of the position in 

97 RA and Dec. 

98 """ 

99 

100 def setDefaults(self): 

101 super().setDefaults() 

102 

103 # Compute per-group quantities 

104 self.process.buildActions.residual.buildAction.buildAction = RAcosDec() 

105 self.process.buildActions.x = LoadVector(vectorKey="coord_ra") 

106 self.process.buildActions.y = LoadVector(vectorKey="coord_dec") 

107 

108 self.produce = SkyPlot() 

109 

110 self.produce.plotTypes = ["any"] 

111 self.produce.plotName = "ra_residuals" 

112 self.produce.xAxisLabel = "R.A. (degrees)" 

113 self.produce.yAxisLabel = "Dec. (degrees)" 

114 self.produce.zAxisLabel = "RAcos(Dec) - RAcos(Dec)$_{mean}$" 

115 

116 

117class StellarAstrometricResidualsDecSkyPlot(StellarAstrometricResidualsBase): 

118 """Plot mean astrometric residuals in RA as a function of the position in 

119 RA and Dec. 

120 """ 

121 

122 def setDefaults(self): 

123 super().setDefaults() 

124 

125 # Compute per-group quantities 

126 self.process.buildActions.residual.buildAction.buildAction.vectorKey = "coord_dec" 

127 self.process.buildActions.x = LoadVector(vectorKey="coord_ra") 

128 self.process.buildActions.y = LoadVector(vectorKey="coord_dec") 

129 

130 self.produce = SkyPlot() 

131 

132 self.produce.plotTypes = ["any"] 

133 self.produce.plotName = "ra_residuals" 

134 self.produce.xAxisLabel = "R.A. (degrees)" 

135 self.produce.yAxisLabel = "Dec. (degrees)" 

136 self.produce.zAxisLabel = "RAcos(Dec) - RAcos(Dec)$_{mean}$" 

137 

138 

139class StellarAstrometricResidualsRAFocalPlanePlot(StellarAstrometricResidualsBase): 

140 """Plot mean astrometric residuals in RA as a function of the focal plane 

141 position. 

142 """ 

143 

144 def setDefaults(self): 

145 super().setDefaults() 

146 

147 # Compute per-group quantities 

148 self.process.buildActions.residual.buildAction.buildAction = RAcosDec() 

149 

150 self.produce = FocalPlanePlot() 

151 self.produce.xAxisLabel = "x (focal plane)" 

152 self.produce.yAxisLabel = "y (focal plane)" 

153 self.produce.zAxisLabel = "RAcos(Dec) - RAcos(Dec)$_{mean}$ (mArcsec)" 

154 

155 

156class StellarAstrometricResidualStdDevRAFocalPlanePlot(StellarAstrometricResidualsBase): 

157 """Plot mean astrometric residuals in RA as a function of the focal plane 

158 position. 

159 """ 

160 

161 def setDefaults(self): 

162 super().setDefaults() 

163 

164 # Compute per-group quantities 

165 self.process.buildActions.residual.buildAction.buildAction = RAcosDec() 

166 

167 self.produce = FocalPlanePlot() 

168 self.produce.statistic = "std" 

169 self.produce.xAxisLabel = "x (focal plane)" 

170 self.produce.yAxisLabel = "y (focal plane)" 

171 self.produce.zAxisLabel = "Std(RAcos(Dec) - RAcos(Dec)$_{mean}$) (mArcsec)" 

172 

173 

174class StellarAstrometricResidualsDecFocalPlanePlot(StellarAstrometricResidualsBase): 

175 """Plot mean astrometric residuals in RA as a function of the focal plane 

176 position. 

177 """ 

178 

179 def setDefaults(self): 

180 super().setDefaults() 

181 

182 # Compute per-group quantities 

183 self.process.buildActions.residual.buildAction.buildAction.vectorKey = "coord_dec" 

184 

185 self.produce = FocalPlanePlot() 

186 self.produce.xAxisLabel = "x (focal plane)" 

187 self.produce.yAxisLabel = "y (focal plane)" 

188 self.produce.zAxisLabel = "Dec - Dec$_{mean}$ (mArcsec)" 

189 

190 

191class StellarAstrometricResidualStdDevDecFocalPlanePlot(StellarAstrometricResidualsBase): 

192 """Plot mean astrometric residuals in RA as a function of the focal plane 

193 position. 

194 """ 

195 

196 def setDefaults(self): 

197 super().setDefaults() 

198 

199 # Compute per-group quantities 

200 self.process.buildActions.residual.buildAction.buildAction.vectorKey = "coord_dec" 

201 

202 self.produce = FocalPlanePlot() 

203 self.produce.statistic = "std" 

204 self.produce.xAxisLabel = "x (focal plane)" 

205 self.produce.yAxisLabel = "y (focal plane)" 

206 self.produce.zAxisLabel = "Std(Dec - Dec$_{mean}$) (mArcsec)"