Marvin Quantity Classes

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 3-D array with the value of the quantity measured. The first axis of the array must be the wavelength dimension.
  • wavelength (ndarray) – A 1-D array with the wavelength of each spectral measurement. It must have the same length as the spectral dimesion of value.
  • unit (Unit) – An astropy unit with the units for value.
  • 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 by ModelCube.deredden.
  • ivar (ndarray) – An array with the same shape as value contianing the associated inverse variance.
  • mask (ndarray) – Same as ivar but for the associated bitmask.
  • binid (ndarray) – The associated binid map for this datacube. Only set for DAP ModelCube datacubes.
  • 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 the DataCube.redcorr.
Returns:deredden (DataCube) – A DataCube with the flux and ivar corrected from reddening.
Raises:ValueError – If redcorr=None and DataCube.redcorr=None.
std

The standard deviation of the measurement.

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 (array-like) – The 1-D array contianing the spectrum.
  • wavelength (array-like, 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 (array-like, optional) – The inverse variance array for value.
  • std (array-like, optional) – The standard deviation associated with value.
  • mask (array-like, optional) – The mask array for value.
  • kwargs (dict) – Keyword arguments to be passed to Quantity when it is initialised.
Returns:

spectrum – An astropy Quantity-like 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='seaborn-darkgrid', figure=None, return_figure=False, **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 y-axis, respectively, defined as a tuple of two elements [xmin, xmax]. If the range is None, 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 non-zero will not be shown 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 as Wavelength.
  • plt_style (str) – Matplotlib style sheet to use. Default is ‘seaborn-darkgrid’.
  • figure (Figure or None) – The matplotlib Figure object from which the axes must be created. If figure=None, a new figure will be created.
  • return_figure (bool) – If True, the matplotlib Figure 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. If return_figure=True, a tuple will be returned of the form (ax, fig), where fig is the associated Figure.

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()
error

The standard deviation of the measurement.

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.

inst_sigma_correction()[source]

Override Map.inst_sigma_correction with AttributeError.

datamodel

Returns the associated Property.

pixmask

Maskbit instance for the MANGA_DAPPIXMASK flag.

See Maskbit (marvin.utils.general.maskbit.Maskbit) for documentation and marvin.utils.general.maskbit.Maskbit() for API reference.

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 general-use Quantity-powered 2D array with features such as units, inverse variance, mask, quick acces to statistics methods, and plotting. While Map 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 a Maps 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. A Map would be, for example, the map for emline_gflux and channel ha_6564.

A Map is normally initialised from a Maps by calling the getMap method. It can be initialialised directly using the Map.from_maps classmethod.

Parameters:
  • array (array-like) – The 2-D 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 (array-like, optional) – The inverse variance array for value.
  • mask (array-like, optional) – The mask array for value.
  • binid (array-like, optional) – The associated binid map.
classmethod from_maps(maps, prop, dtype=None, copy=True)[source]

Initialise a Map from a Maps.

getMaps()[source]

Returns the associated Maps.

getSpaxel(**kwargs)[source]

Returns a Spaxel.

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 multi-panel 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 (tuple-like) – Percentile clip (see Default Plotting Parameters for defaults).
  • sigma_clip (float) – Sigma clip. Default is False.
  • cbrange (tuple-like) – If None, set automatically. Default is None.
  • symmetric (bool) – Draw a colorbar that is symmetric around zero (see Default Plotting Parameters for default).
  • snr_min (float) – Minimum signal-to-noise 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 is None.
  • title_mode (str) – The mode to generate a title automatically, if title is not set. Usually 'string' or 'latex'. Default is 'string'. See to_string() for details.
  • cblabel (str) – If None, set automatically from unit. For no colorbar label, set to ‘’. Default is None.
  • sky_coords (bool) – If True, show plot in sky coordinates (i.e., arcsec), otherwise show in spaxel coordinates. Default is False.
  • 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 is True.
  • plt_style (str) – Matplotlib style sheet to use. Default is ‘seaborn-darkgrid’.
  • fig (matplotlib Figure object) – Use if creating subplot of a multi-panel plot. Default is None.
  • ax (matplotlib Axis object) – Use if creating subplot of a multi-panel 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='8485-1901')
>>> ha = maps['emline_gflux_ha_6564']
>>> fig, ax = mapplot.plot(dapmap=ha)
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 with data_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 from MarvinToolsClass, path is mandatory for Map 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.

datamodel

Returns the associated Property.

error

Computes the standard deviation of the measurement.

masked

Return a masked array using the recommended masks.

pixmask

Maskbit instance for the MANGA_DAPPIXMASK flag.

See Maskbit (marvin.utils.general.maskbit.Maskbit) for documentation and marvin.utils.general.maskbit.Maskbit() for API reference.

snr

Return the signal-to-noise ratio for each spaxel in the map.

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, or None if not defined.
  • mask (int or None) – The mask value associated with value, or None if not defined.