Quantity Classes¶
Base classes¶

class
marvin.tools.quantities.base_quantity.
BinInfo
(spaxel=None, parent=None, datamodel=None)[source]¶ Bases:
object
Provides information about the bin associated with this quantity.

get_bin_spaxels
(lazy=True)[source]¶ Returns a list of the spaxels associated with this bin.
Parameters: lazy (bool) – If True
, the spaxels returned will be lazy loaded. Spaxels can be fully loaded by calling theirload
method.Returns: spaxels (list) – A list of all the Spaxel
instances associated with this quantity binid.

binid
¶ Returns the binid associated to this quantity and spaxel.

binid_map
¶ Returns the binid Map associated to this quantity.

binid_mask
¶ Returns a mask of the spaxels with the same binid.

is_binned
¶ Returns
True`
if the parent object is binned.


class
marvin.tools.quantities.base_quantity.
QuantityMixIn
[source]¶ Bases:
object
A MixIn that provides common functionalities to Quantity classes.

descale
()[source]¶ Returns a copy of the object in which the scale is unity.
Example
>>> dc.unit Unit("1e17 erg / (Angstrom cm2 s spaxel)") >> dc[100, 15, 15] <DataCube 0.270078063011169 1e17 erg / (Angstrom cm2 s spaxel)> >>> dc_descaled = dc.descale() >>> d_descaled.unit Unit("Angstrom cm2 s spaxel") >>> dc[100, 15, 15] <DataCube 2.70078063011169e18 erg / (Angstrom cm2 s spaxel)>

error
¶ Compute the standard deviation of the measurement.

masked
¶ Return a masked array.
If the
pixmask
is set, and the maskbit contains theDONOTUSE
andNOCOV
labels, the returned array will be masked for the values containing those bits. Otherwise, all values where the mask is greater than zero will be masked.

pixmask
¶ Maskbit instance for the pixmask flag.
See Maskbit Utilities for documentation and
Maskbit
for API reference.

snr
¶ Return the signaltonoise ratio for each spaxel in the map.

Datacube¶

class
marvin.tools.quantities.datacube.
DataCube
[source]¶ Bases:
astropy.units.quantity.Quantity
,marvin.tools.quantities.base_quantity.QuantityMixIn
A
Quantity
powered representation of a 3D data cube.A
DataCube
represents a 3D array in which two of the dimensions correspond to the spatial direction, with the third one being the spectral direction.Parameters:  value (
ndarray
) – A 3D array with the value of the quantity measured. The first axis of the array must be the wavelength dimension.  wavelength (
ndarray
) – A 1D array with the wavelength of each spectral measurement. It must have the same length as the spectral dimesion ofvalue
.  unit (
Unit
) – Anastropy unit
with the units forvalue
.  scale (float) – The scale factor of the spectrum value.
 wavelength_unit (astropy.unit.Unit) – The units of the wavelength solution. Defaults to Angstrom.
 redcorr (
ndarray
) – The reddenning correction, used byModelCube.deredden
.  ivar (
ndarray
) – An array with the same shape asvalue
contianing the associated inverse variance.  mask (
ndarray
) – Same asivar
but for the associated bitmask.  binid (
ndarray
) – The associated binid map for this datacube. Only set for DAPModelCube
datacubes.  pixmask_flag (str) – The maskbit flag to be used to convert from mask bits to labels (e.g., MANGA_DRP3PIXMASK).
 kwargs (dict) – Keyword arguments to be passed to
Quantity
when it is initialised.

deredden
(redcorr=None)[source]¶ Returns the dereddened datacube.
Parameters: redcorr (float or None) – The reddening correction to apply. If None
, defaults to theDataCube.redcorr
.Returns: deredden (DataCube) – A DataCube
with the flux and ivar corrected from reddening.Raises: ValueError
– Ifredcorr=None
andDataCube.redcorr=None
.

std
¶ The standard deviation of the measurement.
 value (
Spectrum¶

class
marvin.tools.quantities.spectrum.
Spectrum
[source]¶ Bases:
astropy.units.quantity.Quantity
,marvin.tools.quantities.base_quantity.QuantityMixIn
A class representing an spectrum with extra functionality.
Parameters:  value (arraylike) – The 1D array contianing the spectrum.
 wavelength (arraylike, optional) – The wavelength solution for
value
.  scale (float, optional) – The scale factor of the spectrum value.
 unit (astropy.unit.Unit, optional) – The unit of the spectrum.
 wavelength_unit (astropy.unit.Unit, optional) – The units of the wavelength solution. Defaults to Angstrom.
 ivar (arraylike, optional) – The inverse variance array for
value
.  std (arraylike, optional) – The standard deviation associated with
value
.  mask (arraylike, optional) – The mask array for
value
.  pixmask_flag (str) – The maskbit flag to be used to convert from mask bits to labels (e.g., MANGA_DRP3PIXMASK).
 kwargs (dict) – Keyword arguments to be passed to
Quantity
when it is initialised.
Returns: spectrum – An astropy Quantitylike object that contains the spectrum, as well as inverse variance, mask, and wavelength (itself a Quantity array).

plot
(xlim=None, ylim=None, show_std=True, use_mask=True, n_sigma=1, xlabel='Wavelength', ylabel='Flux', show_units=True, plt_style='seaborndarkgrid', figure=None, return_figure=False, title=None, ytrim='positive', **kwargs)[source]¶ Plots the spectrum.
Displays the spectrum showing, optionally, the \(n\sigma\) region, and applying the mask.
Parameters:  xlim,ylim (tuple or None) – The range to display for the x and yaxis, respectively,
defined as a tuple of two elements
[xmin, xmax]
. If the range isNone
, the range for the xaxis range will be set automatically by matploltib while the yaxis limits will be optimised to reject extreme data points.  show_std (bool) – If
True
, the \(n\sigma\) range above and below the spectrum values will be shown as a shadowed area.n_sigma
determines how many sigmas will be plotted.  use_mask (bool) – If
True
, the region in which the mask is set toDONOTUSE
will be masked out in the plot.  show_units (bool) – If
True
, the units will be added to the axis labels.  n_sigma (float) – The number of standard deviations that will be shown if
show_std=True
.  xlabel,ylabel (str or None) – The axis labels to be passed to the plot. If not defined, the y
axis will be labelled as
Flux
and the x axis asWavelength
.  ytrim (str) – The default ylimit behavior when no ylim specified. Can be “positive”, “percentile”, or “minmax”. “positive” imposes a lower y bound of 0. “percentile” performs a 10% sigma clipping on the data to compute the bounds. “minmax” uses the straight min/max of the data. Default is “positive”.
 title (str) – The title of the plot
 plt_style (str) – Matplotlib style sheet to use. Default is ‘seaborndarkgrid’.
 figure (
Figure
or None) – The matplotlibFigure
object from which the axes must be created. Iffigure=None
, a new figure will be created.  return_figure (bool) – If
True
, the matplotlibFigure
object used will be returned along with the axes object.  kwargs (dict) – Keyword arguments to be passed to
plot
.
Returns: axes – The
Axes
object containing the plot representing the spectrum. Ifreturn_figure=True
, a tuple will be returned of the form(ax, fig)
, wherefig
is the associatedFigure
.Example
>>> ax = spectrum.plot(n_sigma=3) >>> ax.show()
We can change the range of the axes after the object has been created.
>>> ax.set_xlim(6500, 6600) >>> ax.show()
 xlim,ylim (tuple or None) – The range to display for the x and yaxis, respectively,
defined as a tuple of two elements

std
¶ The standard deviation of the measurement.
Map¶

class
marvin.tools.quantities.map.
EnhancedMap
(*args, **kwargs)[source]¶ Bases:
marvin.tools.quantities.map.Map
Creates a Map that has been modified.

datamodel
¶ Returns the associated
Property
.


class
marvin.tools.quantities.map.
Map
[source]¶ Bases:
astropy.units.quantity.Quantity
,marvin.tools.quantities.base_quantity.QuantityMixIn
Describes 2D array object with addtional features.
A generaluse
Quantity
powered 2D array with features such as units, inverse variance, mask, quick acces to statistics methods, and plotting. WhileMap
can be used for any 2D array, it is mostly intended to represent an extension in a DAP MAPS file (normally known in MaNGA as a map). Unlike aMaps
object, which contains all the information from a DAP MAPS file, this class represents only one of the multiple 2D maps contained within. For instance,Maps
may contain emission line maps for multiple channels. AMap
would be, for example, the map foremline_gflux
and channelha_6564
.A
Map
is normally initialised from aMaps
by calling thegetMap
method. It can be initialialised directly using theMap.from_maps
classmethod.Parameters:  array (arraylike) – The 2D array contianing the spectrum.
 unit (astropy.unit.Unit, optional) – The unit of the spectrum.
 scale (float, optional) – The scale factor of the spectrum value.
 ivar (arraylike, optional) – The inverse variance array for
value
.  mask (arraylike, optional) – The mask array for
value
.  binid (arraylike, optional) – The associated binid map.
 pixmask_flag (str) – The maskbit flag to be used to convert from mask bits to labels (e.g., MANGA_DAPPIXMASK).

inst_sigma_correction
()[source]¶ Correct for instrumental broadening.
Correct observed stellar or emission line velocity dispersion for instrumental broadening.

plot
(*args, **kwargs)[source]¶ Make single panel map or one panel of multipanel map plot.
Please see the Plotting Tutorial for examples.
Parameters:  dapmap (marvin.tools.quantities.Map) – Marvin Map object. Default is
None
.  value (array) – Data array. Default is
None
.  ivar (array) – Inverse variance array. Default is
None
.  mask (array) – Mask array. Default is
None
.  cmap (str) – Colormap (see Default Plotting Parameters for defaults).
 percentile_clip (tuplelike) – Percentile clip (see Default Plotting Parameters for defaults).
 sigma_clip (float) – Sigma clip. Default is
False
.  cbrange (tuplelike) – If
None
, set automatically. Default isNone
.  symmetric (bool) – Draw a colorbar that is symmetric around zero (see Default Plotting Parameters for default).
 snr_min (float) – Minimum signaltonoise for keeping a valid measurement (see Default Plotting Parameters for default).
 log_cb (bool) – Draw a log normalized colorbar. Default is
False
.  title (str) – If
None
, set automatically from property (and channel) name(s). For no title, set to ‘’. Default isNone
.  title_mode (str) – The mode to generate a title automatically, if
title
is not set. Usually'string'
or'latex'
. Default is'string'
. Seeto_string()
for details.  cblabel (str) – If
None
, set automatically from unit. For no colorbar label, set to ‘’. Default isNone
.  sky_coords (bool) – If
True
, show plot in sky coordinates (i.e., arcsec), otherwise show in spaxel coordinates. Default isFalse
.  use_masks (bool, str, list) – Use DAP bitmasks. If
True
, use the recommended DAP masks. Otherwise provide a mask name as a string or multiple mask names as a list of strings. Default isTrue
.  plt_style (str) – Matplotlib style sheet to use. Default is ‘seaborndarkgrid’.
 fig (matplotlib Figure object) – Use if creating subplot of a multipanel plot. Default is
None
.  ax (matplotlib Axis object) – Use if creating subplot of a multipanel plot. Default is
None
.  patch_kws (dict) – Keyword args to pass to matplotlib.patches.Rectangle.
Default is
None
.  imshow_kws (dict) – Keyword args to pass to ax.imshow.
Default is
None
.  cb_kws (dict) – Keyword args to set and draw colorbar. Default is
None
.  return_cb (bool) – Return colorbar axis. Default is
False
.  return_cbrange (bool) – Return colorbar range without drawing plot. Default is
False
.
Returns: fig, ax (tuple) – matplotlib.figure, matplotlib.axes
Example
>>> import marvin.utils.plot.map as mapplot >>> maps = Maps(plateifu='84851901') >>> ha = maps['emline_gflux_ha_6564'] >>> fig, ax = mapplot.plot(dapmap=ha)
 dapmap (marvin.tools.quantities.Map) – Marvin Map object. Default is

classmethod
restore
(path, delete=False)[source]¶ Restore a Map object from a pickled file.
If
delete=True
, the pickled file will be removed after it has been unplickled. Note that, for map objects instantiated from a Maps object withdata_origin='file'
, the original file must exists and be in the same path as when the object was first created.

save
(path, overwrite=False)[source]¶ Pickle the map to a file.
This method will fail if the map is associated to a Maps loaded from the db.
Parameters:  path (str) – The path of the file to which the
Map
will be saved. Unlike for other Marvin Tools that derive fromMarvinToolsClass
,path
is mandatory forMap
given that the there is no default path for a given map.  overwrite (bool) – If True, and the
path
already exists, overwrites it. Otherwise it will fail.
Returns: path (str) – The realpath to which the file has been saved.
 path (str) – The path of the file to which the

datamodel
¶ Returns the associated
Property
.

masked
¶ Return a masked array using the recommended masks.

std
¶ The standard deviation of the measurement.
Analysis Property¶

class
marvin.tools.quantities.analysis_props.
AnalysisProperty
[source]¶ Bases:
astropy.units.quantity.Quantity
,marvin.tools.quantities.base_quantity.QuantityMixIn
A class describing a measurement with additional information.
Represents a quantity with an associated unit and possibly an associated error and mask.
Parameters:  value (float) – The value of the quantity.
 unit (astropy.unit.Unit, optional) – The unit of the quantity.
 scale (float, optional) – The scale factor of the quantity value.
 ivar (float or None) – The inverse variance associated with
value
, orNone
if not defined.  mask (int or None) – The mask value associated with
value
, orNone
if not defined.  pixmask_flag (str) – The maskbit flag to be used to convert from mask bits to labels (e.g., MANGA_DAPPIXMASK).

std
¶ The standard deviation of the measurement.