Skip to content

Commit

Permalink
add plot moc method
Browse files Browse the repository at this point in the history
  • Loading branch information
smcguire-cmu committed Nov 1, 2024
1 parent f5a3e20 commit b467f2b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/lsdb/catalog/dataset/healpix_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,15 +428,28 @@ def plot_pixels(self, projection: str = "MOL", **kwargs):
"""Create a visual map of the pixel density of the catalog.
Args:
projection (str) The map projection to use. Valid values include:
- moll - Molleweide projection (default)
- gnom - Gnomonic projection
- cart - Cartesian projection
- orth - Orthographic projection
projection (str) The map projection to use. Available projections listed at
https://docs.astropy.org/en/stable/wcs/supported_projections.html
kwargs (dict): additional keyword arguments to pass to plotting call.
"""
return self.hc_structure.plot_pixels(projection=projection, **kwargs)

def plot_moc(self, **kwargs):
"""Create a visual map of the coverage of the catalog.
Args:
kwargs: additional keyword arguments to pass to hats.Catalog.plot_moc
"""
self.hc_structure.plot_moc(**kwargs)

def plot_coverage(self, **kwargs):
"""Create a visual map of the coverage of the catalog.
Args:
kwargs: additional keyword arguments to pass to hats.Catalog.plot_moc
"""
self.plot_moc(**kwargs)

def to_hats(
self,
base_catalog_path: str | Path | UPath,
Expand Down
25 changes: 25 additions & 0 deletions tests/lsdb/catalog/test_catalog.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import hipscat as hc
from pathlib import Path

import dask.array as da
Expand Down Expand Up @@ -531,6 +532,30 @@ def test_plot_pixels(small_sky_order1_catalog, mocker):
)


# pylint: disable=no-member
def test_plot_moc(small_sky_order1_catalog, mocker):
mocker.patch("hats.catalog.healpix_dataset.healpix_dataset.plot_moc")
small_sky_order1_catalog.plot_moc()

hc.catalog.healpix_dataset.healpix_dataset.plot_moc.assert_called_once()
assert (
hc.catalog.healpix_dataset.healpix_dataset.plot_moc.call_args[0][0]
== small_sky_order1_catalog.hc_structure.moc
)


# pylint: disable=no-member
def test_plot_coverage(small_sky_order1_catalog, mocker):
mocker.patch("hats.catalog.healpix_dataset.healpix_dataset.plot_moc")
small_sky_order1_catalog.plot_coverage()

hc.catalog.healpix_dataset.healpix_dataset.plot_moc.assert_called_once()
assert (
hc.catalog.healpix_dataset.healpix_dataset.plot_moc.call_args[0][0]
== small_sky_order1_catalog.hc_structure.moc
)


def test_square_bracket_columns(small_sky_order1_catalog):
columns = ["ra", "dec", "id"]
column_subset = small_sky_order1_catalog[columns]
Expand Down

0 comments on commit b467f2b

Please sign in to comment.