Coverage for python/lsst/faro/measurement/TractMeasurement.py : 69%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# This product includes software developed by the LSST Project
2# (https://www.lsst.org).
3# See the COPYRIGHT file at the top-level directory of this distribution
4# for details of code ownership.
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program. If not, see <https://www.gnu.org/licenses/>.
19import lsst.pipe.base as pipeBase
20from lsst.verify.tasks import MetricConnections
22from lsst.faro.base.CatalogMeasurementBase import (
23 CatalogMeasurementBaseConfig,
24 CatalogMeasurementBaseTask,
25)
27__all__ = (
28 "TractMeasurementConnections",
29 "TractMeasurementConfig",
30 "TractMeasurementTask",
31 "TractMultiBandMeasurementConnections",
32 "TractMultiBandMeasurementConfig",
33 "TractMultiBandMeasurementTask",
34)
37class TractMeasurementConnections(
38 MetricConnections,
39 dimensions=("tract", "skymap", "band"),
40 defaultTemplates={
41 "coaddName": "deepCoadd",
42 "photoCalibName": "deepCoadd_calexp.photoCalib",
43 "wcsName": "deepCoadd_calexp.wcs",
44 },
45):
47 catalogs = pipeBase.connectionTypes.Input(
48 doc="Object catalog.",
49 dimensions=("tract", "patch", "skymap", "band"),
50 storageClass="SourceCatalog",
51 name="deepCoadd_forced_src",
52 multiple=True,
53 )
55 photoCalibs = pipeBase.connectionTypes.Input(
56 doc="Photometric calibration object.",
57 dimensions=("tract", "patch", "skymap", "band"),
58 storageClass="PhotoCalib",
59 name="{photoCalibName}",
60 multiple=True,
61 )
63 astromCalibs = pipeBase.connectionTypes.Input(
64 doc="WCS for the catalog.",
65 dimensions=("tract", "patch", "skymap", "band"),
66 storageClass="Wcs",
67 name="{wcsName}",
68 multiple=True,
69 )
71 measurement = pipeBase.connectionTypes.Output(
72 doc="Per-tract measurement.",
73 dimensions=("tract", "skymap", "band"),
74 storageClass="MetricValue",
75 name="metricvalue_{package}_{metric}",
76 )
79class TractMeasurementConfig(
80 CatalogMeasurementBaseConfig, pipelineConnections=TractMeasurementConnections
81):
82 pass
85class TractMeasurementTask(CatalogMeasurementBaseTask):
87 ConfigClass = TractMeasurementConfig
88 _DefaultName = "tractMeasurementTask"
90 def run(self, catalogs, photoCalibs, astromCalibs, dataIds):
91 return self.measure.run(
92 self.config.connections.metric, catalogs, photoCalibs, astromCalibs, dataIds
93 )
95 def runQuantum(self, butlerQC, inputRefs, outputRefs):
96 inputs = butlerQC.get(inputRefs)
97 inputs["dataIds"] = [
98 butlerQC.registry.expandDataId(cat.dataId) for cat in inputRefs.catalogs
99 ]
100 outputs = self.run(**inputs)
101 if outputs.measurement is not None:
102 butlerQC.put(outputs, outputRefs)
103 else:
104 self.log.debug(
105 "Skipping measurement of {!r} on {} " "as not applicable.",
106 self,
107 inputRefs,
108 )
111class TractMultiBandMeasurementConnections(
112 TractMeasurementConnections,
113 dimensions=("tract", "skymap"),
114 defaultTemplates={
115 "coaddName": "deepCoadd",
116 "photoCalibName": "deepCoadd_calexp.photoCalib",
117 },
118):
120 cat = pipeBase.connectionTypes.Input(
121 doc="Object catalog.",
122 dimensions=("tract", "skymap", "patch", "band"),
123 storageClass="SourceCatalog",
124 name="deepCoadd_forced_src",
125 multiple=True,
126 )
128 photoCalibs = pipeBase.connectionTypes.Input(
129 doc="Photometric calibration object.",
130 dimensions=("tract", "skymap", "patch", "band"),
131 storageClass="PhotoCalib",
132 name="{photoCalibName}",
133 multiple=True,
134 )
136 measurement = pipeBase.connectionTypes.Output(
137 doc="Per-tract measurement.",
138 dimensions=("tract", "skymap"),
139 storageClass="MetricValue",
140 name="metricvalue_{package}_{metric}",
141 )
144class TractMultiBandMeasurementConfig(
145 CatalogMeasurementBaseConfig,
146 pipelineConnections=TractMultiBandMeasurementConnections,
147):
148 pass
151class TractMultiBandMeasurementTask(TractMeasurementTask):
153 ConfigClass = TractMultiBandMeasurementConfig
154 _DefaultName = "tractMultiBandMeasurementTask"