From 24711c0281ee6ccef8581884d323cc4583d81aa4 Mon Sep 17 00:00:00 2001 From: Aloma Blanch Date: Thu, 16 Jul 2020 20:43:04 -0500 Subject: [PATCH] Added flow rate plots at each outlet + Q_avg --- functions.py | 28 ++++++++++++++++++++-------- main.py | 4 +++- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/functions.py b/functions.py index a3f9367..3aea860 100644 --- a/functions.py +++ b/functions.py @@ -82,17 +82,11 @@ def pressure(folder,N_ts,T_cyc,dt,n_cyc): Nc = round(T_cyc/dt) time = np.linspace(0,T_cyc,Nc) fig, ax = plt.subplots() - # SBP = [] - # DBP = [] - # MBP = [] SBP = np.empty(pressure.shape[1]) DBP = np.empty(pressure.shape[1]) MBP = np.empty(pressure.shape[1]) for i in range(0,pressure.shape[1]): - ax.plot(time,pressure[N_ts-Nc:N_ts,i]/1333.22,label='ROI-'+str(i+2)) - # SBP.append(np.amax(pressure[N_ts-Nc:N_ts,i]/1333.22)) - # DBP.append(np.amin(pressure[N_ts-Nc:N_ts,i]/1333.22)) - # MBP.append(mean(pressure[N_ts-Nc:N_ts,i]/1333.22)) + ax.plot(time,pressure[N_ts-Nc:N_ts,i]/1333.22,label='ROI-'+str(i+2)) SBP[i] = (np.amax(pressure[N_ts-Nc:N_ts,i]/1333.22)) DBP[i] = (np.amin(pressure[N_ts-Nc:N_ts,i]/1333.22)) MBP[i] = (mean(pressure[N_ts-Nc:N_ts,i]/1333.22)) @@ -103,8 +97,26 @@ def pressure(folder,N_ts,T_cyc,dt,n_cyc): ax.spines['top'].set_visible(False) ax.legend(loc=0) plt.show() - return (DBP,MBP,SBP,PP) + + +def flow(folder,N_ts,T_cyc,dt,n_cyc): + flow = np.loadtxt(folder+'/QHistRCR.dat',skiprows=2,) + Nc = round(T_cyc/dt) + time = np.linspace(0,T_cyc,Nc) + fig, ax = plt.subplots() + Q = np.empty(flow.shape[1]) + for i in range(0,flow.shape[1]): + ax.plot(time,flow[N_ts-Nc:N_ts,i],label='ROI-'+str(i+2)) + Q[i] = (mean(flow[N_ts-Nc:N_ts,i])) + + ax.set(xlabel='time [s]', ylabel='Flow [mL/s]', + title='Flow @ each outlet') + ax.spines['right'].set_visible(False) + ax.spines['top'].set_visible(False) + ax.legend(loc=0) + plt.show() + return Q diff --git a/main.py b/main.py index 705aec8..63e5003 100644 --- a/main.py +++ b/main.py @@ -13,7 +13,7 @@ from scipy import signal import statistics -from functions import error_plot, periodicity, pressure +from functions import error_plot, periodicity, pressure, flow # Selct dir Tk().withdraw() @@ -51,3 +51,5 @@ periodicity(project,folder,dt,T_cyc,n_cyc) # Pressure (DBP,MBP,SBP,PP) = pressure(folder,N_ts,T_cyc,dt,n_cyc) +# Flow Rate +(Q_avg) = flow(folder,N_ts,T_cyc,dt,n_cyc)