Coverage for tests/test_camera.py: 41%

35 statements  

« prev     ^ index     » next       coverage.py v7.2.1, created at 2023-03-12 03:48 -0700

1# 

2# LSST Data Management System 

3# 

4# Copyright 2008-2016 AURA/LSST. 

5# 

6# This product includes software developed by the 

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

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 LSST License Statement and 

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

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

22# 

23import unittest 

24from collections import namedtuple 

25 

26import lsst.utils.tests 

27from lsst.afw.image import Filter 

28from lsst.obs.hsc import HscMapper 

29 

30 

31class CameraTestCase(lsst.utils.tests.TestCase): 

32 

33 def setUp(self): 

34 self.mapper = HscMapper(root=".", calibRoot=".") 

35 self.camera = self.mapper.camera 

36 

37 def tearDown(self): 

38 del self.camera 

39 del self.mapper 

40 

41 def testName(self): 

42 self.assertEqual(self.camera.getName(), "HSC") 

43 

44 def testNumCcds(self): 

45 self.assertEqual(len(list(self.camera.getIdIter())), 112) 

46 

47 def testCcdSize(self): 

48 for ccd in self.camera: 

49 self.assertEqual(ccd.getBBox().getWidth(), 2048) 

50 self.assertEqual(ccd.getBBox().getHeight(), 4176) 

51 

52 def testFilters(self): 

53 # Check that the mapper has defined some standard filters. 

54 # Note that this list is not intended to be comprehensive -- we 

55 # anticipate that more filters can be added without causing the test 

56 # to break -- but captures the standard HSC broad-band filters. 

57 FilterName = namedtuple("FilterName", ["alias", "canonical"]) 

58 filterNames = ( 

59 FilterName(alias="HSC-G", canonical="g"), 

60 FilterName(alias="HSC-R", canonical="r"), 

61 FilterName(alias="HSC-I", canonical="i"), 

62 FilterName(alias="HSC-Z", canonical="z"), 

63 FilterName(alias="HSC-Y", canonical="y"), 

64 FilterName(alias="unknown", canonical="unknown") 

65 ) 

66 

67 for filterName in filterNames: 

68 self.assertIn(filterName.alias, self.mapper.filters) 

69 self.assertEqual(Filter(filterName.alias).getCanonicalName(), filterName.canonical) 

70 

71 

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

73 def setUp(self): 

74 HscMapper.clearCache() 

75 lsst.utils.tests.MemoryTestCase.setUp(self) 

76 

77 

78def setup_module(module): 

79 lsst.utils.tests.init() 

80 

81 

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

83 lsst.utils.tests.init() 

84 unittest.main()