Coverage for tests/test_ticket-2986.py: 36%
37 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-02-01 10:22 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2023-02-01 10:22 +0000
1#
2# LSST Data Management System
3#
4# Copyright 2008-2016 AURA/LSST.
5#
6# This product includes software developed by the
7# LSST Project (http://www.lsst.org/).
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 LSST License Statement and
20# the GNU General Public License along with this program. If not,
21# see <https://www.lsstcorp.org/LegalNotices/>.
22#
23import unittest
26import numpy as np
28import lsst.geom
29import lsst.afw.geom as afwGeom
30import lsst.afw.table as afwTable
31import lsst.meas.algorithms as measAlg
32import lsst.utils.tests
35class Ticket2986Test(unittest.TestCase):
37 def test(self):
38 schema = afwTable.ExposureTable.makeMinimalSchema()
39 schema.addField("ccd", np.int32, doc="CCD number")
40 schema.addField("visit", np.int32, doc="Visit number")
41 schema.addField("goodpix", np.int32, doc="Number of good pixels")
42 schema.addField("weight", float, doc="Weighting for this CCD")
43 ccds = afwTable.ExposureCatalog(schema)
45 scale = 1.0e-4*lsst.geom.degrees
46 wcs = afwGeom.makeSkyWcs(crpix=lsst.geom.Point2D(0.0, 0.0),
47 crval=lsst.geom.SpherePoint(0.0, 0.0, lsst.geom.degrees),
48 cdMatrix=afwGeom.makeCdMatrix(scale=scale))
49 new = ccds.addNew()
50 new.set("id", 0)
51 new.set("bbox_min_x", 0)
52 new.set("bbox_min_y", 0)
53 new.set("bbox_max_x", 1024)
54 new.set("bbox_max_y", 1024)
56 # The following lines are critical for reproducing the bug, because
57 # the code is reading a double starting at the 'ccd' (offset 24), and
58 # it sees a zero (from the zero in 'ccd' and the leading zeros in 'visit').
59 new.set("ccd", 0)
60 new.set("visit", 6789)
62 new.set("goodpix", 987654321)
63 new.set("weight", 1.0)
64 new.setPsf(measAlg.SingleGaussianPsf(23, 23, 2.345))
65 new.setWcs(wcs)
67 # In the presence of the bug, the following fails with
68 # lsst::pex::exceptions::RuntimeError thrown in src/CoaddPsf.cc
69 # with message: "Could not find a valid average position for CoaddPsf"
70 measAlg.CoaddPsf(ccds, wcs)
73class TestMemory(lsst.utils.tests.MemoryTestCase):
74 pass
77def setup_module(module):
78 lsst.utils.tests.init()
81if __name__ == "__main__": 81 ↛ 82line 81 didn't jump to line 82, because the condition on line 81 was never true
82 lsst.utils.tests.init()
83 unittest.main()