Coverage for tests/test_ccdoffsets.py: 33%
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# See COPYRIGHT file at the top of the source tree.
2#
3# This file is part of fgcmcal.
4#
5# Developed for the LSST Data Management System.
6# This product includes software developed by the LSST Project
7# (https://www.lsst.org).
8# See the COPYRIGHT file at the top-level directory of this distribution
9# for details of code ownership.
10#
11# This program is free software: you can redistribute it and/or modify
12# it under the terms of the GNU General Public License as published by
13# the Free Software Foundation, either version 3 of the License, or
14# (at your option) any later version.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License
22# along with this program. If not, see <https://www.gnu.org/licenses/>.
23"""Test the fgcmcal computeCcdOffsets code with testdata_jointcal.
24"""
26import unittest
27import os
29import lsst.utils
30import lsst.daf.persistence as dafPersist
32import lsst.fgcmcal as fgcmcal
35class FgcmCcdOffsetsTest(lsst.utils.tests.TestCase):
36 @classmethod
37 def setUpClass(cls):
38 try:
39 cls.dataDir = lsst.utils.getPackageDir('testdata_jointcal')
40 except LookupError:
41 raise unittest.SkipTest("testdata_jointcal not setup")
43 def test_fgcmCcdOffsetsHsc(self):
44 """
45 Test computation of ccd offsets for HSC.
46 """
48 lsst.log.setLevel("HscMapper", lsst.log.FATAL)
50 butler = dafPersist.Butler(os.path.join(self.dataDir, 'hsc'))
52 visit = 36236
53 ccd = 87
55 visitInfo = butler.get('calexp_visitInfo', visit=visit, ccd=ccd)
56 rotAngle = visitInfo.getBoresightRotAngle().asDegrees()
58 camera = butler.get('camera')
60 ccdOffsets = fgcmcal.utilities.computeCcdOffsets(camera, rotAngle)
62 # Spot check relative orientations of some of the ccds
63 # This is based on
64 # https://subarutelescope.org/Observing/Instruments/HSC/CCDPosition_20170212.png
65 # The goal here is to check that North is Up, South is Down,
66 # East is Left, and West is Right.
67 self.assertLess(ccdOffsets['DELTA_RA'][15], ccdOffsets['DELTA_RA'][10])
68 self.assertLess(ccdOffsets['DELTA_RA'][95], ccdOffsets['DELTA_RA'][90])
69 self.assertGreater(ccdOffsets['DELTA_RA'][46], 0.0)
71 self.assertLess(ccdOffsets['DELTA_DEC'][15], ccdOffsets['DELTA_DEC'][95])
72 self.assertLess(ccdOffsets['DELTA_DEC'][10], ccdOffsets['DELTA_DEC'][90])
73 self.assertGreater(ccdOffsets['DELTA_DEC'][97], 0.0)
75 # Check the sizes
76 # The projected size of the ccds varies with radius over the large
77 # HSC field-of-view. Empirically, the x size is between 0.07 and 0.10 deg
78 # and the y size is between 0.17 and 0.20 deg for the non-rotated CCDs.
79 # This test checks that the orientations of the CCDs are as expected for
80 # rotated/non-rotated CCDs (relative size of RA/DEC), and that the size
81 # is roughly correct. Because these values are only used for visualization
82 # in the fgcm code, this does not need to be perfect.
84 rotatedCcds = [100, 101, 102, 103]
86 for i, ccd in enumerate(ccdOffsets['CCDNUM']):
87 if ccd in rotatedCcds:
88 self.assertLess(ccdOffsets['RA_SIZE'][i], ccdOffsets['DEC_SIZE'][i])
89 self.assertGreater(ccdOffsets['DEC_SIZE'][i], 0.17)
90 self.assertLess(ccdOffsets['DEC_SIZE'][i], 0.20)
91 self.assertGreater(ccdOffsets['RA_SIZE'][i], 0.07)
92 self.assertLess(ccdOffsets['RA_SIZE'][i], 0.10)
93 else:
94 self.assertGreater(ccdOffsets['RA_SIZE'][i], ccdOffsets['DEC_SIZE'][i])
95 self.assertGreater(ccdOffsets['RA_SIZE'][i], 0.17)
96 self.assertLess(ccdOffsets['RA_SIZE'][i], 0.20)
97 self.assertGreater(ccdOffsets['DEC_SIZE'][i], 0.07)
98 self.assertLess(ccdOffsets['DEC_SIZE'][i], 0.10)
101class TestMemory(lsst.utils.tests.MemoryTestCase):
102 pass
105def setup_module(module):
106 lsst.utils.tests.init()
109if __name__ == "__main__": 109 ↛ 110line 109 didn't jump to line 110, because the condition on line 109 was never true
110 lsst.utils.tests.init()
111 unittest.main()