PyEphem:坐标转换银河到赤道
PyEphem: coordinate transformation galactic to equatorial
我在尝试进行坐标转换时遇到 PyEphem 问题。基本上在这个小例子中,我尝试计算 (l,b) = (52°,68.5°) 的赤道坐标。
我认为它应该是这样工作的:
import ephem
galactic = ephem.Galactic(52.0/360.0,68.5/360.0)
equatorial = ephem.Equatorial(galactic, epoch=ephem.J2000)
print('%.13f %.13f' % (equatorial.ra*360.0, equatorial.dec*360.0))
输出是 1640.9226879684597 -101.5405093325453
这当然不是我所期望的,因为 RA 的范围是 0° 到 360°,DEC 的范围是 -90° 到 90°。
哪里出错了?
编辑
我需要按照正确答案指出的那样将度数转换为弧度。最后我的解决方案:
import ephem
import math
galactic = ephem.Galactic(52.0/180.0*math.pi,68.5/180.0*math.pi)
equatorial = ephem.Equatorial(galactic, epoch=ephem.J2000)
print('%.13f %.13f' % (equatorial.ra/math.pi*180.0, equatorial.dec/math.pi*180.0))
虽然我没有使用 ephem 模块的经验,但我很确定它需要字符串作为 Galactic()
和 Equatorial()
的参数。因此,它们 return 是一个字符串元组,而不是浮点数。
equatorial.ra
和 equatorial.dec
以弧度为单位。
>>> help(equatorial.ra)
Help on Angle object:
class Angle(builtins.float)
| An angle in radians that can print itself in an astronomical format.
| Use ephem.degrees() and ephem.radians() to create one.
|
我在尝试进行坐标转换时遇到 PyEphem 问题。基本上在这个小例子中,我尝试计算 (l,b) = (52°,68.5°) 的赤道坐标。
我认为它应该是这样工作的:
import ephem
galactic = ephem.Galactic(52.0/360.0,68.5/360.0)
equatorial = ephem.Equatorial(galactic, epoch=ephem.J2000)
print('%.13f %.13f' % (equatorial.ra*360.0, equatorial.dec*360.0))
输出是 1640.9226879684597 -101.5405093325453
这当然不是我所期望的,因为 RA 的范围是 0° 到 360°,DEC 的范围是 -90° 到 90°。
哪里出错了?
编辑
我需要按照正确答案指出的那样将度数转换为弧度。最后我的解决方案:
import ephem
import math
galactic = ephem.Galactic(52.0/180.0*math.pi,68.5/180.0*math.pi)
equatorial = ephem.Equatorial(galactic, epoch=ephem.J2000)
print('%.13f %.13f' % (equatorial.ra/math.pi*180.0, equatorial.dec/math.pi*180.0))
虽然我没有使用 ephem 模块的经验,但我很确定它需要字符串作为 Galactic()
和 Equatorial()
的参数。因此,它们 return 是一个字符串元组,而不是浮点数。
equatorial.ra
和 equatorial.dec
以弧度为单位。
>>> help(equatorial.ra)
Help on Angle object:
class Angle(builtins.float)
| An angle in radians that can print itself in an astronomical format.
| Use ephem.degrees() and ephem.radians() to create one.
|