Coverage for tests/test_cfht.py: 45%
23 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-20 03:54 -0700
« prev ^ index » next coverage.py v7.4.4, created at 2024-03-20 03:54 -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.
12import os.path
13import unittest
15import astropy.time
16import astropy.units as u
18from astro_metadata_translator import ObservationInfo
19from astro_metadata_translator.tests import MetadataAssertHelper, read_test_file
21TESTDIR = os.path.abspath(os.path.dirname(__file__))
24class MegaPrimeTestCase(unittest.TestCase, MetadataAssertHelper):
25 """Test CFHT Megaprime translations."""
27 datadir = os.path.join(TESTDIR, "data")
29 def test_megaprime_translator(self):
30 test_data = (
31 (
32 "fitsheader-megaprime.yaml",
33 dict(
34 telescope="CFHT 3.6m",
35 instrument="MegaPrime",
36 boresight_rotation_coord="sky",
37 boresight_rotation_angle=0 * u.degree,
38 dark_time=615.0 * u.s,
39 detector_exposure_id=37398350,
40 detector_name="ccd02",
41 detector_unique_name="ccd02",
42 detector_num=2,
43 detector_serial="8352-15-3",
44 exposure_id=1038843,
45 exposure_group="1038843",
46 exposure_time=615.037 * u.s,
47 focus_z=0.0 * u.mm, # default value
48 group_counter_end=1038843,
49 group_counter_start=1038843,
50 has_simulated_content=False,
51 object="w2.+2+2",
52 observation_counter=1038843,
53 observation_id="1038843",
54 observation_type="science",
55 observation_reason="science",
56 observing_day=20081101,
57 observing_day_offset=astropy.time.TimeDelta(0, format="sec", scale="tai"),
58 physical_filter="i.MP9702",
59 pressure=617.65 * u.hPa,
60 relative_humidity=39.77,
61 science_program="08BL05",
62 temperature=0.9 * u.deg_C,
63 visit_id=1038843,
64 ),
65 ),
66 (
67 "fitsheader-megaprime-calexp-849375-14.yaml",
68 dict(
69 telescope="CFHT 3.6m",
70 instrument="MegaPrime",
71 boresight_rotation_coord="sky",
72 boresight_rotation_angle=0 * u.degree,
73 dark_time=300.0 * u.s,
74 detector_exposure_id=30577599,
75 detector_name="ccd99",
76 detector_unique_name="ccd99",
77 detector_num=99,
78 detector_serial="8434-13-5",
79 exposure_id=849375,
80 exposure_group="849375",
81 exposure_time=300.202 * u.s,
82 focus_z=0.0 * u.mm, # default value
83 group_counter_end=849375,
84 group_counter_start=849375,
85 has_simulated_content=False,
86 object="D3",
87 observation_counter=849375,
88 observation_id="849375",
89 observation_type="science",
90 observation_reason="science",
91 observing_day=20060520,
92 physical_filter="r",
93 pressure=615.79 * u.hPa,
94 relative_humidity=15.76,
95 science_program="06AL01",
96 temperature=1.75 * u.deg_C,
97 visit_id=849375,
98 ),
99 ),
100 )
101 for file, expected in test_data:
102 with self.subTest(f"Testing {file}"):
103 self.assertObservationInfoFromYaml(file, self.datadir, **expected)
105 def test_megaprime_stripping(self):
106 header = read_test_file("fitsheader-megaprime.yaml", dir=self.datadir)
107 v1 = ObservationInfo(header)
109 # Check that headers have been removed
110 new_hdr = v1.stripped_header()
111 self.assertNotIn("INSTRUME", new_hdr)
112 self.assertNotIn("TELESCOP", new_hdr)
113 self.assertIn("CCD", new_hdr)
116if __name__ == "__main__": 116 ↛ 117line 116 didn't jump to line 117, because the condition on line 116 was never true
117 unittest.main()