Map¶
Map
is a single map for a single galaxy. The main data that it contains are the value
, ivar
, and mask
arrays of the map.
Initializing a Map¶
To get a Map
, we first create a marvin.tools.maps.Maps
object, which contains all of the maps for a galaxy. Then we select an individual Map
in one of four ways:
exact key slicing,
dot syntax,
getMap
method, orfuzzy key slicing.
>>> from marvin.tools import Maps
>>> maps = Maps(plateifu='8485-1901')
>>> # exact key slicing
>>> ha = maps['emline_gflux_ha_6564']
>>> # dot syntax
>>> ha = maps.emline_gflux_ha_6564
>>> # getMap()
>>> ha = maps.getMap('emline_gflux_ha_6564')
>>> # equivalently
>>> ha = maps.getMap('emline_gflux', channel='ha_6564')
>>> # fuzzy key slicing
>>> ha = maps['gflux ha']
Fuzzy key slicing works if the input is unambiguously associated with a particular key:
>>> maps['gflux ha'] # == maps['emline_gflux_ha_6564']
>>> maps['gvel oiii 5008'] # == maps[emline_gvel_oiii_5008]
>>> maps['stellar sig'] # == maps['stellar_sigma']
>>> # Ambiguous: there are several velocity properties (stellar and emission lines).
>>> maps['vel'] # ValueError
>>> # Ambiguous: there are two [O III] lines.
>>> maps['gflux oiii'] # ValueError
Basic Attributes¶
The values, inverse variances, and bitmasks of the map can be accessed via the value
, ivar
, and mask
attributes, respectively.
>>> ha.value # (34, 34) array
>>> ha.ivar # (34, 34) array
>>> ha.mask # (34, 34) array --- same as ha.pixmask.mask
>>> ha.value[17] # get the middle row (i.e., "y")
array([ 0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0.0360246, 0.0694705, 0.135435 ,
0.564578 , 1.44708 , 3.12398 , 7.72712 , 14.2869 ,
22.2461 , 29.1134 , 32.1308 , 28.9591 , 21.4879 ,
13.9937 , 7.14412 , 3.84099 , 1.64863 , 0.574292 ,
0.349627 , 0.196499 , 0.144375 , 0.118376 , 0. ,
0. , 0. , 0. , 0. ])
Accessing an Individual Spaxel¶
Slicing a Map
returns the property for a single spaxel:
>>> ha[17, 17] # the Halpha flux value in the central spaxel
<Marvin Map (property='emline_gflux_ha_6564')>
30.7445 1e-17 erg / (cm2 s spaxel)
Accessing the Parent Maps Object¶
From a Map
object we can access its parent Maps
object via the maps
attribute.
>>> ha.getMaps() == maps # True
Map Arithmetic¶
Map
objects can be added, subtracted, multiplied, divided, or raised to a power. You can also take the logarithm of them.
>>> ha = maps['emline_gflux_ha_6564']
>>> nii = maps['emline_gflux_nii_6585']
>>> sum_ = nii + ha
>>> diff = nii - ha
>>> prod = nii * ha
>>> quot = nii / ha
>>> pow_ = ha**0.5
>>> n2ha = np.log10(nii / ha)
In addition to performing the arithmetic operation on the value
, the resulting EnhancedMap
has correctly propagated ivar
, mask
, pixmask
, unit
, and scale
.
Masking¶
The masked
attribute is a numpy masked array. The data
attribute is the value
array and the mask
attribute is a boolean array. mask
is True
for a given spaxel if any of the recommended bad data flags (NOCOV, UNRELIABLE, and DONOTUSE) are set.
>>> ha.masked[17]
masked_array(data=[--, --, --, --, --, --, --, 0.0360246, 0.0694705,
0.135435, 0.564578, 1.44708, 3.12398, 7.72712, 14.2869,
22.2461, 29.1134, 32.1308, 28.9591, 21.4879, 13.9937,
7.14412, 3.84099, 1.64863, 0.574292, 0.349627,
0.196499, 0.144375, 0.118376, --, --, --, --, --],
mask=[ True, True, True, True, True, True, True, False,
False, False, False, False, False, False, False, False,
False, False, False, False, False, False, False, False,
False, False, False, False, False, True, True, True,
True, True],
fill_value=1e+20)
For more fine-grained data quality control, you can select spaxels using pixmask
, which contains the mask
values, knows the MANGA_DAPPIXMASK
schema, and has convenience methods for converting between mask values, bit values, and labels.
See Maskbit Utilities for details.
>>> ha.pixmask
<Maskbit 'MANGA_DAPPIXMASK' shape=(34, 34)>
>>> ha.pixmask.schema
bit label description
0 0 NOCOV No coverage in this spaxel
1 1 LOWCOV Low coverage in this spaxel
2 2 DEADFIBER Major contributing fiber is dead
3 3 FORESTAR Foreground star
4 4 NOVALUE Spaxel was not fit because it did not meet sel...
5 5 UNRELIABLE Value is deemed unreliable; see TRM for defini...
6 6 MATHERROR Mathematical error in computing value
7 7 FITFAILED Attempted fit for property failed
8 8 NEARBOUND Fitted value is too near an imposed boundary; ...
9 9 NOCORRECTION Appropriate correction not available
10 10 MULTICOMP Multi-component velocity features present
11 30 DONOTUSE Do not use this spaxel for science
>>> ha.pixmask.mask # == ha.mask
>>> ha.pixmask.bits # bits corresponding to mask array
>>> ha.pixmask.labels # labels corresponding to mask array
Note: For MANGA_DAPPIXMASK
, DONOTUSE is a consolidation of the flags NOCOV, LOWCOV, DEADFIBER, FORESTAR, NOVALUE, MATHERROR, FITFAILED, and NEARBOUND.
Common Masking Operations¶
>>> # Spaxels not covered by the IFU
>>> nocov = ha.pixmask.get_mask('NOCOV')
>>> # Spaxels flagged as bad data
>>> bad_data = ha.pixmask.get_mask(['UNRELIABLE', 'DONOTUSE'])
>>> # Custom mask (flag data as DONOTUSE to hide in plotting)
>>> custom_mask = (ha.value < 1e-17) * ha.pixmask.labels_to_value('DONOTUSE')
>>> # Combine masks
>>> my_mask = nocov | custom_mask
Plotting¶
Map
can be easily plotted using the plot
method. Details on plotting parameters and defaults can be found here. For a guide about making different types of plots see the Plotting Tutorial.
>>> from marvin.tools import Maps
>>> maps = Maps('8485-1901')
>>> ha = maps.emline_gflux_ha_6564
>>> ha.plot() # plot the H-alpha flux map.
Saving and Restoring¶
Finally, we can save()
our Map
object as a MaNGA pickle file (*.mpf
) and then restore()
it.
>>> from marvin.tools.quantities import Map
>>> ha.save(path='/path/to/save/directory/ha_8485-1901.mpf')
>>> zombie_ha = Map.restore(path='/path/to/save/directory/ha_8485-1901.mpf')
Reference/API¶
Class Inheritance Diagram
Class
|
Describes 2D array object with addtional features. |
Methods
|
Compute the standard deviation of the measurement. |
|
Correct for instrumental broadening. |
|
Return a masked array using the recommended masks. |
|
Maskbit instance for the pixmask flag. |
|
Make single panel map or one panel of multi-panel map plot. |
|
Restore a Map object from a pickled file. |
|
Pickle the map to a file. |
|
Return the signal-to-noise ratio for each spaxel in the map. |
EnhancedMap¶
An EnhancedMap
is a Map
that has been modified by a map arithmetic operation (+
, -
, *
, /
, **
, or np.log10()
). It inherits most of the attributes of a Map
.
Reference/API¶
Class Inheritance Diagram
Class
|
Creates a Map that has been modified. |
Methods
|
Pickle the map to a file. |
|
Restore a Map object from a pickled file. |
|
Return a masked array using the recommended masks. |
|
Compute the standard deviation of the measurement. |
|
Return the signal-to-noise ratio for each spaxel in the map. |
|
Make single panel map or one panel of multi-panel map plot. |