In [1]:
%pylab inline
In [2]:
## We have to call all Chempy functions from within the /Chempy/source/ folder
from Chempy.parameter import ModelParameters
from Chempy.solar_abundance import solar_abundances
In [3]:
# This loads the default parameters, you can check and change them in paramter.py
a = ModelParameters()
In [4]:
# These are the implemented solar abundances
print(a.solar_abundance_name_list)
In [5]:
# First we load the default solar abundances from Asplund 2009
basic_solar = solar_abundances()
getattr(basic_solar, a.solar_abundance_name)()
In [6]:
# The Hydrogen fraction
basic_solar.x
Out[6]:
In [7]:
# The Helium fraction
basic_solar.y
Out[7]:
In [8]:
# The metallicity (all elements heavier than Helium)
basic_solar.z
Out[8]:
In [9]:
print('#, symbol, mass fraction, photospheric abundance, error')
txt = "{0:3s} {1:3d} {2:.8f} {3:0.2f} {4:.2f}"
for i, (item, a, b) in enumerate(zip(basic_solar.all_elements[:30],
basic_solar.fractions,
basic_solar.table)):
print(txt.format(item, i + 1, a, b['photospheric'], b['error']))
In [10]:
# these are all the element names
symbols = np.array(basic_solar.all_elements)
# Plotting the table up to Element 60
fig = plt.figure(figsize=(17.69,8.27), dpi=300)
ax1 = fig.add_subplot(111)
ax1.errorbar(np.arange(len(symbols)), basic_solar.table['photospheric'], xerr=None,yerr=basic_solar.table['error'],linestyle = '-',marker='x',capthick =2,capsize = 10, ms = 10, mew = 2, color = 'b',elinewidth=2,label= 'Solar abundances')
plt.xticks(np.arange(len(symbols)), symbols)
plt.xlim((0,60))
plt.ylabel("A(Element)")
plt.title("The famous element distribution in the Sun in logarithmic scale")
plt.show()
In [11]:
# We sort the elements for their masses
j = np.argsort(basic_solar.fractions)[::-1]
# And print a list of top 20 most abundant elements in the Sun (according to Asplund+ 2009)
print('Symbol, Mass fraction')
for i,item in enumerate(symbols[j][:20]):
print('{0:3d}'.format(i+1),
'{0:3s}'.format(item),
'{0:.6f}'.format(basic_solar.fractions[j][i]))
In [12]:
# The same functionality is available for the other solar abundances, we also load Lodders+ 2009
basic_solar_lodders = solar_abundances()
getattr(basic_solar_lodders, 'Lodders09')()
# And Asplund+ 2005
basic_solar_asplund05 = solar_abundances()
basic_solar_asplund05.Asplund05_pure_solar()
# Then we print their metallicities:
print('{0:2f}'.format(basic_solar.z),
'{0:2f}'.format(basic_solar_lodders.z),
'{0:2f}'.format(basic_solar_asplund05.z))
In [13]:
# Now we plot the abundances of these three Solar abundance patterns
fig = plt.figure(figsize=(17.69,8.27), dpi=300)
ax1 = fig.add_subplot(111)
ax1.errorbar(np.arange(len(symbols)),basic_solar.table['photospheric'],xerr=None,yerr=basic_solar.table['error'], alpha = 0.5, linestyle = '-',marker='x',capthick =2,capsize = 10, ms = 10, mew = 2, color = 'b',elinewidth=2,label= 'Asplund+2009')
ax1.errorbar(np.arange(len(symbols)),basic_solar_lodders.table['photospheric'],xerr=None,yerr=basic_solar_lodders.table['error'], alpha = 0.5, linestyle = '-',marker='x',capthick =2,capsize = 10, ms = 10, mew = 2, color = 'r',elinewidth=2,label= 'Lodders+2009')
ax1.errorbar(np.arange(len(symbols)),basic_solar_asplund05.table['photospheric'],xerr=None,yerr=basic_solar_asplund05.table['error'], alpha = 0.5, linestyle = '-',marker='x',capthick =2,capsize = 10, ms = 10, mew = 2, color = 'g',elinewidth=2,label= 'Asplund+2005')
plt.xticks(np.arange(len(symbols)), symbols)
plt.xlim((0,60))
plt.ylabel("A(Element)")
plt.title("Differing abundances, but overall agreement is quite good.")
plt.legend()
plt.show()
In [14]:
# Here we load an APOGEE correction for Asplund+ 2005
basic_solar_apogee = solar_abundances()
getattr(basic_solar_apogee, 'Asplund05_apogee_correction')()
# And plot a comparison to the original Asplund+ 2005 abundances
fig = plt.figure(figsize=(17.69,8.27), dpi=300)
ax1 = fig.add_subplot(111)
ax1.errorbar(np.arange(len(symbols)),basic_solar_asplund05.table['photospheric'],xerr=None,yerr=basic_solar_asplund05.table['error'], alpha = 0.5, linestyle = '-',marker='x',capthick =2,capsize = 10, ms = 10, mew = 2, color = 'g',elinewidth=2,label= 'Asplund+2005')
ax1.errorbar(np.arange(len(symbols)),basic_solar_apogee.table['photospheric'],xerr=None,yerr=basic_solar_apogee.table['error'], alpha = 0.5, linestyle = '-',marker='x',capthick =2,capsize = 10, ms = 10, mew = 2, color = 'm',elinewidth=2,label= 'Asplund+2005 Apogee')
plt.xticks(np.arange(len(symbols)), symbols)
plt.xlim((0,60))
plt.ylabel("A(Element)")
plt.title("Corrections from the APOGEE Pipeline.")
plt.legend()
plt.show()
In [15]:
from Chempy.infall import PRIMORDIAL_INFALL
# We initialise the primordial infall routine
solar_scaled_material = PRIMORDIAL_INFALL(list(basic_solar.all_elements),np.copy(basic_solar.table))
# and ask to give back the fractions of solar scaled material with [FE/H] = -0.3 dex
solar_scaled_material.solar(-0.3)
# Then we plot a comparison
fig = plt.figure(figsize=(17.69,8.27), dpi=300)
ax1 = fig.add_subplot(111)
ax1.plot(np.arange(len(symbols)),basic_solar.fractions,label= 'Asplund+2009')
ax1.plot(np.arange(len(symbols)),solar_scaled_material.fractions, label= 'Asplund+2009 half solar')
plt.xticks(np.arange(len(symbols)), symbols)
plt.xlim((0,60))
plt.ylabel("Mass fraction")
plt.yscale('log')
plt.title("Scaling the solar abundances")
plt.legend()
plt.show()
In [ ]:
In [ ]:
In [ ]: