Skip to content
Newer
Older
100644 179 lines (159 sloc) 6.35 KB
ca24149 @johnmgregoire add lots of utility files and some in-development ac analysis just to…
authored
1 import time, copy
2 import os
3 import sys
4 import numpy
5 import h5py
6 #from PnSC_ui import *
7 #from PnSC_dataimport import *
8 from PnSC_SCui import *
9 #from PnSC_math import *
10 from PnSC_h5io import *
11 from PnSC_main import *
12 from matplotlib.ticker import FuncFormatter
13 import scipy.integrate
14
15 selectcell=1
16 p='C:/Users/JohnnyG/Documents/PythonCode/Vlassak/NanoCalorimetry/AuSiCu_pnsc_all.h5'
17
18 def myexpformat(x, pos):
19 for ndigs in range(2):
20 lab=(('%.'+'%d' %ndigs+'e') %x).replace('e+0','e').replace('e+','e').replace('e0','').replace('e-0','e-')
21 if eval(lab)==x:
22 return lab
23 return lab
24 ExpTickLabels=FuncFormatter(myexpformat)
25
26 def make_ticklabels_invisible(ax, x=True, y=True):
27 if x:
28 for tl in ax.get_xticklabels():
29 tl.set_visible(False)
30 if y:
31 for tl in ax.get_yticklabels():
32 tl.set_visible(False)
33
34
35
36 nskip=100
37
38 cycleindex=0
39
40 savef='C:/Users/JohnnyG/Documents/HarvardWork/MG/PnSCplots/batchplotbycell_June2'
41
42 cols=['k', 'b', 'g', 'r', 'c', 'm', 'y']*3
43
44 expdicts=[\
45 dict([('name', 'heat1a'), ('heatseg', 2), ('coolseg', 4)]), \
46 dict([('name', 'heat1b'), ('heatseg', 2), ('coolseg', 4)]), \
47 dict([('name', 'heat1c'), ('heatseg', 2), ('coolseg', 4)]), \
48 dict([('name', 'heat1d'), ('heatseg', 2), ('coolseg', 4)]), \
49 dict([('name', 'heat2'), ('heatseg', 2), ('coolseg', 4)]), \
50 dict([('name', 'heat3'), ('heatseg', 2), ('coolseg', 4)]), \
51 dict([('name', 'heat4a'), ('heatseg', 2), ('coolseg', 4)]), \
52 dict([('name', 'heat4b'), ('heatseg', 2), ('coolseg', 4)]), \
53 dict([('name', 'heat4c'), ('heatseg', 2), ('coolseg', 3)]), \
54 dict([('name', 'heat6a'), ('heatseg', 2), ('coolseg', 4)]), \
55 dict([('name', 'heat6b'), ('heatseg', 2), ('coolseg', 4)]), \
56 dict([('name', 'heat6c'), ('heatseg', 2), ('coolseg', 3)]), \
57 dict([('name', 'heat7'), ('heatseg', 2), ('coolseg', 3)]), \
58 dict([('name', 'heat8'), ('heatseg', 2), ('coolseg', 4)]), \
59 ]
60
61 axl=get25pylabaxes(horizslowaxis=True)
62 taxl=[ax.twinx() for ax in axl]
63
64 metadictlist=[]
65 allsegdict=[]
66 for count, ed in enumerate(expdicts):
67 exp=ed['name']
68 f, hppaths=experimenthppaths(p, exp)
69 f.close()
70 hpsdl=None
71 saveh5hpname=None
72 for hpp in hppaths:
73 h5hpname=hpp.rpartition('/')[2]
74 f, g=gethpgroup(p, exp, h5hpname=h5hpname)
75 cell=g.attrs['CELLNUMBER']
76 f.close()
77 hpsdl=CreateHeatProgSegDictList(p, exp, h5hpname)
78 saveh5hpname=h5hpname
79 if not hpsdl is None:
80 ed['cell']=cell
81 T=hpsdl[ed['heatseg']]['sampletemperature'][cycleindex][nskip:-1*nskip]
82 maxT=T.max()
83 T=numpy.concatenate([T, hpsdl[ed['coolseg']]['sampletemperature'][cycleindex][nskip:-1*nskip]])
84 i=0
85 dt=[]
86 while len(dt)<2:
87 try:
88 dt=hpsdl[i]['cycletime'][cycleindex][0:2]
89 i+=1
90 except:
91 dt=[]
92 break
93 if len(dt)<0:
94 continue
95 dt=dt[1]-dt[0]
96 timeabove=len(numpy.where(T>800.)[0])*dt
97 axl[cell-1].plot(count, maxT, '%sD' %cols[count])
98 taxl[cell-1].plot(count, timeabove, '%sx' %cols[count])
99 axl[cell-1].set_ylabel('cell %d, max Temp (C)' %cell)
100 taxl[cell-1].set_ylabel('Time above 800C (s)(X)')
101 ed['maxT']=maxT
102 ed['secabove800C']=timeabove
103 metadictlist+=[copy.deepcopy(ed)]
104 for ax in axl:
105 ax.set_xlim(-0.5, len(expdicts)-0.5)
106 savebool=False
107 if savebool:
108 f=h5py.File(p, mode='r+')
109 g=f['calbycellmetadata']
110 f.close()
111 # if `selectcell` in g:
112 # cg=g[`selectcell`]
113 # else:
114 # cg=g.create_group(`selectcell`)
115 # for metadict in metadictlist:
116 # if selectcell==1 and metadict['name'].startswith('heat1'):
117 # continue
118 # if selectcell==6 and metadict['name']=='heat6a':
119 # continue
120 # if selectcell==16 and (metadict['name']=='heat2' or metadict['name']=='heat8'):
121 # continue
122 # if selectcell==19 and metadict['name'].startswith('heat1'):
123 # continue
124 # if selectcell==20 and metadict['name']=='heat4a':
125 # continue
126 # if selectcell==22 and metadict['name']=='heat4b':
127 # continue
128 # if selectcell==24 and metadict['name']=='heat6a':
129 # continue
130 # if selectcell==25 and (metadict['name']=='heat2' or metadict['name']=='heat3'):
131 # continue
132 # if metadict['name'] in cg:
133 # mg=cg[metadict['name']]
134 # else:
135 # mg=cg.create_group(metadict['name'])
136 # for k, v in metadict.iteritems():
137 # mg.attrs[k]=v
138 # f.close()
139 #
140 #plotcpregions=True
141 #if plotcpregions:
142 # for i, (metadict, hpsdl) in enumerate(zip(metadictlist, allsegdict)):
143 # if not 'Cpregions_enthalpy' in metadict.keys():
144 # continue
145 # T=hpsdl[metadict['heatseg']]['sampletemperature'][cycleindex]
146 # C=hpsdl[metadict['heatseg']]['sampleheatcapacity'][cycleindex]
147 # pylab.plot(T, C)
148 # pv=numpy.max(hpsdl[metadict['heatseg']]['sampleheatcapacity'][cycleindex])
149 # nv=numpy.min(hpsdl[metadict['heatseg']]['sampleheatcapacity'][cycleindex])
150 # lgen=lambda s:((s>0) and ([pv, pv], ) or ([nv, nv], ))[0]
151 #
152 # rxnindlist=[metadict['Cpregions_glassind'], metadict['Cpregions_xtalind'], metadict['Cpregions_meltind'], metadict['Cpregions_melt2ind']]
153 # for regind, (enth, Tp, Cp, Tmean, i, j) in enumerate(zip(metadict['Cpregions_enthalpy'], metadict['Cpregions_T_Cmax'], metadict['Cpregions_Cmax'], metadict['Cpregions_Tweightedmean'], metadict['Cpregions_cycindstart'], metadict['Cpregions_cycindstop'])):
154 # if regind in rxnindlist:
155 # col=['b', 'g', 'r', 'r'][rxnindlist.index(regind)]
156 # else:
157 # col=(.4, .4, .4)
158 # #pylab.plot([T[i], T[j]], lgen(numpy.sign(Cp)), 'k--')
159 # pylab.fill(T[i:j], C[i:j], color=col)
160 # pylab.plot(Tp, Cp, 'kx')
161 # pylab.plot(Tmean, 0, 'k*')
162 # pylab.xlim(plotTlim)
163 # Cinrange= C[(T>plotTlim[0])&(T<plotTlim[1])]
164 # a=Cinrange.min()
165 # b=Cinrange.max()
166 # pylab.ylim(a-0.02*(b-a), b+0.02*(b-a))
167 # pylab.savefig(os.path.join(os.path.join(savef, 'cell%02d' %selectcell),'Cpregions_cell%02d_%s.png' %(selectcell, metadict['name'])))
168 # pylab.clf()
169
170
171
172
173 #orderarray=numpy.abs(numpy.array(cool400))
174
175
176
177 pylab.show()
178 print 'done'
Something went wrong with that request. Please try again.