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

84 statements  

« prev     ^ index     » next       coverage.py v7.2.5, created at 2023-05-20 09:58 +0000

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.focalPlanePlot import FocalPlanePlot 

33from ..actions.plot.skyPlot import SkyPlot 

34from ..actions.vector import ( 

35 BandSelector, 

36 ConvertFluxToMag, 

37 ConvertUnits, 

38 DownselectVector, 

39 LoadVector, 

40 RAcosDec, 

41 ResidualWithPerGroupStatistic, 

42 SnSelector, 

43 ThresholdSelector, 

44) 

45from ..interfaces import AnalysisTool 

46 

47 

48class StellarAstrometricResidualsBase(AnalysisTool): 

49 """Plot mean astrometric residuals. 

50 

51 The individual source measurements are grouped together by object index 

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

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

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

55 """ 

56 

57 def setDefaults(self): 

58 super().setDefaults() 

59 

60 # Apply per-source selection criteria 

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

62 

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

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

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

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

67 

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

69 

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

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

72 

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

74 

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

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

77 vectorKey="mags", 

78 op="le", 

79 threshold=24, 

80 ) 

81 self.process.filterActions.y = DownselectVector( 

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

83 ) 

84 self.process.filterActions.z = DownselectVector( 

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

86 ) 

87 self.process.filterActions.detector = DownselectVector( 

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

89 ) 

90 

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

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

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

94 

95 

96class StellarAstrometricResidualsRASkyPlot(StellarAstrometricResidualsBase): 

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

98 RA and Dec. 

99 """ 

100 

101 def setDefaults(self): 

102 super().setDefaults() 

103 

104 # Compute per-group quantities 

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

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

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

108 

109 self.produce = SkyPlot() 

110 

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

112 self.produce.plotName = "ra_residuals" 

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

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

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

116 

117 

118class StellarAstrometricResidualsDecSkyPlot(StellarAstrometricResidualsBase): 

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

120 RA and Dec. 

121 """ 

122 

123 def setDefaults(self): 

124 super().setDefaults() 

125 

126 # Compute per-group quantities 

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

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

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

130 

131 self.produce = SkyPlot() 

132 

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

134 self.produce.plotName = "ra_residuals" 

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

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

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

138 

139 

140class StellarAstrometricResidualsRAFocalPlanePlot(StellarAstrometricResidualsBase): 

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

142 position. 

143 """ 

144 

145 def setDefaults(self): 

146 super().setDefaults() 

147 

148 # Compute per-group quantities 

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

150 

151 self.produce = FocalPlanePlot() 

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

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

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

155 

156 

157class StellarAstrometricResidualStdDevRAFocalPlanePlot(StellarAstrometricResidualsBase): 

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

159 position. 

160 """ 

161 

162 def setDefaults(self): 

163 super().setDefaults() 

164 

165 # Compute per-group quantities 

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

167 

168 self.produce = FocalPlanePlot() 

169 self.produce.statistic = "std" 

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

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

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

173 

174 

175class StellarAstrometricResidualsDecFocalPlanePlot(StellarAstrometricResidualsBase): 

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

177 position. 

178 """ 

179 

180 def setDefaults(self): 

181 super().setDefaults() 

182 

183 # Compute per-group quantities 

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

185 

186 self.produce = FocalPlanePlot() 

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

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

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

190 

191 

192class StellarAstrometricResidualStdDevDecFocalPlanePlot(StellarAstrometricResidualsBase): 

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

194 position. 

195 """ 

196 

197 def setDefaults(self): 

198 super().setDefaults() 

199 

200 # Compute per-group quantities 

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

202 

203 self.produce = FocalPlanePlot() 

204 self.produce.statistic = "std" 

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

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

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