ruizca / gdpyc Goto Github PK
View Code? Open in Web Editor NEWGas and Dust Python Calculator
Home Page: https://gdpyc.readthedocs.io
License: BSD 3-Clause Clear License
Gas and Dust Python Calculator
Home Page: https://gdpyc.readthedocs.io
License: BSD 3-Clause Clear License
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!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.