Coverage for tests/test_latiss.py: 26%
Shortcuts 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
Shortcuts 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 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/>.
21#
22import os
23import sys
24import unittest
26import lsst.log
27import lsst.utils.tests
28from lsst.geom import arcseconds, Extent2I
29import lsst.afw.image
31from lsst.obs.lsst.testHelper import ObsLsstButlerTests, ObsLsstObsBaseOverrides
34class TestLatiss(ObsLsstObsBaseOverrides, ObsLsstButlerTests):
35 instrumentDir = "latiss"
37 def setUp(self):
38 dataIds = {'raw': {'expId': 3018092000065, 'detector': 0, 'dayObs': '2018-09-20', 'seqNum': 65},
39 'bias': {'detector': 0, 'dayObs': '2018-09-20', 'seqNum': 65},
40 'flat': unittest.SkipTest,
41 'dark': unittest.SkipTest
42 }
43 self.setUp_tests(self._butler, self._mapper, dataIds)
45 ccdExposureId_bits = 52
46 exposureIds = {'raw': 3018092000065, 'bias': 3018092000065}
47 filters = {'raw': 'unknown~unknown', 'bias': '_unknown_'}
48 exptimes = {'raw': 27.0, 'bias': 0}
49 detectorIds = {'raw': 0, 'bias': 0}
50 detector_names = {'raw': 'RXX_S00', 'bias': 'RXX_S00'}
51 detector_serials = {'raw': 'ITL-3800C-068', 'bias': 'ITL-3800C-098'}
52 dimensions = {'raw': Extent2I(4608, 4096),
53 'bias': Extent2I(4072, 4000)}
54 sky_origin = unittest.SkipTest
55 raw_subsets = (({'level': 'sensor'}, 1),
56 ({'level': 'sensor', 'filter': 'unknown~unknown'}, 1),
57 ({'level': 'sensor', 'filter': 'foo'}, 0),
58 ({'level': 'sensor', 'dayObs': '2018-09-20'}, 1),
59 ({'level': 'sensor', 'expId': 3018092000065}, 1),
60 ({'level': 'sensor', 'expId': 9999999999999}, 0),
61 ({'level': 'filter'}, 1),
62 ({'level': 'filter', 'expId': 3018092000065}, 1),
63 ({'level': 'expId'}, 1),
64 ({'level': 'expId', 'filter': 'unknown~unknown'}, 1),
65 ({'level': 'expId', 'filter': 'foo'}, 0)
66 )
67 linearizer_type = unittest.SkipTest
68 self.setUp_butler_get(ccdExposureId_bits=ccdExposureId_bits,
69 exposureIds=exposureIds,
70 filters=filters,
71 exptimes=exptimes,
72 detectorIds=detectorIds,
73 detector_names=detector_names,
74 detector_serials=detector_serials,
75 dimensions=dimensions,
76 sky_origin=sky_origin,
77 raw_subsets=raw_subsets,
78 linearizer_type=linearizer_type
79 )
81 path_to_raw = os.path.join(self.data_dir, "raw", "2018-09-20", "3018092000065-det000.fits")
82 keys = set(('filter', 'patch', 'tract', 'visit', 'channel', 'amp', 'style', 'detector', 'dstype',
83 'calibDate', 'half', 'label', 'dayObs', 'run', 'snap', 'detectorName', 'raftName',
84 'numSubfilters', 'fgcmcycle', 'name', 'pixel_id', 'description', 'subfilter', 'expId',
85 'seqNum', 'subdir',))
86 query_format = ["expId", "seqNum", "dayObs"]
87 queryMetadata = (({'expId': 3018092000065}, [(3018092000065, 65, '2018-09-20')]),
88 ({'detector': 0}, [(3018092000065, 65, '2018-09-20')]),
89 ({'seqNum': 65}, [(3018092000065, 65, '2018-09-20')]),
90 )
91 map_python_type = lsst.afw.image.DecoratedImageF
92 map_python_std_type = lsst.afw.image.ExposureF
93 map_cpp_type = 'DecoratedImageF'
94 map_storage_name = 'FitsStorage'
95 metadata_output_path = None # Not on sky data so processCcd not run.
97 raw_filename = '3018092000065-det000.fits'
98 default_level = 'sensor'
99 raw_levels = (('sensor', set(['expId', 'detector', 'dayObs'])),
100 ('skyTile', set(['expId', 'dayObs'])),
101 ('filter', set(['expId'])),
102 ('expId', set(['expId', 'dayObs']))
103 )
104 self.setUp_mapper(output=self.data_dir,
105 path_to_raw=path_to_raw,
106 keys=keys,
107 query_format=query_format,
108 queryMetadata=queryMetadata,
109 metadata_output_path=metadata_output_path,
110 map_python_type=map_python_type,
111 map_python_std_type=map_python_std_type,
112 map_cpp_type=map_cpp_type,
113 map_storage_name=map_storage_name,
114 raw_filename=raw_filename,
115 default_level=default_level,
116 raw_levels=raw_levels,
117 test_config_metadata=False,
118 )
120 self.setUp_camera(camera_name='LATISS',
121 n_detectors=1,
122 first_detector_name='RXX_S00',
123 plate_scale=9.5695 * arcseconds,
124 )
126 super().setUp()
128 def testCcdExposureId(self):
129 exposureId = self.butler.get('ccdExposureId', dataId={})
130 self.assertEqual(exposureId, 0)
132 exposureId = self.butler.get('ccdExposureId', dataId={"visit": 1, "detector": 0})
133 self.assertEqual(exposureId, 1)
135 exposureId = self.butler.get('ccdExposureId', dataId={"visit": 1})
136 self.assertEqual(exposureId, 1)
138 exposureId = self.butler.get('ccdExposureId', dataId={"dayObs": "2020-01-01", "seqNum": 999,
139 "controller": "O"})
140 self.assertEqual(exposureId, 2020010100999)
142 # This will trigger a Python log message and lsst.log message
143 with self.assertLogs(level="WARNING") as cm:
144 with lsst.log.UsePythonLogging():
145 exposureId = self.butler.get('ccdExposureId', dataId={"visit": 1, "detector": 1})
146 self.assertEqual(len(cm.output), 2)
147 self.assertEqual(exposureId, 1)
149 with self.assertRaises(ValueError):
150 exposureId = self.butler.get('ccdExposureId', dataId={"dayObs": "2020-01-01", "seqNum": 1000000})
152 with self.assertRaises(ValueError):
153 exposureId = self.butler.get('ccdExposureId', dataId={"dayObs": "20-01-01", "seqNum": 9999})
155 def testDetectorName(self):
156 name = self.mapper._extractDetectorName({})
157 self.assertEqual(name, "RXX_S00")
160class MemoryTester(lsst.utils.tests.MemoryTestCase):
161 pass
164def setup_module(module):
165 lsst.utils.tests.init()
168if __name__ == '__main__': 168 ↛ 169line 168 didn't jump to line 169, because the condition on line 168 was never true
169 setup_module(sys.modules[__name__])
170 unittest.main()