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]:
Phi Ma Sa Mg
0 0.0 0.557322 0.067476 0.468722
1 0.5 0.543682 0.134539 0.430470
2 1.0 0.487743 0.082410 0.381277
3 1.5 0.373238 0.048243 0.267245
4 2.0 0.326144 0.031638 0.209683
5 2.5 0.301667 0.034709 0.199168
6 3.0 0.235943 0.032090 0.134345
7 3.5 0.238555 0.015709 0.135005
8 4.0 0.204032 0.015977 0.106308

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 [ ]: