Coverage for tests/test_makeDiscreteSkyMap.py: 24%
43 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-01-27 02:45 -0800
« prev ^ index » next coverage.py v6.5.0, created at 2023-01-27 02:45 -0800
1#
2# LSST Data Management System
3# Copyright 2012 LSST Corporation.
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 <http://www.lsstcorp.org/LegalNotices/>.
21#
22import unittest
24import lsst.geom
25import lsst.afw.geom as afwGeom
26import lsst.skymap
27from lsst.pipe.tasks.makeDiscreteSkyMap import MakeDiscreteSkyMapTask, MakeDiscreteSkyMapConfig
30class MakeDiscreteSkyMapTestCase(unittest.TestCase):
31 """Test MakeDiscreteSkyMapTask."""
32 def setUp(self):
33 self.config = MakeDiscreteSkyMapConfig()
34 self.task = MakeDiscreteSkyMapTask(config=self.config)
36 self.cd_matrix = afwGeom.makeCdMatrix(scale=0.2*lsst.geom.arcseconds)
37 self.crpix = lsst.geom.Point2D(100, 100)
38 self.crval1 = lsst.geom.SpherePoint(10.0*lsst.geom.degrees, 0.0*lsst.geom.degrees)
39 self.wcs1 = afwGeom.makeSkyWcs(crpix=self.crpix, crval=self.crval1, cdMatrix=self.cd_matrix)
40 self.bbox = lsst.geom.Box2I(corner=lsst.geom.Point2I(0, 0), dimensions=lsst.geom.Extent2I(200, 200))
41 self.crval2 = lsst.geom.SpherePoint(11.0*lsst.geom.degrees, 1.0*lsst.geom.degrees)
42 self.wcs2 = afwGeom.makeSkyWcs(crpix=self.crpix, crval=self.crval2, cdMatrix=self.cd_matrix)
43 self.crval3 = lsst.geom.SpherePoint(20.0*lsst.geom.degrees, 10.0*lsst.geom.degrees)
44 self.wcs3 = afwGeom.makeSkyWcs(crpix=self.crpix, crval=self.crval3, cdMatrix=self.cd_matrix)
46 def test_run(self):
47 """Test running the MakeDiscreteSkyMapTask."""
48 wcs_bbox_tuple_list = [
49 (self.wcs1, self.bbox),
50 (self.wcs2, self.bbox)
51 ]
52 results = self.task.run(wcs_bbox_tuple_list)
54 skymap = results.skyMap
55 self.assertIsInstance(skymap, lsst.skymap.DiscreteSkyMap)
56 self.assertEqual(len(skymap), 1)
57 tract_info = skymap[0]
59 # Ensure that the tract contains our points.
60 self.assertTrue(tract_info.contains(self.crval1))
61 self.assertTrue(tract_info.contains(self.crval2))
63 def test_append(self):
64 wcs_bbox_tuple_list = [
65 (self.wcs1, self.bbox),
66 (self.wcs2, self.bbox)
67 ]
68 results = self.task.run(wcs_bbox_tuple_list)
70 skymap = results.skyMap
72 wcs_bbox_tuple_list2 = [
73 (self.wcs3, self.bbox)
74 ]
75 results2 = self.task.run(wcs_bbox_tuple_list2, oldSkyMap=skymap)
77 skymap = results2.skyMap
78 self.assertIsInstance(skymap, lsst.skymap.DiscreteSkyMap)
79 self.assertEqual(len(skymap), 2)
81 tract_info1 = skymap[0]
83 # Ensure that the tract contains our points.
84 self.assertTrue(tract_info1.contains(self.crval1))
85 self.assertTrue(tract_info1.contains(self.crval2))
87 tract_info2 = skymap[1]
89 # Ensure that the tract contains our points.
90 self.assertTrue(tract_info2.contains(self.crval3))
93if __name__ == "__main__": 93 ↛ 94line 93 didn't jump to line 94, because the condition on line 93 was never true
94 unittest.main()