Coverage for tests/test_cfht.py: 43%

22 statements  

« prev     ^ index     » next       coverage.py v7.3.1, created at 2023-09-20 10:39 +0000

1# This file is part of astro_metadata_translator. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

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

6# See the LICENSE file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# Use of this source code is governed by a 3-clause BSD-style 

10# license that can be found in the LICENSE file. 

11 

12import os.path 

13import unittest 

14 

15import astropy.units as u 

16 

17from astro_metadata_translator import ObservationInfo 

18from astro_metadata_translator.tests import MetadataAssertHelper, read_test_file 

19 

20TESTDIR = os.path.abspath(os.path.dirname(__file__)) 

21 

22 

23class MegaPrimeTestCase(unittest.TestCase, MetadataAssertHelper): 

24 """Test CFHT Megaprime translations.""" 

25 

26 datadir = os.path.join(TESTDIR, "data") 

27 

28 def test_megaprime_translator(self): 

29 test_data = ( 

30 ( 

31 "fitsheader-megaprime.yaml", 

32 dict( 

33 telescope="CFHT 3.6m", 

34 instrument="MegaPrime", 

35 boresight_rotation_coord="sky", 

36 boresight_rotation_angle=0 * u.degree, 

37 dark_time=615.0 * u.s, 

38 detector_exposure_id=37398350, 

39 detector_name="ccd02", 

40 detector_unique_name="ccd02", 

41 detector_num=2, 

42 detector_serial="8352-15-3", 

43 exposure_id=1038843, 

44 exposure_group="1038843", 

45 exposure_time=615.037 * u.s, 

46 focus_z=0.0 * u.mm, # default value 

47 group_counter_end=1038843, 

48 group_counter_start=1038843, 

49 has_simulated_content=False, 

50 object="w2.+2+2", 

51 observation_counter=1038843, 

52 observation_id="1038843", 

53 observation_type="science", 

54 observation_reason="science", 

55 observing_day=20081101, 

56 physical_filter="i.MP9702", 

57 pressure=617.65 * u.hPa, 

58 relative_humidity=39.77, 

59 science_program="08BL05", 

60 temperature=0.9 * u.deg_C, 

61 visit_id=1038843, 

62 ), 

63 ), 

64 ( 

65 "fitsheader-megaprime-calexp-849375-14.yaml", 

66 dict( 

67 telescope="CFHT 3.6m", 

68 instrument="MegaPrime", 

69 boresight_rotation_coord="sky", 

70 boresight_rotation_angle=0 * u.degree, 

71 dark_time=300.0 * u.s, 

72 detector_exposure_id=30577599, 

73 detector_name="ccd99", 

74 detector_unique_name="ccd99", 

75 detector_num=99, 

76 detector_serial="8434-13-5", 

77 exposure_id=849375, 

78 exposure_group="849375", 

79 exposure_time=300.202 * u.s, 

80 focus_z=0.0 * u.mm, # default value 

81 group_counter_end=849375, 

82 group_counter_start=849375, 

83 has_simulated_content=False, 

84 object="D3", 

85 observation_counter=849375, 

86 observation_id="849375", 

87 observation_type="science", 

88 observation_reason="science", 

89 observing_day=20060520, 

90 physical_filter="r", 

91 pressure=615.79 * u.hPa, 

92 relative_humidity=15.76, 

93 science_program="06AL01", 

94 temperature=1.75 * u.deg_C, 

95 visit_id=849375, 

96 ), 

97 ), 

98 ) 

99 for file, expected in test_data: 

100 with self.subTest(f"Testing {file}"): 

101 self.assertObservationInfoFromYaml(file, self.datadir, **expected) 

102 

103 def test_megaprime_stripping(self): 

104 header = read_test_file("fitsheader-megaprime.yaml", dir=self.datadir) 

105 v1 = ObservationInfo(header) 

106 

107 # Check that headers have been removed 

108 new_hdr = v1.stripped_header() 

109 self.assertNotIn("INSTRUME", new_hdr) 

110 self.assertNotIn("TELESCOP", new_hdr) 

111 self.assertIn("CCD", new_hdr) 

112 

113 

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

115 unittest.main()