Coverage for tests/test_bestEffortIsr.py: 40%

44 statements  

« prev     ^ index     » next       coverage.py v7.4.1, created at 2024-02-09 14:32 +0000

1# This file is part of summit_utils. 

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 

22import unittest 

23 

24import lsst.utils.tests 

25 

26from lsst.summit.utils.bestEffort import BestEffortIsr 

27from lsst.summit.utils.quickLook import QuickLookIsrTask 

28import lsst.summit.utils.butlerUtils as butlerUtils 

29import lsst.afw.image as afwImage 

30 

31 

32class BestEffortIsrTestCase(lsst.utils.tests.TestCase): 

33 

34 @classmethod 

35 def setUpClass(cls): 

36 try: 

37 cls.bestEffortIsr = BestEffortIsr() 

38 except FileNotFoundError: 

39 raise unittest.SkipTest("Skipping tests that require the LATISS butler repo.") 

40 

41 # chosen as this is available in the following locations - collections: 

42 # NCSA - LATISS/raw/all 

43 # TTS - LATISS-test-data-tts 

44 # summit - LATISS_test_data 

45 cls.dataId = {'day_obs': 20210121, 'seq_num': 743, 'detector': 0} 

46 

47 def test_getExposure(self): 

48 # in most locations this will load a pre-made image 

49 exp = self.bestEffortIsr.getExposure(self.dataId) 

50 self.assertIsInstance(exp, afwImage.Exposure) 

51 

52 # this will always actually run isr with whatever calibs are available 

53 exp = self.bestEffortIsr.getExposure(self.dataId, forceRemake=True) 

54 self.assertIsInstance(exp, afwImage.Exposure) 

55 

56 def test_getExposureFromExpRecord(self): 

57 """Test getting with an expRecord. This requires also passing in 

58 the detector number as a kwarg. 

59 """ 

60 expRecord = butlerUtils.getExpRecordFromDataId(self.bestEffortIsr.butler, self.dataId) 

61 

62 exp = self.bestEffortIsr.getExposure(expRecord, detector=0) 

63 self.assertIsInstance(exp, afwImage.Exposure) 

64 

65 # and then again with just the dataCoordinate 

66 exp = self.bestEffortIsr.getExposure(expRecord.dataId, detector=0) 

67 self.assertIsInstance(exp, afwImage.Exposure) 

68 

69 # Try forceRemake with an expRecord and a detector as a kwarg 

70 # as forceRemake has a different code path, as it has to get a raw 

71 exp = self.bestEffortIsr.getExposure(expRecord.dataId, detector=0, forceRemake=True) 

72 self.assertIsInstance(exp, afwImage.Exposure) 

73 

74 def test_raises(self): 

75 """Ensure function cannot be called without specifying a detector. 

76 """ 

77 dataId = self.dataId 

78 dataId.pop('detector') 

79 with self.assertRaises(ValueError): 

80 self.bestEffortIsr.getExposure(dataId) 

81 

82 def test_quicklook_connections(self): 

83 """Test that various QuickLookIsrConnections inputs are no longer 

84 required. 

85 """ 

86 connections = QuickLookIsrTask.ConfigClass.ConnectionsClass(config=QuickLookIsrTask.ConfigClass()) 

87 self.assertEqual(connections.bias.minimum, 0) 

88 self.assertEqual(connections.flat.minimum, 0) 

89 self.assertEqual(connections.ccdExposure.minimum, 1) 

90 

91 

92class TestMemory(lsst.utils.tests.MemoryTestCase): 

93 pass 

94 

95 

96def setup_module(module): 

97 lsst.utils.tests.init() 

98 

99 

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

101 lsst.utils.tests.init() 

102 unittest.main()