healpix_plot.plot#
- healpix_plot.plot(cell_ids, data, *, healpix_grid, sampling_grid, projection='Mollweide', view=None, agg='mean', interpolation='nearest', background_value=nan, rgb_clip=(0.0, 1.0), ax=None, title=None, colorbar=False, cmap='viridis', vmin=None, vmax=None, norm=None, axis_labels=None)[source]#
resample and plot healpix data
- Parameters:
cell_ids (
numpy.ndarray) – The cell ids describing the spatial position of the data.data (
numpy.ndarray) – The data to plot. If 1D, will be color-coded using the standard matplotlib mechanisms. If 2D, the last axis must have a size of 3 (for RGB) or 4 (for RGBA).healpix_grid (
HealpixGridordictofstrtoany) – The healpix grid parameters necessary to interpretcell_ids.sampling_grid (
SamplingGridordictofstrtoany) – The target grid.projection (
strorcartopy.crs.CRS) – The projection used to construct a new axis. Ignored ifaxis given.view (
tupleoffloat, optional) – If given, defines the extent of the displayed plot.agg (
str, default:"mean") – Aggregation to deduplicate the data.interpolation (
str, default:"nearest") – The algorithm used to interpolate from healpix to the target grid. Available values:"nearest": nearest-neighbour resampling"bilinear": bilinear resampling
background_value (
float, default:numpy.nan) – The background value for missing values.ax (
matplotlib.axis.Axis, optional) – The axis to plot on. If not passed, a new figure with a single axis is created usingprojectionandfigure_params.vmin (
float, optional) – Minimum value to color-code.vmax (
float, optional) – Maximum value to color-code.norm (
matplotlib.norm.Norm, optional) – Normalization class for more control.cmap (
strormatplotlib.colors.Colormap, default:"viridis") – The colormap to use for plotting.axis_labels (
dictofstrtostror"none", optional) – Axis labels. Possible values:if
Noneor not passed,"Longitude"and"Latitude"are used.dict: the keys
"x"and"y"are used"none": no axis labels
- Returns:
mappable (
matplotlib.image.AxisImage) – The mappable of the image to allow further processing.
Examples
>>> import healpix_plot >>> import numpy as np
Define the source grid:
>>> healpix_params = healpix_plot.HealpixParameters( ... level=4, ... indexing_scheme="nested", ... ) >>> cell_ids = np.arange(12 * 4 ** healpix_params["level"], dtype="uint64")
Create the data:
>>> lon, lat = healpix_params.operations.healpix_to_lonlat( ... cell_ids, ... **healpix_params.as_keyword_params(), ... ) >>> data = np.cos(8 * np.deg2rad(lon)) * np.sin(4 * np.deg2rad(lat))
Plot the data
>>> healpix_plot.plot( ... cell_ids, ... data, ... sampling_grid={"shape": 1024}, ... healpix_grid=healpix_params, ... ) <matplotlib.image.AxesImage at 0x...>