Now that you have installed Marvin, it's time to take your first steps. If you want to learn more about how Marvin works, then go see General Info to learn about Marvin Modes, Versions, or Downloading. If you just want to play, then read on.
First let's run some boilerplate code for Python 2/3 compatibility and plotting in the notebook:
In [1]:
from __future__ import print_function, division, absolute_import
import matplotlib.pyplot as plt
%matplotlib inline
Now, let’s import Marvin:
In [2]:
import marvin
Let's see what release we're using. Releases can be either MPLs (e.g. MPL-5) or DRs (e.g. DR13), however DRs are currently disabled in Marvin.
In [3]:
marvin.config.release
Out[3]:
On intial import, Marvin will set the default data release to use the latest MPL available, currently MPL-5. You can change the version of MaNGA data using the Marvin Config.
In [7]:
from marvin import config
config.setRelease('MPL-3')
print('MPL:', config.release)
You can also specifically change releases using the setMPL method as well:
In [10]:
config.setMPL('MPL-5')
print('MPL:', config.release)
But let's work with MPL-4:
In [11]:
config.setRelease('MPL-4')
# check designated version
config.release
Out[11]:
In [12]:
from marvin.tools.cube import Cube
Let's load a cube from a local file. Start by specifying the full path and name of the file, such as:
/Users/Brian/Work/Manga/redux/v1_5_1/8485/stack/manga-8485-1901-LOGCUBE.fits.gz
EDIT Next Cell
In [13]:
#----- EDIT THIS CELL -----#
# filename = '/Users/Brian/Work/Manga/redux/v1_5_1/8485/stack/manga-8485-1901-LOGCUBE.fits.gz'
filename = 'path/to/manga/cube/manga-8485-1901-LOGCUBE.fits.gz'
filename = '/Users/andrews/manga/spectro/redux/v1_5_1/8485/stack/manga-8485-1901-LOGCUBE.fits.gz'
filename = '/Users/Brian/Work/Manga/redux/v1_5_1/8485/stack/manga-8485-1901-LOGCUBE.fits.gz'
Create a Cube object:
In [14]:
cc = Cube(filename=filename)
Now we have a Cube object:
In [15]:
print(cc)
How about we look at some meta-data
In [16]:
cc.ra, cc.dec, cc.header['SRVYMODE']
Out[16]:
...and the quality and target bits
In [17]:
cc.targetbit
Out[17]:
In [18]:
cc.qualitybit
Out[18]:
In [34]:
spax = cc[10,10]
In [36]:
# print the spaxel to see the x,y coord from the lower left, and the coords relative to the cube center, x_cen/y_cen
spax
Out[36]:
Spaxels have a spectrum associated with it. It has the wavelengths and fluxes of each spectral channel:
Alternatively grab a spaxel with getSpaxel. Use the xyorig keyword to set the coordinate origin point: 'lower' or 'center'. The default is "center"
In [41]:
# let's grab the central spaxel
spax = cc.getSpaxel(x=0, y=0)
spax
Out[41]:
In [42]:
spax.spectrum.wavelength
Out[42]:
In [43]:
spax.spectrum.flux
Out[43]:
In [44]:
# turn on interactive plotting
%matplotlib notebook
In [45]:
spax.spectrum.plot()
Out[45]:
Save plot to Downloads directory:
In [30]:
# To save the plot, we need to draw it in the same cell as the save command.
spax.spectrum.plot()
import os
plt.savefig(os.getenv('HOME') + '/Downloads/my-first-spectrum.png')
# NOTE - if you are using the latest version of iPython and Jupyter notebooks, then interactive matplotlib plots
# should be enabled. You can save the figure with the save icon in the interactive toolbar.
In [ ]: