def test_sg_to_equa(self): for line in self.tevcat: ra,dec = line[1] sgl,sgb = line[2] sg = astro.I3SuperGalactic(sgl*I3Units.degree, sgb*I3Units.degree) eq = astro.I3GetEquatorialFromSuperGalactic(sg) self.assertAlmostEqual(eq.ra/I3Units.degree,ra,2) self.assertAlmostEqual(eq.dec/I3Units.degree,dec,2)
def test_equa_from_sg(self): random.seed(0) for n in range(10000): sg = astro.I3SuperGalactic(random.uniform(0,2*math.pi), random.uniform(-math.pi/2,math.pi/2), ) eq = astro.I3GetEquatorialFromSuperGalactic(sg) sgprime = astro.I3GetSuperGalacticFromEquatorial(eq) self.assert_almost_equal(math.cos(sg.b)*sg.l,math.cos(sgprime.b)*sgprime.l,1e-9) self.assert_almost_equal(sg.b,sgprime.b,1e-10) self.assert_less(astro.angular_distance(sg.l,sg.b,sgprime.l,sgprime.b),1e-10)
def test_sg_from_equa(self): random.seed(0) for n in range(10000): eq = astro.I3Equatorial(random.uniform(0,2* math.pi), random.uniform(-math.pi/2,math.pi/2), ) sg = astro.I3GetSuperGalacticFromEquatorial(eq) eqprime = astro.I3GetEquatorialFromSuperGalactic(sg) self.assert_almost_equal(math.cos(eq.dec)*eq.ra ,math.cos(eqprime.dec)*eqprime.ra,1e-9) self.assert_almost_equal(eq.dec,eqprime.dec,1e-10) self.assert_less(astro.angular_distance(eq.ra,eq.dec,eqprime.ra,eqprime.dec),1e-10)
def test_reference_points(self): #Test the reference points that define the galactic coordinate system #take from Wikipedia, the orignal paper was in B1950 #celestial north pole eq = astro.I3Equatorial((12+51.4/60.)*15*I3Units.degree, 27.13 * I3Units.degree) gal = astro.I3GetGalacticFromEquatorial(eq) self.assertAlmostEqual(gal.b/I3Units.degree,+90,1) #south pole eq.ra = (+51.4/60.)*15*I3Units.degree eq.dec = -27.13 * I3Units.degree gal = astro.I3GetGalacticFromEquatorial(eq) self.assertAlmostEqual(gal.b/I3Units.degree,-90,1) #galactic center eq.ra = (17+45.6/60.)*15*I3Units.degree eq.dec = -28.94 * I3Units.degree gal = astro.I3GetGalacticFromEquatorial(eq) self.assertAlmostEqual(gal.b/I3Units.degree,0,1) self.assertAlmostEqual(gal.l/I3Units.degree,360,1) #anti-center eq.ra = (5+45.6/60.)*15*I3Units.degree eq.dec = +28.94 * I3Units.degree gal = astro.I3GetGalacticFromEquatorial(eq) self.assertAlmostEqual(gal.b/I3Units.degree,0,1) self.assertAlmostEqual(gal.l/I3Units.degree,180,1) #now test the reverse transform #galactic north pole gal = astro.I3Galactic( 0 * I3Units.degree, +90 * I3Units.degree) eq = astro.I3GetEquatorialFromGalactic(gal) self.assertAlmostEqual(eq.ra/I3Units.degree, (12+51.4/60.)*15.,1) self.assertAlmostEqual(eq.dec/I3Units.degree, 27.13,1) #south pole gal.l = 0 * I3Units.degree gal.b = -90 * I3Units.degree eq = astro.I3GetEquatorialFromGalactic(gal) self.assertAlmostEqual(eq.ra/I3Units.degree, (0+51.4/60.)*15.,1) self.assertAlmostEqual(eq.dec/I3Units.degree, -27.13,1) #galactic center gal.l = 0 * I3Units.degree gal.b = 0 * I3Units.degree eq = astro.I3GetEquatorialFromGalactic(gal) self.assertAlmostEqual(eq.ra/I3Units.degree, (17+45.6/60.)*15.,1) self.assertAlmostEqual(eq.dec/I3Units.degree, -28.94,1) #anti center gal.l = 0 * I3Units.degree gal.b = 180 * I3Units.degree eq = astro.I3GetEquatorialFromGalactic(gal) self.assertAlmostEqual(eq.ra/I3Units.degree, (5+45.6/60.)*15.,1) self.assertAlmostEqual(eq.dec/I3Units.degree, +28.94,1) #supergalactic north pole sg = astro.I3SuperGalactic() sg.b = 90 *I3Units.degree sg.l = 0 *I3Units.degree gal = astro.I3GetGalacticFromSuperGalactic(sg) self.assertAlmostEqual(gal.l/I3Units.degree, 47.37,6) self.assertAlmostEqual(gal.b/I3Units.degree, 6.32,6) eq = astro.I3GetEquatorialFromSuperGalactic(sg) print(eq.ra/I3Units.degree/15,eq.dec/I3Units.degree) self.assertAlmostEqual(eq.ra/I3Units.degree, 18.92*15,1) self.assertAlmostEqual(eq.dec/I3Units.degree, 15.7,1) #supergalactic origin sg = astro.I3SuperGalactic() sg.b = 0 *I3Units.degree sg.l = 0 *I3Units.degree gal = astro.I3GetGalacticFromSuperGalactic(sg) self.assertAlmostEqual(gal.l/I3Units.degree, 137.37,6) self.assertAlmostEqual(gal.b/I3Units.degree, 0,6) eq = astro.I3GetEquatorialFromSuperGalactic(sg) self.assertAlmostEqual(eq.ra/I3Units.degree, 2.82*15,1) self.assertAlmostEqual(eq.dec/I3Units.degree, 59.5,1)