Coverage for python/lsst/analysis/tools/atools/stellarLocus.py: 14%
145 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-05 12:16 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-05 12:16 +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
23__all__ = (
24 "StellarLocusBase",
25 "WPerpPSF",
26 "WPerpCModel",
27 "XPerpPSF",
28 "XPerpCModel",
29 "YPerpPSF",
30 "YPerpCModel",
31)
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 MagSelector,
41 SnSelector,
42 StarSelector,
43)
44from ..interfaces import AnalysisTool
47class StellarLocusBase(AnalysisTool):
48 # Use this as the Base Class for now StellarLocusBaseMetric
49 parameterizedBand: bool = False
51 def setDefaults(self):
52 super().setDefaults()
53 self.prep.selectors.flagSelector = CoaddPlotFlagSelector()
55 self.prep.selectors.snSelector = SnSelector()
56 self.prep.selectors.snSelector.threshold = 300
58 self.prep.selectors.magSelector = MagSelector()
59 self.prep.selectors.magSelector.maxMag = 22.5
61 self.prep.selectors.starSelector1 = StarSelector()
62 self.prep.selectors.starSelector2 = StarSelector()
63 self.prep.selectors.starSelector3 = StarSelector()
65 self.process.buildActions.x = ExtinctionCorrectedMagDiff()
66 self.process.buildActions.x.magDiff.returnMillimags = False
67 self.process.buildActions.y = ExtinctionCorrectedMagDiff()
68 self.process.buildActions.y.magDiff.returnMillimags = False
70 self.process.calculateActions.approxMagDepth = ApproxFloor(vectorKey="mag")
72 self.produce.plot = ColorColorFitPlot()
75class WPerpPSF(StellarLocusBase):
76 def setDefaults(self):
77 super().setDefaults()
78 colorBands = ["g", "r", "i"]
79 fluxType = "psfFlux"
80 self.prep.selectors.flagSelector.bands = colorBands
81 self.prep.selectors.snSelector.bands = ["r"]
82 self.prep.selectors.snSelector.fluxType = "{band}_" + fluxType
83 self.prep.selectors.magSelector.bands = ["r"]
84 self.prep.selectors.magSelector.fluxType = "{band}_" + fluxType
86 self.prep.selectors.starSelector1.vectorKey = colorBands[0] + "_extendedness"
87 self.prep.selectors.starSelector2.vectorKey = colorBands[1] + "_extendedness"
88 self.prep.selectors.starSelector3.vectorKey = colorBands[2] + "_extendedness"
90 self.process.buildActions.x.magDiff.col1 = colorBands[0] + "_" + fluxType
91 self.process.buildActions.x.magDiff.col2 = colorBands[1] + "_" + fluxType
92 self.process.buildActions.y.magDiff.col1 = colorBands[1] + "_" + fluxType
93 self.process.buildActions.y.magDiff.col2 = colorBands[2] + "_" + fluxType
94 self.process.buildActions.mag = ConvertFluxToMag(vectorKey=colorBands[1] + "_" + fluxType)
96 self.process.calculateActions.wPerp_psfFlux = StellarLocusFitAction()
97 stellarLocusFitDict = {
98 "xMin": 0.28,
99 "xMax": 1.0,
100 "yMin": 0.02,
101 "yMax": 0.48,
102 # The "fixed" values were roughly derived from w_2023_50 HSC-RC2
103 # processing (DM-42194). See commit message for further details.
104 "mFixed": 0.483,
105 "bFixed": -0.042,
106 }
107 for item in stellarLocusFitDict.items():
108 self.process.calculateActions.wPerp_psfFlux.stellarLocusFitDict.update([item])
110 self.produce.metric.units = {
111 "wPerp_psfFlux_sigmaMAD": "mmag",
112 "wPerp_psfFlux_median": "mmag",
113 }
115 self.produce.plot.xAxisLabel = "{} - {} ({}) [mags]".format(
116 colorBands[0], colorBands[1], fluxType.replace("Flux", "")
117 )
118 self.produce.plot.yAxisLabel = "{} - {} ({}) [mags]".format(
119 colorBands[1], colorBands[2], fluxType.replace("Flux", "")
120 )
121 self.produce.plot.xLims = (-0.7, 1.99)
122 self.produce.plot.yLims = (-0.7, 2.49)
123 self.produce.plot.magLabel = "{} {}_Mag".format(
124 self.prep.selectors.magSelector.bands[0], fluxType.replace("Flux", "")
125 )
126 self.produce.plot.plotName = "wPerp_" + fluxType
129class WPerpCModel(WPerpPSF):
130 def setDefaults(self):
131 super().setDefaults()
132 colorBands = ["g", "r", "i"]
133 fluxType = "cModelFlux"
135 self.prep.selectors.snSelector.fluxType = "{band}_" + fluxType
136 self.prep.selectors.magSelector.fluxType = "{band}_" + fluxType
138 self.process.buildActions.x.magDiff.col1 = colorBands[0] + "_" + fluxType
139 self.process.buildActions.x.magDiff.col2 = colorBands[1] + "_" + fluxType
140 self.process.buildActions.y.magDiff.col1 = colorBands[1] + "_" + fluxType
141 self.process.buildActions.y.magDiff.col2 = colorBands[2] + "_" + fluxType
142 self.process.buildActions.mag = ConvertFluxToMag(vectorKey=colorBands[1] + "_" + fluxType)
144 self.process.calculateActions.wPerp_cModelFlux = StellarLocusFitAction()
145 stellarLocusFitDict = {
146 "xMin": 0.28,
147 "xMax": 1.0,
148 "yMin": 0.02,
149 "yMax": 0.48,
150 # The "fixed" values were roughly derived from w_2023_50 HSC-RC2
151 # processing (DM-42194). See commit message for further details.
152 "mFixed": 0.483,
153 "bFixed": -0.042,
154 }
155 for item in stellarLocusFitDict.items():
156 self.process.calculateActions.wPerp_cModelFlux.stellarLocusFitDict.update([item])
158 self.produce.metric.units = {
159 "wPerp_cModelFlux_sigmaMAD": "mmag",
160 "wPerp_cModelFlux_median": "mmag",
161 }
163 self.produce.plot.xAxisLabel = "{} - {} ({}) [mags]".format(
164 colorBands[0], colorBands[1], fluxType.replace("Flux", "")
165 )
166 self.produce.plot.yAxisLabel = "{} - {} ({}) [mags]".format(
167 colorBands[1], colorBands[2], fluxType.replace("Flux", "")
168 )
169 self.produce.plot.magLabel = "{} {}_Mag".format(
170 self.prep.selectors.magSelector.bands[0], fluxType.replace("Flux", "")
171 )
172 self.produce.plot.plotName = "wPerp_" + fluxType
175class XPerpPSF(WPerpPSF):
176 def setDefaults(self):
177 super().setDefaults()
178 fluxType = "psfFlux"
180 self.process.calculateActions.xPerp_psfFlux = StellarLocusFitAction()
181 stellarLocusFitDict = {
182 "xMin": 1.05,
183 "xMax": 1.55,
184 "yMin": 0.78,
185 "yMax": 1.62,
186 # The "fixed" values were roughly derived from w_2023_50 HSC-RC2
187 # processing (DM-42194). See commit message for further details.
188 "mFixed": 60.0,
189 "bFixed": -75.0,
190 }
191 for item in stellarLocusFitDict.items():
192 self.process.calculateActions.xPerp_psfFlux.stellarLocusFitDict.update([item])
194 self.produce.metric.units = {
195 "xPerp_psfFlux_sigmaMAD": "mmag",
196 "xPerp_psfFlux_median": "mmag",
197 }
198 self.produce.plot.plotName = "xPerp_" + fluxType
201class XPerpCModel(WPerpCModel):
202 def setDefaults(self):
203 super().setDefaults()
204 fluxType = "cModelFlux"
206 self.process.calculateActions.xPerp_cModelFlux = StellarLocusFitAction()
207 stellarLocusFitDict = {
208 "xMin": 1.05,
209 "xMax": 1.55,
210 "yMin": 0.78,
211 "yMax": 1.62,
212 # The "fixed" values were roughly derived from w_2023_50 HSC-RC2
213 # processing (DM-42194). See commit message for further details.
214 "mFixed": 60.0,
215 "bFixed": -75.0,
216 }
217 for item in stellarLocusFitDict.items():
218 self.process.calculateActions.xPerp_cModelFlux.stellarLocusFitDict.update([item])
220 self.produce.metric.units = {
221 "xPerp_cModelFlux_sigmaMAD": "mmag",
222 "xPerp_cModelFlux_median": "mmag",
223 }
224 self.produce.plot.plotName = "xPerp_" + fluxType
227class YPerpPSF(StellarLocusBase):
228 def setDefaults(self):
229 super().setDefaults()
231 colorBands = ["r", "i", "z"]
232 fluxType = "psfFlux"
233 self.prep.selectors.flagSelector.bands = colorBands
234 self.prep.selectors.snSelector.bands = ["i"]
235 self.prep.selectors.snSelector.fluxType = "{band}_" + fluxType
236 self.prep.selectors.magSelector.bands = ["i"]
237 self.prep.selectors.magSelector.fluxType = "{band}_" + fluxType
239 self.prep.selectors.starSelector1.vectorKey = colorBands[0] + "_extendedness"
240 self.prep.selectors.starSelector2.vectorKey = colorBands[1] + "_extendedness"
241 self.prep.selectors.starSelector3.vectorKey = colorBands[2] + "_extendedness"
243 self.process.buildActions.x.magDiff.col1 = colorBands[0] + "_" + fluxType
244 self.process.buildActions.x.magDiff.col2 = colorBands[1] + "_" + fluxType
245 self.process.buildActions.y.magDiff.col1 = colorBands[1] + "_" + fluxType
246 self.process.buildActions.y.magDiff.col2 = colorBands[2] + "_" + fluxType
247 self.process.buildActions.mag = ConvertFluxToMag(vectorKey=colorBands[1] + "_" + fluxType)
249 self.process.calculateActions.yPerp_psfFlux = StellarLocusFitAction()
250 stellarLocusFitDict = {
251 "xMin": 0.82,
252 "xMax": 2.01,
253 "yMin": 0.37,
254 "yMax": 0.90,
255 # The "fixed" values were roughly derived from w_2023_50 HSC-RC2
256 # processing (DM-42194). See commit message for further details.
257 "mFixed": 0.385,
258 "bFixed": 0.064,
259 }
260 for item in stellarLocusFitDict.items():
261 self.process.calculateActions.yPerp_psfFlux.stellarLocusFitDict.update([item])
263 self.produce.metric.units = {
264 "yPerp_psfFlux_sigmaMAD": "mmag",
265 "yPerp_psfFlux_median": "mmag",
266 }
268 self.produce.plot.xAxisLabel = "{} - {} ({}) [mags]".format(
269 colorBands[0], colorBands[1], fluxType.replace("Flux", "")
270 )
271 self.produce.plot.yAxisLabel = "{} - {} ({}) [mags]".format(
272 colorBands[1], colorBands[2], fluxType.replace("Flux", "")
273 )
274 self.produce.plot.xLims = (-0.8, 3.59)
275 self.produce.plot.yLims = (-0.5, 1.49)
276 self.produce.plot.magLabel = "{} {}_Mag".format(
277 self.prep.selectors.magSelector.bands[0], fluxType.replace("Flux", "")
278 )
279 self.produce.plot.plotName = "yPerp_psfFlux"
282class YPerpCModel(YPerpPSF):
283 def setDefaults(self):
284 super().setDefaults()
285 colorBands = ["r", "i", "z"]
286 fluxType = "cModelFlux"
288 self.prep.selectors.snSelector.fluxType = "{band}_" + fluxType
289 self.prep.selectors.magSelector.fluxType = "{band}_" + fluxType
291 self.process.buildActions.x.magDiff.col1 = colorBands[0] + "_" + fluxType
292 self.process.buildActions.x.magDiff.col2 = colorBands[1] + "_" + fluxType
293 self.process.buildActions.y.magDiff.col1 = colorBands[1] + "_" + fluxType
294 self.process.buildActions.y.magDiff.col2 = colorBands[2] + "_" + fluxType
295 self.process.buildActions.mag = ConvertFluxToMag(vectorKey=colorBands[1] + "_" + fluxType)
297 self.process.calculateActions.yPerp_cModelFlux = StellarLocusFitAction()
298 stellarLocusFitDict = {
299 "xMin": 0.82,
300 "xMax": 2.01,
301 "yMin": 0.37,
302 "yMax": 0.90,
303 # The "fixed" values were roughly derived from w_2023_50 HSC-RC2
304 # processing (DM-42194). See commit message for further details.
305 "mFixed": 0.385,
306 "bFixed": 0.064,
307 }
308 for item in stellarLocusFitDict.items():
309 self.process.calculateActions.yPerp_cModelFlux.stellarLocusFitDict.update([item])
311 self.produce.metric.units = {
312 "yPerp_cModelFlux_sigmaMAD": "mmag",
313 "yPerp_cModelFlux_median": "mmag",
314 }
316 self.produce.plot.xAxisLabel = "{} - {} ({}) [mags]".format(
317 colorBands[0], colorBands[1], fluxType.replace("Flux", "")
318 )
319 self.produce.plot.yAxisLabel = "{} - {} ({}) [mags]".format(
320 colorBands[1], colorBands[2], fluxType.replace("Flux", "")
321 )
322 self.produce.plot.magLabel = "{} {}_Mag".format(
323 self.prep.selectors.magSelector.bands[0], fluxType.replace("Flux", "")
324 )
325 self.produce.plot.plotName = "yPerp_" + fluxType