marvin.utils.plot.map
contains utility functions for plotting Marvin maps. The main function in this module is ~marvin.utils.plot.map.plot
, which is thinly wrapped by the ~marvin.tools.quantities.Map.plot
method in the ~marvin.tools.quantities.Map
class for convenience.
~marvin.utils.plot.map.plot
makes plotting a publication-quality MaNGA map easy with its carefully chosen default parameters.
from marvin.tools.maps import Maps import marvin.utils.plot.map as mapplot
from marvin.tools.maps import Maps import marvin.utils.plot.map as mapplot maps = Maps(plateifu='8485-1901') ha = maps['emline_gflux_ha_6564'] fig, ax = mapplot.plot(dapmap=ha) # == ha.plot()
However, you may want to do further processing of the map, so you can override the default DAP ~marvin.utils.plot.map.plot.value
, ~marvin.utils.plot.map.plot.ivar
, and/or ~marvin.utils.plot.map.plot.mask
with your own arrays.
fig, ax = mapplot.plot(dapmap=ha, value=ha.value * 10.)
A ~marvin.utils.plot.map.plot.dapmap
object is not even necessary for ~marvin.utils.plot.map.plot
, though if you do not provide a ~marvin.utils.plot.map.plot.dapmap
object, then you will need to set a ~marvin.utils.plot.map.plot.value
. You will also need to provide other attributes, such as ~marvin.utils.plot.map.plot.title
and ~marvin.utils.plot.map.plot.cblabel
, that are by default set from attributes of the ~marvin.utils.plot.map.plot.dapmap
object.
import numpy as np
fig, ax = mapplot.plot(value=np.random.random((34, 34)), mask=ha.mask)
This flexibilty is especially useful for passing in a custom mask, such as one created with the ~marvin.tools.maps.Maps.get_bpt
method. For more explanation of the mask manipulation in this specific example, see the plotting tutorial <marvin-plotting-map-starforming>
.
from marvin.tools.maps import Maps masks, __, __ = maps.get_bpt(show_plot=False)
# Create a bitmask for non-star-forming spaxels by taking the # complement (~) of the BPT global star-forming mask (where True == star-forming) # and mark those spaxels as "DONOTUSE". mask_non_sf = ~masks['sf']['global'] * ha.pixmask.labels_to_value('DONOTUSE')
# Do a bitwise OR between DAP mask and non-star-forming mask. mask = ha.mask | mask_non_sf fig, ax = mapplot.plot(dapmap=ha, mask=mask) # == ha.plot(mask=mask)
~marvin.utils.plot.map.plot
lets you build multi-panel plots because it accepts pre-defined matplotlib.figure and matplotlib.axes objects.
import matplotlib.pyplot as plt plt.style.use('seaborn-darkgrid') # set matplotlib style sheet
plateifus = ['8485-1901', '7443-12701'] mapnames = ['stellar_vel', 'stellar_sigma']
rows = len(plateifus) cols = len(mapnames) fig, axes = plt.subplots(rows, cols, figsize=(8, 8)) for row, plateifu in zip(axes, plateifus): maps = Maps(plateifu=plateifu) for ax, mapname in zip(row, mapnames): mapplot.plot(dapmap=maps[mapname], fig=fig, ax=ax, title=' '.join((plateifu, mapname)))
fig.tight_layout()
For more in-depth discussion of using ~marvin.utils.plot.map
, please see the following sections:
marvin-plotting-tutorial
marvin-plotting-quick-map
marvin-plotting-multipanel-single
marvin-plotting-multipanel-multiple
marvin-plotting-custom-map-cbrange
marvin-plotting-custom-map-snr-min
marvin-plotting-custom-map-axes
Plot Halpha Map of Star-forming Spaxels <marvin-plotting-map-starforming>
Plot [NII]/Halpha Flux Ratio Map of Star-forming Spaxels <marvin-plotting-niiha-map-starforming>
marvin-plotting-qualitative-colorbar
marvin-plotting-custom-map-mask
MPL-5+ |
---|
Property Type Bad Data Bitmasks Colormap Percentile Clip Symmetric Colorbar Minimum SNR |
==================== ==================== ========= =============== ================== =========== |
default UNRELIABLE, DONOTUSE linearlab 5, 95 False 1 |
velocities UNRELIABLE, DONOTUSE RdBu_r 10, 90 True 0a |
velocity dispersions UNRELIABLE, DONOTUSE inferno 10, 90 False 1 |
a Velocities do not have a minimum SNR. This allows spaxels near the zero-velocity contour to be displayed, but users are cautioned that some spaxels could have arbitrarily low SNRs.
Note: MPL-4 uses the same default plotting parameters as MPL-5, except the Bad Data Bitmasks, which use bit 1 (roughly DONOTUSE) for all properties.
~marvin.utils.plot.map.mask_low_snr
creates a mask of a map where the data is below a minimum signal-to-noise ratio.
from marvin.tools.maps import Maps
import marvin.utils.plot.map as mapplot
maps = Maps(plateifu='8485-1901')
ha = maps['emline_gflux_ha_6564']
low_snr = mapplot.mask_low_snr(value=ha.value, ivar=ha.ivar, snr_min=1)
Important: In 2.1.4, the call signature is low_snr_mask(value, ivar, snr_min)
. In version 2.2.0, this changes to mask_low_snr(value, ivar, snr_min)
.
~marvin.utils.plot.map.mask_neg_values
creates a mask of a map where the values are negative. This is necessary to avoid erros when using a logarithmic colorbar.
from marvin.tools.maps import Maps
import marvin.utils.plot.map as mapplot
maps = Maps(plateifu='8485-1901')
ha = maps['emline_gflux_ha_6564']
neg_values = mapplot.mask_neg_values(value=ha.value)
Important: In 2.1.4, the call signature is log_colorbar_mask(value, log_cb)
. In version 2.2.0, this changes to mask_neg_values(value)
.
~marvin.utils.plot.map.set_title
sets the title of the axis object. You can directly specify the title or construct it from the property name (and channel name).
import marvin.utils.plot.map as mapplot
title = mapplot.set_title(title=None, property_name=ha.datamodel.name, channel=ha.datamodel.channel.name)
Module
marvin.utils.plot.map
Functions
marvin.utils.plot.map.ax_setup marvin.utils.plot.map.mask_low_snr marvin.utils.plot.map.mask_neg_values marvin.utils.plot.map.plot marvin.utils.plot.map.set_title