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 CatalogMeasurementBaseConfig, CatalogMeasurementBaseTask
24__all__ = ("TractMeasurementConnections", "TractMeasurementConfig",
25 "TractMeasurementTask",
26 "TractMultiBandMeasurementConnections", "TractMultiBandMeasurementConfig",
27 "TractMultiBandMeasurementTask")
30class TractMeasurementConnections(MetricConnections,
31 dimensions=("tract", "skymap",
32 "band"),
33 defaultTemplates={"coaddName": "deepCoadd",
34 "photoCalibName": "deepCoadd_calexp.photoCalib",
35 "wcsName": "deepCoadd_calexp.wcs"}):
37 catalogs = pipeBase.connectionTypes.Input(doc="Object catalog.",
38 dimensions=("tract", "patch",
39 "skymap", "band"),
40 storageClass="SourceCatalog",
41 name="deepCoadd_forced_src",
42 multiple=True)
44 photoCalibs = pipeBase.connectionTypes.Input(doc="Photometric calibration object.",
45 dimensions=("tract", "patch",
46 "skymap", "band"),
47 storageClass="PhotoCalib",
48 name="{photoCalibName}",
49 multiple=True)
51 astromCalibs = pipeBase.connectionTypes.Input(doc="WCS for the catalog.",
52 dimensions=("tract", "patch",
53 "skymap", "band"),
54 storageClass="Wcs",
55 name="{wcsName}",
56 multiple=True)
58 measurement = pipeBase.connectionTypes.Output(doc="Per-tract measurement.",
59 dimensions=("tract", "skymap",
60 "band"),
61 storageClass="MetricValue",
62 name="metricvalue_{package}_{metric}")
65class TractMeasurementConfig(CatalogMeasurementBaseConfig,
66 pipelineConnections=TractMeasurementConnections):
67 pass
70class TractMeasurementTask(CatalogMeasurementBaseTask):
72 ConfigClass = TractMeasurementConfig
73 _DefaultName = "tractMeasurementTask"
75 def run(self, catalogs, photoCalibs, astromCalibs, dataIds):
76 return self.measure.run(self.config.connections.metric, catalogs, photoCalibs, astromCalibs, dataIds)
78 def runQuantum(self, butlerQC, inputRefs, outputRefs):
79 inputs = butlerQC.get(inputRefs)
80 inputs['dataIds'] = [butlerQC.registry.expandDataId(cat.dataId) for cat in inputRefs.catalogs]
81 outputs = self.run(**inputs)
82 if outputs.measurement is not None:
83 butlerQC.put(outputs, outputRefs)
84 else:
85 self.log.debug("Skipping measurement of {!r} on {} "
86 "as not applicable.", self, inputRefs)
89class TractMultiBandMeasurementConnections(TractMeasurementConnections,
90 dimensions=("tract", "skymap"),
91 defaultTemplates={"coaddName": "deepCoadd", "photoCalibName":
92 "deepCoadd_calexp.photoCalib"}):
94 cat = pipeBase.connectionTypes.Input(doc="Object catalog.",
95 dimensions=("tract", "skymap", "patch",
96 "band"),
97 storageClass="SourceCatalog",
98 name="deepCoadd_forced_src",
99 multiple=True)
101 photoCalibs = pipeBase.connectionTypes.Input(doc="Photometric calibration object.",
102 dimensions=("tract", "skymap",
103 "patch", "band"),
104 storageClass="PhotoCalib",
105 name="{photoCalibName}",
106 multiple=True)
108 measurement = pipeBase.connectionTypes.Output(doc="Per-tract measurement.",
109 dimensions=("tract", "skymap"),
110 storageClass="MetricValue",
111 name="metricvalue_{package}_{metric}")
114class TractMultiBandMeasurementConfig(CatalogMeasurementBaseConfig,
115 pipelineConnections=TractMultiBandMeasurementConnections):
116 pass
119class TractMultiBandMeasurementTask(TractMeasurementTask):
121 ConfigClass = TractMultiBandMeasurementConfig
122 _DefaultName = "tractMultiBandMeasurementTask"