How to sort through a list of observable coordinates?

岁酱吖の 提交于 2019-12-11 14:10:59

问题


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

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)

And this is an example of how my list off coordinates is outputted in 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)]>

回答1:


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

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

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]

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]

Giving me the following 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)]>

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



来源:https://stackoverflow.com/questions/35991109/how-to-sort-through-a-list-of-observable-coordinates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!