Coverage for tests/test_cfht.py: 46%

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 

14import astropy.units as u 

15 

16from astro_metadata_translator.tests import read_test_file, MetadataAssertHelper 

17from astro_metadata_translator import ObservationInfo 

18 

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

20 

21 

22class MegaPrimeTestCase(unittest.TestCase, MetadataAssertHelper): 

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

24 

25 def test_megaprime_translator(self): 

26 test_data = (("fitsheader-megaprime.yaml", 

27 dict(telescope="CFHT 3.6m", 

28 instrument="MegaPrime", 

29 boresight_rotation_coord="sky", 

30 boresight_rotation_angle=0*u.degree, 

31 dark_time=615.0*u.s, 

32 detector_exposure_id=37398350, 

33 detector_name="ccd02", 

34 detector_unique_name="ccd02", 

35 detector_num=2, 

36 detector_serial="8352-15-3", 

37 exposure_id=1038843, 

38 exposure_group="1038843", 

39 exposure_time=615.037*u.s, 

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

41 observation_counter=1038843, 

42 observation_id="1038843", 

43 observation_type="science", 

44 observation_reason="science", 

45 observing_day=20081101, 

46 physical_filter="i.MP9702", 

47 pressure=617.65*u.hPa, 

48 relative_humidity=39.77, 

49 science_program="08BL05", 

50 temperature=0.9*u.deg_C, 

51 visit_id=1038843, 

52 )), 

53 ("fitsheader-megaprime-calexp-849375-14.yaml", 

54 dict(telescope="CFHT 3.6m", 

55 instrument="MegaPrime", 

56 boresight_rotation_coord="sky", 

57 boresight_rotation_angle=0*u.degree, 

58 dark_time=300.0*u.s, 

59 detector_exposure_id=30577599, 

60 detector_name="ccd99", 

61 detector_unique_name="ccd99", 

62 detector_num=99, 

63 detector_serial="8434-13-5", 

64 exposure_id=849375, 

65 exposure_group="849375", 

66 exposure_time=300.202*u.s, 

67 object="D3", 

68 observation_counter=849375, 

69 observation_id="849375", 

70 observation_type="science", 

71 observation_reason="science", 

72 observing_day=20060520, 

73 physical_filter="r", 

74 pressure=615.79*u.hPa, 

75 relative_humidity=15.76, 

76 science_program="06AL01", 

77 temperature=1.75*u.deg_C, 

78 visit_id=849375, 

79 )), 

80 ) 

81 for file, expected in test_data: 

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

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

84 

85 def test_megaprime_stripping(self): 

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

87 v1 = ObservationInfo(header) 

88 

89 # Check that headers have been removed 

90 new_hdr = v1.stripped_header() 

91 self.assertNotIn("INSTRUME", new_hdr) 

92 self.assertNotIn("TELESCOP", new_hdr) 

93 self.assertIn("CCD", new_hdr) 

94 

95 

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

97 unittest.main()