Cone search demo#
This notebook walks through performing a cone search of the pixels in a HATS catalog. This shows strategies for visualizing a catalog’s partitions, and using hats’s spatial metadata to improve performance in targeted queries.
[1]:
import hats
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 = hats.read_hats(catalog_path)
[3]:
## Plot catalog pixels
hats.inspection.plot_pixels(catalog)
[3]:
(<Figure size 1000x500 with 2 Axes>,
<WCSAxes: title={'center': 'Catalog pixel density map - small_sky_order1'}>)

[4]:
import astropy.units as u
from astropy.coordinates import SkyCoord
from astropy.visualization.wcsaxes import SphericalCircle
fig, ax = hats.inspection.plot_pixels(catalog)
cone_center = SkyCoord(ra=ra * u.deg, dec=dec * u.deg)
s = SphericalCircle(
cone_center,
radius_degrees * u.degree,
edgecolor="purple",
facecolor="none",
transform=ax.get_transform("icrs"),
)
ax.add_patch(s)
[4]:
<astropy.visualization.wcsaxes.patches.SphericalCircle at 0x701f845ccd50>

[5]:
## Filter catalog and plot filtered pixels
radius_arcseconds = radius_degrees * 3600
filtered_catalog = catalog.filter_by_cone(ra, dec, radius_arcseconds)
hats.inspection.plot_pixels(filtered_catalog)
[5]:
(<Figure size 1000x500 with 2 Axes>,
<WCSAxes: title={'center': 'Catalog pixel density map - small_sky_order1'}>)
