How To Sort Through A List Of Observable Coordinates?
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 la
Solution 1:
I'll just illustrate how you can use numpy indexing with boolean masks on some arbitary coordinates:
from astropy.coordinatesimportSkyCoordimport astropy.unitsas 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) indeg
[(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) indeg
[(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.
Post a Comment for "How To Sort Through A List Of Observable Coordinates?"