diff --git a/tools/evaluation/thesisBiventricle.py b/tools/evaluation/thesisBiventricle.py index dfa42d657353035ef25b4318bae8c8516b125fca..efb3267e412eff63f3f646fd5236b30098a00ef7 100644 --- a/tools/evaluation/thesisBiventricle.py +++ b/tools/evaluation/thesisBiventricle.py @@ -9,7 +9,7 @@ eP='../../../data/biventricleTT/SimpleExcitation/GerachDiffusion/' fSISVI=eP+'SI0004/' fSIOC=eP+'SIOC0004/' fSIICI=eP+'SIICI0004/' -fGS=eP+'GS0004/theta1/' +fGS=eP+'GS0004/theta1/' #'../../../data/biventricleTT/SimpleExcitation/GerachDiffusion/GS0004/theta1/' fGShalve=eP+'GS0004/' @@ -54,7 +54,7 @@ def tactValuesAndErrorPerPoint(): nL=['\\SISVI','\\SIOC','\\SIICI','\\GPDE']#,'\\GShalve'] fL=[fSISVI,fSIOC,fSIICI,fGS]#,fGShalve] - tabWriter = TableWriter(lL,tL,sdt,endTime,1,[fSISVI],listEvaluationPoints) + tabWriter = TableWriter(lL,tL,sdt,endTime,1,[fSIOC],listEvaluationPoints) savePath='../../../thesis-lindner/thesis/tables/erstmal/TTGD/' tabWriter.writetactAndErrorPerPoint(fL,nL,savePath,threshold) @@ -125,8 +125,62 @@ def plotPotential(): listEvaluationPoints=[1,2,3,4,5,6,7,8,9] plot=Plot(lL,tL,sdt,endTime,1,listEvaluationPoints) plot.plotSpaceForPointp(fSIOC,9,3,1,1) - - +def plotExtraError(): + lL=[2,3,4,5] + tL=[0,1,2,3] + sdt=0.0004 + endTime=0.65 + listEvaluationPoints=[2,3,4,5,6,7,8,9] + listEvaluationPoints=[8] + + nL=['\\SISVI','\\SIOC','\\SIICI','\\GPDE'] + fL=[fSISVI,fSIOC,fSIICI,fGS] + + savePath='../../../thesis-lindner/thesis/images/erstmal/' + plot=Plot(lL,tL,sdt,endTime,1,listEvaluationPoints) + j=tL[-1] + l=lL[-1] + for p in listEvaluationPoints: + plot.VIntErrorInSpace(fL,nL,threshold,p,j,savePath,fSIOC) + plot.VIntErrorInTime(fL,nL,threshold,p,l,savePath,fSIOC) +def plotTactErrorPerPoint(): + lL=[2,3,4,5] + tL=[0,1,2,3] + sdt=0.0004 + endTime=0.65 + listEvaluationPoints=[2,3,4,5,6,7,8,9] + listEvaluationPoints=[8] + + nL=['\\SISVI','\\SIOC','\\SIICI','\\GPDE'] + fL=[fSISVI,fSIOC,fSIICI,fGS] + + savePath='../../../thesis-lindner/thesis/images/erstmal/' + plot=Plot(lL,tL,sdt,endTime,1,listEvaluationPoints) + j=tL[-1] + l=lL[-1] + for p in listEvaluationPoints: + plot.tactErrorInSpace(fL,nL,threshold,p,j,savePath,fSIOC) + plot.tactErrorInTime(fL,nL,threshold,p,l,savePath,fSIOC) + +def plotSchwinger(): + lL=[2,3,4,5] + tL=[0] + sdt=0.0004 + endTime=0.65 + listEvaluationPoints=[2,3,4,5,6,7,8,9] + listEvaluationPoints=[8] + + nL=['\\SISVI','\\SIOC','\\SIICI','\\GPDE'] + fL=[fSISVI,fSIOC,fSIICI,fGS] + + savePath='../../../thesis-lindner/thesis/images/erstmal/' + plot=Plot(lL,tL,sdt,endTime,1,listEvaluationPoints) + j=3 + for p in listEvaluationPoints: + plot.Unterschwinger(fL,nL,threshold,p,j,savePath) + plot.Oberschwinger(fL,nL,threshold,p,j,savePath) + + def WriteDurationPerTimeStepTab(): lL=[2,3,4] tL=[0] @@ -173,15 +227,18 @@ def WorkPrecisonDiagram(case): if __name__=="__main__": language='d' plotSchwinger() - AllValueTabs() + #AllValueTabs() #plotPotential() diffcase ='tact' - DifferencePerPointTabs(diffcase) + #DifferencePerPointTabs(diffcase) diffcase='VDiffInt' - DifferencePerPointTabs(diffcase) + # DifferencePerPointTabs(diffcase) #activationTimeExtrapolateTab() - tactValuesAndErrorPerPoint() - ErrorExtraVInt() - WriteDurationPerTimeStepTab() - WorkPrecisonDiagram('') + #tactValuesAndErrorPerPoint() + #plotTactErrorPerPoint() + #ErrorExtraVInt() + #WriteDurationPerTimeStepTab() + # WorkPrecisonDiagram('') + #plotSchwinger() + plotExtraError() diff --git a/tools/evaluation/utility/latexTables.py b/tools/evaluation/utility/latexTables.py index 33c462219225a680be42d0801a629d9dcc0cd3e1..cc74f45c649b195d1fb07126478ca00d890c6d47 100644 --- a/tools/evaluation/utility/latexTables.py +++ b/tools/evaluation/utility/latexTables.py @@ -583,7 +583,7 @@ class Table: (tact2,id_tact2)=comp.getActivaitionTimeFromVWithID(t2,V2,threshold) value=-1000.0 if case=='tact': - value = tact1-tact2 + value = 1000.0*(tact1-tact2) elif case=='VInt': id_dur1=self.getTimeID(id_tact1,j) id_dur2=self.getTimeID(id_tact2,j) @@ -603,7 +603,10 @@ class Table: (t1,G1)=read.getDataFromTXT(fL[alg],read.createFilename(l,j,self.m)+'Gamma',p) (t2,G2)=read.getDataFromTXT(fL[alg],read.createFilename(l-1,j,self.m)+'Gamma',p) value=comp.L2DiffInterval(G1,G2,self.sdt,j,j) - block += " & $"+ str("%8.4f"%(value))+"$" + if case =='tact': + block += " & $"+ str("%8.3f"%(value))+"$" + else: + block += " & $"+ str("%8.4f"%(value))+"$" else: block+=" & - " block+='\\\\\n' @@ -651,8 +654,8 @@ class Table: (tact2,id_tact2)=comp.getActivaitionTimeFromVWithID(t2,V2,threshold) value=-1000.0 if case=='tact': - value = tact1-tact2 - block += " & $"+ str("%8.5f"%(value))+"$" + value = 1000.0*(tact1-tact2) + block += " & $"+ str("%8.3f"%(value))+"$" elif case=='VInt': id_dur1=self.getTimeID(id_tact1,j) id_dur2=self.getTimeID(id_tact2,j-1) @@ -2572,6 +2575,8 @@ class Table: (t,V)=read.getDataFromTXT(alg,read.createFilename(l,j,self.m),p) if len(t)==standardlength: t_act=comp.getActivaitionTimeFromV(t,V,threshold) + #if p==8 and l==5 and j==3 and alg=='../../../data/biventricleTT/SimpleExcitation/GerachDiffusion/GS0004/theta1/': + # print('table',1000.0*t_act,tactRef,abs(t_act-tactRef)/tactRef) value=abs(t_act-tactRef)/tactRef block += " & $"+ str("%8.4f"%(value))+"$" else: @@ -3079,7 +3084,7 @@ class TableWriter: def writeAPDTable(self,fL,nL,savePath,threshold): for p in self.evalP: - cap='Die Dauer des Aktionspotentials $\\tdur(\\V^{j,\\ell},'+self.tab.getPointNamebyNumber(p,True) +')$ auf dem biventrikulären Gebiet mit der vereinfachten Anregung für verschiedene Zeitdiskretisierungsverfahren' + cap='Die Dauer des Aktionspotentials $\\tdur(\\V^{j,\\ell},'+self.tab.getPointNamebyNumber(p,True) +')$ in s auf dem biventrikulären Gebiet mit der vereinfachten Anregung für verschiedene Zeitdiskretisierungsverfahren' label ='tab:APDBVSEP'+str(p) filename=savePath +'APDBVSEinP'+str(p) with open(filename+'.tex', 'w') as output_file: @@ -3146,7 +3151,7 @@ class TableWriter: label ='tab:DifferencesLtwoActP'+str(p) filename=savePath +'DifferencesBiventricleLtwoActP'+str(p) elif case =='tact': - cap='Differenzen der Aktivierungszeiten $\\tact$ der benachbarten Ortslevel (links) und Zeitlevel (rechts) in '+self.tab.getPointNamebyNumber(p,False) + cap='Differenzen der Aktivierungszeiten $\\tact$ in ms der benachbarten Ortslevel (links) und Zeitlevel (rechts) in '+self.tab.getPointNamebyNumber(p,False) label ='tab:DifferencestactP'+str(p) filename=savePath +'DifferencesBiventricletactP'+str(p) elif case =='VDiffInt': diff --git a/tools/evaluation/utility/plotting.py b/tools/evaluation/utility/plotting.py index affeeb1751bce630f5b7215ec617d099ecb4e339..012f5e8ce5361af998f6705df2e6e5d49c8f79c0 100644 --- a/tools/evaluation/utility/plotting.py +++ b/tools/evaluation/utility/plotting.py @@ -500,7 +500,7 @@ class Plot: value=max(V[id_tact:]) minimalV.append(value) labelname=nL[i] - plt.plot(self.lL,minimalV,color=self.colorList[i],label=labelname,marker=self.markerList[0],linewidth=1) + plt.plot(self.lL,minimalV,color=self.colorList[i],label=labelname,marker=self.markerList[i],linewidth=3.5) plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.) plotname='OberschwingerPlotj'+str(j)+'P'+str(p) plt.xlabel('Ortslevel $\\ell$') @@ -519,7 +519,7 @@ class Plot: value=min(V[:id_tact]) minimalV.append(value) labelname=nL[i] - plt.plot(self.lL,minimalV,color=self.colorList[i],label=labelname,marker=self.markerList[0],linewidth=1) + plt.plot(self.lL,minimalV,color=self.colorList[i],label=labelname,marker=self.markerList[i],linewidth=3.5) plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.) plotname='UnterschwingerPlotj'+str(j)+'P'+str(p) plt.xlabel('Ortslevel $\\ell$') @@ -528,18 +528,65 @@ class Plot: #plt.show() self.saveTikz(sP,plotname) plt.close() - - def tactErrorInSpace(self,fL,nL,threshold,p,j,sP): - tactRef=comp.getTextFullExtrapolate(self.lL[-1],self.tL[-1],1,p,fL[1],threshold) + def VIntErrorInSpace(self,fL,nL,th,p,j,sP,exP): + tact_ref=comp.getTextFullExtrapolate(self.lL[-1],self.tL[-1],1,p,exP,th,'') + (t_f,VInt_full)=comp.getVIntFullExtrapolate(self.lL[-1],self.tL[-1],1,p,exP,self.sdt,th,durEvalActi,tact_ref,'') + norm_full=comp.L2(VInt_full,self.sdt,self.T,self.tL[-2],False) + for i in range(len(nL)): + VIntError=[] + for l in self.lL: + (t,V)= read.getDataFromTXT(fL[i],read.createFilename(l,j,1),p) + (tact,id_tact)=comp.getTactPerCase(t,V,th,'',True) + id_dur=self.getTimeID(id_tact,j) + value=comp.L2DiffInterval(V[id_tact:id_dur],VInt_full,self.sdt,j,self.tL[-2],p) + value=value/norm_full + VIntError.append(value) + labelname=nL[i] + plt.plot(self.lL,VIntError,color=self.colorList[i],label=labelname,marker=self.markerList[i],linewidth=3.5) + plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.) + plotname='VIntErrorSpacePlotj'+str(j)+'P'+str(p) + plt.xlabel('Ortsevel $\\ell$') + plt.ylabel('$\errorVact^{'+str(j)+',\ell,'+str(p)+'}$ ') + plt.xticks(np.arange(1, len(self.lL), step=1.0)) + #plt.show() + self.saveTikz(sP,plotname) + plt.close() + def VIntErrorInTime(self,fL,nL,th,p,l,sP,exP): + tact_ref=comp.getTextFullExtrapolate(self.lL[-1],self.tL[-1],1,p,exP,th,'') + (t_f,VInt_full)=comp.getVIntFullExtrapolate(self.lL[-1],self.tL[-1],1,p,exP,self.sdt,th,durEvalActi,tact_ref,'') + norm_full=comp.L2(VInt_full,self.sdt,self.T,self.tL[-2],False) + for i in range(len(nL)): + VIntError=[] + for j in self.tL: + (t,V)= read.getDataFromTXT(fL[i],read.createFilename(l,j,1),p) + (tact,id_tact)=comp.getTactPerCase(t,V,th,'',True) + id_dur=self.getTimeID(id_tact,j) + value=comp.L2DiffInterval(V[id_tact:id_dur],VInt_full,self.sdt,j,self.tL[-2],p) + value=value/norm_full + VIntError.append(value) + labelname=nL[i] + plt.plot(self.tL,VIntError,color=self.colorList[i],label=labelname,marker=self.markerList[i],linewidth=3.5) + plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.) + plotname='VIntErrorTimePlotl'+str(l)+'P'+str(p) + plt.xlabel('Zeitlevel $j$') + plt.ylabel('$\errorVact^{'+str(j)+',\ell,'+str(p)+'}$ ') + plt.xticks(np.arange(1, len(self.lL), step=1.0)) + #plt.show() + self.saveTikz(sP,plotname) + plt.close() + def tactErrorInSpace(self,fL,nL,threshold,p,j,sP,exP): + tactRef=comp.getTextFullExtrapolate(self.lL[-1],self.tL[-1],1,p,exP,threshold) for i in range(len(nL)): tactError=[] for l in self.lL: (t,V)= read.getDataFromTXT(fL[i],read.createFilename(l,j,1),p) t_act=comp.getActivaitionTimeFromV(t,V,threshold) + #if p==8 and l==5 and nL[i]=='\\GPDE': + # print('plotting',1000.0*t_act,tactRef,abs(t_act-tactRef)/tactRef) value=abs(t_act-tactRef)/tactRef tactError.append(value) labelname=nL[i] - plt.plot(self.lL,tactError,color=self.colorList[i],label=labelname,marker=self.markerList[0],linewidth=1) + plt.plot(self.lL,tactError,color=self.colorList[i],label=labelname,marker=self.markerList[i],linewidth=3.5) plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.) plotname='TactErrorSpacePlotj'+str(j)+'P'+str(p) plt.xlabel('Ortsevel $\\ell$') @@ -551,7 +598,7 @@ class Plot: def tactErrorInTime(self,fL,nL,threshold,p,l,sP): - tactRef=comp.getTextFullExtrapolate(self.lL[-1],self.tL[-1],1,p,fL[1],threshold) + tactRef=comp.getTextFullExtrapolate(self.lL[-1],self.tL[-1],1,p,exP,threshold) for i in range(len(nL)): tactError=[] for j in self.tL: @@ -560,7 +607,7 @@ class Plot: value=abs(t_act-tactRef)/tactRef tactError.append(value) labelname=nL[i] - plt.plot(self.tL,tactError,color=self.colorList[i],label=labelname,marker=self.markerList[0],linewidth=1) + plt.plot(self.tL,tactError,color=self.colorList[i],label=labelname,marker=self.markerList[i],linewidth=3.5) plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.) plotname='TactErrorTimePlotl'+str(l)+'P'+str(p) plt.xlabel('Zeitlevel $j$')