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.


In [28]:
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


In [5]:
# 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.


In [6]:
diff = copy.deepcopy(stvel)
diff.value = havel.value - stvel.value
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

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


In [10]:
diff.plot()


Out[10]:
(<matplotlib.figure.Figure at 0x11009ceb8>,
 <matplotlib.axes._subplots.AxesSubplot at 0x11005b7b8>)

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


In [9]:
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)


4. Stack spectra in inner gas disk


In [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')

    # copy the first spaxel so that the stack is a Marvin Spaxel object
    stack = copy.deepcopy(spaxels[0])
    
    # overwrite the flux with the mean flux of the spectra in the stack (but keep the other meta-data)
    stack.spectrum.flux = np.mean([sp.spectrum.flux for sp in spaxels], axis=0)

    return stack

In [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)

In [22]:
# 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


In [23]:
# adjust continuum normalization for ease of by-eye comparison
stack_pos_adjusted = copy.deepcopy(stack_pos)
stack_pos_adjusted.spectrum.flux /= 2

In [29]:
fig = plt.figure(figsize=(15, 4))
ax, fig = stack_pos_adjusted.spectrum.plot(figure=fig, return_figure=True)
ax, fig = stack_neg.spectrum.plot(figure=fig, return_figure=True)



In [34]:
# zoom in on calcium H and K lines
fig = plt.figure(figsize=(15, 4))
ax, fig = stack_pos_adjusted.spectrum.plot(figure=fig, return_figure=True)
ax, fig = stack_neg.spectrum.plot(figure=fig, return_figure=True)
ax.set_xlim([4050, 4400])
ax.set_ylim([0., 0.12])


Out[34]:
(0.0, 0.12)

In [32]:
# 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.spectrum.plot(figure=fig, return_figure=True)
ax.set_xlim([6850, 7200])
ax.set_ylim([0.13, 0.27])


Out[32]:
(0.13, 0.27)

In [ ]: