##Preamble
from __future__ import division,print_function
import pandas as pds
rc('figure',figsize=(12,4))
rc('legend',loc='best')
rc('font',size = 14.0)
import os
from os.path import expanduser
%load_ext autoreload
%autoreload 2
import scipy.optimize as opt
from scipy import stats
import uncertainties as unc
from uncertainties import unumpy
import ProcessingCTRData as pc
print("Complete")
Complete
df = pds.read_csv('alldata.csv',index_col=[0,1])
df = df[df.length == 30]
df = df[df.CTR < 300]
df = df[df.specialkey != 'normal']
chifit = [pc.getchi(grp,plot=False) for key, grp in df.groupby(['SampleB','configuration'])]
for col in df.columns:
if col.endswith('err'):
df[col[:-3]] = df.apply(lambda srs : unc.ufloat(srs[col[:-3]],srs[col]),axis=1)
df = df.drop(col,1)
df['ggevents'] = unumpy.uarray(list(df.numofsamples),list(sqrt(df.numofsamples)))
def ProperMean(agrp):
if isinstance(agrp.dtype,object):
return mean(list(agrp))
else:
return mean(agrp)
df = df.groupby(['SampleB','configuration']).aggregate(ProperMean)
print(df.CTR)
df['chifit'] = chifit
fdf = list(df.CTR)
#df = df.sort('CTR',ascending=False)
for col in df.columns:
if col in ['length', 'ggevents']:
ff = "{0:.0f}"
elif col in ['ERleft','ERright']:
ff = "{0:.2f}"
else:
ff = "{0:.1f}"
try:
df[col] = [ff.format(val).replace("+/-","$\pm$") for val in df[col]]
except ValueError:
continue
print(df.to_latex(float_format=lambda x: '%10.1f' % x, index=True,columns=["ERleft","ERright","ggevents","location","CTR","chisquared","chifit"]))
SampleB configuration 30A wrapped 273+/-15 30B wrapped 246.4+/-2.3 Name: CTR, dtype: object \begin{tabular}{llllllll} \toprule {} & ERleft & ERright & ggevents & location & CTR & chisquared & chifit \\ SampleB configuration & & & & & & & \\ \midrule 30A wrapped & 10.24$\pm$0.11 & 15.91$\pm$0.16 & 253$\pm$11 & 261.6$\pm$4.5 & 273.1$\pm$14.6 & 0.9 & 0.3 \\ 30B wrapped & 9.47$\pm$0.02 & 13.29$\pm$0.02 & 2713$\pm$20 & 16.3$\pm$0.7 & 246.4$\pm$2.3 & 1.6 & 0.6 \\ \bottomrule \end{tabular}
df = pds.read_csv('alldata.csv',index_col=[0,1])
df = df[df.length == 20]
df = df[df.CTR < 300]
df = df[df.SampleB != '2396']
chifit = [pc.getchi(grp,plot=False) for key, grp in df.groupby(['SampleB','configuration'])]
for col in df.columns:
if col.endswith('err'):
df[col[:-3]] = df.apply(lambda srs : unc.ufloat(srs[col[:-3]],srs[col]),axis=1)
df = df.drop(col,1)
df['ggevents'] = unumpy.uarray(list(df.numofsamples),list(sqrt(df.numofsamples)))
def ProperMean(agrp):
if isinstance(agrp.dtype,object):
return mean(list(agrp))
else:
return mean(agrp)
df = df.groupby(['SampleB','configuration']).aggregate(ProperMean)
print(df.CTR)
df['chifit'] = chifit
fdf = list(df.CTR)
#df = df.sort('CTR',ascending=False)
for col in df.columns:
if col in ['length', 'ggevents']:
ff = "{0:.0f}"
elif col in ['ERleft','ERright']:
ff = "{0:.2f}"
else:
ff = "{0:.1f}"
try:
df[col] = [ff.format(val).replace("+/-","$\pm$") for val in df[col]]
except ValueError:
continue
print(df.to_latex(float_format=lambda x: '%10.1f' % x, index=True,columns=["ERleft","ERright","ggevents","location","CTR","chisquared","chifit"]))
SampleB configuration 20A wrapped 228+/-7 20B wrapped 230+/-4 Name: CTR, dtype: object \begin{tabular}{llllllll} \toprule {} & ERleft & ERright & ggevents & location & CTR & chisquared & chifit \\ SampleB configuration & & & & & & & \\ \midrule 20A wrapped & 10.86$\pm$0.03 & 15.78$\pm$0.03 & 1394$\pm$17 & 206.0$\pm$1.6 & 227.7$\pm$6.7 & 1.2 & 0.4 \\ 20B wrapped & 11.00$\pm$0.02 & 14.42$\pm$0.02 & 1601$\pm$13 & 224.5$\pm$1.0 & 230.4$\pm$4.2 & 1.2 & 0.9 \\ \bottomrule \end{tabular}
df = pds.read_csv('alldata.csv',index_col=[0,1])
data = "1.640 1.560 1.640 1.560 72.4 72.7 5 1.640 1.560 1.700 1.500 72.4 72.7 20 1.640 1.560 1.900 1.300 72.4 72.7 20 1.640 1.560 2.100 1.100 72.4 72.7 20"
data = array([row.split('\t') for row in data.split(' ')],dtype=float)
Voltages = (data[:,2]-data[:,3])*1e3
df = df[df.specialkey == 'threshold']
df['threshold'] = df.uniquename.apply(lambda astr : Voltages[int(astr.split('_')[-1])])
df = df[df.length == 30]
#df = df[df.CTR < 300]
for col in df.columns:
if col.endswith('err'):
df[col[:-3]] = df.apply(lambda srs : unc.ufloat(srs[col[:-3]],srs[col]),axis=1)
df = df.drop(col,1)
df['ggevents'] = unumpy.uarray(list(df.numofsamples),list(sqrt(df.numofsamples)))
def ProperMean(agrp):
if isinstance(agrp.dtype,object):
return mean(list(agrp))
else:
return mean(agrp)
ptpchange = ptp(df.groupby(['SampleB','threshold']).CTR)
df = df.groupby(['SampleB','threshold']).aggregate(ProperMean)
df['ptpchange'] = ptpchange
for col in df.columns:
if col in ['length', 'ggevents']:
ff = "{0:.0f}"
elif col in ['ERleft','ERright']:
ff = "{0:.2f}"
else:
ff = "{0:.1f}"
try:
df[col] = [ff.format(val).replace("+/-","$\pm$") for val in df[col]]
except ValueError:
continue
print(df.to_latex(float_format=lambda x: '%10.1f' % x, index=True,columns=['ptpchange',"ERleft","ERright","ggevents","location","CTR","chisquared"]))
\begin{tabular}{llllllll} \toprule {} & ptpchange & ERleft & ERright & ggevents & location & CTR & chisquared \\ SampleB threshold & & & & & & & \\ \midrule 30A 80 & 102.8$\pm$35.3 & 10.24$\pm$0.07 & 15.61$\pm$0.10 & 245$\pm$7 & 346.7$\pm$3.1 & 308.3$\pm$10.6 & 0.6 \\ 200 & 35.7$\pm$16.8 & 10.01$\pm$0.04 & 15.78$\pm$0.05 & 1098$\pm$15 & 550.2$\pm$1.6 & 337.4$\pm$5.5 & 1.0 \\ 600 & 34.5$\pm$14.9 & 9.98$\pm$0.04 & 16.10$\pm$0.05 & 1221$\pm$16 & 789.8$\pm$1.6 & 358.7$\pm$5.4 & 1.0 \\ 1000 & 38.0$\pm$15.7 & 10.12$\pm$0.04 & 16.01$\pm$0.06 & 1197$\pm$17 & 898.6$\pm$1.9 & 359.5$\pm$5.9 & 1.1 \\ \bottomrule \end{tabular}