Coverage for tests/test_cfht.py: 50%

Shortcuts on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

22 statements  

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 object="w2.+2+2", 

45 observation_counter=1038843, 

46 observation_id="1038843", 

47 observation_type="science", 

48 observation_reason="science", 

49 observing_day=20081101, 

50 physical_filter="i.MP9702", 

51 pressure=617.65 * u.hPa, 

52 relative_humidity=39.77, 

53 science_program="08BL05", 

54 temperature=0.9 * u.deg_C, 

55 visit_id=1038843, 

56 ), 

57 ), 

58 ( 

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

60 dict( 

61 telescope="CFHT 3.6m", 

62 instrument="MegaPrime", 

63 boresight_rotation_coord="sky", 

64 boresight_rotation_angle=0 * u.degree, 

65 dark_time=300.0 * u.s, 

66 detector_exposure_id=30577599, 

67 detector_name="ccd99", 

68 detector_unique_name="ccd99", 

69 detector_num=99, 

70 detector_serial="8434-13-5", 

71 exposure_id=849375, 

72 exposure_group="849375", 

73 exposure_time=300.202 * u.s, 

74 object="D3", 

75 observation_counter=849375, 

76 observation_id="849375", 

77 observation_type="science", 

78 observation_reason="science", 

79 observing_day=20060520, 

80 physical_filter="r", 

81 pressure=615.79 * u.hPa, 

82 relative_humidity=15.76, 

83 science_program="06AL01", 

84 temperature=1.75 * u.deg_C, 

85 visit_id=849375, 

86 ), 

87 ), 

88 ) 

89 for file, expected in test_data: 

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

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

92 

93 def test_megaprime_stripping(self): 

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

95 v1 = ObservationInfo(header) 

96 

97 # Check that headers have been removed 

98 new_hdr = v1.stripped_header() 

99 self.assertNotIn("INSTRUME", new_hdr) 

100 self.assertNotIn("TELESCOP", new_hdr) 

101 self.assertIn("CCD", new_hdr) 

102 

103 

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

105 unittest.main()