-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadCurveTimeComp.py
116 lines (102 loc) · 3.65 KB
/
readCurveTimeComp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import numpy as np
import matplotlib.pyplot as pyt
## take all curves of the same sample (particular material and batch)
## and compare the spectrum
## Also usable as a replacement to readCurveRefCheck.py,
## to compare with past refs
from datetime import date
import sys
from Curve import (Curve, curvesKeyword, curveCreation,
specPlotter,curvesAge, curvesRef, readCurveFile)
execfile('readCurveInput_default.py') # loads default setting
execfile('readCurveInput_0708test.py')
allc = curvesKeyword(allcurves, name = keyword)
allc2 = curvesKeyword(allcurves, name = keyword2)
refc = curvesKeyword(refcurves, name = refkeyword)
cref = refc[refnum]
fig, (ax1,ax2) = pyt.subplots(2,1, sharex=True, gridspec_kw=shr, figsize = figsize)
if baseline:
t , df = False, False
tLabel = 'Transmission'
fig.suptitle(eval(titleGen), y=.95, size=17)
iterfarb, iterfarb2 = iter(farben),iter(farben2)
numPlotted = 0
if showRef:
lbl = cref.nametag #str(c.datetag)
ax1.plot(x[s],cref.avgcurve(t=t)[s], label = 'Ref ' + lbl,
color = 'blue',linewidth = 1.5)
if isFirstLast:
# Only first and last sample to show agregate change
for array in [allc,allc2]:
c = array[0]
clr = iterfarb2.next()
lbl = c.label() if isOrigLabel else cLabel[numPlotted]
ax1.plot(x[s],c.avgcurve(t=t)[s], label = lbl, color = clr,
linestyle = 'dashed',linewidth = 1.7)
numPlotted+=1
for array in [allc,allc2]:
c = array[-1]
clr = iterfarb.next()
lbl = c.label() if isOrigLabel else cLabel[numPlotted]
ax1.plot(x[s],c.avgcurve(t=t)[s], label = lbl, color = clr,linewidth = 1.2)
numPlotted+=1
else:
for c in allc:
clr = iterfarb.next()
lbl = c.label() if isOrigLabel else cLabel[numPlotted]
ax1.plot(x[s],c.avgcurve(t=t)[s], label = lbl, color = clr,linewidth = 1)
numPlotted+=1
for c in allc2:
clr = iterfarb2.next()
lbl = c.label() if isOrigLabel else cLabel[numPlotted]
ax1.plot(x[s],c.avgcurve(t=t)[s], label = lbl, color = clr,linewidth = 1)#, linestyle = 'dashed')
numPlotted+=1
if not baseline and showErr:
ax1.plot(x[s],allc[0].errcurve(t=t)[s]*10, label = 'Error x10', color = 'cyan')
ax1.grid(True)
ax1.legend(loc = 0, fontsize = legFont)
ax1.set_xlabel('Wavelength nm')
ax1.set_ylabel(tLabel)
if t:
ax1.set_ylim([0.,1.])
avgpcterr = np.abs(cref.errcurve(t=t))/cref.avgcurve(t=t)
# to show diff in absp plots
if (not t) and df:
avgpcterr = np.abs(cref.errcurve(t=t))
if not baseline:
# error shades
ax2.fill_between(x[s],-avgpcterr[s],avgpcterr[s], label = 'err',alpha = .3) #default .2
iterfarb, iterfarb2 = iter(farben), iter(farben2)
if isFirstLast:
# Only first and last sample to show agregate change
ref = cref.avgcurve(t=t)
for array in [allc,allc2]:
c = array[0]
avg = c.avgcurve(t=t)
ax2.plot(x[s],(avg/ref-1)[s],
linestyle='dashed', linewidth = 1.8, color = iterfarb2.next())
for array in [allc,allc2]:
c = array[-1]
avg = c.avgcurve(t=t)
ax2.plot(x[s],(avg/ref-1)[s],
linewidth = 1.2, color = iterfarb.next())
else:
for c in allc:
if (not t) and df:
ax2.plot(x[s],(c.avgcurve(t=t)-cref.avgcurve(t=t))[s], color = iterfarb.next())
else:
ax2.plot(x[s],(c.avgcurve(t=t)/cref.avgcurve(t=t)-1)[s],
linewidth = 1.5, color = iterfarb.next())
for c in allc2:
if (not t) and df:
ax2.plot(x[s],(c.avgcurve(t=t)-cref.avgcurve(t=t))[s],
color = iterfarb2.next())#, linestyle = 'dashed')
else:
ax2.plot(x[s],(c.avgcurve(t=t)/cref.avgcurve(t=t)-1)[s],
color = iterfarb2.next())#, linestyle = 'dashed')
ax2.grid(True)
ax2.set_xlabel('Wavelength nm')
ax2.set_ylabel('Diff' if (not t) and df else 'Ratio-1')
ax2.set_ylim(ratioyrange)
pyt.show(block = isBlocked)
#fig.savefig('plots/SpecCompPS-PVT-6_7/SpecComp'+refkeyword+'.png')