Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom plot title #396

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/hats/inspection/visualize_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,34 @@
return file_io.read_fits_image(map_file_pointer)


def plot_points(catalog: Catalog, **kwargs):
def plot_points(catalog: Catalog, plot_title: str | None = None, **kwargs):
"""Create a visual map of the input points of an in-memory catalog.

Args:
catalog (`hats.catalog.Catalog`) Catalog to display
plot_title (str): Optional title for the plot
kwargs: Additional args to pass to `plot_healpix_map`
"""
if not catalog.on_disk:
raise ValueError("on disk catalog required for point-wise visualization")
point_map = _read_point_map(catalog.catalog_base_dir)
return plot_healpix_map(point_map, title=f"Catalog point density map - {catalog.catalog_name}", **kwargs)
default_title = f"Catalog point density map - {catalog.catalog_name}"
return plot_healpix_map(point_map, title=default_title if plot_title is None else plot_title, **kwargs)

Check warning on line 65 in src/hats/inspection/visualize_catalog.py

View check run for this annotation

Codecov / codecov/patch

src/hats/inspection/visualize_catalog.py#L64-L65

Added lines #L64 - L65 were not covered by tests


def plot_pixels(catalog: HealpixDataset, **kwargs):
def plot_pixels(catalog: HealpixDataset, plot_title: str | None = None, **kwargs):
"""Create a visual map of the pixel density of the catalog.

Args:
catalog (`hats.catalog.Catalog`) Catalog to display
plot_title (str): Optional title for the plot
kwargs: Additional args to pass to `plot_healpix_map`
"""
pixels = catalog.get_healpix_pixels()
default_title = f"Catalog pixel density map - {catalog.catalog_name}"
return plot_pixel_list(
pixels=pixels,
plot_title=f"Catalog pixel density map - {catalog.catalog_name}",
plot_title=default_title if plot_title is None else plot_title,
**kwargs,
)

Expand Down