In [1]:
output_file = 'solarabundances.fits'
In [2]:
import matplotlib.pyplot as plt
import numpy as np
from astropy.io import fits
from astropy.table import Table,Column,join
In [3]:
fl = 'asplund2009_abundances.txt'
asplund = Table.read(fl,format='ascii',comment=';')
asplund.remove_column('DIFF_PH_MET')
#Excise Z>75 data
gd = (asplund['Z'] <= 75)
solar = asplund[gd]
Add column for references:
In [4]:
reference_column = Column(['Asplund+ (2009)']*np.size(solar), name='Reference', dtype='U30')
solar.add_column(reference_column)
Simple text list of element names:
In [5]:
element_names=np.chararray.strip(solar['ELEMENT'])
In [6]:
o_indx = np.where((element_names.lower() == 'O'.lower()))
solar[o_indx]
Out[6]:
In [7]:
steffen = [8.76, 0.02]
solar['BEST'][o_indx] = steffen[0] # Steffen abundance
solar['ERR'][o_indx] = steffen[1]
solar['PHOTO'][o_indx] = steffen[0] # Steffen abundance
solar['PHOTO_ERR'][o_indx] = steffen[1]
solar['Reference'][o_indx] = 'Steffen+ (2015)'
#Total mass:
mmm = (10.**(solar['PHOTO'][0]-12.)/0.7381)
#Old oxygen mass:
print("Old O mass fraction: {0:0.5f}".format((10.**(asplund['PHOTO'][o_indx]-12.)*16./mmm)[0]))
#New oxygen mass:
print("New O mass fraction: {0:0.5f}".format((10.**(solar['BEST'][o_indx]-12.)*16./mmm)[0]))
In [8]:
solar[o_indx]
Out[8]:
In [9]:
amarsi = [8.69, 0.03]
solar['BEST'][o_indx] = amarsi[0] # Steffen abundance
solar['ERR'][o_indx] = amarsi[1]
solar['PHOTO'][o_indx] = amarsi[0] # Steffen abundance
solar['PHOTO_ERR'][o_indx] = amarsi[1]
solar['Reference'][o_indx] = 'Amarsi+ (2018);Asplund+ (2009)'
#Total mass:
mmm = (10.**(solar['PHOTO'][0]-12.)/0.7381)
#Old oxygen mass:
print("Old O mass fraction: {0:0.5f}".format((10.**(asplund['PHOTO'][o_indx]-12.)*16./mmm)[0]))
#New oxygen mass:
print("New O mass fraction: {0:0.5f}".format((10.**(solar['BEST'][o_indx]-12.)*16./mmm)[0]))
In [10]:
solar[o_indx]
Out[10]:
In [11]:
iso = Table.read('isotopes.dat',format='ascii',comment=';;')
iso.keep_columns(['Z','AtomicWeight'])
atoms = join(solar,iso,keys='Z')
Now we have all the information we want in the combined table atoms
.
In [12]:
atoms[0:5]
Out[12]:
In [13]:
atoms.write(output_file,overwrite=True)
In [156]:
# The abundance by mass:
eps = (10.**(atoms['BEST']-12.)*atoms['AtomicWeight']).data
total_mass = eps.sum()
In [157]:
plt.plot(atoms['Z'],np.log10(eps/total_mass),'ro-',markersize=4,lw=1);
In [158]:
X = eps[0]/total_mass
Y = eps[1]/total_mass
In [159]:
zzz = (atoms['Z'] > 2)
Z = eps[zzz].sum()/total_mass
In [160]:
print("\nMean abundances by mass: X=H, Y=He, Z=metals; mean mass per H atom, µ.\n")
print("\tX = {0:0.4f}".format(X))
print("\tY = {0:0.4f}".format(Y))
print("\tZ = {0:0.4f}".format(Z))
print("\tµ = {0:0.4f}".format(1./X))
Thus the metal mass fraction in the solar system is Z = 0.0131.
The mean mass per H is µ = 1.36.