Coverage for python/lsst/source/injection/inject_coadd.py: 61%

21 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-12-01 14:07 +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/>. 

21 

22from __future__ import annotations 

23 

24__all__ = ["CoaddInjectConnections", "CoaddInjectConfig", "CoaddInjectTask"] 

25 

26from lsst.pipe.base.connectionTypes import Input, Output 

27 

28from .inject_base import BaseInjectConfig, BaseInjectConnections, BaseInjectTask 

29 

30 

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

39 

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 ) 

58 

59 

60class CoaddInjectConfig( # type: ignore [call-arg] 

61 BaseInjectConfig, 

62 pipelineConnections=CoaddInjectConnections, 

63): 

64 """Coadd-level configuration for source injection tasks.""" 

65 

66 pass 

67 

68 

69class CoaddInjectTask(BaseInjectTask): 

70 """Coadd-level class for injecting sources into images.""" 

71 

72 _DefaultName = "coaddInjectTask" 

73 ConfigClass = CoaddInjectConfig 

74 

75 def runQuantum(self, butler_quantum_context, input_refs, output_refs): 

76 inputs = butler_quantum_context.get(input_refs) 

77 

78 inputs["psf"] = inputs["input_exposure"].getPsf() 

79 inputs["photo_calib"] = inputs["input_exposure"].getPhotoCalib() 

80 inputs["wcs"] = inputs["input_exposure"].getWcs() 

81 

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)