Coverage for python/lsst/analysis/tools/atools/astrometricRepeatability.py: 24%
84 statements
« prev ^ index » next coverage.py v7.2.6, created at 2023-05-24 02:36 -0700
« prev ^ index » next coverage.py v7.2.6, created at 2023-05-24 02:36 -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
23__all__ = (
24 "StellarAstrometricResidualsRAFocalPlanePlot",
25 "StellarAstrometricResidualsDecFocalPlanePlot",
26 "StellarAstrometricResidualStdDevRAFocalPlanePlot",
27 "StellarAstrometricResidualStdDevDecFocalPlanePlot",
28 "StellarAstrometricResidualsRASkyPlot",
29 "StellarAstrometricResidualsDecSkyPlot",
30)
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
48class StellarAstrometricResidualsBase(AnalysisTool):
49 """Plot mean astrometric residuals.
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 """
57 def setDefaults(self):
58 super().setDefaults()
60 # Apply per-source selection criteria
61 self.prep.selectors.bandSelector = BandSelector()
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"
68 self.process.buildActions.residual.buildAction = ResidualWithPerGroupStatistic()
70 self.process.buildActions.x = LoadVector(vectorKey="x")
71 self.process.buildActions.y = LoadVector(vectorKey="y")
73 self.process.buildActions.detector = LoadVector(vectorKey="detector")
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 )
91 self.process.buildActions.statMask = SnSelector()
92 self.process.buildActions.statMask.threshold = 0
93 self.process.buildActions.statMask.fluxType = "psfFlux"
96class StellarAstrometricResidualsRASkyPlot(StellarAstrometricResidualsBase):
97 """Plot mean astrometric residuals in RA as a function of the position in
98 RA and Dec.
99 """
101 def setDefaults(self):
102 super().setDefaults()
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")
109 self.produce = SkyPlot()
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}$"
118class StellarAstrometricResidualsDecSkyPlot(StellarAstrometricResidualsBase):
119 """Plot mean astrometric residuals in RA as a function of the position in
120 RA and Dec.
121 """
123 def setDefaults(self):
124 super().setDefaults()
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")
131 self.produce = SkyPlot()
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}$"
140class StellarAstrometricResidualsRAFocalPlanePlot(StellarAstrometricResidualsBase):
141 """Plot mean astrometric residuals in RA as a function of the focal plane
142 position.
143 """
145 def setDefaults(self):
146 super().setDefaults()
148 # Compute per-group quantities
149 self.process.buildActions.residual.buildAction.buildAction = RAcosDec()
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)"
157class StellarAstrometricResidualStdDevRAFocalPlanePlot(StellarAstrometricResidualsBase):
158 """Plot mean astrometric residuals in RA as a function of the focal plane
159 position.
160 """
162 def setDefaults(self):
163 super().setDefaults()
165 # Compute per-group quantities
166 self.process.buildActions.residual.buildAction.buildAction = RAcosDec()
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)"
175class StellarAstrometricResidualsDecFocalPlanePlot(StellarAstrometricResidualsBase):
176 """Plot mean astrometric residuals in RA as a function of the focal plane
177 position.
178 """
180 def setDefaults(self):
181 super().setDefaults()
183 # Compute per-group quantities
184 self.process.buildActions.residual.buildAction.buildAction.vectorKey = "coord_dec"
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)"
192class StellarAstrometricResidualStdDevDecFocalPlanePlot(StellarAstrometricResidualsBase):
193 """Plot mean astrometric residuals in RA as a function of the focal plane
194 position.
195 """
197 def setDefaults(self):
198 super().setDefaults()
200 # Compute per-group quantities
201 self.process.buildActions.residual.buildAction.buildAction.vectorKey = "coord_dec"
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)"