-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Hi!
I think it would be very handy and cool to have a healpix map returned when one uses plot_map function from 'data' module. Also the hires data should be included if needed.
it requires a modification only of a few lines in core.py, as below
@classmethod
def plot_map(cls, map_name, plotname=None, hires=False):
"""
Full-sky plot (mollweide projection) of the map.
**Note:** this method needs ``healpy`` and ``matplotlib``.
Parameters
----------
map_name : ``str``
Name of the map to be plotted. Use ``show_maps`` method
to see a list of all available maps.
plotname : ``str`` or ``None``, optional
Name of the file where the plot will be saved. If ``None``,
the plot is shown but not saved. Defaults to ``None``.
hires : bool
whether to use high resolution map
Returns
-------
plot : ``numpy.ndarray``
2D numpy array with the plot.
hpmap : ``numpy.ndarray``
1D numpy array with the healpix map being plot.
"""
import healpy as hp
import matplotlib.pyplot as plt
cls._check_map(map_name)
if not hires:
hpmapfile = "{}_{}_healpix_lowres.fits".format(
cls._map_type, map_name)
else:
hpmapfile = "{}_{}_healpix_hires.fits".format(
cls._map_type, map_name)
hpmapfile = os.path.join(cls._data_path, hpmapfile)
hpmap = hp.read_map(hpmapfile)
title = "{} ({})".format(map_name, cls._maps[map_name])
if cls._map_type == "h1_nh":
unit_label = "cm-2"
minval, maxval = 1e19, 3e22
else:
unit_label = "mag"
minval, maxval = 0, hpmap.max()
plot = hp.mollview(
hpmap,
title=title,
norm="hist",
min=minval,
max=maxval,
unit=unit_label,
return_projected_map=True,
)
if plotname is None:
plt.show()
else:
plt.savefig(plotname)
return plot, hpmap
And for this reason, returning low/hi resolution map should be an argument.
Healpix NH maps are useful for creating masks for, say, X-ray surveys.
Thanks!
Metadata
Metadata
Assignees
Labels
No labels