In [1]:
# Import some numerical math and plotting packages
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
# Import the MesaProfile package
from MesaProfile import MesaProfile
# Import the OrderedDict package for working with MesaProfile outputs
from collections import OrderedDict
In [2]:
# Read the input MESA profile
mesa = MesaProfile('profile64.data')
mstar = mesa.getStar()
In [3]:
# List the data fields available in the profile
for k in mstar.keys():
print(k)
In [4]:
# Find out what isotopes the profile contains
isotope_list = mesa.getIsotopes()
nisotopes = len(isotope_list)
print('The MESA profile contains {} isotopes.'.format(nisotopes))
In [9]:
# Plot the abundances in the profile
fig, ax = plt.subplots()
colormap = plt.get_cmap('viridis')
isocolors = [colormap(i) for i in np.linspace(0, 1, nisotopes)]
legend_handles = []
for i, isotope in enumerate(isotope_list):
handle = ax.plot(mstar['mass'], mstar[isotope], color=isocolors[i], label=isotope)
legend_handles.append(handle)
handles, labels = ax.get_legend_handles_labels()
lgd = ax.legend(handles, labels, bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
ax.set_xlabel('Mass ($M_\\odot$)')
ax.set_ylabel('Mass Fractions')
plt.savefig('profile64.massfrac.png', bbox_extra_artists=(lgd,), bbox_inches='tight', dpi=300)
In [7]:
# Plot the electron fraction (Ye) profile
fig, ax = plt.subplots()
ax.plot(mstar['mass'],mstar['ye'],'b')
ax.set_xlabel('Mass ($M_\\odot$)')
ax.set_ylabel('Electron Fraction ($\\mathrm{Y_e}$)')
plt.savefig('profile64.ye.png', dpi=300)
In [ ]:
# Plot the density profile
fig, ax = plt.subplots()
ax.plot(mstar['mass'],10.0**mstar['logRho'],'b')
ax.set_xlabel('Mass ($M_\\odot$)')
ax.set_ylabel('Density ($g/cm^3$)')
In [ ]:
# Plot the temperature profile
fig, ax = plt.subplots()
ax.plot(mstar['mass'],10.0**mstar['logT'],'b')
ax.set_xlabel('Mass ($M_\\odot$)')
ax.set_ylabel('Temperature ($K$)')
In [ ]:
# Plot the mass-radius profile
fig, ax = plt.subplots()
ax.plot(mstar['radiuscm'],mstar['mass'],'b')
ax.set_xlabel('Radius (cm)')
ax.set_ylabel('Mass ($M_\\odot$)')
In [ ]: