Skip to content

Commit

Permalink
Improve interoperability with lsdb
Browse files Browse the repository at this point in the history
  • Loading branch information
camposandro committed Jan 31, 2024
1 parent 66684b9 commit 6ec57b6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/hipscat/catalog/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
filter_pixels_by_polygon,
)
from hipscat.pixel_math.validators import (
validate_box_search,
validate_declination_values,
validate_polygon,
validate_radec_search,
validate_radius,
)

Expand Down Expand Up @@ -95,7 +95,7 @@ def filter_by_box(
Returns:
A new catalog with only the pixels that overlap with the specified region
"""
validate_radec_search(ra, dec)
validate_box_search(ra, dec)
ra, dec = transform_radec(ra, dec)
if ra is not None and dec is not None:
vertices = form_polygon(ra, dec)
Expand Down
8 changes: 4 additions & 4 deletions src/hipscat/pixel_math/box_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from hipscat.pixel_math import HealpixPixel
from hipscat.pixel_math.filter import get_filtered_pixel_list
from hipscat.pixel_math.polygon_filter import SphericalCoordinates
from hipscat.pixel_math.validators import validate_radec_search
from hipscat.pixel_math.validators import validate_box_search
from hipscat.pixel_tree.pixel_tree import PixelTree
from hipscat.pixel_tree.pixel_tree_builder import PixelTreeBuilder

Expand All @@ -31,7 +31,7 @@ def filter_pixels_by_box(
List of HealpixPixels representing only the pixels that overlap with the right
ascension or the declination region.
"""
validate_radec_search(ra, dec)
validate_box_search(ra, dec)
max_order = pixel_tree.get_max_depth()
search_tree = (
_generate_ra_strip_pixel_tree(ra, max_order)
Expand All @@ -41,12 +41,12 @@ def filter_pixels_by_box(
return get_filtered_pixel_list(pixel_tree, search_tree)


def transform_radec(ra, dec) -> Tuple[List[float] | None, List[float] | None]:
def transform_radec(ra, dec) -> Tuple[Tuple[float, float] | None, Tuple[float, float] | None]:
"""Transforms ra and dec values before performing the search.
Wraps right ascension values to the [0,360] degree range and
sorts declination values by ascending order."""
if ra is not None:
ra = wrap_angles(ra)
ra = tuple(wrap_angles(ra))
if dec is not None:
dec = list(np.sort(dec))
return ra, dec
Expand Down
2 changes: 1 addition & 1 deletion src/hipscat/pixel_math/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def is_polygon_degenerate(vertices: np.ndarray) -> bool:
return bool(np.isclose(center_distance, 0))


def validate_radec_search(ra, dec):
def validate_box_search(ra, dec):
"""Checks if ra and dec values are valid for the box search.
They must be pairs (of minimum and maximum value)."""
values_provided = False
Expand Down

0 comments on commit 6ec57b6

Please sign in to comment.