Coverage for tests / test_decam.py: 60%
13 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-28 08:38 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-28 08:38 +0000
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.tests import MetadataAssertHelper
20TESTDIR = os.path.abspath(os.path.dirname(__file__))
23class DecamTestCase(unittest.TestCase, MetadataAssertHelper):
24 """Test DECam translations."""
26 datadir = os.path.join(TESTDIR, "data")
28 def test_decam_translator(self) -> None:
29 test_data = (
30 (
31 "fitsheader-decam.yaml",
32 dict(
33 telescope="CTIO 4.0-m telescope",
34 instrument="DECam",
35 boresight_rotation_coord="sky",
36 dark_time=201.15662 * u.s,
37 detector_exposure_id=22938825,
38 detector_name="1",
39 detector_unique_name="S1",
40 detector_group="S",
41 detector_num=25,
42 detector_serial="S3-111_107419-8-3",
43 exposure_id=229388,
44 exposure_group="229388",
45 exposure_time=200.0 * u.s,
46 exposure_time_requested=200.0 * u.s,
47 focus_z=2497.32 * u.um,
48 group_counter_end=229388,
49 group_counter_start=229388,
50 has_simulated_content=False,
51 object="DES supernova hex SN-S1 tiling 22",
52 observation_counter=229388,
53 observation_id="ct4m20130901t060255",
54 observation_type="science",
55 observation_reason="science",
56 observing_day=20130831,
57 physical_filter="z DECam SDSS c0004 9260.0 1520.0",
58 pressure=779.0 * u.hPa,
59 relative_humidity=23.0,
60 science_program="2012B-0001",
61 temperature=11.9 * u.deg_C,
62 visit_id=229388,
63 wcs_params=dict(max_sep=1.5),
64 ),
65 ),
66 (
67 "fitsheader-decam-0160496.yaml",
68 dict(
69 telescope="CTIO 4.0-m telescope",
70 instrument="DECam",
71 boresight_rotation_coord="sky",
72 boresight_rotation_angle=90 * u.degree,
73 dark_time=0.0407898 * u.s,
74 detector_exposure_id=16049625,
75 detector_name="1",
76 detector_unique_name="S1",
77 detector_group="S",
78 detector_num=25,
79 detector_serial="S3-111_107419-8-3",
80 exposure_id=160496,
81 exposure_group="160496",
82 exposure_time=0.0 * u.s,
83 exposure_time_requested=0.0 * u.s,
84 focus_z=0.0 * u.um,
85 group_counter_end=160496,
86 group_counter_start=160496,
87 has_simulated_content=False,
88 object="postflats-BIAS",
89 observation_counter=160496,
90 observation_id="ct4m20121211t220632",
91 observation_type="zero",
92 observation_reason="unknown",
93 observing_day=20121211,
94 observing_day_offset=astropy.time.TimeDelta(12 * 3600, format="sec", scale="tai"),
95 physical_filter="solid plate 0.0 0.0", # corrected value
96 pressure=777.0 * u.hPa,
97 relative_humidity=38.0,
98 science_program="2012B-0416",
99 temperature=17.0 * u.deg_C,
100 visit_id=160496,
101 wcs_params=dict(max_sep=1.5),
102 ),
103 ),
104 (
105 "fitsheader-decam-calexp-0412037_10.yaml",
106 dict(
107 telescope="CTIO 4.0-m telescope",
108 instrument="DECam",
109 boresight_rotation_coord="sky",
110 boresight_rotation_angle=90 * u.degree,
111 dark_time=87.1054702 * u.s,
112 detector_exposure_id=41203701,
113 detector_name="29",
114 detector_unique_name="S29",
115 detector_group="S",
116 detector_num=1,
117 detector_serial="S3-06_123195-15-3",
118 exposure_id=412037,
119 exposure_group="412037",
120 exposure_time=86.0 * u.s,
121 exposure_time_requested=86.0 * u.s,
122 focus_z=2828.00 * u.um,
123 group_counter_end=412037,
124 group_counter_start=412037,
125 has_simulated_content=False,
126 object="Blind15A_03",
127 observation_counter=412037,
128 observation_id="ct4m20150220t004721",
129 observation_type="science",
130 observation_reason="science",
131 observing_day=20150219,
132 physical_filter="g",
133 pressure=777.0 * u.hPa,
134 relative_humidity=76.0,
135 science_program="2015A-0608",
136 temperature=9.0 * u.deg_C,
137 visit_id=412037,
138 wcs_params=dict(max_sep=5.0),
139 ),
140 ),
141 (
142 "fitsheader-decam-instcal-c4d_190402_050618_ooi_VR_v1.yaml",
143 dict(
144 telescope="CTIO 4.0-m telescope",
145 instrument="DECam",
146 boresight_rotation_coord="sky",
147 boresight_rotation_angle=90 * u.degree,
148 dark_time=120.7646399 * u.s,
149 detector_exposure_id=84529101,
150 detector_name="29",
151 detector_unique_name="S29",
152 detector_group="S",
153 detector_num=1,
154 detector_serial="S3-06_123195-15-3",
155 exposure_id=845291,
156 exposure_group="845291",
157 exposure_time=120.0 * u.s,
158 exposure_time_requested=120.0 * u.s,
159 focus_z=2174.28 * u.um,
160 group_counter_end=845291,
161 group_counter_start=845291,
162 has_simulated_content=False,
163 object="",
164 observation_counter=845291,
165 observation_id="ct4m20190402t050618",
166 observation_type="science",
167 observation_reason="science",
168 observing_day=20190401,
169 physical_filter="VR DECam c0007 6300.0 2600.0",
170 pressure=779.0 * u.hPa,
171 relative_humidity=38.0,
172 science_program="2019A-0337",
173 temperature=15.1 * u.deg_C,
174 visit_id=845291,
175 wcs_params=dict(max_sep=5.0),
176 check_altaz=True,
177 ),
178 ),
179 (
180 "fitsheader-decam-raw_dec050441_25.yaml",
181 dict(
182 telescope="CTIO 4.0-m telescope",
183 instrument="DECam",
184 boresight_rotation_coord="sky",
185 boresight_rotation_angle=90.0 * u.degree,
186 dark_time=31.1290202 * u.s,
187 detector_exposure_id=17776425,
188 detector_name="1",
189 detector_unique_name="S1",
190 detector_group="S",
191 detector_num=25,
192 detector_serial="S3-111_107419-8-3",
193 exposure_id=177764,
194 exposure_group="177764",
195 exposure_time=30.0 * u.s,
196 exposure_time_requested=30.0 * u.s,
197 focus_z=2387.06 * u.um,
198 group_counter_end=177764,
199 group_counter_start=177764,
200 has_simulated_content=False,
201 object="Trifid and Lagoon",
202 observation_counter=177764,
203 observation_id="ct4m20130213t090140",
204 observation_type="science",
205 observation_reason="science",
206 observing_day=20130212,
207 physical_filter="g DECam SDSS c0001 4720.0 1520.0",
208 pressure=780.0 * u.hPa,
209 relative_humidity=32.0,
210 science_program="2013A-0351",
211 temperature=14.2 * u.deg_C,
212 visit_id=177764,
213 # The boresight should have shifted by at least 6 arcmin
214 # (and AZ/ZD have not been adjusted, so they should be
215 # different).
216 wcs_params=dict(min_sep=6.0, max_sep=7.0),
217 check_altaz=True,
218 ),
219 ),
220 )
221 for file, expected in test_data:
222 with self.subTest(f"Testing {file}"):
223 self.assertObservationInfoFromYaml(file, dir=self.datadir, **expected)
226if __name__ == "__main__":
227 unittest.main()