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