MaNGA IDL Tutorial
This tutorial will first describe how to access RSS files with IDL, and then continue with a description on how to access datacubes. Examples of plotting and exploring spectra are included.
Accessing RSS files with IDL
These instructions will use the software package IDL along with the MaNGA galaxy 12-193481 (PLATE-IFU = 7443-12703). IDL requires a license. If you do not have access to IDL, please see the other tutorials that use free software (e.g python). For the MaNGA data, you can download the RSS file and datacube for this galaxy yourself with the following rsync commands in your terminal (replace LOCAL_PATH):
RSS
rsync -avz rsync://data.sdss.org/dr16/manga/spectro/redux/v2_4_3/7443/stack/manga-7443-12703-LOGRSS.fits.gz LOCAL_PATH
Cube
rsync -avz rsync://data.sdss.org/dr16/manga/spectro/redux/v2_4_3/7443/stack/manga-7443-12703-LOGCUBE.fits.gz LOCAL_PATH
The differences between the RSS and datacube files are here.
Reading an RSS file
In your IDL terminal, read in the flux and wavelength extensions. Note that the extensions for the MaNGA RSS files are listed in its datamodel.
file = 'manga-7443-12703-LOGRSS.fits.gz' flux = MRDFITS(file, "flux", hdr1) ;flux in 10^17 erg/s/cm^2/Ang/fiber wave = MRDFITS(file, "wave", hdr4) ; wavelength in Angstrom
As the flux and wavelength was read in, IDL should have printed the size "MRDFITS: Image array (4563,1905) Type=Real*4" for flux and "MRDFITS: Image array (4563) Type=Real*8" . The flux has dimensions of wavelength vs number of fibers, where the number of fibers is the IFU size times the number of exposures (127x15=1905). There are 4563 pixels in wavelength. To see this again explicitly for flux:
size_rss = SIZE(flux) print, size_rss(1) ;number of wavelength pixels print, size_rss(2) ;number of fibers
Plot a spectrum from a single fiber in RSS
Now, let's plot a spectrum for a single fiber. We will choose fiber 1313 because it is located near the center (finding fiber positions will be discussed later).
plot, wave, flux(*,1313), /xs, xtitle='wavelength(Ang)', ytitle='Flux'
You should see a nice emission line spectrum, with the strongest line being Hα around 6850 Angstroms (note it is not at 6563 Ang due to the redshift of the galaxy).
The mask and ivar extension are also useful. Both are the same size and format as the flux extension. When mask does not equal 0, this indicates a bad pixel. Ivar stands for the inverse variance.
mask = MRDFITS(file, "mask") ivar = MRDFITS(file, "ivar")
Now we can overplot the flux of fiber 1313, masking out any bad pixels. Besides the mask, whenever ivar is 0, this also indicates a bad pixel.
ok = WHERE(mask(*,1313) eq 0 and ivar(*,1313) gt 0) ;finding good pixels loadct, 38 ;for the color table oplot, wave[ok], flux[ok,1313], color=90
The overplotted green spectrum should be almost identical to the original spectrum. We can also use ivar to overplot the one sigma error for this fiber spectrum.
oplot, wave[ok], sqrt(1./ivar[ok,1313]), color=210
The error should be very small and close to zero, with some spikes around the emission lines.
Now let's zoom in to look at the Hα emission. First, we should correct for the redshift. The redshift for this galaxy is 0.04. This can be found in the drpall file.
restwave = wave/(1.+0.04) ;rest frame wavelength
Hα emission is at 6560 Angstroms in the rest frame. We can now replot the flux in this wavelength range.
plot, restwave[ok], flux[ok,1313], xrange=[6530,6600], /xs, $ xtitle='wavelength', ytitle='flux'
The Hα emission line is the strong line towards the center and [NII] emission lines are on either side.
Find the location of an individual fiber in RSS
To find the location or position of the fiber in the IFU, we use the xpos and ypos extensions. These give the position in arcsecs along the x and y axis, with the center at the orgin (0,0). These positions are also in a 2D array of wavelength and fiber. The positions can change slightly as a function of wavelength cause of the different dispersions. Usually you can take the position at a single wavelength, say at Hα (6560 Angstrom) or 5000 Angstrom, depending on what wavelength range is interesting for your science. Let's read in xpos and ypos and find out the location of fiber 1313.
xpos = MRDFITS(file,"xpos") ;reading in the xpos ypos = MRDFITS(file,"ypos") ;reading in the ypos print, wave[1400] ;wavelength chosen for position of fiber print, xpos[1400,1313] ;xpos at given wavelength and fiber 1313 print, ypos[1400,1313] ;ypos at given wavelength and fiber 1313
Reading in a datacube
First read in the 'FLUX' and 'WAVE' (wavelength) extensions with MRDFITS. You can define the extensions either by their numbers or their names, an overview of all extensions in the MaNGA data cube format is given in its datamodel.
file = 'manga-7443-12703-LOGCUBE.fits.gz' flux = MRDFITS(file, "flux", hdr1) ;flux extension wave = MRDFITS(file, "wave", hdr4) ; wavelength in Angstrom
Flux is now a three-dimensional (3D) array, with two spatial dimensions, and one wavelength dimension. The pixelscale of the spatial dimensions is given in the header:
print, hdr1 ; displays the header information scale_x = SXPAR(hdr1, 'CD1_1') ; pixelscale in x, in arcseconds scale_y = SXPAR(hdr1, 'CD2_2') ; pixelscale in y, in arcseconds
but given that scale_x is equal to scale_y (apart from a sign)
scale = scale_y*3600. ; scale in arcseconds
The size of the flux-cube depends on the size of the IFU:
size_cube = SIZE(flux) print, size_cube[1] ; number of elements in spatial x-direction print, size_cube[2] ; number of elements in spatial y-direction print, size_cube[3] ; number of elements in wavelength direction
Plot a spectrum from a datacube
In this exercise, we will plot the nuclear spectrum of 12-193481.
As you have seen above, 12-193481 is a cube of 74 x 74 spatial pixels (also called spaxels in IFU speak). The central spectrum is therefore stored in flux[37, 37, *]. Plot this spectrum as a function of wavelength:
PLOT, wave, flux[37, 37, *], /XS
You can change the indices to correspond to any spaxel you're interested in. You can also plot the spectrum at a given location by clicking on that region in an image of the galaxy. First, let's make a broadband image of 12-193481:
cont = total(flux,3) ;make an image image_plot,cont
Now, use IDL's cursor command to select a pixel:
cursor,x,y ;Use your cursor to click the position where you want to extract the spectrum. x=round(x) ;just rounding to the nearest pixel y=round(y) plot,wave,flux[x,y,*],xtitle='wavelength (angstroms)', $ ytitle='flux (10^-17 erg/s/cm^2)',title='spectrum at (x,y) = $ '+strtrim(string(x),2)+','+strtrim(string(y),2),/xsty
Make an Hα map from a datacube
Collapse the spectra of 12-193481 over a wavelength interval of 6820 to 6840 Angstroms, corresponding to the extent of the Hα emission for this galaxy:
lam_alpha = WHERE( (wave gt 6820) AND (wave lt 6840) ) alpha = TOTAL(flux[*,*,lam_alpha], 3)
Use IMAGE_PLOT to make an Hα map of 12-193481. The resulting map should look something like this: