Coverage for tests/test_latiss.py : 26%

Hot-keys 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': {'visit': 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': '????~????', '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-098', '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', 'filter': '????~????'}, 1),
56 ({'level': 'sensor', 'visit': 3018092000065}, 1),
57 ({'level': 'filter', 'visit': 3018092000065}, 1),
58 ({'level': 'visit', 'filter': '????~????'}, 1)
59 )
60 linearizer_type = unittest.SkipTest
61 self.setUp_butler_get(ccdExposureId_bits=ccdExposureId_bits,
62 exposureIds=exposureIds,
63 filters=filters,
64 exptimes=exptimes,
65 detectorIds=detectorIds,
66 detector_names=detector_names,
67 detector_serials=detector_serials,
68 dimensions=dimensions,
69 sky_origin=sky_origin,
70 raw_subsets=raw_subsets,
71 linearizer_type=linearizer_type
72 )
74 path_to_raw = os.path.join(self.data_dir, "raw", "2018-09-20", "3018092000065-det000.fits")
75 keys = set(('filter', 'patch', 'tract', 'visit', 'channel', 'amp', 'style', 'detector', 'dstype',
76 'calibDate', 'half', 'label', 'dayObs', 'run', 'snap', 'detectorName', 'raftName',
77 'numSubfilters', 'fgcmcycle', 'name', 'pixel_id', 'description', 'subfilter', 'expId'))
78 query_format = ["visit", "seqNum", "dayObs"]
79 queryMetadata = (({'visit': 3018092000065}, [(3018092000065, 65, '2018-09-20')]),
80 ({'detector': 0}, [(3018092000065, 65, '2018-09-20')]),
81 ({'seqNum': 65}, [(3018092000065, 65, '2018-09-20')]),
82 )
83 map_python_type = lsst.afw.image.DecoratedImageF
84 map_python_std_type = lsst.afw.image.ExposureF
85 map_cpp_type = 'DecoratedImageF'
86 map_storage_name = 'FitsStorage'
87 metadata_output_path = None # Not on sky data so processCcd not run.
89 raw_filename = '3018092000065-det000.fits'
90 default_level = 'visit'
91 raw_levels = (('skyTile', set(['expId', 'detector', 'dayObs'])),
92 ('filter', set(['expId', 'detector', 'dayObs'])),
93 ('visit', set(['expId', 'detector', 'dayObs']))
94 )
95 self.setUp_mapper(output=self.data_dir,
96 path_to_raw=path_to_raw,
97 keys=keys,
98 query_format=query_format,
99 queryMetadata=queryMetadata,
100 metadata_output_path=metadata_output_path,
101 map_python_type=map_python_type,
102 map_python_std_type=map_python_std_type,
103 map_cpp_type=map_cpp_type,
104 map_storage_name=map_storage_name,
105 raw_filename=raw_filename,
106 default_level=default_level,
107 raw_levels=raw_levels,
108 test_config_metadata=False,
109 )
111 self.setUp_camera(camera_name='LATISS',
112 n_detectors=1,
113 first_detector_name='RXX_S00',
114 plate_scale=10.112 * arcseconds,
115 )
117 super().setUp()
119 def testCcdExposureId(self):
120 exposureId = self.butler.get('ccdExposureId', dataId={})
121 self.assertEqual(exposureId, 0)
123 exposureId = self.butler.get('ccdExposureId', dataId={"visit": 1, "detector": 0})
124 self.assertEqual(exposureId, 1)
126 exposureId = self.butler.get('ccdExposureId', dataId={"visit": 1})
127 self.assertEqual(exposureId, 1)
129 exposureId = self.butler.get('ccdExposureId', dataId={"dayObs": "2020-01-01", "seqNum": 999,
130 "controller": "O"})
131 self.assertEqual(exposureId, 2020010100999)
133 # This will trigger a Python log message and lsst.log message
134 with self.assertLogs(level="WARNING") as cm:
135 with lsst.log.UsePythonLogging():
136 exposureId = self.butler.get('ccdExposureId', dataId={"visit": 1, "detector": 1})
137 self.assertEqual(len(cm.output), 2)
138 self.assertEqual(exposureId, 1)
140 with self.assertRaises(ValueError):
141 exposureId = self.butler.get('ccdExposureId', dataId={"dayObs": "2020-01-01", "seqNum": 1000000})
143 with self.assertRaises(ValueError):
144 exposureId = self.butler.get('ccdExposureId', dataId={"dayObs": "20-01-01", "seqNum": 9999})
146 def testDetectorName(self):
147 name = self.mapper._extractDetectorName({})
148 self.assertEqual(name, "RXX_S00")
151class MemoryTester(lsst.utils.tests.MemoryTestCase):
152 pass
155def setup_module(module):
156 lsst.utils.tests.init()
159if __name__ == '__main__': 159 ↛ 160line 159 didn't jump to line 160, because the condition on line 159 was never true
160 setup_module(sys.modules[__name__])
161 unittest.main()