Compare commits
2 Commits
a0040a7090
...
c3c570764b
Author | SHA1 | Date | |
---|---|---|---|
|
c3c570764b | ||
|
070428663c |
22
functions.py
22
functions.py
|
@ -42,7 +42,7 @@ def cycle(folder,dt,save_path):
|
||||||
ax.plot(time,pressure[:,-1]/1333.22,'b')
|
ax.plot(time,pressure[:,-1]/1333.22,'b')
|
||||||
ax.plot(t_pk_loc, P_peaks/1333.22, "or",label='peak location')
|
ax.plot(t_pk_loc, P_peaks/1333.22, "or",label='peak location')
|
||||||
ax.set(xlabel='time [s]', ylabel='Pressure [mmHg]',
|
ax.set(xlabel='time [s]', ylabel='Pressure [mmHg]',
|
||||||
title='Pressure at last outlet')
|
title='Pressure at last outlet')
|
||||||
ax.spines['right'].set_visible(False)
|
ax.spines['right'].set_visible(False)
|
||||||
ax.spines['top'].set_visible(False)
|
ax.spines['top'].set_visible(False)
|
||||||
ax.legend(loc=0)
|
ax.legend(loc=0)
|
||||||
|
@ -221,9 +221,11 @@ def rcr(project_folder):
|
||||||
return Rc_C_Rd
|
return Rc_C_Rd
|
||||||
|
|
||||||
def barPlot(project_folder,DBP,MBP,SBP,PP,Q_avg,save_path):
|
def barPlot(project_folder,DBP,MBP,SBP,PP,Q_avg,save_path):
|
||||||
import csv
|
aimed_all = [1] #No li agrada fer append en una llista buida, no recordo perquè i segur que es pot fer millor
|
||||||
with open(project_folder+'/aimed.csv', 'r') as f:
|
f = open(project_folder+'/aimed.txt', 'r') #obrir el fitxer
|
||||||
aimed_all = list(csv.reader(f, delimiter=';'))
|
for line in f:
|
||||||
|
aimed_all = line.split() #fas una llista amb cada valor de la línia carregan-te els espais buits
|
||||||
|
del aimed_all[0] #esborrar el primer valor que has posat perquè no estigues buida la llista
|
||||||
|
|
||||||
def plot_bar(CFD,aimed,name,save_path,unit):
|
def plot_bar(CFD,aimed,name,save_path,unit):
|
||||||
labels = []
|
labels = []
|
||||||
|
@ -254,6 +256,16 @@ def barPlot(project_folder,DBP,MBP,SBP,PP,Q_avg,save_path):
|
||||||
|
|
||||||
autolabel(rects1)
|
autolabel(rects1)
|
||||||
autolabel(rects2)
|
autolabel(rects2)
|
||||||
|
# Create labels
|
||||||
|
err = []
|
||||||
|
zip_object = zip(CFD, aimed)
|
||||||
|
for x1_i, x2_i in zip_object:
|
||||||
|
err.append(round((x1_i-x2_i)/x2_i*100,2))
|
||||||
|
|
||||||
|
# Text on the top of each barplot
|
||||||
|
for i in range(len(x)):
|
||||||
|
plt.text(x = x[i]- width/2, y = max(CFD[i],aimed[i])+0.15*max(max(CFD,aimed)), s = str(err[i])+'%', fontsize = 8, color='r')
|
||||||
|
|
||||||
fig.tight_layout()
|
fig.tight_layout()
|
||||||
# plt.show()
|
# plt.show()
|
||||||
plt.savefig(save_path + '/'+name+'_bar.pdf')
|
plt.savefig(save_path + '/'+name+'_bar.pdf')
|
||||||
|
@ -283,5 +295,3 @@ def barPlot(project_folder,DBP,MBP,SBP,PP,Q_avg,save_path):
|
||||||
CFD = [round(float(i),1) for i in Q_avg]
|
CFD = [round(float(i),1) for i in Q_avg]
|
||||||
aimed = [round(float(i),1) for i in aimed_all[4]]
|
aimed = [round(float(i),1) for i in aimed_all[4]]
|
||||||
plot_bar(CFD,aimed,'Q_avg',save_path,' [mL/s]')
|
plot_bar(CFD,aimed,'Q_avg',save_path,' [mL/s]')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user