27 __all__ = [
"ButlerGetTests"]
32 Tests of obs_* Butler get() functionality. 34 In the subclasses's setUp(): 35 * Call setUp_butler_get() to fill in required parameters. 39 ccdExposureId_bits=None,
45 detector_serials=None,
49 good_detectorIds=None,
54 Set up the necessary variables for butlerGet tests. 56 All "exposure name" entries below should correspond to an entry in 62 ccdExposureId_bits : `int` 63 expected value of ccdExposureId_bits 65 dict of exposure name : ccdExposureId (the number as returned by the butler) 67 dict of exposure name : filter name 69 dict of exposure name : exposure time 70 detector_names : `dict` 71 dict of exposure name : detector name 73 dict of exposure name : detectorId 74 detector_serials : `dict` 75 dict of exposure name : detector serial 77 dict of exposure name : dimensions (as a geom.Extent2I) 78 sky_origin : `tuple` of `float` 79 Longitude, Latitude of 'raw' exposure 80 raw_subsets : `tuple` of (kwargs, `int`) 81 keyword args and expected number of subsets for butler.subset('raw', **kwargs) 82 good_detectorIds : `list` of `int` 83 list of valid ccd numbers 84 bad_detectorIds : `list` of `int` 85 list of invalid ccd numbers 86 linearizer_type : `dict` 87 dict of detectorId (usually `int`): LinearizerType 88 (e.g. lsst.ip.isr.LinearizeLookupTable.LinearityType), 89 or unittest.SkipTest to skip all linearizer tests. 92 fields = [
'ccdExposureId_bits',
106 ButlerGet = collections.namedtuple(
"ButlerGetData", fields)
109 exposureIds=exposureIds,
112 detectorIds=detectorIds,
113 detector_names=detector_names,
114 detector_serials=detector_serials,
115 dimensions=dimensions,
116 sky_origin=sky_origin,
117 raw_subsets=raw_subsets,
118 good_detectorIds=good_detectorIds,
119 bad_detectorIds=bad_detectorIds,
120 linearizer_type=linearizer_type
124 bits = self.butler.get(
'ccdExposureId_bits')
127 def _test_exposure(self, name):
128 if self.dataIds[name]
is unittest.SkipTest:
129 self.skipTest(
'Skipping %s as requested' % (inspect.currentframe().f_code.co_name))
130 exp = self.butler.get(name, self.dataIds[name])
132 exp_md = self.butler.get(name +
"_md", self.dataIds[name])
133 self.assertEqual(
type(exp_md),
type(exp.getMetadata()))
135 self.assertEqual(exp.getDimensions(), self.
butler_get_data.dimensions[name])
136 self.assertEqual(exp.getDetector().getId(), self.
butler_get_data.detectorIds[name])
137 self.assertEqual(exp.getDetector().getName(), self.
butler_get_data.detector_names[name])
138 self.assertEqual(exp.getDetector().getSerial(), self.
butler_get_data.detector_serials[name])
139 self.assertEqual(exp.getFilter().getName(), self.
butler_get_data.filters[name])
140 exposureId = self.butler.get(
'ccdExposureId', dataId=self.dataIds[name])
142 self.assertEqual(exp.getInfo().getVisitInfo().getExposureTime(), self.
butler_get_data.exptimes[name])
152 self.assertEqual(exp.hasWcs(),
True)
153 origin = exp.getWcs().getSkyOrigin()
154 self.assertAlmostEqual(origin.getLongitude().asDegrees(), self.
butler_get_data.sky_origin[0])
155 self.assertAlmostEqual(origin.getLatitude().asDegrees(), self.
butler_get_data.sky_origin[1])
166 @unittest.skip(
'Cannot test this, as there is a bug in the butler! DM-8097')
168 exp = self.butler.get(
'raw', self.dataIds[
'raw'], immediate=
True)
171 sub = self.butler.get(
"raw_sub", self.dataIds[
'raw'], bbox=bbox, immediate=
True)
172 self.assertEqual(sub.getImage().getBBox(), bbox)
173 self.assertImagesEqual(sub, exp.Factory(exp, bbox))
177 subset = self.butler.subset(
"raw", **kwargs)
178 self.assertEqual(len(subset), expect, msg=
"Failed for kwargs: {}".
format(kwargs))
181 """Test that we can get a linearizer for good detectorIds.""" 183 self.skipTest(
'Skipping %s as requested' % (inspect.currentframe().f_code.co_name))
185 camera = self.butler.get(
"camera")
187 detector = camera[detectorId]
188 linearizer = self.butler.get(
"linearizer", dataId=dict(ccd=detectorId), immediate=
True)
189 self.assertEqual(linearizer.LinearityType, self.
butler_get_data.linearizer_type[detectorId])
190 linearizer.checkDetector(detector)
193 """Do bad detectorIds raise?""" 195 self.skipTest(
'Skipping %s as requested' % (inspect.currentframe().f_code.co_name))
198 with self.assertRaises(RuntimeError):
199 self.butler.get(
"linearizer", dataId=dict(ccd=badccd), immediate=
True)
def test_exposureId_bits(self)
def test_raw_sub_bbox(self)
def _test_exposure(self, name)
def test_subset_raw(self)
def test_get_linearizer_bad_detectorIds(self)
def setUp_butler_get(self, ccdExposureId_bits=None, exposureIds=None, filters=None, exptimes=None, detectorIds=None, detector_names=None, detector_serials=None, dimensions=None, sky_origin=None, raw_subsets=None, good_detectorIds=None, bad_detectorIds=None, linearizer_type=None)
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
def test_get_linearizer(self)