Ejemplo n.º 1
0
 def sanity_aitoff(self):
   """
     Checking Aitoff projection.
   """
   for i in xrange(100):
     l = numpy.random.random() * 360.0
     b = numpy.random.random() * 180.0 - 90.0
     x, y = aitoff(l, b)
     l2, b2 = inverseAitoff(x, y)
     self.assertTrue(self.mrd(l2, l) < 1e-6)
     self.assertTrue(self.mrd(b2, b) < 1e-6)
Ejemplo n.º 2
0
 def test_inverseAitoff(self):
   err = 0
   for i in xrange(1000):
     l = numpy.random.random() * 360.0 - 180.0
     b = numpy.random.random() * 180.0 - 90.0
     x, y = aitoffLegacy.aitoff(l, b)
     l2, b2 = aitoffLegacy.inverseAitoff(x, y)
     if abs(l-l2) > 1e-6 or abs(b-b2) > 1e-6:
       print "Problem: "
       print "  ", l, b, x, y, l2, b2
       err += 1
   self.assertEqual(err, 0)
Ejemplo n.º 3
0
 def test_aitoff(self):
   fn = "aitoff.test"
   good, dat = self.getData(fn)
   self.assertEqual(good, True)
   err = 0
   for i in xrange(len(dat[::,0])):
     x, y = aitoffLegacy.aitoff(dat[i,0], dat[i,1])
     # The second condition (abs(x)>1e-2)) because IDL uses single precision
     if (abs((x-dat[i,2])/x) > 1e-4 and (abs(x)>1e-2)) or (abs((y-dat[i,3])/y) > 1e-4 and (abs(y) > 1e-2)):
       print "Problem: "
       print "  l, b, x(IDL), y(IDL), x(Python), y(Python): ", dat[i,0], dat[i,1], x, y, dat[i,2], dat[i,3]
       err += 1
   self.assertEqual(err, 0)