Compare commits
2 Commits
ca94398ec8
...
e77d6f0d9a
Author | SHA1 | Date | |
---|---|---|---|
|
e77d6f0d9a | ||
|
6dcd1a4641 |
18
functions.py
18
functions.py
|
@ -8,13 +8,9 @@ Created on Thu Jul 16 15:08:27 2020
|
|||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib.ticker as mtick
|
||||
from tkinter import Tk
|
||||
from tkinter.filedialog import askopenfilename, asksaveasfile, askdirectory
|
||||
import pandas as pd
|
||||
import tkinter as tk
|
||||
from statistics import mean
|
||||
from scipy.signal import find_peaks
|
||||
# from scipy.signal import find_peaks
|
||||
import matplotlib.transforms as mtransforms
|
||||
|
||||
|
||||
|
@ -44,7 +40,7 @@ def error_plot(folder,t_step,r_criteria,save_path):
|
|||
title='Last nonlinear residual error for each time step')
|
||||
ax.spines['right'].set_visible(False)
|
||||
ax.spines['top'].set_visible(False)
|
||||
plt.show()
|
||||
# plt.show()
|
||||
plt.savefig(save_path + '/Last_nonlin_res_error.pdf')
|
||||
# Semilog scale
|
||||
fig, ax = plt.subplots()
|
||||
|
@ -54,7 +50,7 @@ def error_plot(folder,t_step,r_criteria,save_path):
|
|||
title='Log - Last nonlinear residual error for each time step')
|
||||
ax.spines['right'].set_visible(False)
|
||||
ax.spines['top'].set_visible(False)
|
||||
plt.show()
|
||||
# plt.show()
|
||||
plt.savefig(save_path + '/Log_Last_nonlin_res_error.pdf')
|
||||
fig.savefig(save_path + '/Log_Last_nonlin_res_error.jpg',dpi=150)
|
||||
|
||||
|
@ -80,7 +76,7 @@ def periodicity(project,folder,dt,T_cyc,n_cyc,save_path):
|
|||
ax.spines['right'].set_visible(False)
|
||||
ax.spines['top'].set_visible(False)
|
||||
ax.legend(loc=0)
|
||||
plt.show()
|
||||
# plt.show()
|
||||
plt.savefig(save_path + '/periodicity.pdf')
|
||||
fig.savefig(save_path + '/periodicity.jpg',dpi=150)
|
||||
|
||||
|
@ -109,7 +105,7 @@ def pressure(folder,N_ts,T_cyc,dt,n_cyc,save_path):
|
|||
ax.spines['right'].set_visible(False)
|
||||
ax.spines['top'].set_visible(False)
|
||||
ax.legend(loc=0)
|
||||
plt.show()
|
||||
# plt.show()
|
||||
plt.savefig(save_path + '/pressure.pdf')
|
||||
fig.savefig(save_path + '/pressure.jpg',dpi=150)
|
||||
return (DBP,MBP,SBP,PP)
|
||||
|
@ -130,7 +126,7 @@ def flow(folder,N_ts,T_cyc,dt,n_cyc,save_path):
|
|||
ax.spines['right'].set_visible(False)
|
||||
ax.spines['top'].set_visible(False)
|
||||
ax.legend(loc=0)
|
||||
plt.show()
|
||||
# plt.show()
|
||||
plt.savefig(save_path + '/flow.pdf')
|
||||
fig.savefig(save_path + '/flow.jpg',dpi=150)
|
||||
return Q
|
||||
|
@ -168,7 +164,7 @@ def inlet_flow_waveform(project_folder,t_btw_rst,N_ts,dt,T_cyc,n_cyc,save_path):
|
|||
for x, y, t in zip(t_pts[(-n_cyc-1):], Q_pts[(-n_cyc-1):], time):
|
||||
plt.text(x, y, t, transform=trans_offset, fontsize=12)
|
||||
ax.legend(loc=0)
|
||||
plt.show()
|
||||
# plt.show()
|
||||
plt.savefig(save_path + '/inlet_waveform.pdf')
|
||||
fig.savefig(save_path + '/inlet_waveform.jpg',dpi=150)
|
||||
print('{0} time steps saved, available to visualize in ParaView.'.format(np.unique(np.round(t_pts,3)).shape[0]))
|
||||
|
|
|
@ -83,19 +83,26 @@ def generatePDF(save_path,project,DBP,MBP,SBP,PP,Q_avg,txt1,txt2):
|
|||
pdf.set_title(title)
|
||||
pdf.set_author('Aloma Blanch Granada')
|
||||
|
||||
pdf.print_section(1, 'Cehcking convergency and periodicity')
|
||||
pdf.image(save_path +'/Log_Last_nonlin_res_error.jpg', x = None, y = None, w = 140, h = 100, type = '', link = '')
|
||||
pdf.image(save_path +'/periodicity.jpg', x = None, y = None, w = 140, h = 100, type = '', link = '')
|
||||
pdf.cell(0, 10,txt1[0], 0, 1)
|
||||
pdf.cell(0, 10,txt1[1], 0, 1)
|
||||
pdf.cell(0, 10,txt1[2], 0, 1)
|
||||
pdf.print_section(1, 'Checking convergency and periodicity')
|
||||
pdf.image(save_path +'/Log_Last_nonlin_res_error.jpg', x = 40, y = None, w = 140, h = 100, type = '', link = '')
|
||||
pdf.image(save_path +'/periodicity.jpg', x = 40, y = None, w = 140, h = 100, type = '', link = '')
|
||||
pdf.set_font('Arial', '', 10)
|
||||
pdf.cell(0, 10,' ', 0, 1)
|
||||
pdf.cell(0, 5,txt1[0], 0, 1)
|
||||
pdf.cell(0, 5,txt1[1], 0, 1)
|
||||
pdf.cell(0, 5,txt1[2], 0, 1)
|
||||
pdf.cell(0, 5,txt1[3], 0, 1)
|
||||
pdf.cell(0, 5,txt1[4], 0, 1)
|
||||
|
||||
pdf.print_section(2, 'Cehcking Pressures at each outlet')
|
||||
pdf.image(save_path +'/pressure.jpg', x = None, y = None, w = 140, h = 100, type = '', link = '')
|
||||
pdf.print_section(2, 'Checking Pressures at each outlet')
|
||||
pdf.image(save_path +'/pressure.jpg', x = 40, y = None, w = 140, h = 100, type = '', link = '')
|
||||
|
||||
width_cell=[20,30,30,30,30,30,30];
|
||||
# pfd.SetFillColor(193,229,252); # Background color of header
|
||||
pdf.set_font('Times', '', 10)
|
||||
# Header starts
|
||||
pdf.cell(0, 25,' ', 0, 1)
|
||||
pdf.set_x(35)
|
||||
pdf.cell(width_cell[0],10,'ROI',1,0,'C') # First header column
|
||||
pdf.cell(width_cell[1],10,'DBP [mmHg]',1,0,'C') # Second header column
|
||||
pdf.cell(width_cell[2],10,'MBP [mmHg]',1,0,'C') # Third header column
|
||||
|
@ -103,6 +110,7 @@ def generatePDF(save_path,project,DBP,MBP,SBP,PP,Q_avg,txt1,txt2):
|
|||
pdf.cell(width_cell[4],10,'PP [mmHg]',1,1,'C') # Fourth header column
|
||||
# Rows
|
||||
for i in range(0,len(SBP)):
|
||||
pdf.set_x(35)
|
||||
pdf.cell(width_cell[0],10,'ROI-'+ str(i+2),1,0,'C') # First column of row 1
|
||||
pdf.cell(width_cell[1],10,str(round(DBP[i],2)),1,0,'C') # Second column of row 1
|
||||
pdf.cell(width_cell[2],10,str(round(MBP[i],2)),1,0,'C') # Third column of row 1
|
||||
|
@ -110,21 +118,26 @@ def generatePDF(save_path,project,DBP,MBP,SBP,PP,Q_avg,txt1,txt2):
|
|||
pdf.cell(width_cell[4],10,str(round(PP[i],2)),1,1,'C') # Fourth column of row 1
|
||||
|
||||
|
||||
pdf.print_section(3, 'Cehcking Flow Rate at each outlet')
|
||||
pdf.image(save_path +'/flow.jpg', x = None, y = None, w = 140, h = 100, type = '', link = '')
|
||||
pdf.print_section(3, 'Checking Flow Rate at each outlet')
|
||||
pdf.image(save_path +'/flow.jpg', x = 40, y = None, w = 140, h = 100, type = '', link = '')
|
||||
|
||||
width_cell=[20,60];
|
||||
width_cell=[20,45];
|
||||
# pfd.SetFillColor(193,229,252); # Background color of header
|
||||
pdf.set_font('Times', '', 10)
|
||||
# Header starts
|
||||
pdf.cell(0, 25,' ', 0, 1)
|
||||
pdf.set_x(80)
|
||||
pdf.cell(width_cell[0],10,'ROI',1,0,'C') # First header column
|
||||
pdf.cell(width_cell[1],10,'Average Flow rate [mL/s]',1,1,'C') # Second header column
|
||||
# Rows
|
||||
for i in range(0,len(Q_avg)):
|
||||
pdf.set_x(80)
|
||||
pdf.cell(width_cell[0],10,'ROI-'+ str(i+2),1,0,'C')
|
||||
pdf.cell(width_cell[1],10,str(round(Q_avg[i],2)),1,1,'C')
|
||||
|
||||
|
||||
pdf.print_section(4, 'Cehcking Inlet Flow Waveform and time steps saved')
|
||||
pdf.image(save_path +'/inlet_waveform.jpg', x = None, y = None, w = 140, h = 100, type = '', link = '')
|
||||
pdf.cell(0, 10,txt2, 0, 1)
|
||||
pdf.print_section(4, 'Checking Inlet Flow Waveform and time steps saved')
|
||||
pdf.image(save_path +'/inlet_waveform.jpg', x = 40, y = 50, w = 140, h = 100, type = '', link = '')
|
||||
pdf.set_font('Arial', '', 10)
|
||||
pdf.cell(0, 5,txt2, 0, 1)
|
||||
pdf.output(save_path + '/' + project + '-report.pdf', 'F')
|
22
main.py
22
main.py
|
@ -5,18 +5,19 @@ Created on Thu Jul 16 15:08:27 2020
|
|||
@author: Aloma Blanch
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib.ticker as mtick
|
||||
# import numpy as np
|
||||
# import matplotlib.pyplot as plt
|
||||
# import matplotlib.ticker as mtick
|
||||
from tkinter import Tk
|
||||
from tkinter.filedialog import askopenfilename, asksaveasfile, askdirectory
|
||||
import pandas as pd
|
||||
import tkinter as tk
|
||||
# from tkinter.filedialog import askopenfilename, asksaveasfile, askdirectory
|
||||
from tkinter.filedialog import askdirectory
|
||||
# import pandas as pd
|
||||
# import tkinter as tk
|
||||
import os.path
|
||||
from scipy.signal import find_peaks_cwt
|
||||
from scipy import signal
|
||||
import statistics
|
||||
from fpdf import FPDF
|
||||
# from scipy.signal import find_peaks_cwt
|
||||
# from scipy import signal
|
||||
# import statistics
|
||||
# from fpdf import FPDF
|
||||
|
||||
|
||||
from functions import error_plot, periodicity, pressure, flow, inlet_flow_waveform
|
||||
|
@ -65,6 +66,5 @@ txt1 = periodicity(project,folder,dt,T_cyc,n_cyc,save_path)
|
|||
# Inlet Flow Rate + and t saved
|
||||
txt2 = inlet_flow_waveform(project_folder,t_btw_rst,N_ts,dt,T_cyc,n_cyc,save_path)
|
||||
|
||||
|
||||
# Create PDF report
|
||||
generatePDF(save_path,project,DBP,MBP,SBP,PP,Q_avg,txt1,txt2)
|
Loading…
Reference in New Issue
Block a user