Coverage for python/lsst/source/injection/inject_coadd.py: 61%
21 statements
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-01 16:17 +0000
« prev ^ index » next coverage.py v7.4.3, created at 2024-03-01 16:17 +0000
1# This file is part of source_injection.
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/>.
22from __future__ import annotations
24__all__ = ["CoaddInjectConnections", "CoaddInjectConfig", "CoaddInjectTask"]
26from lsst.pipe.base.connectionTypes import Input, Output
28from .inject_base import BaseInjectConfig, BaseInjectConnections, BaseInjectTask
31class CoaddInjectConnections(
32 BaseInjectConnections,
33 dimensions=("skymap", "tract", "patch", "band"),
34 defaultTemplates={
35 "coadd_name": "deep",
36 },
37):
38 """Coadd-level connections for source injection tasks."""
40 input_exposure = Input(
41 doc="Exposure to inject synthetic sources into.",
42 name="{coadd_name}Coadd",
43 storageClass="ExposureF",
44 dimensions=("skymap", "tract", "patch", "band"),
45 )
46 output_exposure = Output(
47 doc="Injected Exposure.",
48 name="{injected_prefix}{coadd_name}Coadd",
49 storageClass="ExposureF",
50 dimensions=("skymap", "tract", "patch", "band"),
51 )
52 output_catalog = Output(
53 doc="Catalog of injected sources.",
54 name="{injected_prefix}{coadd_name}Coadd_catalog",
55 storageClass="ArrowAstropy",
56 dimensions=("skymap", "tract", "patch", "band"),
57 )
60class CoaddInjectConfig( # type: ignore [call-arg]
61 BaseInjectConfig,
62 pipelineConnections=CoaddInjectConnections,
63):
64 """Coadd-level configuration for source injection tasks."""
66 pass
69class CoaddInjectTask(BaseInjectTask):
70 """Coadd-level class for injecting sources into images."""
72 _DefaultName = "coaddInjectTask"
73 ConfigClass = CoaddInjectConfig
75 def runQuantum(self, butler_quantum_context, input_refs, output_refs):
76 inputs = butler_quantum_context.get(input_refs)
78 inputs["psf"] = inputs["input_exposure"].getPsf()
79 inputs["photo_calib"] = inputs["input_exposure"].getPhotoCalib()
80 inputs["wcs"] = inputs["input_exposure"].getWcs()
82 input_keys = ["injection_catalogs", "input_exposure", "sky_map", "psf", "photo_calib", "wcs"]
83 outputs = self.run(**{key: value for (key, value) in inputs.items() if key in input_keys})
84 butler_quantum_context.put(outputs, output_refs)