In [2]:
# import some modules using standard naming conventions
from pylab import *
import pandas as pd
# find the .csv files and read them into pandas data sets
import glob
flist = glob.glob('/usgs/data1/csherwood/poking_eyeball/*.csv')
In [3]:
def Phi(mm):
return -1.44296504*log(mm)
In [4]:
def my_read(csv):
phi = float(csv[-6:-4])/10. # extract phi size from CSV file name
df = pd.read_csv(csv) # create Pandas DataFrame from each CSV file
mg = df.geom_mean.mean() # mean of geometric means
m = df.arith_mean
ma = m.mean() # mean of arithmetic means
sa = m.std() # std of arithmetic means
return phi,ma,sa,mg
In [5]:
# list of stats for each file
stats = [my_read(f) for f in flist]
# convert to array
stats = array(stats)
In [6]:
# create a data frame from the stats array
df_stats = pd.DataFrame(stats,columns=['Phi','Ma','Sa','Mg'])
df_stats
Out[6]:
In [7]:
# list of full DataFrames
df_list = [pd.read_csv(f) for f in flist]
In [8]:
# 1st column of stats array is the phi size
phi = stats[:,0]
In [9]:
# make a dictionary of phi_size: full data_frame
d = dict(zip(phi, df_list))
In [14]:
plot(phi,phi,'-k')
plot(phi-0.5,phi,'--k') # one sieve larger
for p,df in d.iteritems():
plot(p*ones_like(df.geom_mean),Phi(df.geom_mean),'o',color='0.8')
plot(phi,Phi(df_stats.Mg),'or')
xlim([-.5,4.5])
xlabel('Sieve size (phi)')
ylabel('DGS geometric mean (phi)')
title('MOF Poking Eyeball Tests, May 3, 2013')
grid()
In [ ]: