Hide keyboard shortcuts

Hot-keys 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

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_id="1038843", 

42 observation_type="science", 

43 observation_reason="science", 

44 physical_filter="i.MP9702", 

45 pressure=617.65*u.hPa, 

46 relative_humidity=39.77, 

47 science_program="08BL05", 

48 temperature=0.9*u.deg_C, 

49 visit_id=1038843, 

50 )), 

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

52 dict(telescope="CFHT 3.6m", 

53 instrument="MegaPrime", 

54 boresight_rotation_coord="sky", 

55 boresight_rotation_angle=0*u.degree, 

56 dark_time=300.0*u.s, 

57 detector_exposure_id=30577599, 

58 detector_name="ccd99", 

59 detector_unique_name="ccd99", 

60 detector_num=99, 

61 detector_serial="8434-13-5", 

62 exposure_id=849375, 

63 exposure_group="849375", 

64 exposure_time=300.202*u.s, 

65 object="D3", 

66 observation_id="849375", 

67 observation_type="science", 

68 observation_reason="science", 

69 physical_filter="r", 

70 pressure=615.79*u.hPa, 

71 relative_humidity=15.76, 

72 science_program="06AL01", 

73 temperature=1.75*u.deg_C, 

74 visit_id=849375, 

75 )), 

76 ) 

77 for file, expected in test_data: 

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

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

80 

81 def test_megaprime_stripping(self): 

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

83 v1 = ObservationInfo(header) 

84 

85 # Check that headers have been removed 

86 new_hdr = v1.stripped_header() 

87 self.assertNotIn("INSTRUME", new_hdr) 

88 self.assertNotIn("TELESCOP", new_hdr) 

89 self.assertIn("CCD", new_hdr) 

90 

91 

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

93 unittest.main()