Coverage for python/lsst/analysis/tools/tasks/ccdVisitTableAnalysis.py: 51%
37 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-01-10 12:16 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2023-01-10 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__ = ("CcdVisitTableAnalysisTask",)
25from lsst.cp.pipe._lookupStaticCalibration import lookupStaticCalibration
26from lsst.daf.butler import DataCoordinate
27from lsst.pex.config import Field
28from lsst.pipe.base import connectionTypes as cT
29from lsst.skymap import BaseSkyMap
31from .base import AnalysisBaseConfig, AnalysisBaseConnections, AnalysisPipelineTask
34class CcdVisitTableAnalysisConnections(
35 AnalysisBaseConnections,
36 dimensions=("skymap", "instrument"),
37 defaultTemplates={"outputName": "ccdVisitTable"},
38):
39 data = cT.Input(
40 doc="Collection based source table to load from the butler.",
41 name="ccdVisitTable",
42 storageClass="DataFrame",
43 deferLoad=True,
44 dimensions=("instrument",),
45 )
46 calibrateConfig = cT.Input(
47 doc="Collection based calibrate task config to load from the butler.",
48 name="calibrate_config",
49 storageClass="Config",
50 dimensions=(),
51 )
52 makeWarpConfig = cT.Input(
53 doc="Collection based makeWarp task config to load from the butler.",
54 name="makeWarp_config",
55 storageClass="Config",
56 dimensions=(),
57 )
58 skymap = cT.Input(
59 doc="Input definition of geometry/bbox and projection/wcs for warped exposures.",
60 name=BaseSkyMap.SKYMAP_DATASET_TYPE_NAME,
61 storageClass="SkyMap",
62 dimensions=("skymap",),
63 )
64 camera = cT.PrerequisiteInput(
65 doc="Input camera to use for focal plane geometry.",
66 name="camera",
67 storageClass="Camera",
68 dimensions=("instrument",),
69 isCalibration=True,
70 lookupFunction=lookupStaticCalibration,
71 )
73 def __init__(self, *, config=None):
74 super().__init__(config=config)
75 # No metrics are computed for this task, so remove output dataset.
76 self.outputs.remove("metrics")
77 if not config.introspectMakeWarpConfig:
78 self.inputs.remove("makeWarpConfig")
81class CcdVisitTableAnalysisConfig(AnalysisBaseConfig, pipelineConnections=CcdVisitTableAnalysisConnections):
82 introspectMakeWarpConfig = Field[bool](
83 doc="Whether to introspect the makeWarp_config dataset to obtain the actual "
84 "maxEllipResidual and maxScalesSizeScatter thresholds in this run? Set to "
85 "False if makeWarp has not yet been run on given collection.",
86 default=True,
87 )
90class CcdVisitTableAnalysisTask(AnalysisPipelineTask):
91 ConfigClass = CcdVisitTableAnalysisConfig
92 _DefaultName = "ccdVisitTableAnalysisTask"
94 def runQuantum(self, butlerQC, inputRefs, outputRefs):
95 # Docs inherited from base class.
96 inputs = butlerQC.get(inputRefs)
97 dataId = butlerQC.quantum.dataId
98 if dataId is not None:
99 dataId = DataCoordinate.standardize(dataId, universe=butlerQC.registry.dimensions)
100 plotInfo = self.parsePlotInfo(inputs, dataId)
101 data = self.loadData(inputs["data"])
102 skymap = None if "skymap" not in inputs.keys() else inputs["skymap"]
103 camera = None if "camera" not in inputs.keys() else inputs["camera"]
104 calibrateConfig = inputs["calibrateConfig"]
105 makeWarpConfig = None if "makeWarpConfig" not in inputs.keys() else inputs["makeWarpConfig"]
107 outputs = self.run(
108 data=data,
109 plotInfo=plotInfo,
110 camera=camera,
111 skymap=skymap,
112 calibrateConfig=calibrateConfig,
113 makeWarpConfig=makeWarpConfig,
114 )
115 butlerQC.put(outputs, outputRefs)