Coverage for python/lsst/pipe/tasks/rewrite_images/_rewrite_lazy_coadd.py: 0%

28 statements  

« prev     ^ index     » next       coverage.py v7.17.0, created at 2026-11-02 10:16 +0000

1# This file is part of pipe_tasks. 

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/>. 

21 

22from __future__ import annotations 

23 

24__all__ = ("RewriteLazyCoaddConnections", "RewriteLazyCoaddTask", "RewriteLazyCoaddConfig") 

25 

26from typing import ClassVar 

27 

28import lsst.pipe.base.connectionTypes as cT 

29from lsst.afw.image import Exposure as LegacyExposure 

30from lsst.daf.butler import DataCoordinate 

31from lsst.images.cells import CellCoadd 

32from lsst.pex.config import Field 

33from lsst.pipe.base import ( 

34 InputQuantizedConnection, 

35 OutputQuantizedConnection, 

36 PipelineTask, 

37 PipelineTaskConfig, 

38 PipelineTaskConnections, 

39 QuantumContext, 

40 Struct, 

41) 

42from lsst.skymap import BaseSkyMap 

43 

44 

45class RewriteLazyCoaddConnections( 

46 PipelineTaskConnections, 

47 dimensions={"patch", "band"}, 

48 defaultTemplates={"legacy_prefix": "legacy_", "future_prefix": ""}, 

49): 

50 legacy_exposure = cT.Input( 

51 "{legacy_prefix}template_coadd", 

52 storageClass="ExposureF", 

53 dimensions={"patch", "band"}, 

54 doc="The lazy-PSF Exposure coadd to convert.", 

55 ) 

56 sky_map = cT.Input( 

57 doc="Description of the skymap's tracts and patches.", 

58 name=BaseSkyMap.SKYMAP_DATASET_TYPE_NAME, 

59 storageClass="SkyMap", 

60 dimensions=("skymap",), 

61 ) 

62 future_cell_coadd = cT.Output( 

63 "{future_prefix}template_coadd", 

64 storageClass="CellCoadd", 

65 dimensions={"patch", "band"}, 

66 doc="The output CellCoadd.", 

67 ) 

68 

69 config: RewriteLazyCoaddConfig 

70 

71 

72class RewriteLazyCoaddConfig( 

73 PipelineTaskConfig, 

74 pipelineConnections=RewriteLazyCoaddConnections, 

75): 

76 instrument = Field( 

77 "Name of the instrument assumed for all inputs to this coadd.", 

78 dtype=str, 

79 default="LSSTCam", 

80 ) 

81 

82 

83class RewriteLazyCoaddTask(PipelineTask): 

84 ConfigClass: ClassVar[type[RewriteLazyCoaddConfig]] = RewriteLazyCoaddConfig 

85 config: RewriteLazyCoaddConfig 

86 _DefaultName = "rewriteLazyCoadd" 

87 

88 def runQuantum( 

89 self, 

90 butlerQC: QuantumContext, 

91 inputRefs: InputQuantizedConnection, 

92 outputRefs: OutputQuantizedConnection, 

93 ) -> None: 

94 inputs = butlerQC.get(inputRefs) 

95 outputs = self.run(**inputs, data_id=butlerQC.quantum.dataId) 

96 butlerQC.put(outputs, outputRefs) 

97 

98 def run( 

99 self, 

100 legacy_exposure: LegacyExposure, 

101 sky_map: BaseSkyMap, 

102 data_id: DataCoordinate, 

103 ) -> Struct: 

104 future_cell_coadd = CellCoadd.from_legacy_lazy_coadd( 

105 legacy_exposure, 

106 instrument=self.config.instrument, 

107 tract_info=sky_map[data_id["tract"]], 

108 patch=data_id["patch"], 

109 band=data_id["band"], 

110 ) 

111 return Struct(future_cell_coadd=future_cell_coadd)