Coverage for tests/test_raWrap.py: 31%
42 statements
« prev ^ index » next coverage.py v6.5.0, created at 2023-03-09 03:27 -0800
« prev ^ index » next coverage.py v6.5.0, created at 2023-03-09 03:27 -0800
1#
2# LSST Data Management System
3# Copyright 2008, 2009, 2010 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#
23import os
24import unittest
26import lsst.utils
27import lsst.geom
28import lsst.afw.geom as afwGeom
29from lsst.afw.fits import readMetadata
30import lsst.utils.tests
33class WCSTestRaWrap(unittest.TestCase):
34 '''A test set for the RA=0 wrap-around'''
36 def setUp(self):
37 mydir = lsst.utils.getPackageDir('afw')
38 self.assertIsNotNone(mydir)
39 self.datadir = os.path.join(mydir, 'tests')
41 def test1(self):
42 wcsfn = os.path.join(self.datadir, 'imsim-v85518312-fu-R43-S12.wcs2')
43 hdr = readMetadata(wcsfn)
44 wcs1 = afwGeom.makeSkyWcs(hdr)
46 crval = wcs1.getSkyOrigin()
47 cd = wcs1.getCdMatrix()
48 print(cd)
49 crval_p = lsst.geom.Point2D(crval.getLongitude().asDegrees(),
50 crval.getLatitude().asDegrees())
51 origin = wcs1.getPixelOrigin()
52 print(crval_p)
53 print(origin)
54 wcs2 = afwGeom.makeSkyWcs(crpix=origin, crval=crval, cdMatrix=cd)
56 for wcs in [wcs1, wcs2]:
57 print(wcs)
58 print('x, y, RA, Dec, pixscale("/pix), pixscale2')
59 for x, y in [(0, 0), (300, 0), (350, 0), (360, 0), (370, 0), (380, 0), (400, 0)]:
60 pixPos = lsst.geom.PointD(x, y)
61 radec = wcs.pixelToSky(pixPos)
62 ra = radec.getLongitude().asDegrees()
63 dec = radec.getLatitude().asDegrees()
64 pixscale = wcs.getPixelScale(pixPos).asArcseconds()
65 print(x, y, ra, dec, pixscale)
66 self.assertLess(abs(pixscale - 0.2), 1e-3)
69class MemoryTester(lsst.utils.tests.MemoryTestCase):
70 pass
73def setup_module(module):
74 lsst.utils.tests.init()
77if __name__ == "__main__": 77 ↛ 78line 77 didn't jump to line 78, because the condition on line 77 was never true
78 lsst.utils.tests.init()
79 unittest.main()