如何对可观察坐标列表进行排序?

How to sort through a list of observable coordinates?

我正在努力寻找从坐标列表中删除不需要的目标的最佳方法。我的坐标 (Ra, Dec) 是使用 astropy.coordinates.SkyCoord 形成的,但我有大量 un-observable 目标的偏角太低,所以我想做的是整理我的列表并删除所有目标例如,偏角低于 -10 度(因为我的 telescope 在北半球)。

这是我生成列表的代码行,为了简化起见,它被称为 radecs,并从天球坐标中获取 Ra 和 Dec。

radecs = astropy.coordinates.SkyCoord(ra=phi*u.rad, dec=(0.5*np.pi - theta)*u.rad)

这是我的坐标列表如何在 Python 中输出的示例。

<SkyCoord (ICRS): (ra, dec) in deg
    [(45.0, 60.0), (135.0, 45.0), (225.0, 25.0), ...,
    (135.0, 55.0), (225.0, 70.0), (315.0, -20.0)]>

我将举例说明如何在某些任意坐标上使用带有布尔掩码的 numpy 索引:

from astropy.coordinates import SkyCoord
import astropy.units as u
import numpy as np
phi = np.linspace(0,2*np.pi,20)
theta = np.linspace(0, np.pi, 20)
radecs = SkyCoord(ra=phi*u.rad, dec=(0.5*np.pi - theta)*u.rad)
radecs

给我 radecs:

<SkyCoord (ICRS): (ra, dec) in deg
    [(0.0, 90.0), (18.94736842, 80.52631579), (37.89473684, 71.05263158),
     (56.84210526, 61.57894737), (75.78947368, 52.10526316),
     (94.73684211, 42.63157895), (113.68421053, 33.15789474),
     (132.63157895, 23.68421053), (151.57894737, 14.21052632),
     (170.52631579, 4.73684211), (189.47368421, -4.73684211),
     (208.42105263, -14.21052632), (227.36842105, -23.68421053),
     (246.31578947, -33.15789474), (265.26315789, -42.63157895),
     (284.21052632, -52.10526316), (303.15789474, -61.57894737),
     (322.10526316, -71.05263158), (341.05263158, -80.52631579),
     (0.0, -90.0)]>

要获得 radecsdec(赤纬),您可以访问 属性:

radecs.dec

[90, 80.526316, 71.052632, 61.578947, 52.105263, 42.631579, 33.157895, 23.684211, 14.210526, 4.7368421, −4.7368421, −14.210526, −23.684211, −33.157895, −42.631579, −52.105263, −61.578947, −71.052632, −80.526316, −90]

因此我们可以通过创建掩码访问所有偏角高于 -10 度的目标:

radecs.dec > - 10 * u.degree

然后索引所有满足这个掩码的目标:

radecs2 = radecs[radecs.dec > - 10 * u.degree]

给我以下 radecs2:

<SkyCoord (ICRS): (ra, dec) in deg
    [(0.0, 90.0), (18.94736842, 80.52631579), (37.89473684, 71.05263158),
     (56.84210526, 61.57894737), (75.78947368, 52.10526316),
     (94.73684211, 42.63157895), (113.68421053, 33.15789474),
     (132.63157895, 23.68421053), (151.57894737, 14.21052632),
     (170.52631579, 4.73684211), (189.47368421, -4.73684211)]>

基本上你所做的只是最后一步(radecs2 = radecs[radecs.dec > - 10 * u.degree]),所有其他步骤都只是解释性的。