Coverage for tests/test_apertures.py: 48%
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 fgcmcal.
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/>.
21"""Test the fgcmcal computeApertureRadius code with testdata_jointcal.
22"""
24import unittest
25import os
27import lsst.utils
28import lsst.daf.persistence as dafPersist
30from lsst.fgcmcal.utilities import computeApertureRadiusFromDataRef, computeApertureRadiusFromName
33class FgcmApertureTest(lsst.utils.tests.TestCase):
34 @classmethod
35 def setUpClass(cls):
36 try:
37 cls.dataDir = lsst.utils.getPackageDir('testdata_jointcal')
38 except LookupError:
39 raise unittest.SkipTest("testdata_jointcal not setup")
41 def test_fgcmApertureHsc(self):
42 """
43 Test computeApertureRadius for HSC.
44 """
45 lsst.log.setLevel("HscMapper", lsst.log.FATAL)
47 butler = dafPersist.Butler(os.path.join(self.dataDir, 'hsc'))
49 dataRef = butler.dataRef('src', visit=34648, ccd=51)
51 self.assertRaises(RuntimeError, computeApertureRadiusFromDataRef, dataRef, 'base_PsfFlux_instFlux')
52 self.assertRaises(RuntimeError, computeApertureRadiusFromDataRef, dataRef, 'not_a_field')
53 self.assertEqual(computeApertureRadiusFromDataRef(dataRef, 'slot_CalibFlux_instFlux'), 12.0)
54 self.assertEqual(computeApertureRadiusFromDataRef(dataRef,
55 'base_CircularApertureFlux_12_0_instFlux'),
56 12.0)
57 self.assertEqual(computeApertureRadiusFromDataRef(dataRef,
58 'base_CircularApertureFlux_4_5_instFlux'),
59 4.5)
61 self.assertEqual(computeApertureRadiusFromName('ApFlux_12_0_instFlux'), 12.0)
62 self.assertEqual(computeApertureRadiusFromName('ApFlux_4_5_instFlux'), 4.5)
63 self.assertEqual(computeApertureRadiusFromName('apFlux_12_0_instFlux'), 12.0)
64 self.assertEqual(computeApertureRadiusFromName('apFlux_4_5_instFlux'), 4.5)
65 self.assertRaises(RuntimeError, computeApertureRadiusFromName, 'not_a_field')
68class TestMemory(lsst.utils.tests.MemoryTestCase):
69 pass
72def setup_module(module):
73 lsst.utils.tests.init()
76if __name__ == "__main__": 76 ↛ 77line 76 didn't jump to line 77, because the condition on line 76 was never true
77 lsst.utils.tests.init()
78 unittest.main()