Cone search demo#
This notebook walks through performing a cone search of the pixels in a HiPSCat catalog. This shows strategies for visualizing a catalog’s partitions, and using hipscat’s spatial metadata to improve performance in targeted queries.
[1]:
import hipscat
import healpy as hp
import numpy as np
## Fill in these variables with what's relevant in your use case:
### Change this path!!!
catalog_path = "../../tests/data/small_sky_order1"
ra = 0 # degrees
dec = -80 # degrees
radius_degrees = 10 # degrees
[2]:
## Load catalog
catalog = hipscat.read_from_hipscat(catalog_path)
[3]:
## Plot catalog pixels
hipscat.inspection.plot_pixels(catalog)
[4]:
## Plot the cone using healpy for demonstration
NSIDE = 256
NPIX = hp.nside2npix(NSIDE)
m = np.zeros(NPIX)
center_vec = hp.ang2vec(ra, dec, lonlat=True)
radius_radians = np.radians(radius_degrees)
cone_pixels = hp.query_disc(NSIDE, center_vec, radius_radians)
m[cone_pixels] = 1
hp.mollview(m, title="Cone to search")
[5]:
## Filter catalog and plot filtered pixels
radius_arcseconds = radius_degrees * 3600
filtered_catalog = catalog.filter_by_cone(ra, dec, radius_arcseconds)
hipscat.inspection.plot_pixels(filtered_catalog)