【问题标题】:astlib coordinates code to astropy coordinates codeastlib 坐标代码到 astropy 坐标代码
【发布时间】:2015-01-21 08:45:10
【问题描述】:

我正在尝试修复这段代码,它使用astlib 将坐标转换为使用astropy 坐标模块。这是代码的副本:

from astLib import astCoords as coords

#Convert B1950 coordinates (as given)
clra=zeros(3)
cldec=zeros(3)
for i in range(len(clra)):
    clra[i], cldec[i] = coords.convertCoords(
                                'B1950', 'J2000', clra1950[i],
                                cldec1950[i], 1950
                            )

#Convert input coords to Galactic coords
lgal,bgal = radians(coords.convertCoords(
                        'J2000', 'GALACTIC', ra, 
                        dec,2000
                    ))

我在两件事上需要帮助。

  1. 如果我想从 B1950 更改为 J2000,以及从 J2000 到银河坐标的正确导入,astropy 的正确导入是什么?

  2. 在以coords.convertCoords() 开头的区域中,astropy 的函数和参数是什么?换句话说,我用什么来代替它?

另外,我对这个问题做了一些研究。我在这里找到了这个链接:http://docs.astropy.org/en/v0.2.1/coordinates/

它描述了astropy's 坐标相关函数的符号。但是,那里有很多,我不确定要使用什么以及如何使用它。

【问题讨论】:

标签: python coordinates coords astropy


【解决方案1】:

这是一种方法:

In [1]: import numpy as np

In [2]: from astropy import units as u

In [3]: from astropy.coordinates import SkyCoord, FK4, FK5, Galactic

In [4]: clra = np.zeros(3)

In [5]: cldec = np.zeros(3)

In [6]: c1 = SkyCoord(clra * u.deg, cldec * u.deg, frame=FK4)

In [7]: c2 = c1.transform_to(FK5(equinox='J2000'))

In [8]: c3 = c2.transform_to(Galactic)

In [9]: print(c3.l.degree)
[ 97.74220094  97.74220094  97.74220094]

In [10]: print(c3.b.degree)
[-60.18102359 -60.18102359 -60.18102359]

请注意,您也可以直接将c1 转换为 Galactic。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-06
    • 1970-01-01
    • 2015-07-06
    • 1970-01-01
    • 2012-02-03
    • 2015-07-03
    相关资源
    最近更新 更多