Coverage for tests/test_isrMisc.py: 35%
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#
2# LSST Data Management System
3# Copyright 2008-2017 AURA/LSST.
4#
5# This product includes software developed by the
6# LSST Project (http://www.lsst.org/).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the LSST License Statement and
19# the GNU General Public License along with this program. If not,
20# see <https://www.lsstcorp.org/LegalNotices/>.
21#
23import unittest
25import lsst.afw.geom as afwGeom
26import lsst.utils.tests
27import lsst.ip.isr.straylight as straylight
28import lsst.ip.isr.vignette as vignette
29import lsst.ip.isr.masking as masking
30import lsst.ip.isr.linearize as linearize
32import lsst.ip.isr.isrMock as isrMock
35class IsrMiscCases(lsst.utils.tests.TestCase):
37 def setUp(self):
38 self.inputExp = isrMock.TrimmedRawMock().run()
39 self.mi = self.inputExp.getMaskedImage()
41 def test_straylight(self):
42 """Assert that the straylight task does not error when given an exposure.
43 """
44 task = straylight.StrayLightTask()
45 with self.assertRaises(NotImplementedError):
46 task.run(self.inputExp, None)
48 def test_vignette_noWrite(self):
49 """Assert that the vignette task does not error when given an exposure
50 """
51 config = vignette.VignetteConfig()
52 config.radius = 125.0
53 config.xCenter = 100.0
54 config.yCenter = 100.0
56 config.doWriteVignettePolygon = False
57 task = vignette.VignetteTask(config=config)
58 result = task.run(self.inputExp)
60 # DM-19707: ip_isr functionality not fully tested by unit tests
61 self.assertIsNone(result)
63 def test_vignette_doWrite(self):
64 """Assert that the vignette task does not error when given an exposure
65 """
66 config = vignette.VignetteConfig()
67 config.radius = 125.0
68 config.xCenter = 100.0
69 config.yCenter = 100.0
71 config.doWriteVignettePolygon = True
72 task = vignette.VignetteTask(config=config)
73 result = task.run(self.inputExp)
75 self.assertIsInstance(result, afwGeom.Polygon)
77 def test_masking(self):
78 """Assert that the camera-specific masking task does not error when
79 given an exposure.
80 """
81 task = masking.MaskingTask()
82 result = task.run(self.inputExp)
84 # DM-19707: ip_isr functionality not fully tested by unit tests
85 self.assertIsNone(result)
87 def test_linearize(self):
88 """Assert that the linearize task does not error when a linearity is requested.
89 """
90 for linearityTypeName in ('LookupTable', 'Squared', 'Polynomial', 'Unknown'):
91 result = linearize.Linearizer().getLinearityTypeByName(linearityTypeName)
92 # These return the actual class to use, so use Equal instead of IsInstance.
93 if linearityTypeName == 'LookupTable':
94 self.assertEqual(result, linearize.LinearizeLookupTable, msg=f"{linearityTypeName}")
95 elif linearityTypeName == 'Squared':
96 self.assertEqual(result, linearize.LinearizeSquared, msg=f"{linearityTypeName}")
97 elif linearityTypeName == 'Polynomial':
98 self.assertEqual(result, linearize.LinearizePolynomial, msg=f"{linearityTypeName}")
99 else:
100 # DM-19707: ip_isr functionality not fully tested by unit tests
101 self.assertIsNone(result)
104class MemoryTester(lsst.utils.tests.MemoryTestCase):
105 pass
108def setup_module(module):
109 lsst.utils.tests.init()
112if __name__ == "__main__": 112 ↛ 113line 112 didn't jump to line 113, because the condition on line 112 was never true
113 lsst.utils.tests.init()
114 unittest.main()