0

I'm using the following script in order to calculate the Galactical Center (GC) position in galactical coordinates (in degrees) to celestial coordinates:

import healpy as hp
r = hp.Rotator(coord = ['G', 'C'], deg=True)
ri = hp.Rotator(coord = ['C', 'G'], deg=True)
gz, ga = 0., 0.         # position of GC
gz_e, ga_e = r(gz, ga)
print gz_e, ga_e
zg, ag = ri(gz_e, ga_e)
print zg, ag

These are the results I get:

1.09730865695 -2.91715324734  # celestial
0.0 -1.57079632679            # back to galactical

First of all, the numbers are wrong in celestial as well as in galactical coordinates. There is a chance that I'm using the function wrong (which I hope), or something is wrong with the function itself. Does someone know what is going wrong?

Second: it seems, that I get the numbers in radian back, is that right?

user4050567
  • 87
  • 10
  • can you try using everything in radians and convert at the end? `healpy` uses colatitude, so the center is at 90 degrees. – Andrea Zonca Jan 16 '15 at 17:25
  • It's a little bit confusing that the default value of deg is True. I set it to False and set gz, ga = np.pi/2., 0. Again the first coordinate seems to be calculated right (gz_e and zg), but the second one is still wrong (ga_e & ag): gz_e = 2.07582709512, ga_e = -1.63354890767 , zg = 1.57079632679, ag = 1.11022302489e-16 (altough very close to the right value). – user4050567 Jan 16 '15 at 17:45

1 Answers1

0

deg refers only to the angles in rot, not to the Rotator itself. The Rotator needs theta (colatitude) and phi (longitude) in radians, see:

import healpy as hp
import numpy as np
r = hp.Rotator(coord = ['G', 'C'])
ri = hp.Rotator(coord = ['C', 'G'])
gz, ga = np.pi/2, 0.         # position of GC
gz_e, ga_e = r(gz, ga)

print("Galactic center in Celestial Coordinates")
print(gz_e, ga_e)
zg, ag = ri(gz_e, ga_e)
print("Back to galactic coordinates")
print(zg, ag)

Output:

Galactic center in Celestial Coordinates
2.07582709512 -1.63354890767
Back to galactic coordinates
1.57079632679 -1.11022302489e-16
Andrea Zonca
  • 8,378
  • 9
  • 42
  • 70