Skip to content
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
45 changes: 43 additions & 2 deletions src/sp_validation/plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,8 @@ def plot_area(
projection=None,
outpath=None,
title=None,
colorbar=True,
colorbar_label="Coverage depth",
):
"""Plot Area.

Expand All @@ -494,6 +496,10 @@ def plot_area(
output path, default is ``None``
title : str, optional
print title if not ``None`` (default)
colorbar : bool, optional
add colorbar; default is ``True``
colorbar_label : str, optional
colorbar label; default is "Coverage depth"

Returns
--------
Expand All @@ -520,8 +526,9 @@ def plot_area(
else:
ax = None

im = None
try:
_ = projection.draw_hspmap(
im, lon_raster, lat_raster, values_raster = projection.draw_hspmap(
hsp_map, lon_range=extend[0:2], lat_range=extend[2:]
)
except ValueError:
Expand All @@ -531,6 +538,10 @@ def plot_area(

projection.draw_milky_way(width=25, linewidth=1.5, color="black", linestyle="-")

# Add colorbar if requested and image was drawn
if colorbar and im is not None:
plt.colorbar(im, ax=ax if ax else projection.ax, label=colorbar_label)

if title:
plt.title(title, pad=5)

Expand All @@ -539,8 +550,36 @@ def plot_area(

return projection, ax

def plot_region(self, hsp_map, region, projection=None, outpath=None, title=None):
def plot_region(self, hsp_map, region, projection=None, outpath=None, title=None, colorbar=True, colorbar_label="Coverage depth"):
"""Plot Region.

Plot catalogue in a predefined region on the sky.

Parameters
----------
hsp_map : hsp_HealSparseMap
input map
region : dict
region dictionary with keys 'ra_0', 'extend', 'vmax'
projection : skyproj.McBrydeSkyproj, optional
if ``None`` (default), a new plot is created
outpath : str, optional
output path, default is ``None``
title : str, optional
print title if not ``None`` (default)
colorbar : bool, optional
add colorbar; default is ``True``
colorbar_label : str, optional
colorbar label; default is "Coverage depth"

Returns
--------
skyproj.McBrydeSkyproj
projection instance
plt.axes.Axes
axes instance

"""
return self.plot_area(
hsp_map,
region["ra_0"],
Expand All @@ -549,6 +588,8 @@ def plot_region(self, hsp_map, region, projection=None, outpath=None, title=None
projection=projection,
outpath=outpath,
title=title,
colorbar=colorbar,
colorbar_label=colorbar_label,
)

def plot_all_regions(self, hsp_map, outbase=None):
Expand Down