Skip to content

Commit

Permalink
FileNotFoundError for literaturevalues
Browse files Browse the repository at this point in the history
  • Loading branch information
EFerriss committed Nov 7, 2017
1 parent d7f6441 commit 7473359
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 75 deletions.
Binary file modified pynams/__pycache__/blocks.cpython-36.pyc
Binary file not shown.
Binary file modified pynams/__pycache__/profiles.cpython-36.pyc
Binary file not shown.
Binary file modified pynams/__pycache__/spectra.cpython-36.pyc
Binary file not shown.
Binary file modified pynams/__pycache__/styles.cpython-36.pyc
Binary file not shown.
Binary file modified pynams/diffusion/__pycache__/diffusivities.cpython-36.pyc
Binary file not shown.
Binary file modified pynams/diffusion/__pycache__/literaturevalues.cpython-36.pyc
Binary file not shown.
16 changes: 11 additions & 5 deletions pynams/diffusion/diffusivities.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
Created on Tue May 05 08:16:08 2015
@author: Ferriss
Provides basic plotting and functions for creating Arrhenius diagrams and
handling groups of diffusivities that get plotted on them, including
determining activation energies and pre-exponential terms and calculating
the expected diffusivity at a given temperature.
class Diffusivities() groups together temperatures and diffusivities
for use in plotting directly onto Arrhenius diagrams and solving
for activation energies and pre-exponential components
Also provides basic plotting and functions for creating Arrhenius diagrams and
handling groups of diffusivities that get plotted on them, including
determining activation energies and pre-exponential terms and calculating
the expected diffusivity at a given temperature.
"""
from __future__ import print_function, division, absolute_import
from pynams import styles
Expand All @@ -24,6 +24,7 @@ class Diffusivities() groups together temperatures and diffusivities

GAS_CONSTANT = 0.00831 # kJ/mol K


def solve_Ea_D0(log10D_list, celsius_list, printout=True):
"""
Takes lists of diffusivities as log10 in m2/s and associated
Expand Down Expand Up @@ -79,6 +80,7 @@ def solve_Ea_D0(log10D_list, celsius_list, printout=True):

return Ea, D0


def whatIsD(Ea, D0, celsius, printout=True):
"""
Takes activation energy in kJ/mol, D0 in m2/s and
Expand All @@ -102,6 +104,7 @@ def whatIsD(Ea, D0, celsius, printout=True):
print('log10 D at ', celsius, 'C: ', '{:.1f}'.format(D), ' in m2/s')
return D


class Diffusivities():
def __init__(self,
description=None,
Expand All @@ -124,6 +127,7 @@ def __init__(self,
self.activation_energy_kJmol = activation_energy_kJmol
self.D0_m2s = D0_m2s


def fill_in_data(self, df, mech, percentpv, paper=None):
"""
See usage example in literaturevalues.py in this folder.
Expand Down Expand Up @@ -151,6 +155,7 @@ def fill_in_data(self, df, mech, percentpv, paper=None):
except KeyError:
self.celsius[idx] = []


def solve_Ea_D0(self, printout=True):
"""
Returns and saves as attributes the
Expand All @@ -165,6 +170,7 @@ def solve_Ea_D0(self, printout=True):
self.activation_energy_kJmol.append(Ea)
self.D0_m2s.append(D0)


def whatIsD(self, celsius, orient='ALL', printout=True):
"""
Takes temperature in celsius.
Expand Down
84 changes: 14 additions & 70 deletions pynams/diffusion/literaturevalues.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@author: Ferriss
Library of diffusivities, both data and fit lines, and
some functions to play with them.
some functions to play with them. The data in in a CSV in this folder.
The focus is on hydrogen diffusion in olivine and clinopyroxene.
"""
Expand All @@ -18,20 +18,25 @@
import os

# pull data from spreadsheet
file = os.path.join(pynams.__path__[0], 'diffusion', 'literaturevalues.csv')
try:
file = os.path.join(pynams.__path__[0], 'diffusion',
'literaturevalues.csv')
except FileNotFoundError:
print('Warning: Could not locate and import literature data')
exit()

olivine = pd.read_csv(file)
olivine = olivine.dropna(how='all') # ignore empty rows
olivine.fillna(0, inplace=True) # replace missing values with zero
olivine = olivine.dropna(how='all')
olivine.fillna(0, inplace=True)
olivine["paper"] = olivine["Author"] + ' ' + olivine["Year"].map(str)
olivinegroups = olivine.groupby(['paper', 'mechanism',
'percentpv', 'orientation'])

## Uncomment to see group names
#for x, group in olivinegroups:
# print(x)
#print()


#%%
SanCarlosOlivine = Sample(Fe3=0.003, Fe2=0.174, Mg=1.821, Ti=0., Al=0.)

# Mackwell and Kohlstedt 1990
Expand Down Expand Up @@ -128,8 +133,8 @@ def mix_olivine_mechanisms(percent_slow, celsius):
D16 = Diffusivities(description='Demouchy et al. 2016',
sample=Sample(Fe=0.092, Mg=0.903)) # Ni=0.005, trace Cr



#%% The rest of this has data in an old format that I haven't had a
### need to switch over into the CSV but I don't want to discard

##Wanamaker_Si = Diffusivities(
## description = "San Carlos ol. $V''''_{Si}$\nWanamaker 1994",
Expand All @@ -145,8 +150,6 @@ def mix_olivine_mechanisms(percent_slow, celsius):
# basestyle = {'color' : 'g', 'marker' : '*', 'alpha' : 0.5,
# 'fillstyle' : 'none',
# 'linestyle' : 'none', 'markersize' : 10})


#
## Du Frane & Tybursky 2012 self-diffusion in olivine
#DuFrane = Diffusivities(
Expand All @@ -157,66 +160,7 @@ def mix_olivine_mechanisms(percent_slow, celsius):
# basestyle = {'color' : 'purple', 'marker' : 's', 'alpha' : 0.5,
# 'markersize' : markersizefloat})
#
## ---------------- natural olivine data -----------------------------
## See also OlivineNormalization.xls
#
## Loihi, Hawaii: Hauri 2002 Part 2
## Chemistry estimated from Garcia 1995 Table 2; Al and Ti not measured
#Hauri02 = Diffusivities(description = 'Hauri 2002',
# celsius_u = [1275],
# logDu = [np.log10(4e-9)],
# logDu_error = [],
# sample=Sample(Fe3=0.004, Fe2=0.261, Mg=1.727,
# Al=0., Ti=0.,),
# basestyle = {'marker' : '+', 'color' : 'darkorange',
# 'markersize' : 12,
# 'markeredgewidth' : '2'})
#
## Portnyagin 2008 minimum value, see new Miranov paper
## See Supplementary Materials. Al and Ti not measured in host olivines
#Portnyagin08 = Diffusivities(
# description = 'Portnyagin et al. 2008\nMironov et al. 2015',
# celsius_u = [1140.], logDu = [np.log10(5e-12)],
# sample = Sample(Fe3=0.021, Fe2=0.276, Mg=1.7, Al=0., Ti=0.),
# basestyle = {'marker' : 's', 'color' : 'darkmagenta',
# 'markerfacecolor' : 'white',
# 'markeredgecolor' : 'darkmagenta',
# 'markersize' : markersizefloat,
# 'markeredgewidth' : '1'})
#
## Chen et al. 2011
## Chemistry from Le Voyer 2014 Table 1 SOM1 olivine; Al and Ti not measured...
#Chen11 = Diffusivities(description = 'Chen et al. 2011',
# celsius_u = [1533.-273.15, 1471.-273.15,
# 1437.-273.15, 1561.-273.15],
# logDu = [np.log10(2e-11), np.log10(2.5e-11),
# np.log10(0.5e-11), np.log10(2.5e-11)],
# sample = Sample(Fe3=0.0, Fe2=0.192, Mg=1.784,
# Al=0., Ti=0.,),
# basestyle = {'marker' : 'x', 'color' : 'black',
# 'markersize' : markersizefloat,
# 'markeredgewidth' : '1'})
#
## Gaetani et al. 2012 hydration data
## Moana Loa olivine with melt inclusion unoriented grain;
## MID-1 data in Supplement, Ti and Al not measured...
## *** Si deficiency ***
#Gaetani12 = Diffusivities(description = 'Gaetani et al., 2012',
# celsius_u = [1250.],
# logDu = [np.log10(1.7e-11)],
# sample=Sample(Fe3=0.036, Fe2=0.206, Mg=1.769,
# Al=0., Ti=0.),
# basestyle = {'marker' : 'h', 'color' : 'red',
# 'markeredgecolor' : 'red',
# 'markersize' : 10,
# 'markeredgewidth' : '1',
# 'markerfacecolor' : 'white'})
#
#
#generic = Diffusivities()
#generic.basestyle = {'marker' : 's', 'color' : 'black', 'alpha' : 0.5,
# 'markersize' : markersizefloat, 'linestyle': 'none'}
#

##%% clinopyroxene
#H_CrDiopside_Ingrin95 = Diffusivities(
# description = ''.join(('H in Cr-rich diopside in air',
Expand Down

0 comments on commit 7473359

Please sign in to comment.