Download this as a Jupyter notebook!

Investigating Gas and Stellar Kinematics using Marvin

We’re going to study a galaxy (8711-6102) with an inner gas disk that is rotating faster than the stellar disk.

[1]:
import copy
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('seaborn-darkgrid')
%matplotlib inline

1. Get the Halpha velocity and stellar velocity maps

[3]:
# For Marvin team
from marvin import config
config.forceDbOff()

from marvin.tools.maps import Maps
maps = Maps(plateifu='8711-6102')
havel = maps['emline_gvel_ha_6564']
stvel = maps['stellar_vel']

2. Create a map of the difference between the Halpha and stellar velocities

Hint: copy one of the maps and modify the value, mask, and property_name attributes.

[5]:
diff = havel - stvel
diff.ivar = 1. / ((1. / havel.ivar) + (1. / stvel.ivar))
diff.mask = havel.mask | stvel.mask
diff.property_name = 'Ha vel - stellar vel'
[WARNING]: divide by zero encountered in true_divide (RuntimeWarning)
[WARNING]: divide by zero encountered in true_divide (RuntimeWarning)

3. Plot the difference map using the Marvin Maps plot function

[6]:
diff.plot()
[6]:
(<Figure size 432x288 with 2 Axes>,
 <AxesSubplot:xlabel='spaxel', ylabel='spaxel'>)
[WARNING]: Warning: converting a masked element to nan. (UserWarning)
../../_images/tutorials_exercises_marvin_kinematics_solution_9_2.png

Bonus: plot Halpha velocity, stellar velocity, and difference maps

[7]:
import marvin.utils.plot.map as mapplot
fig, axes = plt.subplots(1, 3, figsize=(15, 4))
for ax, map_ in zip(axes, [havel, stvel, diff]):
    mapplot.plot(dapmap=map_, fig=fig, ax=ax)
[WARNING]: Warning: converting a masked element to nan. (UserWarning)
../../_images/tutorials_exercises_marvin_kinematics_solution_11_1.png

4. Stack spectra in inner gas disk

[12]:
def stack_spectra(ind):
    # get a list of spaxels by passing a list of x-indices and a list of y-indices
    spaxels = maps.getSpaxel(x=ind[0], y=ind[1], xyorig='lower', cube=True)

    # copy the first spaxel so that the stack is a Marvin Spaxel object
    stack = spaxels[0]

    # overwrite the flux with the mean flux of the spectra in the stack (but keep the other meta-data)
    stack.mean_flux = np.mean([sp.flux for sp in spaxels], axis=0)

    return stack
[13]:
# Stack spectra with (Halpha vel - stellar vel) between -70 and -40
ind_neg = np.where((diff.value > -70) & (diff.value < -40))
stack_neg = stack_spectra(ind_neg)
[14]:
# Stack spectra with (Halpha vel - stellar vel) between 40 and 70
ind_pos = np.where((diff.value > 40) & (diff.value < 70))
stack_pos = stack_spectra(ind_pos)

5. Plot stacked spectra from red and blue sides using Marvin Spectrum plot functionality

Hint: divide the Halpha spectrum flux by 2 to get similar normalizations

[22]:
# adjust continuum normalization for ease of by-eye comparison
stack_pos_adjusted = stack_pos
#stack_pos_adjusted.mean_flux /= 2
[23]:
fig = plt.figure(figsize=(15, 4))
ax, fig = stack_neg.flux.plot(figure=fig, return_figure=True)
ax.plot(stack_pos.flux.wavelength, stack_pos_adjusted.mean_flux)
[WARNING]: The truth value of a Quantity is ambiguous. In the future this will raise a ValueError. (AstropyDeprecationWarning)
[23]:
[<matplotlib.lines.Line2D at 0x1a3c21d908>]
../../_images/tutorials_exercises_marvin_kinematics_solution_19_2.png
[24]:
# zoom in on calcium H and K lines
fig = plt.figure(figsize=(15, 4))
ax, fig = stack_neg.flux.plot(figure=fig, return_figure=True)
ax.plot(stack_pos.flux.wavelength, stack_pos_adjusted.mean_flux)
ax.set_xlim([4050, 4400])
ax.set_ylim([0., 0.3])
[WARNING]: The truth value of a Quantity is ambiguous. In the future this will raise a ValueError. (AstropyDeprecationWarning)
[24]:
(0.0, 0.3)
../../_images/tutorials_exercises_marvin_kinematics_solution_20_2.png
[26]:
# zoom in on Halpha line
fig = plt.figure(figsize=(15, 4))
#ax, fig = stack_pos_adjusted.spectrum.plot(figure=fig, return_figure=True)
ax, fig = stack_neg.flux.plot(figure=fig, return_figure=True)
ax.plot(stack_pos.flux.wavelength, stack_pos_adjusted.mean_flux)
ax.set_xlim([6850, 7200])
ax.set_ylim([0.0, 0.7])
[WARNING]: The truth value of a Quantity is ambiguous. In the future this will raise a ValueError. (AstropyDeprecationWarning)
[26]:
(0.0, 0.7)
../../_images/tutorials_exercises_marvin_kinematics_solution_21_2.png
[ ]:

[ ]: