Coverage for python/lsst/analysis/tools/atools/astrometryWithReference.py: 34%
77 statements
« prev ^ index » next coverage.py v7.2.3, created at 2023-04-28 10:26 +0000
« prev ^ index » next coverage.py v7.2.3, created at 2023-04-28 10:26 +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 "TargetRefCatDeltaRAScatterPlot",
25 "TargetRefCatDeltaDecScatterPlot",
26 "TargetRefCatDeltaRASkyPlot",
27 "TargetRefCatDeltaDecSkyPlot",
28)
30from lsst.pex.config import Field
32from ..actions.plot.scatterplotWithTwoHists import ScatterPlotStatsAction, ScatterPlotWithTwoHists
33from ..actions.plot.skyPlot import SkyPlot
34from ..actions.vector import (
35 AstromDiff,
36 DownselectVector,
37 LoadVector,
38 MagColumnNanoJansky,
39 SnSelector,
40 StarSelector,
41 VectorSelector,
42)
43from ..interfaces import AnalysisTool
44from .genericPrep import CoaddPrep, VisitPrep
47class TargetRefCatDelta(AnalysisTool):
48 """Plot the difference in milliseconds between a target catalog and a
49 reference catalog for the coordinate set in `setDefaults`.
50 """
52 parameterizedBand = Field[bool](
53 doc="Does this AnalysisTool support band as a name parameter", default=True
54 )
56 def coaddContext(self) -> None:
57 self.prep = CoaddPrep()
58 self.process.buildActions.starSelector.vectorKey = "{band}_extendedness"
59 self.process.buildActions.mags = MagColumnNanoJansky(vectorKey="{band}_psfFlux")
60 self.process.filterActions.psfFlux = DownselectVector(
61 vectorKey="{band}_psfFlux", selector=VectorSelector(vectorKey="starSelector")
62 )
63 self.process.filterActions.psfFluxErr = DownselectVector(
64 vectorKey="{band}_psfFluxErr", selector=VectorSelector(vectorKey="starSelector")
65 )
67 def visitContext(self) -> None:
68 self.parameterizedBand = False
69 self.prep = VisitPrep()
70 self.process.buildActions.starSelector.vectorKey = "extendedness"
71 self.process.buildActions.mags = MagColumnNanoJansky(vectorKey="psfFlux")
72 self.process.filterActions.psfFlux = DownselectVector(
73 vectorKey="psfFlux", selector=VectorSelector(vectorKey="starSelector")
74 )
75 self.process.filterActions.psfFluxErr = DownselectVector(
76 vectorKey="psfFluxErr", selector=VectorSelector(vectorKey="starSelector")
77 )
79 def setDefaults(self, coordinate):
80 super().setDefaults()
82 self.process.buildActions.starSelector = StarSelector()
83 coordStr = coordinate.lower()
84 self.process.buildActions.astromDiff = AstromDiff(
85 col1=f"coord_{coordStr}_target", col2=f"coord_{coordStr}_ref"
86 )
88 self.process.filterActions.xStars = DownselectVector(
89 vectorKey="mags", selector=VectorSelector(vectorKey="starSelector")
90 )
91 self.process.filterActions.yStars = DownselectVector(
92 vectorKey="astromDiff", selector=VectorSelector(vectorKey="starSelector")
93 )
95 self.process.calculateActions.stars = ScatterPlotStatsAction(vectorKey="yStars")
96 self.process.calculateActions.stars.lowSNSelector.fluxType = "psfFlux"
97 self.process.calculateActions.stars.highSNSelector.fluxType = "psfFlux"
98 self.process.calculateActions.stars.fluxType = "psfFlux"
100 self.produce.plot = ScatterPlotWithTwoHists()
102 self.produce.plot.plotTypes = ["stars"]
103 self.produce.plot.xAxisLabel = "PSF Magnitude (mag)"
104 self.produce.plot.yAxisLabel = f"${coordinate}_{{target}} - {coordinate}_{{ref}}$ (marcsec)"
105 self.produce.plot.magLabel = "PSF Magnitude (mag)"
108class TargetRefCatDeltaRAScatterPlot(TargetRefCatDelta):
109 """Plot the difference in milliseconds between the RA of a target catalog
110 and a reference catalog
111 """
113 def setDefaults(self):
114 super().setDefaults(coordinate="RA")
117class TargetRefCatDeltaDecScatterPlot(TargetRefCatDelta):
118 """Plot the difference in milliseconds between the Dec of a target catalog
119 and a reference catalog
120 """
122 def setDefaults(self):
123 super().setDefaults(coordinate="Dec")
126class TargetRefCatDeltaSkyPlot(AnalysisTool):
127 """Base class for plotting the RA/Dec distribution of stars, with the
128 difference between the RA or Dec of the target and reference catalog as
129 the color.
130 """
132 parameterizedBand = Field[bool](
133 doc="Does this AnalysisTool support band as a name parameter", default=True
134 )
136 def coaddContext(self) -> None:
137 self.prep = CoaddPrep()
139 self.process.buildActions.starStatMask = SnSelector()
140 self.process.buildActions.starStatMask.fluxType = "{band}_psfFlux"
142 def visitContext(self) -> None:
143 self.parameterizedBand = False
144 self.prep = VisitPrep()
146 self.process.buildActions.starStatMask = SnSelector()
147 self.process.buildActions.starStatMask.fluxType = "psfFlux"
149 def setDefaults(self, coordinate):
150 super().setDefaults()
152 coordStr = coordinate.lower()
153 self.process.buildActions.zStars = AstromDiff(
154 col1=f"coord_{coordStr}_target", col2=f"coord_{coordStr}_ref"
155 )
156 self.process.buildActions.xStars = LoadVector()
157 self.process.buildActions.xStars.vectorKey = "coord_ra_target"
158 self.process.buildActions.yStars = LoadVector()
159 self.process.buildActions.yStars.vectorKey = "coord_dec_target"
161 self.produce = SkyPlot()
162 self.produce.plotTypes = ["stars"]
163 self.produce.plotName = f"astromDiffSky_{coordinate}"
164 self.produce.xAxisLabel = "R.A. (degrees)"
165 self.produce.yAxisLabel = "Dec. (degrees)"
166 self.produce.zAxisLabel = f"${coordinate}_{{target}} - {coordinate}_{{ref}}$ (marcsec)"
167 self.produce.plotOutlines = False
170class TargetRefCatDeltaRASkyPlot(TargetRefCatDeltaSkyPlot):
171 """Plot the difference in milliseconds between the RA of a target catalog
172 and a reference catalog as a function of RA and Dec.
173 """
175 def setDefaults(self):
176 super().setDefaults(coordinate="RA")
179class TargetRefCatDeltaDecSkyPlot(TargetRefCatDeltaSkyPlot):
180 """Plot the difference in milliseconds between the Dec of a target catalog
181 and a reference catalog as a function of RA and Dec.
182 """
184 def setDefaults(self):
185 super().setDefaults(coordinate="Dec")