Coverage for python/lsst/analysis/tools/atools/stellarLocus.py: 17%

135 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-10-03 10:01 +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 "StellarLocusBase", 

25 "WPerpPSF", 

26 "WPerpCModel", 

27 "XPerpPSF", 

28 "XPerpCModel", 

29 "YPerpPSF", 

30 "YPerpCModel", 

31) 

32 

33from ..actions.keyedData.stellarLocusFit import StellarLocusFitAction 

34from ..actions.plot.colorColorFitPlot import ColorColorFitPlot 

35from ..actions.scalar import ApproxFloor 

36from ..actions.vector import ( 

37 CoaddPlotFlagSelector, 

38 ConvertFluxToMag, 

39 ExtinctionCorrectedMagDiff, 

40 SnSelector, 

41 StarSelector, 

42) 

43from ..interfaces import AnalysisTool 

44 

45 

46class StellarLocusBase(AnalysisTool): 

47 # Use this as the Base Class for now StellarLocusBaseMetric 

48 parameterizedBand: bool = False 

49 

50 def setDefaults(self): 

51 super().setDefaults() 

52 self.prep.selectors.flagSelector = CoaddPlotFlagSelector() 

53 

54 self.prep.selectors.snSelector = SnSelector() 

55 self.prep.selectors.snSelector.threshold = 300 

56 

57 self.prep.selectors.starSelector = StarSelector() 

58 

59 self.process.buildActions.x = ExtinctionCorrectedMagDiff() 

60 self.process.buildActions.x.magDiff.returnMillimags = False 

61 self.process.buildActions.y = ExtinctionCorrectedMagDiff() 

62 self.process.buildActions.y.magDiff.returnMillimags = False 

63 

64 

65class WPerpPSF(StellarLocusBase): 

66 parameterizedBand: bool = False 

67 

68 def setDefaults(self): 

69 super().setDefaults() 

70 self.prep.selectors.flagSelector.bands = ["g", "r", "i"] 

71 self.prep.selectors.snSelector.bands = ["r"] 

72 self.prep.selectors.snSelector.fluxType = "{band}_psfFlux" 

73 

74 self.prep.selectors.starSelector.vectorKey = "r_extendedness" 

75 

76 self.process.buildActions.x.magDiff.col1 = "g_psfFlux" 

77 self.process.buildActions.x.magDiff.col2 = "r_psfFlux" 

78 

79 self.process.buildActions.y.magDiff.col1 = "r_psfFlux" 

80 self.process.buildActions.y.magDiff.col2 = "i_psfFlux" 

81 

82 self.process.buildActions.mag = ConvertFluxToMag(vectorKey="r_psfFlux") 

83 

84 self.process.calculateActions.wPerp_psfFlux = StellarLocusFitAction() 

85 self.process.calculateActions.wPerp_psfFlux.stellarLocusFitDict = { 

86 "xMin": 0.28, 

87 "xMax": 1.0, 

88 "yMin": 0.02, 

89 "yMax": 0.48, 

90 "mHW": 0.52, 

91 "bHW": -0.08, 

92 } 

93 

94 self.process.calculateActions.approxMagDepth = ApproxFloor(vectorKey="mag") 

95 self.produce.metric.units = { 

96 "wPerp_psfFlux_sigmaMAD": "mmag", 

97 "wPerp_psfFlux_median": "mmag", 

98 } 

99 

100 self.produce.plot = ColorColorFitPlot() 

101 self.produce.plot.xAxisLabel = "g - r (PSF) [mags]" 

102 self.produce.plot.yAxisLabel = "r - i (PSF) [mags]" 

103 self.produce.plot.magLabel = "PSF Mag" 

104 self.produce.plot.plotName = "wPerp_psfFlux" 

105 

106 

107class WPerpCModel(WPerpPSF): 

108 def setDefaults(self): 

109 super().setDefaults() 

110 self.prep.selectors.snSelector.fluxType = "{band}_cModelFlux" 

111 

112 self.process.buildActions.x.magDiff.col1 = "g_cModelFlux" 

113 self.process.buildActions.x.magDiff.col2 = "r_cModelFlux" 

114 

115 self.process.buildActions.y.magDiff.col1 = "r_cModelFlux" 

116 self.process.buildActions.y.magDiff.col2 = "i_cModelFlux" 

117 

118 self.process.buildActions.mag = ConvertFluxToMag(vectorKey="r_cModelFlux") 

119 

120 self.process.calculateActions.wPerp_cmodelFlux = StellarLocusFitAction() 

121 self.process.calculateActions.wPerp_cmodelFlux.stellarLocusFitDict = { 

122 "xMin": 0.28, 

123 "xMax": 1.0, 

124 "yMin": 0.02, 

125 "yMax": 0.48, 

126 "mHW": 0.52, 

127 "bHW": -0.08, 

128 } 

129 

130 self.process.calculateActions.approxMagDepth = ApproxFloor(vectorKey="mag") 

131 

132 self.produce.metric.units = { 

133 "wPerp_cmodelFlux_sigmaMAD": "mmag", 

134 "wPerp_cmodelFlux_median": "mmag", 

135 } 

136 

137 self.produce.plot = ColorColorFitPlot() 

138 self.produce.plot.xAxisLabel = "g - r (CModel) [mags]" 

139 self.produce.plot.yAxisLabel = "r - i (CModel) [mags]" 

140 self.produce.plot.magLabel = "CModel Mag" 

141 self.produce.plot.plotName = "wPerp_cmodelFlux" 

142 

143 

144class XPerpPSF(StellarLocusBase): 

145 def setDefaults(self): 

146 super().setDefaults() 

147 self.prep.selectors.flagSelector.bands = ["g", "r", "i"] 

148 self.prep.selectors.snSelector.bands = ["r"] 

149 self.prep.selectors.snSelector.fluxType = "{band}_psfFlux" 

150 

151 self.prep.selectors.starSelector.vectorKey = "r_extendedness" 

152 

153 self.process.buildActions.x.magDiff.col1 = "g_psfFlux" 

154 self.process.buildActions.x.magDiff.col2 = "r_psfFlux" 

155 

156 self.process.buildActions.y.magDiff.col1 = "r_psfFlux" 

157 self.process.buildActions.y.magDiff.col2 = "i_psfFlux" 

158 

159 self.process.buildActions.mag = ConvertFluxToMag(vectorKey="r_psfFlux") 

160 

161 self.process.calculateActions.xPerp_psfFlux = StellarLocusFitAction() 

162 self.process.calculateActions.xPerp_psfFlux.stellarLocusFitDict = { 

163 "xMin": 1.05, 

164 "xMax": 1.55, 

165 "yMin": 0.78, 

166 "yMax": 1.62, 

167 "mHW": 13.35, 

168 "bHW": -15.54, 

169 } 

170 

171 self.process.calculateActions.approxMagDepth = ApproxFloor(vectorKey="mag") 

172 

173 self.produce.metric.units = { 

174 "xPerp_psfFlux_sigmaMAD": "mmag", 

175 "xPerp_psfFlux_median": "mmag", 

176 } 

177 self.produce.plot = ColorColorFitPlot() 

178 self.produce.plot.xAxisLabel = "g - r (PSF) [mags]" 

179 self.produce.plot.yAxisLabel = "r - i (PSF) [mags]" 

180 self.produce.plot.magLabel = "PSF Mag" 

181 self.produce.plot.plotName = "xPerp_psfFlux" 

182 

183 

184class XPerpCModel(XPerpPSF): 

185 def setDefaults(self): 

186 super().setDefaults() 

187 self.prep.selectors.snSelector.fluxType = "{band}_cModelFlux" 

188 

189 self.process.buildActions.x.magDiff.col1 = "g_cModelFlux" 

190 self.process.buildActions.x.magDiff.col2 = "r_cModelFlux" 

191 

192 self.process.buildActions.y.magDiff.col1 = "r_cModelFlux" 

193 self.process.buildActions.y.magDiff.col2 = "i_cModelFlux" 

194 

195 self.process.calculateActions.xPerp_cmodelFlux = StellarLocusFitAction() 

196 self.process.calculateActions.xPerp_cmodelFlux.stellarLocusFitDict = { 

197 "xMin": 1.05, 

198 "xMax": 1.55, 

199 "yMin": 0.78, 

200 "yMax": 1.62, 

201 "mHW": 13.35, 

202 "bHW": -15.54, 

203 } 

204 

205 self.process.buildActions.mag = ConvertFluxToMag(vectorKey="r_cModelFlux") 

206 

207 self.produce.metric.units = { # type: ignore 

208 "xPerp_cmodelFlux_sigmaMAD": "mmag", 

209 "xPerp_cmodelFlux_median": "mmag", 

210 } 

211 

212 self.produce.plot = ColorColorFitPlot() 

213 self.produce.plot.xAxisLabel = "g - r (CModel) [mags]" 

214 self.produce.plot.yAxisLabel = "r - i (CModel) [mags]" 

215 self.produce.plot.magLabel = "CModel Mag" 

216 self.produce.plot.plotName = "xPerp_cmodelFlux" 

217 

218 

219class YPerpPSF(StellarLocusBase): 

220 def setDefaults(self): 

221 super().setDefaults() 

222 self.prep.selectors.flagSelector.bands = ["r", "i", "z"] 

223 self.prep.selectors.snSelector.bands = ["i"] 

224 self.prep.selectors.snSelector.fluxType = "{band}_psfFlux" 

225 

226 self.prep.selectors.starSelector.vectorKey = "i_extendedness" 

227 

228 self.process.buildActions.x.magDiff.col1 = "r_psfFlux" 

229 self.process.buildActions.x.magDiff.col2 = "i_psfFlux" 

230 

231 self.process.buildActions.y.magDiff.col1 = "i_psfFlux" 

232 self.process.buildActions.y.magDiff.col2 = "z_psfFlux" 

233 

234 self.process.buildActions.mag = ConvertFluxToMag(vectorKey="i_psfFlux") 

235 

236 self.process.calculateActions.yPerp_psfFlux = StellarLocusFitAction() 

237 self.process.calculateActions.yPerp_psfFlux.stellarLocusFitDict = { 

238 "xMin": 0.82, 

239 "xMax": 2.01, 

240 "yMin": 0.37, 

241 "yMax": 0.90, 

242 "mHW": 0.40, 

243 "bHW": 0.03, 

244 } 

245 

246 self.process.calculateActions.approxMagDepth = ApproxFloor(vectorKey="mag") 

247 

248 self.produce.metric.units = { 

249 "yPerp_psfFlux_sigmaMAD": "mmag", 

250 "yPerp_psfFlux_median": "mmag", 

251 } 

252 

253 self.produce.plot = ColorColorFitPlot() 

254 self.produce.plot.xAxisLabel = "r - i (PSF) [mags]" 

255 self.produce.plot.yAxisLabel = "i - z (PSF) [mags]" 

256 self.produce.plot.magLabel = "PSF Mag" 

257 self.produce.plot.plotName = "yPerp_psfFlux" 

258 

259 

260class YPerpCModel(YPerpPSF): 

261 def setDefaults(self): 

262 super().setDefaults() 

263 self.prep.selectors.snSelector.fluxType = "{band}_cModelFlux" 

264 

265 self.process.buildActions.x.magDiff.col1 = "r_cModelFlux" 

266 self.process.buildActions.x.magDiff.col2 = "i_cModelFlux" 

267 

268 self.process.buildActions.y.magDiff.col1 = "i_cModelFlux" 

269 self.process.buildActions.y.magDiff.col2 = "z_cModelFlux" 

270 

271 self.process.buildActions.mag = ConvertFluxToMag(vectorKey="i_cModelFlux") 

272 

273 self.process.calculateActions.yPerp_cmodelFlux = StellarLocusFitAction() 

274 self.process.calculateActions.yPerp_cmodelFlux.stellarLocusFitDict = { 

275 "xMin": 0.82, 

276 "xMax": 2.01, 

277 "yMin": 0.37, 

278 "yMax": 0.90, 

279 "mHW": 0.40, 

280 "bHW": 0.03, 

281 } 

282 

283 self.produce.metric.units = { # type: ignore 

284 "yPerp_cmodelFlux_sigmaMAD": "mmag", 

285 "yPerp_cmodelFlux_median": "mmag", 

286 } 

287 

288 self.produce.plot = ColorColorFitPlot() 

289 self.produce.plot.xAxisLabel = "r - i (CModel) [mags]" 

290 self.produce.plot.yAxisLabel = "i - z (CModel) [mags]" 

291 self.produce.plot.magLabel = "CModel Mag" 

292 self.produce.plot.plotName = "yPerp_cmodelFlux"