Coverage for tests/testApprox.py : 31%

Hot-keys 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
1from __future__ import division
2from builtins import zip
3from builtins import range
4import unittest
5import numpy as np
6import lsst.utils.tests
7import lsst.sims.utils as utils
8import healpy as hp
11def setup_module(module):
12 lsst.utils.tests.init()
15class ApproxCoordTests(unittest.TestCase):
16 """
17 Test the fast approximate ra,dec to alt,az transforms
18 """
20 def test_degrees(self):
21 nside = 64
22 hpids = np.arange(hp.nside2npix(nside))
23 ra, dec = utils.hpid2RaDec(nside, hpids)
24 mjd = 59852.
25 obs = utils.ObservationMetaData(mjd=mjd)
27 alt1, az1, pa1 = utils.altAzPaFromRaDec(ra, dec, obs)
29 alt2, az2 = utils.approx_RaDec2AltAz(ra, dec, obs.site.latitude,
30 obs.site.longitude, mjd)
32 # Check that the fast is similar to the more precice transform
33 tol = 2 # Degrees
34 tol_mean = 1.
35 separations = utils.angularSeparation(az1, alt1, az2, alt2)
36 self.assertLess(np.max(separations), tol)
37 self.assertLess(np.mean(separations), tol_mean)
39 # Check that the fast can nearly round-trip
40 ra_back, dec_back = utils.approx_altAz2RaDec(alt2, az2, obs.site.latitude,
41 obs.site.longitude, mjd)
42 separations = utils.angularSeparation(ra, dec, ra_back, dec_back)
43 self.assertLess(np.max(separations), tol)
44 self.assertLess(np.mean(separations), tol_mean)
46 def test_rad(self):
47 nside = 64
48 hpids = np.arange(hp.nside2npix(nside))
49 ra, dec = utils._hpid2RaDec(nside, hpids)
50 mjd = 59852.
51 obs = utils.ObservationMetaData(mjd=mjd)
53 alt1, az1, pa1 = utils._altAzPaFromRaDec(ra, dec, obs)
55 alt2, az2 = utils._approx_RaDec2AltAz(ra, dec, obs.site.latitude_rad,
56 obs.site.longitude_rad, mjd)
58 # Check that the fast is similar to the more precice transform
59 tol = np.radians(2)
60 tol_mean = np.radians(1.)
61 separations = utils._angularSeparation(az1, alt1, az2, alt2)
63 self.assertLess(np.max(separations), tol)
64 self.assertLess(np.mean(separations), tol_mean)
66 # Check that the fast can nearly round-trip
67 ra_back, dec_back = utils._approx_altAz2RaDec(alt2, az2, obs.site.latitude_rad,
68 obs.site.longitude_rad, mjd)
69 separations = utils._angularSeparation(ra, dec, ra_back, dec_back)
70 self.assertLess(np.max(separations), tol)
71 self.assertLess(np.mean(separations), tol_mean)
74class MemoryTestClass(lsst.utils.tests.MemoryTestCase):
75 pass
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()