Coverage for tests / test_raWrap.py: 33%

40 statements  

« prev     ^ index     » next       coverage.py v7.14.0, created at 2026-05-21 01:29 -0700

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# 

22 

23import os 

24import unittest 

25 

26import lsst.geom 

27import lsst.afw.geom as afwGeom 

28from lsst.afw.fits import readMetadata 

29import lsst.utils.tests 

30 

31TESTDIR = os.path.abspath(os.path.dirname(__file__)) 

32 

33 

34class WCSTestRaWrap(unittest.TestCase): 

35 '''A test set for the RA=0 wrap-around''' 

36 

37 def setUp(self): 

38 self.datadir = TESTDIR 

39 

40 def test1(self): 

41 wcsfn = os.path.join(self.datadir, 'imsim-v85518312-fu-R43-S12.wcs2') 

42 hdr = readMetadata(wcsfn) 

43 wcs1 = afwGeom.makeSkyWcs(hdr) 

44 

45 crval = wcs1.getSkyOrigin() 

46 cd = wcs1.getCdMatrix() 

47 print(cd) 

48 crval_p = lsst.geom.Point2D(crval.getLongitude().asDegrees(), 

49 crval.getLatitude().asDegrees()) 

50 origin = wcs1.getPixelOrigin() 

51 print(crval_p) 

52 print(origin) 

53 wcs2 = afwGeom.makeSkyWcs(crpix=origin, crval=crval, cdMatrix=cd) 

54 

55 for wcs in [wcs1, wcs2]: 

56 print(wcs) 

57 print('x, y, RA, Dec, pixscale("/pix), pixscale2') 

58 for x, y in [(0, 0), (300, 0), (350, 0), (360, 0), (370, 0), (380, 0), (400, 0)]: 

59 pixPos = lsst.geom.PointD(x, y) 

60 radec = wcs.pixelToSky(pixPos) 

61 ra = radec.getLongitude().asDegrees() 

62 dec = radec.getLatitude().asDegrees() 

63 pixscale = wcs.getPixelScale(pixPos).asArcseconds() 

64 print(x, y, ra, dec, pixscale) 

65 self.assertLess(abs(pixscale - 0.2), 1e-3) 

66 

67 

68class MemoryTester(lsst.utils.tests.MemoryTestCase): 

69 pass 

70 

71 

72def setup_module(module): 

73 lsst.utils.tests.init() 

74 

75 

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()