Coverage for tests/test_dm-329.py: 46%
42 statements
« prev ^ index » next coverage.py v7.1.0, created at 2023-02-05 18:01 -0800
« prev ^ index » next coverage.py v7.1.0, created at 2023-02-05 18:01 -0800
1# This file is part of obs_base.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://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 <https://www.gnu.org/licenses/>.
22import unittest
23import os
25import lsst.utils.tests
26import lsst.afw.image
27import lsst.daf.persistence as dafPersist
28import lsst.obs.base
31ROOT = os.path.abspath(os.path.dirname(__file__))
34class MinMapper2(lsst.obs.base.CameraMapper):
35 packageName = 'larry'
37 def __init__(self):
38 policy = dafPersist.Policy(os.path.join(ROOT, 'MinMapper2.yaml'))
39 lsst.obs.base.CameraMapper.__init__(self,
40 policy=policy,
41 repositoryDir=ROOT,
42 root=ROOT,
43 registry=os.path.join(ROOT, 'cfhtls.sqlite3'))
44 return
46 def _transformId(self, dataId):
47 return dataId
49 def _extractDetectorName(self, dataId):
50 return "Detector"
52 @classmethod
53 def getPackageDir(cls):
54 return "/path/to/nowhere"
57class DM329TestCase(unittest.TestCase):
59 def testHdu(self):
60 mapper = MinMapper2()
61 butler = dafPersist.ButlerFactory(mapper=mapper).create()
62 # HDU INT_MIN returns primary array (skipping empty PDU)
63 # HDU 0 returns (header-only) PDU
64 # HDU 1 returns first image plane
65 # HDU 2 returns mask plane
66 # HDU 3 returns variance plane
67 for i in (1, 2, 3):
68 loc = mapper.map("other", dict(ccd=35, hdu=i))
69 expectedLocations = ["bar-35.fits[%d]" % (i,)]
70 self.assertEqual(loc.getStorage().root, ROOT)
71 self.assertEqual(loc.getLocations(), expectedLocations)
72 image = butler.get("other", ccd=35, hdu=i, immediate=True)
73 self.assertIsInstance(image, lsst.afw.image.ImageF)
74 self.assertEqual(image.getHeight(), 2024)
75 self.assertEqual(image.getWidth(), 2248)
76 self.assertEqual(image[200, 25, lsst.afw.image.LOCAL], (0.0, 20.0, 0.0)[i-1])
77 self.assertAlmostEqual(image[200, 26, lsst.afw.image.LOCAL], (1.20544, 0.0, 5.82185)[i-1],
78 places=5)
81class MemoryTester(lsst.utils.tests.MemoryTestCase):
82 pass
85def setup_module(module):
86 lsst.utils.tests.init()
89if __name__ == "__main__": 89 ↛ 90line 89 didn't jump to line 90, because the condition on line 89 was never true
90 lsst.utils.tests.init()
91 unittest.main()