Coverage for tests/test_assemble_cell_coadd.py: 47%

39 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-03-28 04:32 -0700

1# This file is part of drp_tasks. 

2# 

3# LSST Data Management System 

4# This product includes software developed by the 

5# LSST Project (http://www.lsst.org/). 

6# See COPYRIGHT file at the top of the source tree. 

7# 

8# This program is free software: you can redistribute it and/or modify 

9# it under the terms of the GNU General Public License as published by 

10# the Free Software Foundation, either version 3 of the License, or 

11# (at your option) any later version. 

12# 

13# This program is distributed in the hope that it will be useful, 

14# but WITHOUT ANY WARRANTY; without even the implied warranty of 

15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

16# GNU General Public License for more details. 

17# 

18# You should have received a copy of the LSST License Statement and 

19# the GNU General Public License along with this program. If not, 

20# see <https://www.lsstcorp.org/LegalNotices/>. 

21# 

22 

23import unittest 

24 

25import lsst.pipe.base as pipeBase 

26import lsst.utils.tests 

27from assemble_coadd_test_utils import MockCoaddTestData, makeMockSkyInfo 

28from lsst.drp.tasks.assemble_cell_coadd import AssembleCellCoaddConfig, AssembleCellCoaddTask 

29 

30__all__ = ( 

31 "MockAssembleCellCoaddConfig", 

32 "MockAssembleCellCoaddTask", 

33) 

34 

35 

36class MockAssembleCellCoaddConfig(AssembleCellCoaddConfig): 

37 pass 

38 

39 

40class MockAssembleCellCoaddTask(AssembleCellCoaddTask): 

41 """Lightly modified version of `AssembleCellCoaddTask` for unit tests. 

42 

43 The modifications bypass the usual middleware for loading data and setting 

44 up the Task, and instead supply in-memory mock data references to the `run` 

45 method so that the coaddition algorithms can be tested without a Butler. 

46 """ 

47 

48 ConfigClass = MockAssembleCellCoaddConfig 

49 

50 def runQuantum(self, mockSkyInfo, warpRefList): 

51 """Modified interface for testing coaddition algorithms without a 

52 Butler. 

53 

54 Parameters 

55 ---------- 

56 mockSkyInfo : `lsst.pipe.base.Struct` 

57 A simple container that supplies a bounding box and WCS in the 

58 same format as the output of 

59 `lsst.pipe.tasks.CoaddBaseTask.getSkyInfo` 

60 warpRefList : `list` of `lsst.pipe.tasks.MockExposureReference` 

61 Data references to the test exposures that will be coadded, 

62 using the Gen 3 API. 

63 

64 Returns 

65 ------- 

66 retStruct : `lsst.pipe.base.Struct` 

67 The coadded exposure and associated metadata. 

68 """ 

69 

70 self.common = pipeBase.Struct( 

71 units=None, 

72 wcs=mockSkyInfo.wcs, 

73 band="i", 

74 identifiers=pipeBase.Struct(skymap=None, tract=0, patch=42, band="i"), 

75 ) 

76 

77 retStruct = self.run( 

78 warpRefList, 

79 mockSkyInfo, 

80 ) 

81 

82 return retStruct 

83 

84 

85class AssembleCellCoaddTestCase(lsst.utils.tests.TestCase): 

86 """Tests of AssembleCellCoaddTask. 

87 

88 These tests bypass the middleware used for accessing data and managing Task 

89 execution. 

90 """ 

91 

92 def setUp(self): 

93 patch = 42 

94 tract = 0 

95 testData = MockCoaddTestData(fluxRange=1e4) 

96 exposures = {} 

97 matchedExposures = {} 

98 for expId in range(100, 110): 

99 exposures[expId], matchedExposures[expId] = testData.makeTestImage(expId) 

100 self.dataRefList = testData.makeDataRefList( 

101 exposures, matchedExposures, "direct", patch=patch, tract=tract 

102 ) 

103 self.skyInfo = makeMockSkyInfo(testData.bbox, testData.wcs, patch=patch) 

104 

105 def checkRun(self, assembleTask): 

106 """Check that the task runs successfully.""" 

107 result = assembleTask.runQuantum(self.skyInfo, self.dataRefList) 

108 

109 # Check that we produced an exposure. 

110 self.assertTrue(result.multipleCellCoadd is not None) 

111 

112 def testAssembleBasic(self): 

113 """Test that AssembleCellCoaddTask runs successfully without errors. 

114 

115 This test does not check the correctness of the coaddition algorithms. 

116 This is intended to prevent the code from bit rotting. 

117 """ 

118 config = MockAssembleCellCoaddConfig() 

119 assembleTask = MockAssembleCellCoaddTask(config=config) 

120 self.checkRun(assembleTask) 

121 

122 

123class MyMemoryTestCase(lsst.utils.tests.MemoryTestCase): 

124 pass 

125 

126 

127def setup_module(module): 

128 lsst.utils.tests.init() 

129 

130 

131if __name__ == "__main__": 131 ↛ 132line 131 didn't jump to line 132, because the condition on line 131 was never true

132 lsst.utils.tests.init() 

133 unittest.main()