33NB: Testing validity of generated plots is currently not tested in our unit test suite.
44"""
55
6- from typing import Any , Dict , Union
6+ from typing import Any , Dict , List , Union
77
88import healpy as hp
99import numpy as np
1010from matplotlib import pyplot as plt
1111
1212from hipscat .catalog import Catalog
1313from hipscat .io import file_io , paths
14+ from hipscat .pixel_math import HealpixPixel
1415
1516
1617def _read_point_map (catalog_base_dir , storage_options : Union [Dict [Any , Any ], None ] = None ):
@@ -27,7 +28,7 @@ def _read_point_map(catalog_base_dir, storage_options: Union[Dict[Any, Any], Non
2728
2829
2930def plot_points (catalog : Catalog , projection = "moll" , draw_map = True ):
30- """Create a visual map of the input points of the catalog.
31+ """Create a visual map of the input points of an in-memory catalog.
3132
3233 Args:
3334 catalog (`hipscat.catalog.Catalog`) Catalog to display
@@ -37,6 +38,8 @@ def plot_points(catalog: Catalog, projection="moll", draw_map=True):
3738 - cart - Cartesian projection
3839 - orth - Orthographic projection
3940 """
41+ if not catalog .on_disk :
42+ raise ValueError ("on disk catalog required for point-wise visualization" )
4043 point_map = _read_point_map (catalog .catalog_base_dir , storage_options = catalog .storage_options )
4144 _plot_healpix_map (
4245 point_map ,
@@ -58,7 +61,27 @@ def plot_pixels(catalog: Catalog, projection="moll", draw_map=True):
5861 - orth - Orthographic projection
5962 """
6063 pixels = catalog .get_healpix_pixels ()
61- max_order = catalog .partition_info .get_highest_order ()
64+ plot_pixel_list (
65+ pixels = pixels ,
66+ plot_title = f"Catalog pixel density map - { catalog .catalog_name } " ,
67+ projection = projection ,
68+ draw_map = draw_map ,
69+ )
70+
71+
72+ def plot_pixel_list (pixels : List [HealpixPixel ], plot_title : str = "" , projection = "moll" , draw_map = True ):
73+ """Create a visual map of the pixel density of a list of pixels.
74+
75+ Args:
76+ pixels: healpix pixels (order and pixel number) to visualize
77+ plot_title (str): heading for the plot
78+ projection (str) The map projection to use. Valid values include:
79+ - moll - Molleweide projection (default)
80+ - gnom - Gnomonic projection
81+ - cart - Cartesian projection
82+ - orth - Orthographic projection
83+ """
84+ max_order = np .max (pixels ).order
6285
6386 order_map = np .full (hp .order2npix (max_order ), hp .pixelfunc .UNSEEN )
6487
@@ -74,7 +97,7 @@ def plot_pixels(catalog: Catalog, projection="moll", draw_map=True):
7497 _plot_healpix_map (
7598 order_map ,
7699 projection ,
77- f"Catalog pixel density map - { catalog . catalog_name } " ,
100+ plot_title ,
78101 draw_map = draw_map ,
79102 )
80103
0 commit comments