marvin.utils.plot.map
)¶marvin.utils.plot.map
contains utility functions for plotting Marvin maps. The main function in this module is plot()
, which is thinly wrapped by the plot()
method in the Map
class for convenience.
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
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 value
, ivar
, and/or mask
with your own arrays.
fig, ax = mapplot.plot(dapmap=ha, value=ha.value * 10.)
A dapmap
object is not even necessary for plot
, though if you do not provide a dapmap
object, then you will need to set a value
. You will also need to provide other attributes, such as title
and cblabel
, that are by default set from attributes of the 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 get_bpt()
method. For more explanation of the mask manipulation in this specific example, see the plotting tutorial.
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)
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', '8485-1902', '8485-12701']
mapnames = ['stellar_vel', 'stellar_sigma']
rows = len(plateifus)
cols = len(mapnames)
fig, axes = plt.subplots(rows, cols, figsize=(8, 12))
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()
map
¶For more in-depth discussion of using map
, please see the following sections:
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.
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)
.
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)
.
ax_setup()
sets the x- and y-labels and facecolor.
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 (sky_coords[, …]) |
Do basic axis setup for maps. |
marvin.utils.plot.map.mask_low_snr (value, …) |
Mask spaxels with a signal-to-noise ratio below some threshold. |
marvin.utils.plot.map.mask_neg_values (value) |
Mask spaxels with negative values. |
marvin.utils.plot.map.plot (*args, **kwargs) |
Make single panel map or one panel of multi-panel map plot. |
marvin.utils.plot.map.set_title ([title, …]) |
Set title for map. |