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 physical_filter="i.MP9702", 

44 pressure=617.65*u.hPa, 

45 relative_humidity=39.77, 

46 science_program="08BL05", 

47 temperature=0.9*u.deg_C, 

48 visit_id=1038843, 

49 )), 

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

51 dict(telescope="CFHT 3.6m", 

52 instrument="MegaPrime", 

53 boresight_rotation_coord="sky", 

54 boresight_rotation_angle=0*u.degree, 

55 dark_time=300.0*u.s, 

56 detector_exposure_id=30577599, 

57 detector_name="ccd99", 

58 detector_unique_name="ccd99", 

59 detector_num=99, 

60 detector_serial="8434-13-5", 

61 exposure_id=849375, 

62 exposure_group="849375", 

63 exposure_time=300.202*u.s, 

64 object="D3", 

65 observation_id="849375", 

66 observation_type="science", 

67 physical_filter="r", 

68 pressure=615.79*u.hPa, 

69 relative_humidity=15.76, 

70 science_program="06AL01", 

71 temperature=1.75*u.deg_C, 

72 visit_id=849375, 

73 )), 

74 ) 

75 for file, expected in test_data: 

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

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

78 

79 def test_megaprime_stripping(self): 

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

81 v1 = ObservationInfo(header) 

82 

83 # Check that headers have been removed 

84 new_hdr = v1.stripped_header() 

85 self.assertNotIn("INSTRUME", new_hdr) 

86 self.assertNotIn("TELESCOP", new_hdr) 

87 self.assertIn("CCD", new_hdr) 

88 

89 

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

91 unittest.main()