cdshealpix.nested.polygon_search¶
- cdshealpix.nested.polygon_search(lon, lat, depth, flat=False)¶
Get the HEALPix cells contained in a polygon at a given depth.
This method is wrapped around the polygon_coverage method from the cdshealpix Rust crate.
- Parameters:
- lon
astropy.coordinates.Longitude
The longitudes of the vertices defining the polygon.
- lat
astropy.coordinates.Latitude
The latitudes of the vertices defining the polygon.
- depthint
Maximum depth of the HEALPix cells that will be returned.
- flatboolean, optional
False by default (i.e. returns a consistent MOC). If True, the HEALPix cells returned will all be at depth indicated by
depth
.
- lon
- Returns:
- ipix, depth, fully_covered(
numpy.ndarray
,numpy.ndarray
,numpy.ndarray
) A tuple containing 3 numpy arrays of identical size:
ipix
stores HEALPix cell indices.depth
stores HEALPix cell depths.fully_covered
stores flags on whether the HEALPix cells are fully covered by the polygon.
- ipix, depth, fully_covered(
- Raises:
- ValueError
When
lon
andlat
do not have the same dimensions.- IndexError
When the number of distinct vertices given is lesser than 3 (i.e. defining at least a triangle).
Examples
>>> from cdshealpix import polygon_search >>> from astropy.coordinates import Longitude, Latitude >>> import astropy.units as u >>> import numpy as np >>> lon = Longitude(np.random.rand(3) * 360, u.deg) >>> lat = Latitude((np.random.rand(3) * 180 - 90), u.deg) >>> max_depth = 12 >>> ipix, depth, fully_covered = polygon_search(lon, lat, max_depth)