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