Coverage for tests/test_filter_defs.py: 18%
55 statements
« prev ^ index » next coverage.py v7.3.3, created at 2023-12-16 14:35 +0000
« prev ^ index » next coverage.py v7.3.3, created at 2023-12-16 14:35 +0000
1# This file is part of obs_lsst.
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 COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
22import os
23import unittest
24from lsst.obs.lsst import (
25 LSSTCAM_FILTER_DEFINITIONS,
26 LATISS_FILTER_DEFINITIONS,
27 LSSTCAM_IMSIM_FILTER_DEFINITIONS,
28 TS3_FILTER_DEFINITIONS,
29 TS8_FILTER_DEFINITIONS,
30 COMCAM_FILTER_DEFINITIONS,
31 GENERIC_FILTER_DEFINITIONS,
32)
33import lsst.obs.lsst.translators # noqa: F401 -- register the translators
35from astro_metadata_translator import ObservationInfo
36from astro_metadata_translator.tests import read_test_file
38TESTDIR = os.path.abspath(os.path.dirname(__file__))
41class FilterDefTestCase(unittest.TestCase):
42 """Each test reads in raw headers from YAML files, constructs an
43 `ObservationInfo`, and checks that the filter definitions for the
44 corresponding instrument contains the `physical_filter` value
45 computed by the translator code.
46 """
48 datadir = os.path.join(TESTDIR, "headers")
50 def assert_in_filter_defs(self, header_file, filter_def_set):
51 header = read_test_file(header_file, dir=self.datadir)
52 obs_info = ObservationInfo(header, pedantic=True, filename=header_file)
53 self.assertIn(obs_info.physical_filter, filter_def_set)
55 def test_lsstCam_filterdefs(self):
56 filter_def_set = set(_.physical_filter for _ in LSSTCAM_FILTER_DEFINITIONS)
57 test_data = (
58 "lsstCam-MC_C_20190319_000001_R10_S02.yaml",
59 "lsstCam-MC_C_20190319_000001_R22_S21.yaml",
60 "lsstCam-MC_C_20190322_000002_R10_S22.yaml",
61 "lsstCam-MC_C_20190406_000643_R10_S00.yaml",
62 "lsstCam_MC_C_20231125_000600_R12_S10.yaml",
63 )
64 for filename in test_data:
65 with self.subTest(f"Testing {filename}"):
66 self.assert_in_filter_defs(filename, filter_def_set)
68 def test_latiss_filterdefs(self):
69 filter_def_set = set(_.physical_filter for _ in LATISS_FILTER_DEFINITIONS)
70 test_data = (
71 "latiss-2018-09-20-05700065-det000.yaml",
72 "latiss-AT_O_20190306_000014.yaml",
73 "latiss-AT_O_20190329_000022-ats-wfs_ccd.yaml",
74 "latiss-AT_O_20190915_000037.yaml",
75 "latiss-AT_O_20191031_000004.yaml",
76 "latiss-AT_O_20191104_000003.yaml",
77 "latiss-AT_O_20191113_000061.yaml",
78 "latiss-AT_O_20200121_000045.yaml",
79 "latiss-AT_O_20200128_000335.yaml",
80 "latiss-AT_O_20200128_000379.yaml",
81 "latiss-AT_O_20210210_000011.yaml",
82 "latiss-AT_O_20210212_000006.yaml",
83 "latiss-AT_O_20220405_000348.yaml",
84 "latiss-AT_O_20220405_000349.yaml",
85 "latiss-AT_O_20230321_000053.yaml",
86 "latiss-future.yaml",
87 )
88 for filename in test_data:
89 with self.subTest(f"Testing {filename}"):
90 self.assert_in_filter_defs(filename, filter_def_set)
92 def test_imsim_filterdefs(self):
93 filter_def_set = set(
94 _.physical_filter for _ in LSSTCAM_IMSIM_FILTER_DEFINITIONS
95 )
96 test_data = (
97 "imsim-bias-lsst_a_3010002_R11_S00.yaml",
98 "imsim-dark-lsst_a_4010003_R11_S11.yaml",
99 "imsim-flats-lsst_a_5000007_R11_S20_i.yaml",
100 "imsim-lsst_a_204595_R11_S02_i.yaml",
101 )
102 for filename in test_data:
103 with self.subTest(f"Testing {filename}"):
104 self.assert_in_filter_defs(filename, filter_def_set)
106 def test_ts3_filterdefs(self):
107 filter_def_set = set(_.physical_filter for _ in TS3_FILTER_DEFINITIONS)
108 test_data = (
109 "ts3-E2V-CCD250-411_lambda_flat_1000_025_20181115075559.yaml",
110 "ts3-ITL-3800C-098_lambda_flat_1000_067_20160722020740.yaml",
111 )
112 for filename in test_data:
113 with self.subTest(f"Testing {filename}"):
114 self.assert_in_filter_defs(filename, filter_def_set)
116 def test_ts8_filterdefs(self):
117 filter_def_set = set(_.physical_filter for _ in TS8_FILTER_DEFINITIONS)
118 test_data = (
119 "ts8-E2V-CCD250-179_lambda_bias_024_6006D_20180724104156.yaml",
120 "ts8-E2V-CCD250-200-Dev_lambda_flat_0700_6006D_20180724102845.yaml",
121 "ts8-E2V-CCD250-220_fe55_fe55_094_6288_20171215114006.yaml",
122 "ts8-TS_C_20220711_000174_R22_S00.yaml",
123 "ts8-TS_C_20230512_000021_R22_S02.yaml",
124 )
125 for filename in test_data:
126 with self.subTest(f"Testing {filename}"):
127 self.assert_in_filter_defs(filename, filter_def_set)
129 def test_comCam_filterdefs(self):
130 filter_def_set = set(_.physical_filter for _ in COMCAM_FILTER_DEFINITIONS)
131 test_data = (
132 "comCam-CC_C_20190526_000223_R22_S01.yaml",
133 "comCam-CC_C_20190530_000001_R22_S00.yaml",
134 "comCam-CC_H_20100217_006001_R22_S00.yaml",
135 )
136 for filename in test_data:
137 with self.subTest(f"Testing {filename}"):
138 self.assert_in_filter_defs(filename, filter_def_set)
140 def test_generic_filterdefs(self):
141 filter_def_set = set(_.physical_filter for _ in GENERIC_FILTER_DEFINITIONS)
142 test_data = (
143 "phosim-lsst_a_204595_f3_R11_S02_E000.yaml",
144 "lsstCam-MC_H_20100217_000032_R22_S00.yaml", # This is a phosim header
145 "UCD-E2V-CCD250-112-04_flat_flat_100_20181205153143.yaml",
146 "UCD-ITL-3800C-002_flat_flat_100_20180530080354.yaml",
147 )
148 for filename in test_data:
149 with self.subTest(f"Testing {filename}"):
150 self.assert_in_filter_defs(filename, filter_def_set)