# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# ## Introduction to the Interstellar Medium
# ### <NAME>

# ### Figure 7.5: CO and 13CO spectrum toward a star-forming clump in the Rosette molecular cloud

# #### from observations taken with the IRAM 30m telescope by the author in 2002

import numpy as np
import matplotlib.pyplot as plt
from scipy import integrate
# %matplotlib inline

# +
fig = plt.figure(figsize=(6,4))
ax1 = fig.add_subplot(111)
ax1.set_xlabel(r"$v$ (km/s)", fontsize=16)
ax1.set_ylabel(r"$T_{\rm B}$ (K)", fontsize=16)

v, T1, T2 = np.loadtxt('rosette_CO_spectrum.txt', unpack=True)

vmin, vmax = 5, 21
ax1.set_xlim(vmin, vmax)
ax1.set_ylim(-4, 27)

show = (v > vmin+0.75) & (v < vmax-0.75)
ax1.plot(v[show], T1[show], color='k', lw=2, linestyle='solid', drawstyle='steps', label='CO')
ax1.plot(v[show], T2[show], color='k', lw=2, linestyle='dotted', drawstyle='steps', label=r'$^{13}$CO')

# get integrated intensity
int = (v > 11) & (v < 16)
T1_int = integrate.simps(T1[int],v[int])
T2_int = integrate.simps(T2[int],v[int])
print("Integrated CO emission   = {0:5.2f} K km/s".format(T1_int))
print("Integrated 13CO emission = {0:5.2f} K km/s".format(T2_int))

ax1.legend()
fig.tight_layout() 
plt.savefig('rosette_CO_spectrum.pdf')
# -



StarcoderdataJupyterScriptsDedupFiltered