| 1 |
Seaching for pixels around a position (cone search) |
| 2 |
=================================================== |
| 3 |
|
| 4 |
A common operation when using HEALPix maps is to try and find all pixels |
| 5 |
that lie within a certain radius of a given longitude/latitude. One way to |
| 6 |
do this would be to simply find the longitude/latitude of all pixels in the |
| 7 |
HEALPix map then find the spherical distance to the requested longitude |
| 8 |
and latitude, but in practice this would be very inefficient for high |
| 9 |
resolution HEALPix maps where the number of pixels may become arbitrarily large. |
| 10 |
|
| 11 |
Instead, the :meth:`~astropy_healpix.HEALPix.cone_search_lonlat` method can be used to |
| 12 |
efficiently find all HEALpix pixels within a certain radius from a |
| 13 |
longitude/latitude:: |
| 14 |
|
| 15 |
>>> from astropy import units as u |
| 16 |
>>> from astropy_healpix import HEALPix |
| 17 |
>>> hp = HEALPix(nside=16, order='nested') |
| 18 |
>>> print(hp.cone_search_lonlat(10 * u.deg, 30 * u.deg, radius=10 * u.deg)) |
| 19 |
[1269 160 162 1271 1270 1268 1246 1247 138 139 161 1245 136 137 |
| 20 |
140 142 130 131 1239 1244 1238 1241 1243 1265 1267 1276 1273 1277 |
| 21 |
168 169 163 166 164] |
| 22 |
|
| 23 |
Likewise, if a celestial frame was specified using the ``frame`` keyword arguent |
| 24 |
to :class:`~astropy_healpix.HEALPix`, you can use the |
| 25 |
:meth:`~astropy_healpix.HEALPix.cone_search_skycoord` method to query |
| 26 |
around specific celestial coordinates:: |
| 27 |
|
| 28 |
>>> from astropy.coordinates import Galactic |
| 29 |
>>> hp = HEALPix(nside=16, order='nested', frame=Galactic()) |
| 30 |
>>> from astropy.coordinates import SkyCoord |
| 31 |
>>> coord = SkyCoord('00h42m44.3503s +41d16m08.634s') |
| 32 |
>>> print(hp.cone_search_skycoord(coord, radius=5 * u.arcmin)) |
| 33 |
[2537] |