Coverage for python/lsst/analysis/tools/tasks/ccdVisitTableAnalysis.py: 54%

33 statements  

« prev     ^ index     » next       coverage.py v7.4.3, created at 2024-02-24 11:17 +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 

22 

23__all__ = ("CcdVisitTableAnalysisConfig", "CcdVisitTableAnalysisTask") 

24 

25from lsst.pex.config import Field 

26from lsst.pipe.base import connectionTypes as cT 

27from lsst.skymap import BaseSkyMap 

28 

29from ..interfaces import AnalysisBaseConfig, AnalysisBaseConnections, AnalysisPipelineTask 

30 

31 

32class CcdVisitTableAnalysisConnections( 

33 AnalysisBaseConnections, 

34 dimensions=("skymap", "instrument"), 

35 defaultTemplates={"outputName": "ccdVisitTable"}, 

36): 

37 data = cT.Input( 

38 doc="Collection based source table to load from the butler.", 

39 name="ccdVisitTable", 

40 storageClass="ArrowAstropy", 

41 deferLoad=True, 

42 dimensions=("instrument",), 

43 ) 

44 calibrateConfig = cT.Input( 

45 doc="Collection based calibrate task config to load from the butler.", 

46 name="calibrate_config", 

47 storageClass="Config", 

48 dimensions=(), 

49 ) 

50 makeWarpConfig = cT.Input( 

51 doc="Collection based makeWarp task config to load from the butler.", 

52 name="makeWarp_config", 

53 storageClass="Config", 

54 dimensions=(), 

55 ) 

56 skymap = cT.Input( 

57 doc="Input definition of geometry/bbox and projection/wcs for warped exposures.", 

58 name=BaseSkyMap.SKYMAP_DATASET_TYPE_NAME, 

59 storageClass="SkyMap", 

60 dimensions=("skymap",), 

61 ) 

62 camera = cT.PrerequisiteInput( 

63 doc="Input camera to use for focal plane geometry.", 

64 name="camera", 

65 storageClass="Camera", 

66 dimensions=("instrument",), 

67 isCalibration=True, 

68 ) 

69 

70 def __init__(self, *, config=None): 

71 super().__init__(config=config) 

72 # No metrics are computed for this task, so remove output dataset. 

73 self.outputs.remove("metrics") 

74 if not config.introspectMakeWarpConfig: 

75 self.inputs.remove("makeWarpConfig") 

76 

77 

78class CcdVisitTableAnalysisConfig(AnalysisBaseConfig, pipelineConnections=CcdVisitTableAnalysisConnections): 

79 introspectMakeWarpConfig = Field[bool]( 

80 doc="Whether to introspect the makeWarp_config dataset to obtain the actual " 

81 "maxEllipResidual and maxScalesSizeScatter thresholds in this run? Set to " 

82 "False if makeWarp has not yet been run on given collection.", 

83 default=True, 

84 ) 

85 

86 

87class CcdVisitTableAnalysisTask(AnalysisPipelineTask): 

88 ConfigClass = CcdVisitTableAnalysisConfig 

89 _DefaultName = "ccdVisitTableAnalysisTask" 

90 

91 def runQuantum(self, butlerQC, inputRefs, outputRefs): 

92 # Docs inherited from base class. 

93 inputs = butlerQC.get(inputRefs) 

94 dataId = butlerQC.quantum.dataId 

95 plotInfo = self.parsePlotInfo(inputs, dataId) 

96 data = self.loadData(inputs["data"]) 

97 skymap = None if "skymap" not in inputs.keys() else inputs["skymap"] 

98 camera = None if "camera" not in inputs.keys() else inputs["camera"] 

99 calibrateConfig = inputs["calibrateConfig"] 

100 makeWarpConfig = None if "makeWarpConfig" not in inputs.keys() else inputs["makeWarpConfig"] 

101 

102 outputs = self.run( 

103 data=data, 

104 plotInfo=plotInfo, 

105 camera=camera, 

106 skymap=skymap, 

107 calibrateConfig=calibrateConfig, 

108 makeWarpConfig=makeWarpConfig, 

109 ) 

110 butlerQC.put(outputs, outputRefs)