如何对可观察坐标列表进行排序? [英] How to sort through a list of observable coordinates?

查看:96
本文介绍了如何对可观察坐标列表进行排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力寻找从坐标列表中删除不需要的目标的最佳方法。我的坐标(Ra,12月)是使用 astropy.coordinates.SkyCoord 形成的,但是我有很多不可观测的目标,它们的磁偏角都太低,所以我想要要做的就是对我的列表进行排序,并删除所有偏角小于-10度的目标(例如,我的望远镜位于北半球)。

I am struggling to find the best way of removing unwanted targets from a list of coordinates. My coordinates (Ra, Dec) are formed using astropy.coordinates.SkyCoord but I have a large number of un-observable targets that are too low in declination, so what I want to do is sort through my list and remove all targets with a declination lower than -10 degrees for example (as my telescope is in the northern hemisphere).

生成列表的代码行,为简化起见称为 radecs 并获得Ra&

This is the line of my code that produces the list, its called radecs for simplification and gets the Ra & Dec from celestial spherical coordinates.

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

这是我的列表的示例

<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索引

I'll just illustrate how you can use numpy indexing with boolean masks on some arbitary coordinates:

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)]>

获得 dec (偏角)您的 radecs 您可以访问该物业:

to get the dec (declination) of your radecs you can acces the property:

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]

因此我们可以访问所有磁偏角小于<$ c $的目标c> -10 通过创建遮罩来获得学位:

so we can access all targets with a declination above -10 degree by creating a mask:

radecs.dec > - 10 * u.degree

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

and then index all targets which satisfy this mask:

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] ),所有其他步骤都只是为了说明。

essentially all you do is the last step (radecs2 = radecs[radecs.dec > - 10 * u.degree]), all the other steps are just explanatory.

这篇关于如何对可观察坐标列表进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆