Coverage for tests/test_cfht.py: 47%

22 statements  

« prev     ^ index     » next       coverage.py v6.4, created at 2022-06-02 03:27 -0700

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 datadir = os.path.join(TESTDIR, "data") 

25 

26 def test_megaprime_translator(self): 

27 test_data = ( 

28 ( 

29 "fitsheader-megaprime.yaml", 

30 dict( 

31 telescope="CFHT 3.6m", 

32 instrument="MegaPrime", 

33 boresight_rotation_coord="sky", 

34 boresight_rotation_angle=0 * u.degree, 

35 dark_time=615.0 * u.s, 

36 detector_exposure_id=37398350, 

37 detector_name="ccd02", 

38 detector_unique_name="ccd02", 

39 detector_num=2, 

40 detector_serial="8352-15-3", 

41 exposure_id=1038843, 

42 exposure_group="1038843", 

43 exposure_time=615.037 * u.s, 

44 group_counter_end=1038843, 

45 group_counter_start=1038843, 

46 has_simulated_content=False, 

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

48 observation_counter=1038843, 

49 observation_id="1038843", 

50 observation_type="science", 

51 observation_reason="science", 

52 observing_day=20081101, 

53 physical_filter="i.MP9702", 

54 pressure=617.65 * u.hPa, 

55 relative_humidity=39.77, 

56 science_program="08BL05", 

57 temperature=0.9 * u.deg_C, 

58 visit_id=1038843, 

59 ), 

60 ), 

61 ( 

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

63 dict( 

64 telescope="CFHT 3.6m", 

65 instrument="MegaPrime", 

66 boresight_rotation_coord="sky", 

67 boresight_rotation_angle=0 * u.degree, 

68 dark_time=300.0 * u.s, 

69 detector_exposure_id=30577599, 

70 detector_name="ccd99", 

71 detector_unique_name="ccd99", 

72 detector_num=99, 

73 detector_serial="8434-13-5", 

74 exposure_id=849375, 

75 exposure_group="849375", 

76 exposure_time=300.202 * u.s, 

77 group_counter_end=849375, 

78 group_counter_start=849375, 

79 has_simulated_content=False, 

80 object="D3", 

81 observation_counter=849375, 

82 observation_id="849375", 

83 observation_type="science", 

84 observation_reason="science", 

85 observing_day=20060520, 

86 physical_filter="r", 

87 pressure=615.79 * u.hPa, 

88 relative_humidity=15.76, 

89 science_program="06AL01", 

90 temperature=1.75 * u.deg_C, 

91 visit_id=849375, 

92 ), 

93 ), 

94 ) 

95 for file, expected in test_data: 

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

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

98 

99 def test_megaprime_stripping(self): 

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

101 v1 = ObservationInfo(header) 

102 

103 # Check that headers have been removed 

104 new_hdr = v1.stripped_header() 

105 self.assertNotIn("INSTRUME", new_hdr) 

106 self.assertNotIn("TELESCOP", new_hdr) 

107 self.assertIn("CCD", new_hdr) 

108 

109 

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

111 unittest.main()