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 [26]:
from __future__ import print_function, division, absolute_import
import matplotlib.pyplot as plt
%matplotlib inline
Now, let’s import Marvin:
In [1]:
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 [2]:
marvin.config.release
Out[2]:
On intial import, Marvin will set the default data release to use the latest MPL available, currently MPL-6. You can change the version of MaNGA data using the Marvin Config.
In [4]:
from marvin import config
config.setRelease('MPL-5')
print('MPL:', config.release)
But let's work with MPL-6:
In [6]:
config.setRelease('MPL-6')
# check designated version
config.release
Out[6]:
In [7]:
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/v2_3_1/8485/stack/manga-8485-1901-LOGCUBE.fits.gz
EDIT Next Cell
In [9]:
#----- 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/v2_3_1/8485/stack/manga-8485-1901-LOGCUBE.fits.gz'
filename = '/Users/Brian/Work/Manga/redux/v2_3_1/8485/stack/manga-8485-1901-LOGCUBE.fits.gz'
Create a Cube object:
In [10]:
cc = Cube(filename=filename)
Now we have a Cube object:
In [11]:
print(cc)
How about we look at some meta-data
In [12]:
cc.ra, cc.dec, cc.header['SRVYMODE']
Out[12]:
...and the quality and target bits
In [14]:
cc.target_flags
Out[14]:
In [16]:
cc.quality_flag
Out[16]:
In [17]:
spax = cc[10,10]
In [18]:
# 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[18]:
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 [19]:
# let's grab the central spaxel
spax = cc.getSpaxel(x=0, y=0)
spax
Out[19]:
In [21]:
spax.flux.wavelength
Out[21]:
In [22]:
spax.flux
Out[22]:
In [23]:
# turn on interactive plotting
%matplotlib notebook
In [24]:
spax.flux.plot()
Out[24]:
Save plot to Downloads directory:
In [27]:
# To save the plot, we need to draw it in the same cell as the save command.
spax.flux.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 [ ]: