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.
- property binid¶
Returns the binid associated to this quantity and spaxel.
- property binid_map¶
Returns the binid Map associated to this quantity.
- property binid_mask¶
Returns a mask of the spaxels with the same binid.
- property 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("1e-17 erg / (Angstrom cm2 s spaxel)") >> dc[100, 15, 15] <DataCube 0.270078063011169 1e-17 erg / (Angstrom cm2 s spaxel)> >>> dc_descaled = dc.descale() >>> d_descaled.unit Unit("Angstrom cm2 s spaxel") >>> dc[100, 15, 15] <DataCube 2.70078063011169e-18 erg / (Angstrom cm2 s spaxel)>
- property error¶
Compute the standard deviation of the measurement.
- property 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.
- property pixmask¶
Maskbit instance for the pixmask flag.
See Maskbit Utilities for documentation and
Maskbit
for API reference.
- property snr¶
Return the signal-to-noise ratio for each spaxel in the map.
Datacube¶
- class marvin.tools.quantities.datacube.DataCube(value, wavelength, scale=None, unit=Unit(dimensionless), wavelength_unit=Unit('Angstrom'), redcorr=None, ivar=None, mask=None, binid=None, pixmask_flag=None, dtype=None, copy=True, **kwargs)[source]¶
Bases:
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 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 – If
redcorr=None
andDataCube.redcorr=None
.
- property std¶
The standard deviation of the measurement.
Spectrum¶
- class marvin.tools.quantities.spectrum.Spectrum(flux, wavelength, scale=None, unit=Unit('Angstrom'), wavelength_unit=Unit('Angstrom'), ivar=None, std=None, mask=None, dtype=None, copy=True, pixmask_flag=None, **kwargs)[source]¶
Bases:
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
.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 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, title=None, ytrim='positive', **kwargs)[source]¶
Plots the spectrum.
Displays the spectrum showing, optionally, the \(n\sigma\) region, and applying the mask.
- Parameters
xlim (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 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.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 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 (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
.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 y-limit 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 ‘seaborn-darkgrid’.
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.
- 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()
- property std¶
The standard deviation of the measurement.
Map¶
- class marvin.tools.quantities.map.EnhancedMap(value, unit, *args, **kwargs)[source]¶
Bases:
Map
Creates a Map that has been modified.
- property datamodel¶
Returns the associated
Property
.
- class marvin.tools.quantities.map.Map(array, unit=None, scale=1, ivar=None, mask=None, binid=None, pixmask_flag=None, dtype=None, copy=True)[source]¶
Bases:
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. 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 (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.
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 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 isNone
.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 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 ‘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 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.
- property datamodel¶
Returns the associated
Property
.
- property masked¶
Return a masked array using the recommended masks.
- property std¶
The standard deviation of the measurement.
Analysis Property¶
- class marvin.tools.quantities.analysis_props.AnalysisProperty(value, unit=Unit(dimensionless), scale=1, ivar=None, mask=None, pixmask_flag=None, dtype=None, copy=True)[source]¶
Bases:
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).
- property std¶
The standard deviation of the measurement.