All graphs are generated in this notebook from processed data in processeddata.zip
##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)
rc('font', family='serif')
rc('text', usetex=False)
rc('lines', markersize=10)
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
import ProcessingCTRData as pc
print("Complete")
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-1-7d300d4b4b5a> in <module>() 20 import uncertainties as unc 21 ---> 22 import ProcessingCTRData as pc 23 24 print("Complete") ImportError: No module named ProcessingCTRData
#Global Properties
aloc = '/home/mbrown/Desktop/doipaper/figures/' #files saved here!
wrapdict = {'wrapped':'r','unwrapped':'b','partialwrap':cm.gist_rainbow(0.4)}
errwrapdict = {'wrapped':'r','unwrapped':'b','partialwrap':'g'}
savefigures = True
df = pds.read_csv('alldata.csv')
fig, ax = subplots()
ax.grid()
crystaldict = {"30A":"*","30B":"^"}
df = df[df.length == 30]
df = df[df.specialkey == 'normal']
pp = lambda aval : '{:1.2f}'.format(aval)
for config, grp in df.groupby('configuration'):
for key, grp in grp.groupby('SampleB'):
print(config,key)
ax.errorbar(grp.DOI,grp.CTR,yerr=grp.CTRerr,fmt='.',marker=crystaldict[key],color=wrapdict[config],ecolor=errwrapdict[config],label=key+' '+config)
m,b = polyfit(grp.DOI,grp.CTR,1,w=grp.CTRerr)
#ax.hlines(b,0,30,color='k',linestyles='dashed')
print("covariance",pp(m))
print("intercept",pp(b))
m,c,b = polyfit(grp.DOI,grp.CTR,2,w=grp.CTRerr)
print("covariance",pp(m))
print("Gradient",pp(c),"intercept",pp(b))
ax.set_xlabel("Depth of Interaction (mm)")
ax.set_ylabel("Coincidence Time Resolution (ps)")
ax.set_xlim(-2,32)
ax.set_ylim(160,300)
ax.legend(ncol=2)
fig.tight_layout()
if savefigures:
pc.savefigureadir('ctrdoi',aloc,fig)
show()
unwrapped 30A covariance -1.13 intercept 277.75 covariance 0.01 Gradient -1.56 intercept 279.91 unwrapped 30B covariance -0.05 intercept 258.81 covariance 0.02 Gradient -0.80 intercept 262.36 wrapped 30A covariance -0.68 intercept 256.92 covariance -0.13 Gradient 3.22 intercept 236.73 wrapped 30B covariance -0.29 intercept 237.75 covariance 0.01 Gradient -0.76 intercept 239.45
df = pds.read_csv('alldata.csv')
rc('text', usetex=True)
rc('font', family='serif')
fig, ax = subplots()
ax.grid()
crystaldict = {"30A":"*","30B":"^"}
df = df[df.length == 30]
df = df[df.specialkey == 'normal']
for config, grp in df.groupby('configuration'):
for key, grp in grp.groupby('SampleB'):
ax.errorbar(grp.DOI,grp.numofsamples,yerr=sqrt(grp.numofsamples),fmt='.',marker=crystaldict[key],color=wrapdict[config],ecolor=errwrapdict[config],label=key+' '+config)
ax.set_xlim(-2,32)
step = lambda x, xmin, xmax : 1/(xmax-xmin)*((x>=xmin) & (x<=xmax))
x = linspace(-5,40,500)
xs = linspace(-5,5)
y = convolve(step(x,0,30),stats.norm(scale=1/2.355).pdf(xs),mode='same')
y*=3360/max(y)
ax.plot(x,y,'k--')
ax.set_xlabel("Depth of Interaction (mm)")
ax.set_ylabel("Number of $\gamma\gamma$ events detected")
ax.legend(ncol=2)
fig.tight_layout()
if savefigures:
pc.savefigureadir('numberofsamples',aloc,fig)
#pc.savefigureadir('numberofsamples','/home/mbrown/Desktop/figures-svg',fig,ext='svg')
show()
rc('text', usetex=False)
df = pds.read_csv('alldata.csv')
fig, ax = subplots()
ax.grid()
crystaldict = {"30A":"*","30B":"^"}
df = df[df.length == 30]
df = df[df.specialkey == 'normal']
for config, grp in df.groupby('configuration'):
for key, grp in grp.groupby('SampleB'):
ax.errorbar(grp.DOI,grp.location,yerr=grp.locationerr,fmt='.',marker=crystaldict[key],color=wrapdict[config],ecolor=errwrapdict[config],label=key+' '+config)
vals = [unc.ufloat(a,b) for a,b in zip(grp.location, grp.locationerr)]
print(ptp(vals),"ps")
linear = lambda xdata, m,c: m*xdata+c
for reducelim in [30,25,20,15,12]:
fgrp = grp[grp.DOI < reducelim]
(m,c), err = opt.curve_fit(linear,array(fgrp['DOI']),array(fgrp['location']),sigma=fgrp['locationerr'])
merr,cerr = err.diagonal()
#X = linspace(0,30)
#Y = linear(X,m,c)
#ax.plot(X,Y,'k--')
factor = 3E-1
print(config,"<",reducelim,"n", unc.ufloat(m,merr)*factor)
ax.set_xlabel("Depth of Interaction (mm)")
ax.set_ylabel("Delay Peak Centroid (ps)")
ax.set_xlim(-2,32)
ax.set_ylim(100,400)
ax.legend(ncol=2)
fig.tight_layout()
if savefigures:
pc.savefigureadir('centroidposition',aloc,fig)
#pc.savefigureadir('centroidposition','/home/mbrown/Desktop/figures-svg',fig,ext='svg')
show()
227.9+/-2.5 ps unwrapped < 30 n 2.6+/-0.6 unwrapped < 25 n 3.0+/-0.8 unwrapped < 20 n 3.6+/-1.5 unwrapped < 15 n 4.4+/-3.4 unwrapped < 12 n 4.4+/-3.4 223.3+/-2.5 ps wrapped < 30 n 2.4+/-0.5 wrapped < 25 n 3.0+/-0.6 wrapped < 20 n 3.4+/-1.2 wrapped < 15 n 4.3+/-2.3 wrapped < 12 n 4.3+/-2.3
df = pds.read_csv('alldata.csv')
fig, ax = subplots()
ax.grid()
crystaldict = {"30A":"*","30B":"^"}
df = df[df.length == 30]
df = df[df.specialkey == 'normal']
for config, grp in df.groupby('configuration'):
for key, grp in grp.groupby('SampleB'):
ax.errorbar(grp.DOI,grp.ERright,yerr=grp.ERrighterr,fmt='.',marker=crystaldict[key],color=wrapdict[config],ecolor=errwrapdict[config],label=key+' '+config)
ax.set_xlabel("Depth of Interaction (mm)")
ax.set_ylabel("Energy Resolution (%)")
ax.set_xlim(-2,32)
ax.legend(ncol=2)
DOI = linspace(2,30,1000)
Y = lambda xdata, m, c,A : c+A/(xdata-m)**2
fdf = df[df.configuration == 'unwrapped']
param, err = opt.curve_fit(Y,fdf.DOI,fdf.ERright,sigma=fdf.ERrighterr)
for p,e in zip(param,err.diagonal()):
val = unc.ufloat(p,e)
print(val)
#ax.plot(DOI,Y(DOI,*param),'k--')
fig.tight_layout()
if savefigures:
pc.savefigureadir('energyresolution',aloc,fig)
#pc.savefigureadir('energyresolution','/home/mbrown/Desktop/figures-svg',fig,ext='svg')
show()
0.871+/-0.017 15.38+/-0.12 7+/-4
df = pds.read_csv('alldata.csv')
fig, ax = subplots()
ax.grid()
crystaldict = {"30A":"*","30B":"^"}
df = df[df.length == 30]
df = df[df.specialkey == 'normal']
for config, grp in df.groupby('configuration'):
for key, grp in grp.groupby('SampleB'):
ax.errorbar(grp.DOI,grp.RPloc,yerr=grp.RPlocerr,fmt='.',marker=crystaldict[key],color=wrapdict[config],ecolor=errwrapdict[config],label=key+' '+config)
ax.set_xlabel("Depth of Interaction (mm)")
ax.set_ylabel("Right Photopeak Centroid (Arb.)")
ax.set_xlim(-2,32)
ax.set_ylim(0.3,0.65)
ax.legend(ncol=2)
fig.tight_layout()
if savefigures:
pc.savefigureadir('lightoutput',aloc,fig)
#pc.savefigureadir('lightoutput','/home/mbrown/Desktop/figures-svg',fig,ext='svg')
show()
Marker now changes with wrapping not crystal
markerdict = {'wrapped':'*','unwrapped':'^','partialwrap':'.'}
df = pds.read_csv('alldata.csv')
fig, ax = subplots()
ax.grid()
df = df[df.length == 20]
df = df[df.SampleB == '2396']
df = df[df.specialkey == 'normal']
df = df[df.CTR < 300]
lbl = {"partialwrap":"Partially Wrapped","wrapped":"Wrapped","unwrapped":"Unwrapped"}
for config, grp in df.groupby('configuration'):
for key, grp in grp.groupby('SampleB'):
ax.errorbar(grp.DOI,grp.CTR,yerr=grp.CTRerr, fmt='.', marker=markerdict[config],color=wrapdict[config],ecolor=errwrapdict[config],label=lbl[config])
print(config,key,grp.CTR.mean(),grp.CTRerr.mean())
ax.set_xlabel("Depth of Interaction (mm)")
ax.set_ylabel("Coincidence Time Resolution (ps)")
ax.set_xlim(-1,21)
ax.set_ylim(180,290)
leg = ax.legend(ncol=3)
fig.tight_layout()
if savefigures:
pc.savefigureadir('ctrdoi-20',aloc,fig)
#pc.savefigureadir('ctrdoi-20','/home/mbrown/Desktop/figures-svg',fig,ext='svg')
show()
partialwrap 2396 222.08438844 4.36082971936 unwrapped 2396 239.976829432 7.35808035937 wrapped 2396 198.298205146 4.36152894805
df = pds.read_csv('alldata.csv')
rc('text', usetex=True)
fig, ax = subplots()
ax.grid()
df = df[df.length == 20]
df = df[df.SampleB == '2396']
df = df[df.specialkey == 'normal']
for config, grp in df.groupby('configuration'):
for key, grp in grp.groupby('SampleB'):
ax.errorbar(grp.DOI,grp.numofsamples,yerr=sqrt(grp.numofsamples),fmt='.',marker=markerdict[config],color=wrapdict[config],ecolor=errwrapdict[config],label=lbl[config])
ax.set_xlim(-1,21)
ax.set_ylim(0,7000)
step = lambda x, xmin, xmax : 1/(xmax-xmin)*((x>=xmin) & (x<=xmax))
x = linspace(-5,40,500)
xs = linspace(-5,5)
y = convolve(step(x,0,20),stats.norm(scale=1/2.355).pdf(xs),mode='same')
y*=5000/max(y)
ax.plot(x,y,'k--')
ax.set_xlabel("Depth of Interaction (mm)")
ax.set_ylabel("Number of $\gamma\gamma$ events detected")
ax.legend(ncol=3)
fig.tight_layout()
if savefigures:
pc.savefigureadir('numberofsamples-20',aloc,fig)
#pc.savefigureadir('numberofsamples-20','/home/mbrown/Desktop/figures-svg',fig,ext='svg')
show()
rc('text', usetex=False)
df = pds.read_csv('alldata.csv')
fig, ax = subplots()
ax.grid()
df = df[df.length == 20]
df = df[df.SampleB == '2396']
df = df[df.specialkey == 'normal']
for config, grp in df.groupby('configuration'):
for key, grp in grp.groupby('SampleB'):
ax.errorbar(grp.DOI,grp.location,yerr=grp.locationerr,fmt='.',marker=markerdict[config],color=wrapdict[config],ecolor=errwrapdict[config],label=lbl[config])
vals = [unc.ufloat(a,b) for a,b in zip(grp.location, grp.locationerr)]
print(ptp(vals),"ps")
for reducelim in [20,15,10,8]:
fgrp = grp[grp.DOI < reducelim]
(m,c), err = opt.curve_fit(linear,array(fgrp['DOI']),array(fgrp['location']),sigma=fgrp['locationerr'])
merr,cerr = err.diagonal()
#X = linspace(0,30)
#Y = linear(X,m,c)
#ax.plot(X,Y,'k--')
factor = 3E-1
print(config,"<",reducelim,"n", unc.ufloat(m,merr)*factor)
ax.set_xlabel("Depth of Interaction (mm)")
ax.set_ylabel("Delay Peak Centroid (ps)")
ax.set_xlim(-1,21)
ax.set_ylim(0,250)
ax.legend(ncol=3)
fig.tight_layout()
if savefigures:
pc.savefigureadir('centroidposition-20',aloc,fig)
#pc.savefigureadir('centroidposition-20','/home/mbrown/Desktop/figures-svg',fig,ext='svg')
show()
162.2+/-1.7 ps partialwrap < 20 n 2.6+/-0.4 partialwrap < 15 n 3.9+/-0.4 partialwrap < 10 n 5.0+/-0.6 partialwrap < 8 n 5.0+/-0.6 120+/-12 ps unwrapped < 20 n 3.2+/-0.5 unwrapped < 15 n 3.2+/-0.7 unwrapped < 10 n 3.9+/-1.0 unwrapped < 8 n 3.9+/-1.0 130.7+/-1.5 ps wrapped < 20 n 1.9+/-0.6 wrapped < 15 n 3.4+/-0.5 wrapped < 10 n 4.4+/-1.1 wrapped < 8 n 4.4+/-1.1
df = pds.read_csv('alldata.csv')
fig, ax = subplots()
ax.grid()
df = df[df.length == 20]
df = df[df.SampleB == '2396']
df = df[df.specialkey == 'normal']
for config, grp in df.groupby('configuration'):
for key, grp in grp.groupby('SampleB'):
ax.errorbar(grp.DOI,grp.ERright,yerr=grp.ERrighterr,fmt='.',marker=markerdict[config],color=wrapdict[config],ecolor=errwrapdict[config],label=lbl[config])
ax.set_xlabel("Depth of Interaction (mm)")
ax.set_ylabel("Energy Resolution (%)")
ax.set_xlim(-1,21)
ax.set_ylim(8,25)
ax.legend(ncol=3)
fig.tight_layout()
if savefigures:
pc.savefigureadir('energyresolution-20',aloc,fig)
#pc.savefigureadir('energyresolution-20','/home/mbrown/Desktop/figures-svg',fig,ext='svg')
show()
df = pds.read_csv('alldata.csv')
fig, ax = subplots()
ax.grid()
df = df[df.length == 20]
df = df[df.SampleB == '2396']
df = df[df.specialkey == 'normal']
for config, grp in df.groupby('configuration'):
for key, grp in grp.groupby('SampleB'):
ax.errorbar(grp.DOI,grp.RPloc,yerr=grp.RPlocerr,fmt='.',marker=markerdict[config],color=wrapdict[config],ecolor=errwrapdict[config],label=lbl[config])
ax.set_xlabel("Depth of Interaction (mm)")
ax.set_ylabel("Right Photopeak Centroid (Arb.)")
ax.set_xlim(-1,21)
ax.set_ylim(0.3,0.5)
ax.legend(ncol=3)
fig.tight_layout()
if savefigures:
pc.savefigureadir('lightoutput-20',aloc,fig)
show()
df = pds.read_csv('standarddata.csv')
df["person"] = df.uniquename.apply(lambda astr : astr.split('_')[-2])
df['num'] = df.uniquename.apply(lambda astr : int(astr.split('_')[-1]))
df = df[((df.person == 'MW') & (df.num == 1)) |
(df.length == 5) & (df.person == 'SW') & ((df.num == 4) | (df.num==25)) |
(df.length == 10) & (df.person == 'SW') & (df.num == 1) |
(df.length == 15) & (df.person == 'SW') & (df.num == 1) |
(df.length == 20) & (df.person == 'SW') & ((df.num == 1) | (df.num==9)) |
(df.length == 30) & (df.person == 'SW') & ((df.num == 1) | (df.num==9)) ]
grp = df.groupby(['length'])
fdf = grp.aggregate(np.mean)
fdf['DOI'] = 1
fdf['configuration'] = 'wrapped'
fdf['length'] = [5,10,15,20,30]
fig, ax = subplots()
ax.grid()
Cols = {'MW':'b','SW':'r'}
Marker = {'MW':'*','SW':'^'}
Lbl = {'MW' : 'Wrap 1', 'SW' : 'Wrap 2'}
for key, grp in df.groupby('person'):
ax.errorbar(grp.length, grp.CTR, yerr=grp.CTRerr, fmt=Marker[key], color=Cols[key],label=Lbl[key])
#ax.errorbar(fdf.length, fdf.CTR, yerr=fdf.CTRError, fmt='.', color='b')
ax.set_xlim(-2,32)
ax.set_ylim(120,250)
ax.set_xlabel("Scintillator Crystal Length (mm)")
ax.set_ylabel("Coincidence Time Resolution (ps)")
ax.legend()
fig.tight_layout()
if savefigures:
pc.savefigureadir('standardctr',aloc,fig)
show()