In [1]:
import traceback
import matplotlib
import matplotlib.cm as cm
import pandas as pd
import matplotlib.pyplot as plt
from scipy.signal import argrelextrema
from mpl_toolkits import mplot3d
from mpl_toolkits.mplot3d import axes3d
import matplotlib as mpl
from scipy.signal import find_peaks
from mpl_toolkits.mplot3d import Axes3D
from scipy.signal import butter, lfilter, freqz
import scipy
import warnings
warnings.filterwarnings("ignore")
import FluidicSetupFunctions
import matplotlib.gridspec as gridspec
import numpy as np
import re
import time
import cmcrameri.cm as cmc
from mpl_toolkits.axes_grid1 import make_axes_locatable
import cv2, PIL
plt.style.use('seaborn-v0_8-whitegrid')
matplotlib.rcParams['mathtext.fontset'] = 'stix'
matplotlib.rcParams['font.family'] = 'STIXGeneral'
class MidpointNormalize(mpl.colors.Normalize):
def __init__(self, vmin, vmax, midpoint=0, clip=False):
self.midpoint = midpoint
mpl.colors.Normalize.__init__(self, vmin, vmax, clip)
def __call__(self, value, clip=None):
normalized_min = max(0, 1 / 2 * (1 - abs((self.midpoint - self.vmin) / (self.midpoint - self.vmax))))
normalized_max = min(1, 1 / 2 * (1 + abs((self.vmax - self.midpoint) / (self.midpoint - self.vmin))))
normalized_mid = 0.5
x, y = [self.vmin, self.midpoint, self.vmax], [normalized_min, normalized_mid, normalized_max]
return np.ma.masked_array(np.interp(value, x, y))
def atoi(text):
return int(text) if text.isdigit() else text
def natural_keys(text):
'''
alist.sort(key=natural_keys) sorts in human order
http://nedbatchelder.com/blog/200712/human_sorting.html
(See Toothy's implementation in the comments)
'''
return [ atoi(c) for c in re.split(r'(\d+)', text) ]
def rising_edge(data, thresh):
sign = data >= thresh
pos = np.where(np.convolve(sign, [1, -1]) == 1)
return pos
#Fluidic
Location = r"O:\group-folder\PROJECTS\Stochastic emergent control in modular systems(Mannus, Sergio, Antonio)\EXPERIMENTS\clock\v32\ReplicationPackage"
Foldernames = ["\\FluidicData"] #15 sec out, then exp starts
#ResultsFoldernames = []
#for el in Foldernames:
# ResultsFoldernames.append(Location +'\\RESULTS_'+el[2:])
result_folder = r'O:\group-folder\PROJECTS\Stochastic emergent control in modular systems(Mannus, Sergio, Antonio)\EXPERIMENTS\clock\v32\ReplicationPackage\results'
data = FluidicSetupFunctions.LoadData(Foldernames=Foldernames, Location = Location)
dpi=300
unifieddf = False
for i in range(0, len(data[0])):
print(i,data[1]['Samplename'][i])
Loading... Folder 1 of 1, Sample 1 of 26 Unknown sensor! SSCDP15-4 Unknown sensor! SSCDP15-9 Loading... Folder 1 of 1, Sample 2 of 26 Unknown sensor! SSCDP30-10 Loading... Folder 1 of 1, Sample 3 of 26 Unknown sensor! SSCDP15-4 Unknown sensor! SSCDP15-9 Unknown sensor! SSCDP30-2 Loading... Folder 1 of 1, Sample 4 of 26 Loading... Folder 1 of 1, Sample 5 of 26 Unknown sensor! SSCDP05-3 Unknown sensor! SSCDP30-9 Loading... Folder 1 of 1, Sample 6 of 26 Unknown sensor! SSCDP05-3 Unknown sensor! SSCDP30-9 Loading... Folder 1 of 1, Sample 7 of 26 Unknown sensor! SSCDP05-3 Unknown sensor! SSCDP30-9 Loading... Folder 1 of 1, Sample 8 of 26 Loading... Folder 1 of 1, Sample 9 of 26 Unknown sensor! SSCDP01-9 Loading... Folder 1 of 1, Sample 10 of 26 Unknown sensor! SSCDP01-9 Unknown sensor! SSCDP15-3 Loading... Folder 1 of 1, Sample 11 of 26 Unknown sensor! SSCDP15-4 Unknown sensor! SSCDP30-9 Loading... Folder 1 of 1, Sample 12 of 26 Unknown sensor! SSCDP15-4 Unknown sensor! SSCDP30-9 Loading... Folder 1 of 1, Sample 13 of 26 Unknown sensor! SSCDP15-4 Unknown sensor! SSCDP30-9 Loading... Folder 1 of 1, Sample 14 of 26 Unknown sensor! SSCDP15-4 Unknown sensor! SSCDP15-9 Unknown sensor! SSCDP05-3 Loading... Folder 1 of 1, Sample 15 of 26 Unknown sensor! SSCDP15-4 Unknown sensor! SSCDP15-9 Unknown sensor! SSCDP05-3 Loading... Folder 1 of 1, Sample 16 of 26 Unknown sensor! SSCDP05-9 Loading... Folder 1 of 1, Sample 17 of 26 Unknown sensor! SSCDP05-9 Loading... Folder 1 of 1, Sample 18 of 26 Unknown sensor! SSCDP05-9 Loading... Folder 1 of 1, Sample 19 of 26 Loading... Folder 1 of 1, Sample 20 of 26 Loading... Folder 1 of 1, Sample 21 of 26 Loading... Folder 1 of 1, Sample 22 of 26 Loading... Folder 1 of 1, Sample 23 of 26 Loading... Folder 1 of 1, Sample 24 of 26 Loading... Folder 1 of 1, Sample 25 of 26 Unknown sensor! SSCDP15-9 Loading... Folder 1 of 1, Sample 26 of 26 Unknown sensor! SSCDP15-9 0 PressureControl 1 Fig1A_If230905_V0 2 Fig2_Ifbreak_V0 3 Fig3_20230919_trackingaruco 4 Fig4SingleBoolean_230920_V1 5 Fig4AND_230921_V0 6 Fig4OR_230921_V0 7 Fig3_20230922_V2 8 Fig3_20230922_nestedloop_V1 9 Supplementary2_NOTunableResistance_Highres 10 Supplementary3_NO_memory 11 Supplementary3_NO_memory_bis 12 Supplementary3_NO_memory_tris 13 GoldenRetrieverV5_V1 14 VariablesAmplitude&Frequencyv06 15 IfSensitivity v04 16 Venus0 17 IfSensitivity_Cinfluence 18 forcedisplacement45kPa 19 forcedisplacement30kPa 20 forcedisplacement40kPa 21 forcedisplacement25kPa 22 forcedisplacement50kPa 23 IfElse2 24 Retriever4Review_take4 25 Sequencer04
In [ ]:
In [3]:
#figure specs
from matplotlib import rcParams
rcParams.update({'figure.autolayout': True})
cm = 1/2.54 # centimeters in inches
sizehalfcol = 9.2*cm
size13col = 18.4/3*cm
size1, size2 = 20,8
legendfont = 11 # 9
labelfontsize = 11 # 9
ticks_size=9 # 7
dpi = 300
transparentsave=True
TITLES=False
colorA = '#d37a5a'#'#894a41' #BrownBaloon
colorB = '#b4e181'#'#7fb553' #GreenActuator
colorBdark = '#A4CE75'
colorBdark2 = '#6CAD62'
colorAopaque20 = '#d37a5a33'
colorAopaque25 = '#d37a5a40'
colorBopaque20 = '#b4e18133'
colorBopaque50 = '#b4e18180'
colorBopaque75 = '#b4e181bf'
lwA = 6
lwB = 6
In [ ]:
Figure 2¶
In [ ]:
In [4]:
expidx = 1
df = data[0][expidx]
expname = data[1]['Samplename'][expidx]
print(expname)
#preparing data, converting to kPa the SSCDP sensors, than dividing by 1000 to get kPa
df["pIn"] = (((df["SSCDP30-10"])*2/2.5)*101.3250)
#plt.figure(figsize=[12,6])
#plt.title('Gripper branch ($\,if\,$), Test',fontsize=18)
#plt.plot(df.Time,df.pIn, label="$p$", c='k')
#plt.legend(fontsize=20)
#plt.xlabel("Time (s)",fontsize=20)
#plt.xlim(152,155,)
#plt.xticks(fontsize=20)
#plt.ylabel("Pressure (kPa)",fontsize=20)
#plt.savefig(result_folder+'\\1Aplot.png', dpi=200)
#Isolate tracks in time
peaks, _ = find_peaks(df.pIn, height=(50, 70))
nsecs = .5 #seconds before start time segment
nsece = 3.25 #seconds before end time segment
#plt.plot(df.Time.iloc[peaks], df.pIn.iloc[peaks], "x")
#plt.plot(df.Time, df.pIn)
#plt.show()
deltaTs = [] #separated times before and after peak
pS = [] #separated pressure tracks before and after peak
for peak in peaks:
deltaT = df.Time[peak-int(data[1]['Samplerate'][0]*nsecs):peak+int(data[1]['Samplerate'][0]*nsece)] - df.Time[peak-data[1]['Samplerate'][0]*nsecs]-nsecs
deltaTs.append(deltaT)
pS.append(df.pIn[peak-int(data[1]['Samplerate'][0]*nsecs):peak+int(data[1]['Samplerate'][0]*nsece)])
stdvec = np.std(np.asarray(pS),axis=0)
meanp = np.mean(pS,axis=0)
fig = plt.figure(figsize=[sizehalfcol,sizehalfcol*3/4])
ax = fig.add_subplot(111) #top left
for peak in range(len(peaks)-1):
ax.plot(deltaT,pS[peak],c='lightgray', linewidth = .25)
ax.plot(deltaTs[len(peaks[:10])-1],pS[len(peaks[:10])-1], c='lightgray')
#plot mean + std as shaded
ax.plot(deltaT,np.mean(pS,axis=0),c='k')
#ax.fill_between(deltaT, meanp - stdvec, meanp + stdvec, alpha=0.05, color='k')
ax.hlines(55,deltaT.min(),deltaT.max(), ls='--',color='k') # opening pressure
ax.hlines(35,deltaT.min(),deltaT.max(), ls='--',color=colorBdark2)
#ax.hlines(np.mean(pS,axis=0).min(),0,deltaT.max(), ls='--',color='b')
#ax.hlines(np.mean(pS,axis=0)[0],0,deltaT.max(), ls='--',color='k') #reference pressure
ax.xaxis.set_tick_params(labelsize=int(ticks_size))
ax.yaxis.set_tick_params(labelsize=int(ticks_size))
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
ax.grid(False)
ax.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
ax.set_ylim(0,58)
plt.tight_layout()
ax.set_xlim(deltaT.min()-.05,deltaT.max()+.05)
plt.savefig(result_folder+'\\1Aplot.png', dpi=dpi,transparent=transparentsave)
plt.show()
Fig1A_If230905_V0
Figure 3¶
In [6]:
expidx = 2
df = data[0][expidx]
expname = data[1]['Samplename'][expidx]
print(expname)
tselect = 935 #selecting time of experiment
tselectend = 960
tselectend = 950
df = df[df.Time>tselect]
df = df[df.Time<tselectend]
#preparing data, converting to kPa the SSCDP sensors
df["pGate"] = (((df["SSCDP30-2"])*2/2.5)*101.3250) #pressure at the gate
df["pIn"] = (((df["SSCDP15-9"])*1/2.5)*101.3250) #pressure at the input
df["pAct"] = (((df["SSCDP15-4"])*1/2.5)*101.3250) #pressure at the balloon & finger
peaks, _ = find_peaks(df.pAct, height=(70, 90), prominence=2)
nsecs = 5 #seconds before start time segment
nsece = 10 #seconds before end time segment
tstart = float(df.Time.iloc[peaks])
tsynchoffset = tstart-df.Time.iloc[0] #to have interaction at t=0
pIn = np.mean(df["pIn"].iloc[-5000:])
fig = plt.figure(figsize=[sizehalfcol,sizehalfcol*3/4])
ax = fig.add_subplot(111) #top left
#plt.plot(df.Time.iloc[peaks], df.pAct.iloc[peaks], "ro")
ax.plot(df.Time-tselect-tsynchoffset, df.pIn,color='k', label = '$p_{in}$', linewidth = 1)
#ax.hlines(pIn,0,df.Time.iloc[-1]-tselect,color='k',ls='--')
ax.hlines(73,df.Time.iloc[0]-tselect-tsynchoffset,df.Time.iloc[-1]-tselect-tsynchoffset,color='gray',ls='--')
ax.plot(df.Time-tselect-tsynchoffset, df.pGate,color='royalblue', label= '$p_{G}$', linewidth = 1)
ax.plot(df.Time-tselect-tsynchoffset, df.pAct,color=colorBdark, label = '$p$', linewidth = 1)
#plt.plot(df.Time, df.pIn)
#plt.plot(df.Time, df.pGate)
ax.xaxis.set_tick_params(labelsize=ticks_size)
ax.yaxis.set_tick_params(labelsize=ticks_size)
#ax.set_xticks((.25,.75,1.25,1.75))
#ax.set_xticklabels(('$.25$', '$.75$', '$1.25$','$1.5$'))
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
ax.grid(False)
ax.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
#ax.legend(fontsize=int(legendfont),ncol=2,loc=5,bbox_to_anchor=(.95, .7))
#ax.set_xlim(0,30)
plt.tight_layout()
plt.savefig(result_folder+'\\2Bplot.png', dpi=dpi,transparent=transparentsave)
Fig2_Ifbreak_V0
Figure 4¶
In [7]:
###### Extract visualdata
selectedpospeaks_t = []
selectedpospeaks_x = []
dfpostime = pd.read_csv(Location+'\\3Ciiiplot_18mmaruco.tsv',header=None,delimiter='\t')
peaks, _ = find_peaks(dfpostime[1], height=(13.2, 15), prominence=2)
deltaT = dfpostime[0].iloc[peaks[30]]-dfpostime[0].iloc[peaks[29]] #between peaks
timeres = dfpostime[0].iloc[1]-dfpostime[0].iloc[0]#time resolution
nsecs, nsece = deltaT, deltaT
nsecsidxs, nseceidxs = int(nsecs/timeres), int(nsece /timeres)
for peak in peaks:
selectedpospeaks_t.append(dfpostime[0].iloc[peak-nsecsidxs:peak+nseceidxs] - dfpostime[0].iloc[peak] )
selectedpospeaks_x.append(dfpostime[1].iloc[peak-nsecsidxs:peak+nseceidxs])
#subtract minimal distance
selectedpospeaks_x = 10*np.subtract(selectedpospeaks_x,dfpostime[1].iloc[peaks[20]:peaks[25]].min())
###### Extract fluidic
expidx = 3
df = data[0][expidx]
expname = data[1]['Samplename'][expidx]
print(expname)
df.pA = df['MPX100-4']*7/1000 # as it was a 7bar sensor
df.pB = df['MPX100-10']/1000
#plt.plot(df.Time, df.pA)
#plt.plot(df.Time, df.pB)
timeres = df.Time.iloc[1]-df.Time.iloc[0]#time resolution
selectedpresspeaks_t = []
selectedpresspeaks_pA = []
selectedpresspeaks_pB = []
nsecsidxs, nseceidxs = int(nsecs/timeres), int(nsece /timeres)
peaks, _ = find_peaks(df.pB, height=(33, 40), prominence=2)
print(len(peaks))
for peak in peaks:
selectedpresspeaks_t.append(df.Time.iloc[peak-nsecsidxs:peak+nseceidxs] - df.Time.iloc[peak] )
selectedpresspeaks_pA.append(df.pA.iloc[peak-nsecsidxs:peak+nseceidxs])
selectedpresspeaks_pB.append(df.pB.iloc[peak-nsecsidxs:peak+nseceidxs])
selectedpresspeaks_pA_mean = np.mean(selectedpresspeaks_pA,axis=0)
selectedpresspeaks_pB_mean = np.mean(selectedpresspeaks_pB,axis=0)
selectedpresspeaks_t_mean = np.mean(selectedpresspeaks_t,axis=0)
selectedpospeaks_x_mean = np.mean(selectedpospeaks_x,axis=0)
selectedpospeaks_t_mean = np.mean(selectedpospeaks_t,axis=0)
fig = plt.figure(figsize=[sizehalfcol*2/3,sizehalfcol*3/4])
ax0 = fig.add_subplot(211) #top left
ax1 = fig.add_subplot(212) #top left
idx_start, idx_end = 10,20
for el in range(idx_start,idx_end):
ax1.plot(5.6+selectedpospeaks_t[el],selectedpospeaks_x[el],color='lightgray', linewidth = .25)
ax0.plot(5.6+selectedpresspeaks_t[el],selectedpresspeaks_pA[el],color='darksalmon', linewidth = .25)
ax0.plot(5.6+selectedpresspeaks_t[el],selectedpresspeaks_pB[el],color='skyblue', linewidth = .25)
selectedpresspeaks_pA_mean = np.mean(selectedpresspeaks_pA[idx_start:idx_end],axis=0)
selectedpresspeaks_pB_mean = np.mean(selectedpresspeaks_pB[idx_start:idx_end],axis=0)
selectedpresspeaks_t_mean = np.mean(selectedpresspeaks_t[idx_start:idx_end],axis=0)
selectedpospeaks_x_mean = np.mean(selectedpospeaks_x[idx_start:idx_end],axis=0)
selectedpospeaks_t_mean = np.mean(selectedpospeaks_t[idx_start:idx_end],axis=0)
ax1.plot(5.6+selectedpospeaks_t_mean,selectedpospeaks_x_mean,color='k', linewidth = .5 )
ax0.plot(5.6+selectedpresspeaks_t_mean,selectedpresspeaks_pA_mean,color='red', linewidth = .5 , label = '$p_{1}$')
ax0.plot(5.6+selectedpresspeaks_t_mean,selectedpresspeaks_pB_mean,color='royalblue', linewidth = .5, label = '$p_{2}$')
#ax.plot(df.Time-tselect, df.pA,color='k', label= '$p_{1}$', linewidth = 1)
#ax.plot(df.Time-tselect, df.pB,color='royalblue', label= '$p_{2}$', linewidth = 2.5)
#ax.plot(df.Time-tselect, df.pGate,color=colorA, label= '$p_{G}$', linewidth = 2.5)
#ax.plot(df.Time-tselect, df.pAct,color=colorBdark, label = '$p$', linewidth = 2.5)
#plt.plot(df.Time, df.pIn)
#plt.plot(df.Time, df.pGate)
ax0.xaxis.set_tick_params(labelsize=ticks_size)
ax1.xaxis.set_tick_params(labelsize=ticks_size)
ax0.yaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
#ax.set_yticks((0,25,50))
#ax.set_yticklabels(('$0$', '$25$', '$50$'))
#ax.hlines(14,df.Time.iloc[0]-tselect,df.Time.iloc[-1]-tselect,color='royalblue',ls='--',linewidth=1)
#ax.hlines(26,df.Time.iloc[0]-tselect,df.Time.iloc[-1]-tselect,color='royalblue',ls='--',linewidth=1)
ax0.spines['right'].set_visible(False)
ax0.spines['top'].set_visible(False)
ax0.spines['left'].set_visible(True)
ax0.spines['bottom'].set_visible(True)
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax0.grid(False)
ax1.grid(False)
ax1.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax0.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
ax1.set_ylabel("$\\Delta x$ (mm)",fontsize=int(labelfontsize))
leg = ax0.legend(fontsize=int(legendfont),loc=2,ncol=2, bbox_to_anchor=(0.01,1.4))
# Change to location of the legend.
#bb = leg.get_bbox_to_anchor().inverse_transformed(ax0.transAxes)
#yOffset = .3
#bb.y0 += yOffset
#bb.y1 += yOffset
#leg.set_bbox_to_anchor(bb, transform = ax0.transAxes)
#ax0.set_xlim(-6,1.2)
#ax1.set_xlim(-6,1.2)
fig.tight_layout()
plt.savefig(result_folder+'\\3Ciplotpos_zoom_p&xpos.png', dpi=dpi,transparent=transparentsave)
Fig3_20230919_trackingaruco 26
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [8]:
expidx = 8
expname = data[1]['Samplename'][expidx]
print(expname)
df = data[0][expidx]
df['pA'] = df['MPX100-4']*7/1000 # as it was a 7bar sensor
df['pB'] = df['MPX100-10']*7/1000
df['pC'] = (((df['SSCDP01-9'] )*1/2.5)*101.3250) #pressure at the input
timeres = data[1]['Samplerate'][8]
selectedpresspeaks_t = []
selectedpresspeaks_pA = []
selectedpresspeaks_pB = []
selectedpresspeaks_pC = []
nsecs, nsece = 8,8
df = df[df.Time>975]
df = df[df.Time<1300]
df.Time = df.Time - df.Time.iloc[0]
nsecsidxs, nseceidxs = int(nsecs*timeres), int(nsece *timeres)
peaks, _ = find_peaks(df.pC, height=(25, 40), prominence=2)
print(len(peaks))
plt.scatter(df.Time.iloc[peaks], df.pC.iloc[peaks])
plt.plot(df.Time, df.pC)
for peak in peaks:
selectedpresspeaks_t.append(df.Time.iloc[peak-nsecsidxs:peak+nseceidxs] - df.Time.iloc[peak] )
selectedpresspeaks_pA.append(df.pA.iloc[peak-nsecsidxs:peak+nseceidxs])
selectedpresspeaks_pB.append(df.pB.iloc[peak-nsecsidxs:peak+nseceidxs])
selectedpresspeaks_pC.append(df.pC.iloc[peak-nsecsidxs:peak+nseceidxs])
#plt.xlim(15,300)
selectedpresspeaks_pAs = []
selectedpresspeaks_pBs = []
selectedpresspeaks_pCs = []
selectedpresspeaks_ts = []
for idx in range(1,15):
selectedpresspeaks_pAs.append(selectedpresspeaks_pA[idx].to_numpy())
selectedpresspeaks_pBs.append(selectedpresspeaks_pB[idx].to_numpy())
selectedpresspeaks_pCs.append(selectedpresspeaks_pC[idx].to_numpy())
selectedpresspeaks_ts.append((selectedpresspeaks_t[idx] - selectedpresspeaks_t[idx].iloc[0]).to_numpy())
fig= plt.figure(figsize=[int(sizehalfcol)*1.25,int(sizehalfcol*3/4)])
ax = fig.add_subplot(111)
for el in range(13):
#print(el)
ax.plot(selectedpresspeaks_ts[el],selectedpresspeaks_pAs[el],color='darksalmon', linewidth = .25)
ax.plot(selectedpresspeaks_ts[el],selectedpresspeaks_pBs[el],color='skyblue', linewidth = .25)
ax.plot(selectedpresspeaks_ts[el],selectedpresspeaks_pCs[el],color='#A2F092', linewidth = .25)
selectedpresspeaks_pA_mean = np.mean(selectedpresspeaks_pAs,axis=0)
selectedpresspeaks_pB_mean = np.mean(selectedpresspeaks_pBs,axis=0)
selectedpresspeaks_pC_mean = np.mean(selectedpresspeaks_pCs,axis=0)
selectedpresspeaks_t_mean = np.mean(selectedpresspeaks_ts,axis=0)
ax.plot(selectedpresspeaks_t_mean, selectedpresspeaks_pA_mean,color='red', linewidth = 1 , label = '$p_{1}$')
ax.plot(selectedpresspeaks_t_mean, selectedpresspeaks_pB_mean,color='royalblue', linewidth = 1, label = '$p_{2}$')
ax.plot(selectedpresspeaks_t_mean, selectedpresspeaks_pC_mean,color='#75A36C', linewidth = 1, label = '$p_{3}$')
#ax.plot(df.Time-tselect, df.pA,color='k', label= '$p_{1}$', linewidth = 1)
#ax.plot(df.Time-tselect, df.pB,color='royalblue', label= '$p_{2}$', linewidth = 2.5)
#ax.plot(df.Time-tselect, df.pGate,color=colorA, label= '$p_{G}$', linewidth = 2.5)
#ax.plot(df.Time-tselect, df.pAct,color=colorBdark, label = '$p$', linewidth = 2.5)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
ax.xaxis.set_tick_params(labelsize=ticks_size)
ax.yaxis.set_tick_params(labelsize=ticks_size)
ax.set_yticks((0,25,50,75))
ax.set_yticklabels(('$0$', '$25$', '$50$', '$75$'))
#ax.hlines(14,df.Time.iloc[0]-tselect,df.Time.iloc[-1]-tselect,color='royalblue',ls='--',linewidth=1)
#ax.hlines(26,df.Time.iloc[0]-tselect,df.Time.iloc[-1]-tselect,color='royalblue',ls='--',linewidth=1)
ax.grid(False)
ax.set_xlabel("Time (s)",fontsize=labelfontsize)
ax.set_ylabel("Pressure (kPa)",fontsize=labelfontsize)
leg = ax.legend(fontsize=legendfont,loc=2,ncol=3,bbox_to_anchor =(0,1.2))
# Change to location of the legend.
#bb = leg.get_bbox_to_anchor().inverse_transformed(ax.transAxes)
yOffset = .25
#bb.y0 += yOffset
#bb.y1 += yOffset
#leg.set_bbox_to_anchor(bb, transform = ax.transAxes)
ax.set_ylim(-3,95)
plt.tight_layout()
plt.savefig(result_folder+'\\3NestedPressure.png', dpi=dpi,transparent=transparentsave)
Fig3_20230922_nestedloop_V1 19
In [9]:
from matplotlib import colors
expidx=7
df = data[0][expidx]
expname = data[1]['Samplename'][expidx]
print(expname)
df['p2'] = (7/1000)*df["MPX100-10"] #was a 7bar sensor, pre hyst valve
df['p1'] = (7/1000)*df["MPX100-4"] #was a 7bar sensortselect = 37 #selecting time of experimentInputP = df.PREG.iloc[-3000:].mean()
#preparing data, converting to kPa the SSCDP sensors
VAs = [.1,.2,.3,.1,.2,.3,.1,.1]
VBs = [.75,.75,.75,1.15,1.15,1.15,.2,.3]
tselectstarts = [40,137,239,433,510,622,831,900]
tselectends = [74.5,176.5,282,485,565,672,845,922]
nsteps = [6,4,3,9,5,4,3,4]
dfs = []
deltaTloops = []
def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):
new_cmap = colors.LinearSegmentedColormap.from_list(
'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),
cmap(np.linspace(minval, maxval, n)))
return new_cmap
#imola_truc = truncate_colormap(cmc.bamako, minval=0.0, maxval=.9, n=256)
imola_truc = truncate_colormap(matplotlib.cm.get_cmap('viridis'), minval=0.0, maxval=.9, n=256)
lipari_trunc = truncate_colormap(cmc.lipari, minval=0, maxval=.8, n=256)
cmap2 = imola_truc #time
cmap_discr = lipari_trunc #nsteps
norm = colors.BoundaryNorm(np.arange(2, 10.5, 1), cmap_discr.N)
norm2 = colors.BoundaryNorm(np.linspace(3,10.5, 256), cmap2.N)
sizemaker = 400
fig= plt.figure(figsize=[int(sizehalfcol)*1.1,int(sizehalfcol*1.25)])
#fig= plt.figure(figsize=[int(5),int(5)])
ax0 = fig.add_subplot(221) #top left
ax1 = fig.add_subplot(224) #top left
for exp in range(len(VAs)):
#select df of experiment
dftemp = df[df.Time>tselectstarts[exp]]
dftemp = dftemp[dftemp.Time<tselectends[exp]]
#process peaks
peaks, _ = find_peaks(dftemp.p2, height=(31, 40), prominence=2)
deltaTloop = (np.asarray(dftemp.Time.iloc[peaks][1:]) - np.asarray(dftemp.Time.iloc[peaks][:-1]) ).mean()
if len(str(VBs[exp])[1:])==2:
dfs.append(['$V_{1}=%.1f L$, $V_{2}=%.1f L$'%(VAs[exp],VBs[exp]), dftemp,nsteps[exp],deltaTloop])
else:
dfs.append(['$V_{1}=%.1f L$, $V_{2}=%.2f L$'%(VAs[exp],VBs[exp]), dftemp,nsteps[exp],deltaTloop])
deltaTloops.append(deltaTloop)
matForloopNsteps = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
matForloopDeltaT = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
matPredictionNstep = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
matPredictionDeltaT = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
for idx in range(len(VAs)):
idxVA = np.where(VAs[idx]==np.unique(VAs))[0][0]
idxVB = np.where(VBs[idx]==np.unique(VBs))[0][0]
matForloopNsteps[idxVB][idxVA] = nsteps[idx]
matForloopDeltaT[idxVB][idxVA] = deltaTloops[idx]
matPredictionNstep[idxVB][idxVA] = (32/38)*VBs[idx]/VAs[idx]
matPredictionDeltaT[idxVB][idxVA] = (30)*VAs[idx] * 0.029/(1.125*8.3145*293* 2 )
#Mask out missing for loop data
matForloopNsteps = np.ma.masked_where(matForloopNsteps==0, matForloopNsteps)
matForloopDeltaT = np.ma.masked_where(matForloopDeltaT==0, matForloopDeltaT)
matPredictionNstep = np.ma.masked_where(matPredictionNstep==0, matPredictionNstep)
im0 = ax0.imshow(matForloopNsteps,cmap=cmap_discr, origin ='lower', vmin=2,vmax=10)
im1 = ax1.imshow(matForloopDeltaT,cmap=cmap2, origin ='lower', vmin=2,vmax=11)
ax0.xaxis.set_tick_params(labelsize=ticks_size)
ax0.yaxis.set_tick_params(labelsize=ticks_size)
ax0.spines['right'].set_visible(False)
ax0.spines['top'].set_visible(False)
ax0.spines['left'].set_visible(True)
ax0.spines['bottom'].set_visible(True)
ax0.grid(False)
ax0.set_xlabel("$V_{1} ($L$)$",fontsize=labelfontsize)
ax0.set_ylabel("$V_{2} ($L$)$",fontsize=labelfontsize)
ax1.xaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
#ax0.set_xlabel("$V_{1} (L)$",fontsize=labelfontsize)
ax1.set_xlabel("$V_{1} ($L$)$",fontsize=labelfontsize)
#ax1.set_ylabel("$V_{2} (L)$",fontsize=labelfontsize, )
cbar0 = plt.colorbar(im0, ax=ax0,ticks=np.linspace(2.5, 10.5, 9), format = '%d',fraction=0.06, pad=-5.04,orientation='horizontal')
cbar1 = plt.colorbar(im1, ax=ax1,format = '%d',ticks=np.linspace(2.5, 11, 6),fraction=0.06, pad=-5.04,orientation='horizontal')
cbar0.ax.tick_params(labelsize=labelfontsize)
cbar1.ax.tick_params(labelsize=labelfontsize)
cbar0.set_label('$($-$)$', rotation=-0, fontsize = labelfontsize, labelpad=8)
cbar1.set_label('$($s$)$', rotation=-0, fontsize = labelfontsize, labelpad=8)
ax0.set_xticks((0,1,2))
ax0.set_xticklabels(('$.1$','$.2$', '$.3$'))
ax0.set_yticks((0,1,2,3))
ax0.set_yticklabels(('$.2$','$.3$', '$.75$', '$1.15$'))
ax1.set_xticks((0,1,2))
ax1.set_xticklabels(('$.1$','$.2$', '$.3$'))
ax1.set_yticks((0,1,2,3))
ax1.set_yticklabels(('','', '', ''))
labelx = -0.3 # axes coords
#ax0.text(0,0,'$\\gamma$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax1.text(0,0,'$\\gamma$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax0.text(0,3,'$\\alpha$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax1.text(0,3,'$\\alpha$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax0.text(2,3,'$\\beta$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax1.text(2,3,'$\\beta$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
ax0.scatter(0,0,marker='*',color='white') #gamma
ax1.scatter(0,0,marker='*',color='white')
ax0.scatter(0,3,marker='o',color='white') #alfa
ax1.scatter(0,3,marker='o',color='white')
ax0.scatter(2,3,marker='^',color='white') #beta
ax1.scatter(2,3,marker='^',color='white')
#ax0.yaxis.set_label_coords(labelx, 0.5)
#ax1.yaxis.set_label_coords(labelx, 0.5)
#ax0.set_xlim(.08,.31)
#ax0.set_ylim(.1,1.25)
#ax[1].set_ylim(.1,1.25)
plt.subplots_adjust(hspace=-.05)
#plt.tight_layout()
plt.savefig(result_folder+'\\3ChangingVolumesnew.png', dpi=dpi,transparent=transparentsave,bbox_inches = 'tight')
Fig3_20230922_V2
Figure 6¶
In [10]:
from matplotlib import colors
from matplotlib.colors import LogNorm
import scipy.ndimage
from scipy.ndimage.filters import gaussian_filter
from matplotlib.ticker import LogFormatter
#data = FluidicSetupFunctions.LoadData(Foldernames=Foldernames, Location = Location)
expidx = 14
df = data[0][expidx]
expname = data[1]['Samplename'][expidx]
print(expname)
fs = data[1]['Samplerate'][expidx] # in Hz
df["pG_freq"] = df["MPX700-2"] /1000
df["Q"] = (df["AWM20-1"])
df['pValvePre'] = (((df["SSCDP05-3"])*2/2.5)*101.3250)
df["pValvePost"] = df["MPX100-11"] /1000
df['pAct'] = (((df["SSCDP15-9"])*2/2.5)*101.3250)
df['pG_ampl'] = (((df["SSCDP15-4"])*2/2.5)*101.3250)
legendfont = 11 # 9
labelfontsize = 11 # 9
ticks_size=9 # 7
rising_edges = np.asarray(df.Time.iloc[rising_edge(df['DigOut-1'],1)])+10
falling_edges = rising_edges+20 #20s from spicy
falling_edges[-32:-24] = rising_edges[-32:-24]+40
falling_edges[-24:-16] = rising_edges[-24:-16]+120
falling_edges[-16:-8] = rising_edges[-16:-8]+300
falling_edges[-8:] = rising_edges[-8:]+300
#falling_edges[-2*7:-1*7] = rising_edges[-2*7:-1*7] + 45 #7 runs per settings of pgatefrq
#falling_edges[-1*7:] = rising_edges[-1*7:] + 120 #7 runs per settings of pgatefrq
rising_edges = rising_edges +10
#print(df.Time.max())
legendfont = 11 # 9
labelfontsize = 11 # 9
ticks_size=9 # 7
pActMaxAmplAvg = []
pActMaxPeakPeakAmplAvg = []
pActDeltaTAvg = []
pGfreqAvg = []
pGAmplAvg = []
pActMaxAmplStd = []
pActMaxPeakPeakAmplStd = []
pActDeltaTStd = []
pGfreqStd = []
pGAmplStd = []
nfailed =0
lw = 1
for i in range(len(rising_edges)):
#print(i)
#print(rising_edges[i],falling_edges[i], end='\r')
dftemp = df[(df.Time>rising_edges[i]) & (df.Time<falling_edges[i])]
freqpeaks, _ = find_peaks(dftemp.pValvePost, height=(30, 90))
amplpeaks, _ = find_peaks(dftemp.pAct, height=(dftemp.pAct.max()*.85, dftemp.pAct.max()*1.05))
minimavalue_peaks, _ = find_peaks(dftemp.pAct, height=(dftemp.pAct.min()*.9, dftemp.pAct.min()*1.5),width=10)
pActDeltaTAvg.append(np.mean(np.diff(np.asarray(dftemp.Time.iloc[freqpeaks]))))
pActDeltaTStd.append(np.std(np.diff(np.asarray(dftemp.Time.iloc[freqpeaks]))))
pActMaxAmplAvg.append(np.mean(np.asarray(dftemp.pAct.iloc[amplpeaks])))
pActMaxAmplStd.append(np.std(np.asarray(dftemp.pAct.iloc[amplpeaks])))
ppaverage = np.mean(np.asarray(dftemp.pAct.iloc[amplpeaks])) - np.mean(np.asarray(dftemp.pAct.iloc[minimavalue_peaks]))
ppstd = np.std(np.asarray(dftemp.pAct.iloc[amplpeaks])) + np.std(np.asarray(dftemp.pAct.iloc[minimavalue_peaks]))
if len(minimavalue_peaks)==0:
#print('foundnan, minimalpeaks failed')
ppaverage = np.mean(np.asarray(dftemp.pAct.iloc[amplpeaks]))
ppstd = np.mean(np.asarray(dftemp.pAct.iloc[amplpeaks]))/2
nfailed+=1
pActMaxPeakPeakAmplAvg.append(ppaverage)
pActMaxPeakPeakAmplStd.append(ppstd)
pGfreqAvg.append(np.mean(np.asarray(dftemp.pG_freq)))
pGfreqStd.append(np.std(np.asarray(dftemp.pG_freq)))
pGAmplAvg.append(np.mean(np.asarray(dftemp.pG_ampl)))
pGAmplStd.append(np.std(np.asarray(dftemp.pG_ampl)))
freqdata = np.divide(1,np.asarray(pActDeltaTAvg).reshape((19,8)))
cutidx = 7
resultdf = pd.DataFrame([pActMaxAmplAvg,pActDeltaTAvg,pGfreqAvg,pGAmplAvg,pActMaxAmplStd,pActDeltaTStd,pGfreqStd,pGAmplStd,pActMaxPeakPeakAmplAvg,pActMaxPeakPeakAmplStd]).T
sigmagaussian = 2
datafreq=gaussian_filter(freqdata, sigmagaussian)
def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):
new_cmap = colors.LinearSegmentedColormap.from_list(
'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),
cmap(np.linspace(minval, maxval, n)))
return new_cmap
#imola_truc = truncate_colormap(cmc.bamako, minval=0.0, maxval=.9, n=256)
imola_truc = truncate_colormap(cmc.imola, minval=0, maxval=1, n=256)
lipari_trunc = truncate_colormap(cmc.lipari, minval=0, maxval=1, n=256)
cmap_trunc = truncate_colormap(cmc.tokyo, minval=0, maxval=1, n=256)
cmap2 = imola_truc #time
cmap_discr = lipari_trunc #nsteps
cmap3 = cmap_trunc #nsteps
norm = colors.BoundaryNorm(np.linspace(0,20, 100), cmap_discr.N)
norm2 = colors.BoundaryNorm(np.linspace(0,10, 100), cmap2.N)
norm3 = colors.BoundaryNorm(np.linspace(0,10, 100), cmap3.N)
rgbas_P = []
rgbas_PP = []
rgbas_DeltaT = []
for k in range(len(pActMaxAmplAvg)):
rgbas_P.append(cmap2(pActMaxAmplAvg[k]/np.max(pActMaxAmplAvg)))
rgbas_PP.append(cmap_discr(pActMaxPeakPeakAmplAvg[k]/np.max(pActMaxPeakPeakAmplAvg)))
rgbas_DeltaT.append(cmap_discr(pActDeltaTAvg[k]/np.max(pActDeltaTAvg)))
datap = gaussian_filter(pActMaxAmplAvg, sigmagaussian)
formatter = LogFormatter(10, labelOnlyBase=False)
if True: #MainPlot
sigmagaussian=.5
fig= plt.figure(figsize=[int(sizehalfcol)*2,int(sizehalfcol)*1])
ax2 = fig.add_subplot(121) #top left
ax3 = fig.add_subplot(122) #top left
linewidth = .5
sigmagaussian=.3
datapp = gaussian_filter(pActMaxPeakPeakAmplAvg, sigmagaussian)
ax2.spines['right'].set_visible(False)
ax2.spines['top'].set_visible(False)
ax2.spines['left'].set_visible(True)
ax2.spines['bottom'].set_visible(True)
ax2.grid(False)
ax3.spines['right'].set_visible(False)
ax3.spines['top'].set_visible(False)
ax3.spines['left'].set_visible(True)
ax3.spines['bottom'].set_visible(True)
ax3.grid(False)
CS2 = ax2.contour(datafreq.reshape((19,8)),7,cmap=cmc.lipari,
contours=dict(
coloring ='heatmap',
showlabels = True, # show labels on contours
labelfont = dict( # label font properties
size = 20,
color = 'white')), origin='lower')
ax2.clabel(CS2, inline=100, fontsize=labelfontsize,fmt='%.1f')
CS2 = ax3.contour(datapp.reshape((19,8)),5,cmap=cmc.acton,
contours=dict(
coloring ='heatmap',
showlabels = True, # show labels on contours
labelfont = dict( # label font properties
size = 20,
color = 'k')), origin='lower')
manual_locations = [(5,4),(5,13),(4,14),(3,16),(2,15),(1,16) ]#(2.8, 10), (2.5,13),(2,15),(1.5,17)]
ax3.clabel(CS2, inline=100, fontsize=labelfontsize, fmt='%d',manual=manual_locations)
#CS2 = plt.contourf(datapp.reshape((19,8)),4, color='plum')
ax2.xaxis.set_tick_params(labelsize=ticks_size)
ax2.yaxis.set_tick_params(labelsize=ticks_size)
ax2.yaxis.set_tick_params(labelsize=ticks_size)
ax2.spines['right'].set_visible(False)
ax2.spines['top'].set_visible(False)
ax2.spines['left'].set_visible(True)
ax2.spines['bottom'].set_visible(True)
ax2.grid(False)
ax2.set_xlabel("$p_{G,Ampl.}$ (kPa)",fontsize=labelfontsize)
ax2.set_ylabel("$p_{G,\,f} $ (kPa)",fontsize=labelfontsize)
ax3.xaxis.set_tick_params(labelsize=ticks_size)
ax3.yaxis.set_tick_params(labelsize=ticks_size)
ax3.yaxis.set_tick_params(labelsize=ticks_size)
ax3.spines['right'].set_visible(False)
ax3.spines['top'].set_visible(False)
ax3.spines['left'].set_visible(True)
ax3.spines['bottom'].set_visible(True)
ax3.grid(False)
ax3.set_xlabel("$p_{G,Ampl.}$ (kPa)",fontsize=labelfontsize)
ax3.set_ylabel("$p_{G,\,f} $ (kPa)",fontsize=labelfontsize)
alphaquiver = 1
ax2.set_xticks((0,3,7))
ax2.set_yticks((0,4,8,12,16))
ax2.set_xticklabels(('0','15','30'), rotation=30)
ax2.set_yticklabels(('0','20','40', '60', '80'), rotation=30)
ax3.set_xticks((0,3,7))
ax3.set_yticks((0,4,8,12,16))
ax3.set_xticklabels(('0','15','30'), rotation=30)
ax3.set_yticklabels(('0','20','40', '60', '80'), rotation=30)
#ax1.set_title("$p_{Act.} (kPa)$", fontsize=labelfontsize)
ax2.set_title("$f_{Act.}$ (Hz)", fontsize=labelfontsize)
ax3.set_title("$\\Delta p_{Act.}$ (kPa)", fontsize=labelfontsize)
plt.tight_layout()
plt.savefig(result_folder+'\\%s_combined_contours_new_two.png'%(expname), dpi=dpi,transparent=transparentsave, bbox_inches = 'tight')
plt.show()
VariablesAmplitude&Frequencyv06
Figure 8¶
In [11]:
expidx = 13
df = data[0][expidx]
expname = data[1]['Samplename'][expidx]
print(expname)
fs = data[1]['Samplerate'][expidx] # in Hz
df["pFeedback"] = (((df["SSCDP15-9"])*1/2.5)*101.3250)
df["pBendingS"] = df["MPX100-11"] /1000 # (((df["SSCDP01-3"])/2.5)*101.3250) #sscdp15 used
df['pFlowInputBending'] = df["MPX700-2"] * 2.5/7 #2.5bar instead of a 1 bar used broken
df['pBending'] = (((df["SSCDP05-3"])*2/2.5)*101.3250) #sscdp15
df['pLinearS'] = (((df["SSCDP15-4"])*1/2.5)*101.3250)
df['pLinear'] = df["MPX100-10"] /1000
#rising_edges = np.asarray(df.Time.iloc[rising_edge(df['DigOut-1'],1)])
fig= plt.figure(figsize=[int(sizehalfcol)*2,int(sizehalfcol)*1.2])
ax1 = fig.add_subplot(231) #top left
ax2 = fig.add_subplot(232) #top left
ax3 = fig.add_subplot(233) #top left
ax4 = fig.add_subplot(234) #top left
ax5 = fig.add_subplot(235) #top left
ax6 = fig.add_subplot(236) #top left
linewidth = .5
tevent = 368.7#500.65
tstart = tevent-40#tevent-20
tend = tevent+40#tevent+20
behaviour1start, behaviour1end = tstart-15,tevent-10
behaviour2start, behaviour2end = tevent+10,tevent+30
#ax1.plot(df.Time-tevent,df.pFeedback, color='red', linewidth=linewidth, label = '$p_{Feedback}$')
ax1.plot(df.Time,df.pBending, color=colorBdark2, linewidth=linewidth, label = '$p_{Bending}$')
ax1.plot(df.Time,df.pBendingS,color=colorBdark2,ls='--', linewidth=linewidth, label = '$p_{S, Bending}$')
#
ax2.plot(df.Time,df.pLinear, color='royalblue', linewidth=linewidth, label = '$p_{Linear}$')
ax2.plot(df.Time,df.pLinearS,color='royalblue',ls='--', linewidth=linewidth, label = '$p_{S,Linear}$')
ax3.plot(df.Time,df.pFeedback, color='red', linewidth=linewidth, label = '$p_{Feedback}$')
ax1.vlines(tevent,df.pBending.min(),df.pBending.max(), ls='--', color='k',linewidth=linewidth,zorder=4)
ax2.vlines(tevent,df.pLinear.min(),df.pLinear.max(), ls='--', color='k',linewidth=linewidth,zorder=4)
ax3.vlines(tevent,df.pFeedback.min(),df.pFeedback.max(), ls='--', color='k',linewidth=linewidth,zorder=4)
ax1.set_xlim(tstart,tend)
ax2.set_xlim(tstart,tend)
ax3.set_xlim(tstart,tend)
for ax in [ax1,ax2,ax3,ax4,ax5,ax6]:
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
ax.grid(False)
ax1.legend(fontsize=legendfont, ncol=1,loc='upper left',bbox_to_anchor=(0, 1.6))
ax2.legend(fontsize=legendfont, ncol=1,loc='upper left',bbox_to_anchor=(0, 1.6))
ax3.legend(fontsize=legendfont, ncol=1,loc='upper left',bbox_to_anchor=(0, 1.6))
alphaplot = .05
alphaplot2 = .15
if True:
ax1.axvspan(tstart,tevent,ymax=df.pBending.max(),color='red',alpha=alphaplot)
ax2.axvspan(tstart,tevent,ymax=df.pBending.max(),color='red',alpha=alphaplot)
ax3.axvspan(tstart,tevent,ymax=df.pBending.max(),color='red',alpha=alphaplot)
ax4.axvspan(tstart,tevent,ymax=df.pBending.max(),color='red',alpha=alphaplot)
ax5.axvspan(tstart,tevent,ymax=df.pBending.max(),color='red',alpha=alphaplot)
ax6.axvspan(tstart,tevent,ymax=df.pBending.max(),color='red',alpha=alphaplot)
ax1.axvspan(tevent,tend,ymax=df.pBending.max(),color='green',alpha=alphaplot)
ax2.axvspan(tevent,tend,ymax=df.pBending.max(),color='green',alpha=alphaplot)
ax3.axvspan(tevent,tend,ymax=df.pBending.max(),color='green',alpha=alphaplot)
ax4.axvspan(tevent,tend,ymax=df.pBending.max(),color='green',alpha=alphaplot)
ax5.axvspan(tevent,tend,ymax=df.pBending.max(),color='green',alpha=alphaplot)
ax6.axvspan(tevent,tend,ymax=df.pBending.max(),color='green',alpha=alphaplot)
if True:
ax1.axvspan(behaviour1end,behaviour2start,ymax=df.pBending.max(),color='gray',alpha=alphaplot2)
ax2.axvspan(behaviour1end,behaviour2start,ymax=df.pBending.max(),color='gray',alpha=alphaplot2)
ax3.axvspan(behaviour1end,behaviour2start,ymax=df.pBending.max(),color='gray',alpha=alphaplot2)
#ax4.axvspan(behaviour1end,behaviour2start,ymax=df.pBending.max(),color='gray',alpha=alphaplot2)
#ax5.axvspan(behaviour1end,behaviour2start,ymax=df.pBending.max(),color='gray',alpha=alphaplot2)
#ax6.axvspan(behaviour1end,behaviour2start,ymax=df.pBending.max(),color='gray',alpha=alphaplot2)
ax4.vlines(tevent,df.pBending.min(),df.pBending.max(), ls='--', color='k',linewidth=linewidth,zorder=4)
ax5.vlines(tevent,df.pLinear.min(),df.pLinear.max(), ls='--', color='k',linewidth=linewidth,zorder=4)
ax6.vlines(tevent,df.pFeedback.min(),df.pFeedback.max(), ls='--', color='k',linewidth=linewidth,zorder=4)
##plot zoomed in versions
#ax1.plot(df.Time-tevent,df.pFeedback, color='red', linewidth=linewidth, label = '$p_{Feedback}$')
ax4.plot(df.Time,df.pBending, color=colorBdark2, linewidth=linewidth, label = '$p_{Bending}$')
ax4.plot(df.Time,df.pBendingS,color=colorBdark2,ls='--', linewidth=linewidth, label = '$p_{S, Bending}$')
#
ax5.plot(df.Time,df.pLinear, color='royalblue', linewidth=linewidth, label = '$p_{Linear}$')
ax5.plot(df.Time,df.pLinearS,color='royalblue',ls='--', linewidth=linewidth, label = '$p_{S,Linear}$')
ax6.plot(df.Time,df.pFeedback, color='red', linewidth=linewidth, label = '$p_{Feedback}$')
ax4.set_xlim(-2+behaviour1end,behaviour2start+2)
ax5.set_xlim(-2+behaviour1end,behaviour2start+2)
ax6.set_xlim(-2+behaviour1end,behaviour2start+2)
plt.tight_layout()
#ax1.set_xlabel("Time (s)",fontsize=int(labelfontsize))
#ax2.set_xlabel("Time (s)",fontsize=int(labelfontsize))
#ax3.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax4.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax5.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax6.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax1.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
ax4.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
#ax2.set_ylabel("$p$(kPa)",fontsize=int(labelfontsize))
#ax3.set_ylabel("$p$(kPa)",fontsize=int(labelfontsize))
plt.savefig(result_folder+'\\%s_event.png'%(expname), dpi=dpi,transparent=transparentsave, bbox_inches = 'tight')
GoldenRetrieverV5_V1
Figure S4¶
In [12]:
import cmcrameri.cm as cmc
from matplotlib import gridspec
expname_ = 'sequencer'
cmap_force = matplotlib.cm.get_cmap('Greens')
expidxs = [25]
expidx = expidxs[0]
df = data[0][expidx]
expname = data[1]['Samplename'][expidx]
print(expname)
fs = data[1]['Samplerate'][expidx] # in Hz
df['pIn'] = (df["MPX250-4"]*7/1000)/2.5 #7bar used here instead
df["pFor"] = (((df["SSCDP15-9"])*2/2.5)*101.3250) #used the 2bar here
df["p1"] = df["MPX100-10"] /1000 #
df['p2'] = df["MPX100-2"] /1000
df['p3'] = df["MPX100-11"]*2.5/1000 #2.5bar used here
df['p4'] = df["MPX100-3"]/1000
fig= plt.figure(figsize=[int(sizehalfcol)*2,int(sizehalfcol)*1.5])
ax0 = fig.add_subplot(221)
ax2 = fig.add_subplot(222)
ax1 = fig.add_subplot(223)
ax3 = fig.add_subplot(224)
linewidth = .5
ax0.plot(df.Time,df.pFor, color='k', linewidth=linewidth, label = '$p_{\\mathrm{For}}$')
ax2.plot(df.Time,df.pFor, color='k', linewidth=linewidth, label = '$p_{\\mathrm{For}}$')
color1='#43EF38'
color2='#3781F0'
color3='#F0B237'
color4='#F037A5'
ax1.plot(df.Time,df.p4, color=color4, linewidth=linewidth, label = '$p_{\\mathrm{1}}$')
ax1.plot(df.Time,df.p1, color=color1, linewidth=linewidth, label = '$p_{\\mathrm{2}}$')
ax1.plot(df.Time,df.p2, color=color2, linewidth=linewidth, label = '$p_{\\mathrm{3}}$')
ax1.plot(df.Time,df.p3, color=color3, linewidth=linewidth, label = '$p_{\\mathrm{4}}$')
ax3.plot(df.Time,df.p4, color=color4, linewidth=linewidth, label = '$p_{\\mathrm{1}}$')
ax3.plot(df.Time,df.p1, color=color1, linewidth=linewidth, label = '$p_{\\mathrm{2}}$')
ax3.plot(df.Time,df.p2, color=color2, linewidth=linewidth, label = '$p_{\\mathrm{3}}$')
ax3.plot(df.Time,df.p3, color=color3, linewidth=linewidth, label = '$p_{\\mathrm{4}}$')
tstart = 910
tend = 950
pIn = df.pIn.iloc[np.where((df.Time<tend)&(df.Time>tstart))].mean()
#ax1.set_title('$p_{\\mathrm{in}}=%d$kPa'%(pIn))
ax0.set_xlim(tstart,tend)
ax1.set_xlim(tstart,tend)
tstart = 924
tend = 935
ax1.axvspan(tstart,tend,0,10,alpha=.1, color='k')
ax0.axvspan(tstart,tend,0,40,alpha=.1, color='k')
ax2.set_xlim(tstart,tend)
ax3.set_xlim(tstart,tend)
pIn = df.pIn.iloc[np.where((df.Time<tend)&(df.Time>tstart))].mean()
#ax2.set_title('$p_{\\mathrm{in}}=%d$kPa'%(pIn))
#ax0.legend(fontsize=legendfont, ncol=1)
#ax2.legend(fontsize=legendfont, ncol=5)
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
ax3.spines['right'].set_visible(False)
ax3.spines['top'].set_visible(False)
ax3.spines['left'].set_visible(True)
ax3.spines['bottom'].set_visible(True)
ax3.grid(False)
ax2.spines['right'].set_visible(False)
ax2.spines['top'].set_visible(False)
ax2.spines['left'].set_visible(True)
ax2.spines['bottom'].set_visible(True)
ax2.grid(False)
ax0.spines['right'].set_visible(False)
ax0.spines['top'].set_visible(False)
ax0.spines['left'].set_visible(True)
ax0.spines['bottom'].set_visible(True)
ax0.grid(False)
#ax1.set_ylim(0,1.5)
#ax2.set_ylim(0,2.5)
#ax0.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax1.set_xlabel("Time (s)",fontsize=int(labelfontsize))
#ax2.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax3.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax0.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
ax1.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
#ax2.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
#ax3.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
ax0.legend(fontsize=legendfont, ncol=1,bbox_to_anchor=(0.5, 1., 0.5, 0.5))
ax1.legend(fontsize=legendfont, ncol=4,bbox_to_anchor=(1, 2.5, 0.5, 0.5))
plt.savefig(result_folder+'\\%s_shaded.png'%(expname), dpi=dpi,transparent=transparentsave, bbox_inches = 'tight')
Sequencer04
Figure S11¶
In [14]:
expidx = 15
df = data[0][expidx]
expname = data[1]['Samplename'][expidx]
print(expname)
fs = data[1]['Samplerate'][expidx] # in Hz
#df["pG_freq"] = df["MPX700-2"] /1000
#df["Q"] = (df["AWM20-1"])
#df['pValvePre'] = (((df["SSCDP05-3"])*2/2.5)*101.3250)
#df["pValvePost"] = df["MPX100-11"] /1000
#df['pAct'] = (((df["SSCDP15-9"])*2/2.5)*101.3250)
df['pAct'] = (((df["SSCDP05-9"])*2/2.5)*.5*101.3250) #used sscdp15 instead
pressures = [0,20,30,40,50,60,70,80,85]
rising_edges = [45,195,4*60+20,5*60+20,7*60+5,8*60+15,10*60,12*60+12,16*60+10]
falling_edges = [65,195+40,4*60+45,6*60,7*60+35,8*60+48,11*60,14*60,17*60+5]
#df['pFlowInputBending'] = df["MPX700-2"] * 2.5/7 #2.5bar instead of a 1 bar used broken
#df['pLinearS'] = (((df["SSCDP15-4"])*1/2.5)*101.3250)
#df['pLinear'] = df["MPX700-2"] /1000
#rising_edges = np.asarray(df.Time.iloc[rising_edge(df['DigOut-1'],1)])+10
#falling_edges = rising_edges+20 #20s from spicy
#falling_edges[-32:-24] = rising_edges[-32:-24]+40
#falling_edges[-24:-16] = rising_edges[-24:-16]+120
#falling_edges[-16:-8] = rising_edges[-16:-8]+300
#falling_edges[-8:] = rising_edges[-8:]+300
#falling_edges[-2*7:-1*7] = rising_edges[-2*7:-1*7] + 45 #7 runs per settings of pgatefrq
#falling_edges[-1*7:] = rising_edges[-1*7:] + 120 #7 runs per settings of pgatefrq
#rising_edges = rising_edges +10
pre_secs = int(.5*fs)
post_secs = int(.5*fs)
deltaPs_avg = []
deltaPs_std = []
peakPs_avg = []
peakPs_std = []
pstart_avg = []
pstart_std = [ ]
for i in range(len(rising_edges)):
dftemp = df[(df.Time>rising_edges[i])&(df.Time<falling_edges[i])]
peaks, _ = find_peaks(dftemp.pAct, height=(dftemp.pAct.max()*.8,dftemp.pAct.max()*1.1), distance=2*fs)
#print(i)
if i ==0:
peaks, _ = find_peaks(dftemp.pAct, height=(dftemp.pAct.max()*.7,dftemp.pAct.max()*1.1),distance=.5*fs)
if i ==1:
peaks, _ = find_peaks(dftemp.pAct, height=(dftemp.pAct.max()*.6,dftemp.pAct.max()*.99),distance=.3*fs)
if i ==2:
peaks, _ = find_peaks(dftemp.pAct, height=(dftemp.pAct.max()*.7,dftemp.pAct.max()*.92),distance=.3*fs)
if i ==5:
peaks, _ = find_peaks(dftemp.pAct, height=(dftemp.pAct.max()*.7,dftemp.pAct.max()*1.1), distance=.5*fs)
if i==8:
peaks, _ = find_peaks(dftemp.pAct, height=(dftemp.pAct.max()*.9,dftemp.pAct.max()*1.1), distance=2*fs)
#print(len(peaks))
fig= plt.figure(figsize=[sizehalfcol*2/3,sizehalfcol/2])
ax1 = fig.add_subplot(111) #top left
storedPs = []
for peak in peaks:
ax1.plot(dftemp.Time.iloc[peak-pre_secs:peak+post_secs] - dftemp.Time.iloc[peak],dftemp.pAct.iloc[peak-pre_secs:peak+post_secs],
color='gray', linewidth = .3)
#print('\t',peak+post_secs-peak+pre_secs)
#print(len(dftemp.pAct.iloc[peak-pre_secs:peak+post_secs]))
storedPs.append(dftemp.pAct.iloc[peak-pre_secs:peak+post_secs])
#ax1.plot(dftemp.Time.iloc[peak-pre_secs:peak+post_secs] - dftemp.Time.iloc[peak], np.mean(storedPs,axis=0),
# color='k', linewidth=.8)
#ax1.scatter(dftemp.Time.iloc[peaks],dftemp.pAct.iloc[peaks])
peakPs_avg.append(dftemp.pAct.iloc[peaks].mean())
peakPs_std.append(dftemp.pAct.iloc[peaks].std())
deltaPs_avg.append(dftemp.pAct.iloc[peaks].mean() - dftemp.pAct.iloc[-1])
deltaPs_std.append(dftemp.pAct.iloc[peaks].std())
pstart_avg.append(dftemp.pAct.iloc[-10:].mean())
pstart_std.append(dftemp.pAct.iloc[-10:].std())
ax1.vlines(-.35,pstart_avg[-1],70,linewidth=1, color=colorBdark2,)
ax1.hlines(140/2,-.5,.5, ls = '--', color= 'black', linewidth=.6)
ax1.hlines(pstart_avg[-1],-.5,.5, ls = '--', color= 'gray', linewidth=.6)
ax1.set_ylim(-20,90)
ax1.xaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
ax1.set_title('$p_{\\mathrm{in}}=%.1f$ kPa'%(pstart_avg[-1]), fontsize=labelfontsize)
ax1.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax1.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
#ax.set_ylim(0,58)
plt.tight_layout()
#ax.set_xlim(-.3,+.45)
#ax.set_ylim(-8,90+.05)
plt.savefig(result_folder+'\\%s_%dplot.png'%(expname,i+1), dpi=dpi,transparent=transparentsave)
#for peak in peaks:
# ax1.plot(dftemp.Time.iloc[peaks-pre_secs:peak+post_secs],dftemp.pAct.iloc[peaks-pre_secs:peak+post_secs])
plt.show()
fig= plt.figure(figsize=[int(sizehalfcol)*1.9,int(sizehalfcol)*.6])
ax1 = fig.add_subplot(111) #top left
#ax1.scatter(pstart_avg[:3],np.add(pstart_avg[:3],np.multiply(pstart_avg[:3],(.015+.1)/.1)))
ax1.errorbar(pstart_avg[:3],deltaPs_avg[:3], xerr=pstart_std[:3],yerr=deltaPs_std[:3], label='$If$ not triggered',
color='firebrick', marker = 's', ls = '', elinewidth = 2, ecolor='firebrick',markersize=3)
ax1.errorbar(pstart_avg[3:],deltaPs_avg[3:], xerr=pstart_std[3:],yerr=deltaPs_std[3:], label='$If$ triggered',
color='royalblue', marker = 's', ls = '', elinewidth = 2, ecolor='royalblue',markersize=3)
ax1.xaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
#ax1.set_title('$p_{In}=%.1f kPa$'%(pstart_avg[-1]), fontsize=labelfontsize)
ax1.set_xlabel("$p_{\\mathrm{in}}$ (kPa)",fontsize=int(labelfontsize))
ax1.set_ylabel(" $\\Delta p_{\\mathrm{event}}$(kPa)",fontsize=int(labelfontsize))
ax1.legend(ncol=1, fontsize=labelfontsize)
plt.savefig(result_folder+'\\%s_sumup.png'%(expname), dpi=dpi,transparent=transparentsave)
plt.show()
fig= plt.figure(figsize=[int(sizehalfcol)*1.9,int(sizehalfcol)*.6])
ax1 = fig.add_subplot(111) #top left
ax1.errorbar(pstart_avg[:3],peakPs_avg[:3], xerr=pstart_std[:3],yerr=peakPs_std[:3], label='$If$ not triggered',
color='firebrick', marker = 'o', ls = '', elinewidth = 2, ecolor='firebrick',markersize=3)
ax1.errorbar(pstart_avg[3:],peakPs_avg[3:], xerr=pstart_std[3:],yerr=deltaPs_std[3:], label='$If$ triggered',
color='royalblue', marker = 's', ls = '', elinewidth = 2, ecolor='royalblue',markersize=3)
ax1.xaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
#ax1.set_title('$p_{In}=%.1f kPa$'%(pstart_avg[-1]), fontsize=labelfontsize)
ax1.set_xlabel("$p_{\\mathrm{in}}$ (kPa)",fontsize=int(labelfontsize))
ax1.set_ylabel(" $p_{\\mathrm{event}}$(kPa)",fontsize=int(labelfontsize))
ax1.legend(ncol=1, fontsize=labelfontsize)
plt.savefig(result_folder+'\\%s_sumup_peak.png'%(expname), dpi=dpi,transparent=transparentsave)
IfSensitivity v04
In [ ]:
Figure S12¶
In [15]:
expidx = 17
df = data[0][expidx]
expname = data[1]['Samplename'][expidx]
print(expname)
fs = data[1]['Samplerate'][expidx] # in Hz
#df["pG_freq"] = df["MPX700-2"] /1000
#df["Q"] = (df["AWM20-1"])
#df['pValvePre'] = (((df["SSCDP05-3"])*2/2.5)*101.3250)
#df["pValvePost"] = df["MPX100-11"] /1000
#df['pAct'] = (((df["SSCDP15-9"])*2/2.5)*101.3250)
df['pAct'] = (((df["SSCDP05-9"])*2/2.5)*.5*101.3250) #used sscdp15 instead
rising_edges = np.asarray(df.Time.iloc[rising_edge(df['DigOut-1'],1)])
falling_edges = rising_edges + [60,50,+45,50,120,120]
rising_edges[0]+=20
rising_edges[3]+=5
#rising_edges[2]+=5
#rising_edges[3]+=5
#rising_edges[7]+=5
#rising_edges[8]+=5
#rising_edges[9]+=3
#df['pFlowInputBending'] = df["MPX700-2"] * 2.5/7 #2.5bar instead of a 1 bar used broken
#df['pLinearS'] = (((df["SSCDP15-4"])*1/2.5)*101.3250)
#df['pLinear'] = df["MPX700-2"] /1000
#rising_edges = np.asarray(df.Time.iloc[rising_edge(df['DigOut-1'],1)])+10
#falling_edges = rising_edges+20 #20s from spicy
#falling_edges[-32:-24] = rising_edges[-32:-24]+40
#falling_edges[-24:-16] = rising_edges[-24:-16]+120
#falling_edges[-16:-8] = rising_edges[-16:-8]+300
#falling_edges[-8:] = rising_edges[-8:]+300
#falling_edges[-2*7:-1*7] = rising_edges[-2*7:-1*7] + 45 #7 runs per settings of pgatefrq
#falling_edges[-1*7:] = rising_edges[-1*7:] + 120 #7 runs per settings of pgatefrq
#rising_edges = rising_edges +10
Vstiff = [0,100,200,300,0,0]
peak_avgs = []
peak_stds = []
deltapeak_avgs = []
deltapeak_stds = []
for i in range(len(rising_edges)):
if i not in [4,5]:
dftemp = df[(df.Time>rising_edges[i])&(df.Time<falling_edges[i])]
peaks, _ = find_peaks(dftemp.pAct, height=(dftemp.pAct.max()*.8,dftemp.pAct.max()*1.1), distance=2*fs)
fig= plt.figure(figsize=[sizehalfcol*2/3,sizehalfcol/1.5])
ax1 = fig.add_subplot(111) #top left
storedPs = []
for peak in peaks:
ax1.plot(dftemp.Time.iloc[peak-pre_secs:peak+post_secs] - dftemp.Time.iloc[peak],dftemp.pAct.iloc[peak-pre_secs:peak+post_secs],
color='gray', linewidth = .3)
#print('\t',peak+post_secs-peak+pre_secs)
#print(len(dftemp.pAct.iloc[peak-pre_secs:peak+post_secs]))
storedPs.append(dftemp.pAct.iloc[peak-pre_secs:peak+post_secs])
#ax1.plot(dftemp.Time.iloc[peak-pre_secs:peak+post_secs] - dftemp.Time.iloc[peak], np.mean(storedPs,axis=0),
# color='k', linewidth=.8)
#ax1.scatter(dftemp.Time.iloc[peaks],dftemp.pAct.iloc[peaks])
peakPs_avg.append(dftemp.pAct.iloc[peaks].mean())
peakPs_std.append(dftemp.pAct.iloc[peaks].std())
deltaPs_avg.append(dftemp.pAct.iloc[peaks].mean() - dftemp.pAct.iloc[-1])
deltaPs_std.append(dftemp.pAct.iloc[peaks].std())
pstart_avg.append(dftemp.pAct.iloc[-10:].mean())
pstart_std.append(dftemp.pAct.iloc[-10:].std())
peak_avgs.append(peakPs_avg[-1])
peak_stds.append(peakPs_std[-1])
deltapeak_avgs.append(deltaPs_avg[-1])
deltapeak_stds.append(deltaPs_std[-1])
#print(peakPs_avg[-1],deltaPs_avg[-1])
#ax1.vlines(-.35,pstart_avg[-1],70,linewidth=1, color=colorBdark2,)
ax1.hlines(140/2,-.5,.5, ls = '--', color= 'black', linewidth=.6)
ax1.hlines(pstart_avg[-1],-.5,.5, ls = '--', color= 'gray', linewidth=.6)
#ax1.set_ylim(-20,160)
ax1.xaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
ax1.set_title('$V*=%d$mL'%(Vstiff[i]), fontsize=labelfontsize)
#else:
# ax1.set_title('$V=V_{circuit} + V_{compliant}$', fontsize=labelfontsize)
ax1.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax1.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
#ax.set_ylim(0,58)
plt.tight_layout()
#ax.set_xlim(-.3,+.45)
#ax.set_ylim(-8,90+.05)
plt.savefig(result_folder+'\\%s_%dplot_13kPainVSTAR.png'%(expname,i+1), dpi=dpi,transparent=transparentsave)
plt.show()
ticksnameVol = []
for i in range(4):
ticksnameVol.append('$%d$ mL'%(i*100),)
fig= plt.figure(figsize=[int(sizehalfcol)*1.9,int(sizehalfcol)*.6])
ax1 = fig.add_subplot(111) #top left
for i in range(5):
if i not in [4,5]:
#ax1.scatter(i,pstart_avg[i]*(.03+i*100)/(.03+i*100+.06))
ax1.errorbar(i,peak_avgs[i],yerr=peak_stds[i], #label='$If$ not triggered',
color='firebrick', marker = 's', ls = '', elinewidth = 2, ecolor='firebrick',markersize=3)
ax1.set_xticks((0,1,2,3))
ax1.set_xticklabels(ticksnameVol)
ax1.xaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
#ax1.set_title('$p_{In}=%.1f kPa$'%(pstart_avg[-1]), fontsize=labelfontsize)
ax1.set_xlabel("$V^*$",fontsize=int(labelfontsize))
ax1.set_ylabel(" $p_{\\mathrm{event}}$(kPa)",fontsize=int(labelfontsize))
ax1.legend(ncol=1, fontsize=labelfontsize)
plt.savefig(result_folder+'\\%s_sumup.png'%(expname), dpi=dpi,transparent=transparentsave)
plt.show()
fig= plt.figure(figsize=[int(sizehalfcol)*1.9,int(sizehalfcol)*.6])
ax1 = fig.add_subplot(111) #top left
for i in range(5):
if i not in [4,5]:
ax1.errorbar(i,deltapeak_avgs[i],yerr=deltapeak_stds[i],# label='$If$ not triggered',
color='firebrick', marker = 's', ls = '', elinewidth = 2, ecolor='firebrick',markersize=3)
ax1.set_xticks((0,1,2,3))
ax1.set_xticklabels(ticksnameVol)
ax1.xaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
#ax1.set_title('$p_{In}=%.1f kPa$'%(pstart_avg[-1]), fontsize=labelfontsize)
ax1.set_xlabel("$V^*$",fontsize=int(labelfontsize))
ax1.set_ylabel(" $\\Delta p_{\\mathrm{event}}$(kPa)",fontsize=int(labelfontsize))
ax1.legend(ncol=1, fontsize=labelfontsize, loc = 'lower right')
plt.savefig(result_folder+'\\%s_sumup_peak.png'%(expname), dpi=dpi,transparent=transparentsave)
IfSensitivity_Cinfluence
Figure S13¶
In [ ]:
In [17]:
from scipy.signal import butter, cheby1, filtfilt
expid = 9
df = data[0][expid]
fs = data[1]['Samplerate'][expid] # in Hz
print(data[1]['Samplename'][expid] )
rollingavg_seconds = 30
#preparing data, converting to kPa the SSCDP sensors, than dividing by 1000 to get kPa
df["pG"] = (((df["SSCDP15-3"])*2/2.5)*101.3250)
df["pSD"] = (((df["SSCDP01-9"])*2/2.5)*101.3250)
df['Flow'] = df['AWM20-1']#.where(df['AWM20-1']>0,0.00001) #cleanup noise in sensor
df['Flow_movingAvg'] = df['AWM20-1'].rolling(fs*rollingavg_seconds).mean()
df['pSD_movingAvg'] = df["pSD"].rolling(fs*rollingavg_seconds).mean()
df["pG_movingAvg"] = (((df["SSCDP15-3"])*2/2.5)*101.3250).rolling(fs*rollingavg_seconds).mean()
order = 2
Wn = .5 #cutoff in Hz
btype = 'lowpass'
b, a = butter(order, Wn, btype, fs = fs)
df['pSD_Butter'] = filtfilt(b, a, df["pSD"])
#43
#setpoint presFesto5-1 to .05
#wait 20 s
#switch DigOut-1 on
#setpoint presFesto-0 to 1 in 60 s
#wait 20 s
#setpoint presFesto-0 to 0 in 60 s
#wait 20 s
#switch DigOut-1 off
#44
#setpoint presFesto5-1 to .05
#wait 30 s
#switch DigOut-1 on
#setpoint presFesto-0 to 1 in 240 s
#wait 30 s
#setpoint presFesto-0 to 0 in 240 s
#wait 30 s
#switch DigOut-1 off
#plt.figure(figsize=[12,6])
#plt.title('Gripper branch ($\,if\,$), Test',fontsize=18)
#plt.plot(df.Time,df.pIn, label="$p$", c='k')
#plt.legend(fontsize=20)
#plt.xlabel("Time (s)",fontsize=20)
#plt.xlim(152,155,)
#plt.xticks(fontsize=20)
#plt.ylabel("Pressure (kPa)",fontsize=20)
#plt.savefig(result_folder+'\\1Aplot.png', dpi=200)
rising_edges = np.asarray(df.Time.iloc[rising_edge(df['DigOut-1'],1)])
#if expid ==43:
buffer = -5
rising_edges = rising_edges + buffer#
falling_edges = rising_edges + 145 - buffer#inferred from spicy, 60up, 20 stationary, 60 down
upwards_end = rising_edges + 60 - buffer
half_exp = upwards_end + 10
downwards_start = half_exp + 10 +buffer
#rising_true = [80 , 150, 315, 520, 715]
#ending_true = [120, 175, 375, 565, 760]
#end_intervals = np.add(rising_edges,[40,55,1,80,70,10,80])
#peak_heights_per_interval = [50,60,100,100,100]
#if expid == 44:
#buffer = -5
#rising_edges = rising_edges + buffer
#falling_edges = rising_edges + 610 - buffer#inferred from spicy, 60up, 20 stationary, 60 down
#upwards_end = rising_edges + 240 - buffer
#half_exp = upwards_end + 255
#downwards_start = half_exp + 270 +buffer
#nsecs_s = [.5,.5,.5,.5,.5]
#nsece_s = [1,1,1,1,1]
from matplotlib import colors
def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):
new_cmap = colors.LinearSegmentedColormap.from_list(
'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),
cmap(np.linspace(minval, maxval, n)))
return new_cmap
import cmcrameri.cm as cmc
from matplotlib import gridspec
cmap_pSD = matplotlib.cm.get_cmap('Reds')
cmap_flow = cmc.lajolla#matplotlib.cm.get_cmap('Blues')
cmap_R = cmc.nuuk#matplotlib.cm.get_cmap('Blues')
cmap_flow_trunc = truncate_colormap(cmap_flow, minval=.1, maxval=.8, n=256)
cmap_R_trunc = truncate_colormap(cmap_R, minval=.1, maxval=.8, n=256)
rgbas_pSD = []
rgbas_flow = []
rgbas_R = []
for k in range(len(rising_edges)):
rgbas_pSD.append(cmap_pSD(k/len(rising_edges)))
rgbas_flow.append(cmap_flow_trunc(k/len(rising_edges)))
rgbas_R.append(cmap_R_trunc(k/len(rising_edges)))
fig= plt.figure(figsize=[int(sizehalfcol*1.8),int(sizehalfcol*1.8)])
ax1 = fig.add_subplot(221)
ax2 = fig.add_subplot(224)
ax3 = fig.add_subplot(222)
ax4 = fig.add_subplot(223)
#ax1twin = ax1.twinx()
store_pGs = []
lendftemp = len(df[(df.Time>rising_edges[0]) & (df.Time<falling_edges[0])])
idx_closing = []
idx_opening = []
for k in range(len(rising_edges)):
#ax3 = fig.add_subplot(153)
#ax4 = fig.add_subplot(154)
#ax5 = fig.add_subplot(155)
df_temp = df[(df.Time>rising_edges[k]) & (df.Time<falling_edges[k])] #downwards_startupwards_end
if len(df_temp) == lendftemp:
store_pGs.append(np.asarray(df_temp.pG))
#cleaned_resistance = np.where(df_temp.pSD_movingAvg/df_temp.Flow_movingAvg > 0, df_temp.pSD_movingAvg/df_temp.Flow_movingAvg, 0)
#cleaned_resistance = df_temp.pSD_movingAvg/df_temp.Flow_movingAvg
#df_temp = df_temp[(df_temp.Time>rising_edges[k]) & (df_temp.Time<upwards_end[k]) ]#& (df_temp.Time>downwards_start[k])]
ax4.plot(df_temp.Time - df_temp.Time.iloc[k], df_temp.Flow,color=rgbas_flow[k],zorder=0)
try:
idx_closing.append(np.where(df_temp.Flow<.005)[0][0])
idx_opening.append(np.where(df_temp.Flow<.005)[0][-1])
except:
continue
#ax3.plot(df_temp.Time,df_temp.pSD_movingAvg,color=rgbas[k])
#ax4.plot(df_temp.Time,df_temp.Flow_movingAvg,color=rgbas[k])
#ax5.plot(df_temp.Time,df_temp.pG_movingAvg,color=rgbas[k])
#df_temp = df[(df.Time>half_exp[k]) & (df.Time<falling_edges[k])]
#cleaned_resistance = np.where(df_temp.pSD_movingAvg/df_temp.Flow_movingAvg > 0, df_temp.pSD_movingAvg/df_temp.Flow_movingAvg, 0)
#cleaned_resistance = df_temp.pSD_movingAvg/df_temp.Flow_movingAvg
#ax1.plot(df_temp.pG_movingAvg,df_temp.Flow_movingAvg,color=rgbas[k],linewidth = 1, ls = '--')
#ax2.plot(df_temp.pG_movingAvg,cleaned_resistance,color=rgbas[k],linewidth = 1, ls = '--')
#ax3.plot(df_temp.Time,df_temp.pSD_movingAvg,color=rgbas[k],linewidth = 1, ls = '--')
#ax4.plot(df_temp.Time,df_temp.Flow_movingAvg,color=rgbas[k],linewidth = 1, ls = '--')
#ax5.plot(df_temp.Time,df_temp.pG_movingAvg,color=rgbas[k],linewidth = 1, ls = '--')
#ax2.set_yscale('log')
#ax2.set_ylim(1,5*np.max(cleaned_resistance))
ax1.plot(df_temp.Time - df_temp.Time.iloc[k],np.mean(store_pGs,axis=0),color='k',ls='--', linewidth = 1)
#plot opening/closing presures
vmin,vmax=.3,1
for j in range(len(rising_edges)):
df_temp = df[(df.Time>rising_edges[j]) & (df.Time<falling_edges[j])] #downwards_startupwards_end
try:
ax1.scatter(df_temp.Time.iloc[idx_closing[j]] - df_temp.Time.iloc[k],np.mean(store_pGs,axis=0)[idx_closing[j]],color=rgbas_flow[j], linewidth = 1,
edgecolor='k', marker = 'o', vmin=vmin,vmax=vmax,zorder=5)
ax1.scatter(df_temp.Time.iloc[idx_opening[j]] - df_temp.Time.iloc[k],np.mean(store_pGs,axis=0)[idx_opening[j]],color=rgbas_flow[j], linewidth = 1,
edgecolor='k', marker = 's', vmin=vmin,vmax=vmax,zorder=5)
ax2.scatter( df_temp.pSD.iloc[idx_closing[j]],np.mean(store_pGs,axis=0)[idx_closing[j]],
color=rgbas_flow[j], linewidth = 1,
edgecolor='k', marker = 'o', vmin=vmin,vmax=vmax,zorder=5)
im = ax2.scatter( df_temp.pSD.iloc[idx_opening[j]],np.mean(store_pGs,axis=0)[idx_opening[j]],
color=rgbas_flow[j], linewidth = 1,
edgecolor='k', marker = 's', vmin=vmin,vmax=vmax,zorder=5, cmap=cmap_flow_trunc)
im.set_cmap(cmap_flow_trunc)
except:
continue
#plot resistances in uprising edge
for k in range(len(rising_edges)):
#upwards
df_temp = df[(df.Time>rising_edges[k]+0) & (df.Time<upwards_end[k]+10)] #downwards_startupwards_end
cleaned_resistance = np.where(df_temp.pSD_movingAvg/df_temp.Flow_movingAvg > 0, df_temp.pSD_movingAvg/df_temp.Flow_movingAvg, 0)
idxmaxres = np.where(cleaned_resistance==np.max(cleaned_resistance))[0][0]
#cleaned_resistance = df_temp.pSD_movingAvg/df_temp.Flow_movingAvg
ax3.plot(df_temp.pG_movingAvg[:idxmaxres],cleaned_resistance[:idxmaxres],c=rgbas_flow[k])
ax2.plot(np.linspace(0,150),np.linspace(0,150), ls='--', color='lightgray',zorder=4)
ax4.set_xlabel("Time (s)", fontsize=labelfontsize)
ax4.set_ylabel("$Q_{SD}$ (SLPM)", fontsize=labelfontsize)#, color=cmap_flow_trunc(.5))
#ax1twin.tick_params(color=cmap_flow_trunc(.5))
#ax1twin.tick_params(colors=cmap_flow_trunc(.5), which='both') # 'both' refers to minor and major axes
ax1.set_xlabel("Time (s)", fontsize=labelfontsize)
ax1.set_ylabel("$p_{G}$ (kPa)", fontsize=labelfontsize)
ax1.grid(False)
ax2.grid(False)
ax2.set_xlabel("$p_{SD}$ (kPa)", fontsize=labelfontsize)
ax2.set_ylabel("$p_{G}$ (kPa)", fontsize=labelfontsize)
ax3.set_xlabel("$p_{G}$ (kPa)", fontsize=labelfontsize)
ax3.set_ylabel("$R_{SD}$ (kPa/SLPM)", fontsize=labelfontsize)
#ax1twin.grid(False)
ax2.axis('equal')
ax2.set_xlim(-5,150)
ax2.set_ylim(-5,150)
ax3.set_yscale('log')
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.xaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax2.spines['right'].set_visible(False)
ax2.spines['top'].set_visible(False)
ax2.spines['left'].set_visible(True)
ax2.spines['bottom'].set_visible(True)
ax2.xaxis.set_tick_params(labelsize=ticks_size)
ax2.yaxis.set_tick_params(labelsize=ticks_size)
ax3.spines['right'].set_visible(False)
ax3.spines['top'].set_visible(False)
ax3.spines['left'].set_visible(True)
ax3.spines['bottom'].set_visible(True)
ax3.xaxis.set_tick_params(labelsize=ticks_size)
ax3.yaxis.set_tick_params(labelsize=ticks_size)
ax4.spines['right'].set_visible(False)
ax4.spines['top'].set_visible(False)
ax4.spines['left'].set_visible(True)
ax4.spines['bottom'].set_visible(True)
ax4.xaxis.set_tick_params(labelsize=ticks_size)
ax4.yaxis.set_tick_params(labelsize=ticks_size)
ax3.grid(False)
ax4.grid(False)
#colorbar
cbar_ax = fig.add_axes([0.99, 0.08, 0.02, 0.9]) # Adjust the position and size as needed
cbar = fig.colorbar(im, cax=cbar_ax, ticks=[0.1,.3,.50,.7,.9])
cbar.set_label("$p_{SD}$ (kPa)", fontsize=labelfontsize)
cbar.ax.set_yticklabels(['15','50','75','105','135',])
plt.tight_layout()
plt.savefig(result_folder+'\\S2.png', dpi=dpi,transparent=transparentsave,bbox_inches="tight")
plt.show()
Supplementary2_NOTunableResistance_Highres
In [ ]:
In [ ]:
Figure S14¶
In [18]:
expidx = 4
df = data[0][expidx]
expname = data[1]['Samplename'][expidx]
print(expname)
timeres = data[1]['Samplerate'][expidx]
df["pIn"] = (((df["SSCDP05-3"])*1/2.5)*101.3250) #pressure at the input
df["pOut"] = (((df["SSCDP30-9"])*1/2.5)*101.3250) #pressure at the input
pReg = df.pIn.iloc[-4000:-2000].mean() #pressure at the regulator, measured at the end of the run df["pOut"] = (((df["SSCDP30-9"])*1/2.5)*101.3250) #pressure at the output in parallel with resistor, was a 15psi
df['pouch1'] = (7/1000)*df["MPX100-10"] #was a 7bar sensor, pre hyst valve
df['pouch2'] = (7/1000)*df["MPX100-4"] #was a 7bar sensortselect = 37 #selecting time of experimentInputP = df.PREG.iloc[-3000:].mean()
#preparing data, converting to kPa the SSCDP sensors
df = data[0][expidx]
tselectstart = 300
df = df[df.Time>tselectstart]
df.Time = df.Time - df.Time.iloc[0]
df = df[df.Time<60]
#forcing code to work, error in import
df = data[0][expidx]
onthreshold = pReg
tselectstart = 300
df = df[df.Time>tselectstart]
df.Time = df.Time - df.Time.iloc[0]
df = df[df.Time<60]
idx_off = np.where(df.pouch1<onthreshold)
idx_on = np.where(df.pouch1>onthreshold)
peaksoff,_ = find_peaks(df.pouch1,(32,70),prominence=5)
fig= plt.figure(figsize=[int(sizehalfcol),int(sizehalfcol*.5)])
ax = fig.add_subplot(111) #top left
onthreshold = pReg
idx_off = np.where(df.pouch1<onthreshold)
idx_on = np.where(df.pouch1>onthreshold)
plotbuffer0 = int(.5 * timeres)
plotbuffer1 = int(.74 * timeres)
plotbuffer2 = int(.74 * timeres)
plotbuffer3 = int(.74 * timeres)
plotbuffer4 = int(.05 * timeres)
# red = F54942
ax.plot(df.Time, df.pouch1, linewidth = 1, ls = '-' , label = '$p_{G}$',c = 'gray')
ax.plot(df.Time, df.pOut, linewidth = 1 , label = '$p_{out}$',c = 'k')
#ax.plot(df.Time.iloc[:peaksoff[0]-plotbuffer0],df.pouch1.iloc[:peaksoff[0]-plotbuffer0], ls ='--',marker='',c = '#00AB3B',linewidth = 2)
#ax.plot(df.Time.iloc[peaksoff[0]-plotbuffer0:peaksoff[1]+plotbuffer1],df.pouch1.iloc[peaksoff[0]-plotbuffer0:peaksoff[1]+plotbuffer1], ls ='--',marker='',c = '#F54942',linewidth = 2)
#ax.plot(df.Time.iloc[peaksoff[1]+plotbuffer1:peaksoff[2]],df.pouch1.iloc[peaksoff[1]+plotbuffer1:peaksoff[2]], ls ='--',marker='',c = '#00AB3B',linewidth = 2)
#ax.plot(df.Time.iloc[peaksoff[2]:peaksoff[3]+plotbuffer3],df.pouch1.iloc[peaksoff[2]:peaksoff[3]+plotbuffer3], ls ='--',marker='',c = '#F54942',linewidth = 2)
#ax.plot(df.Time.iloc[peaksoff[3]+plotbuffer3:peaksoff[4]+plotbuffer4],df.pouch1.iloc[peaksoff[3]+plotbuffer3:peaksoff[4]+plotbuffer4], ls ='--',marker='',c = '#00AB3B',linewidth = 2)
#ax.plot(df.Time.iloc[peaksoff[4]+plotbuffer4:],df.pouch1.iloc[peaksoff[4]+plotbuffer4:], ls ='--',marker='',c = '#F54942',linewidth = 2)
#ax.plot(df.Time, df.pOut, linewidth = 1.5, label = '$p_{out}$', c = '#00AB3B')
ax.xaxis.set_tick_params(labelsize=ticks_size)
ax.yaxis.set_tick_params(labelsize=ticks_size)
#ax.set_xticks((.25,.75,1.25,1.75))
#ax.set_xticklabels(('$.25$', '$.75$', '$1.25$','$1.5$'))
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
ax.grid(False)
ax.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
leg = ax.legend(fontsize=int(legendfont),loc=2,ncol=2, bbox_to_anchor=(0.0, 1.6))
# Change to location of the legend.
plt.tight_layout()
plt.savefig(result_folder+'\\4BoolSoloplotblackonly.png', dpi=dpi,transparent=transparentsave,bbox_inches = 'tight')
plt.show()
expidx = 5
df = data[0][expidx]
print(data[1]['Samplename'][expidx])
df["pIn"] = (((df["SSCDP05-3"])*1/2.5)*101.3250) #pressure at the input
df["pOut"] = (((df["SSCDP30-9"])*1/2.5)*101.3250) #pressure at the input
#pReg = 29.5#df.pIn.iloc[-4000:-2000].mean() #pressure at the regulator, measured at the end of the run df["pOut"] = (((df["SSCDP30-9"])*1/2.5)*101.3250) #pressure at the output in parallel with resistor, was a 15psi
df['pG2'] = (7/1000)*df["MPX100-10"] #was a 7bar sensor, pre hyst valve
df['pG1'] = (7/1000)*df["MPX100-4"] #was a 7bar sensortselect = 37 #selecting time of experimentInputP = df.PREG.iloc[-3000:].mean()
#preparing data, converting to kPa the SSCDP sensors
#forcing code to work, error in import
#df = data[0][expidx]
onthreshold = pReg
tselectstart = 880
df = df[df.Time>tselectstart]
df = df[df.Time<tselectstart+55]
#tselectstart = 300
#df = df[df.Time>tselectstart]
#df.Time = df.Time - df.Time.iloc[0]
#df = df[df.Time<60]
#tselectstart = 880
#df = df[df.Time>tselectstart]
#df = df[df.Time<tselectstart+55]
df.Time = df.Time - df.Time.iloc[0]
fig= plt.figure(figsize=[int(sizehalfcol),int(sizehalfcol*.6)])
ax0 = fig.add_subplot(111) #top leftonthreshold = 12
#ax1 = fig.add_subplot(212) #top leftonthreshold = 12
idx_off = np.where(df.pOut<onthreshold)
idx_on = np.where(df.pOut>onthreshold)
#ax.plot(df.Time.iloc[idx_off],df.pOut.iloc[idx_off], ls ='',marker='.',c = '#F54942', label= '$p_{False}$')
#ax.plot(df.Time.iloc[idx_on],df.pOut.iloc[idx_on], ls ='',marker='.',c = '#00AB3B', label= '$p_{True}$')
#ax0.fill_between(df.Time, 0, 30, where=df.pOut > 22, #pout on
# facecolor='#CDFADD')
#ax0.fill_between(df.Time, 0, 30, where=df.pOut < 22, #pout on
# facecolor='#F9DAD9')
ax0.plot(df.Time,df.pOut,linewidth = 1., label = '$p_{out}$', c = 'k')
ax0.plot(df.Time,df.pG2, c = '#E0B05E', label= '$p_{G1}$', linewidth=1)
ax0.plot(df.Time,df.pG1, c = '#5299DE', label= '$p_{G2}$', linewidth=1)
ax0.xaxis.set_tick_params(labelsize=ticks_size)
ax0.yaxis.set_tick_params(labelsize=ticks_size)
#ax1.xaxis.set_tick_params(labelsize=ticks_size)
#ax1.yaxis.set_tick_params(labelsize=ticks_size)
#ax.set_xticks((.25,.75,1.25,1.75))
#ax.set_xticklabels(('$.25$', '$.75$', '$1.25$','$1.5$'))
ax0.spines['right'].set_visible(False)
ax0.spines['top'].set_visible(False)
ax0.spines['left'].set_visible(True)
ax0.spines['bottom'].set_visible(True)
ax0.grid(False)
#ax[0].set_xlabel("Time (s)",fontsize=labelfontsize)
ax0.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
ax0.set_xlabel("Time (s)",fontsize=int(labelfontsize))
leg = ax0.legend(fontsize=legendfont,loc='upper right',ncol=3, bbox_to_anchor=(1.15, 1.25))
#ax1.spines['right'].set_visible(False)
#ax1.spines['top'].set_visible(False)
#ax1.spines['left'].set_visible(True)
#ax1.spines['bottom'].set_visible(True)
ax0.set_ylim(-3,55)
#ax1.set_ylim(-3,40)
#ax1.grid(False)
#ax1.set_xlabel("Time (s)",fontsize=int(labelfontsize))
#ax1.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
#leg = ax1.legend(fontsize=int(legendfont),loc=2,ncol=3, bbox_to_anchor=(0.75, 1.5))
plt.tight_layout()
plt.savefig(result_folder+'\\4BoolANDplot.png', dpi=dpi,transparent=transparentsave)
plt.show()
expidx = 6
df = data[0][expidx]
print(data[1]['Samplename'][expidx])
df["pIn"] = (((df["SSCDP05-3"])*1/2.5)*101.3250) #pressure at the input
df["pOut"] = (((df["SSCDP30-9"])*1/2.5)*101.3250) #pressure at the input
#pReg = 29.5#df.pIn.iloc[-4000:-2000].mean() #pressure at the regulator, measured at the end of the run df["pOut"] = (((df["SSCDP30-9"])*1/2.5)*101.3250) #pressure at the output in parallel with resistor, was a 15psi
df['pG2'] = (7/1000)*df["MPX100-10"] #was a 7bar sensor, pre hyst valve
df['pG1'] = (7/1000)*df["MPX100-4"] #was a 7bar sensortselect = 37 #selecting time of experimentInputP = df.PREG.iloc[-3000:].mean()
#preparing data, converting to kPa the SSCDP sensors
tselectstart = 480
df = df[df.Time>tselectstart]
df = df[df.Time<tselectstart+55]
df.Time = df.Time - df.Time.iloc[0]
fig= plt.figure(figsize=[int(sizehalfcol),int(sizehalfcol*.6)])
ax0 = fig.add_subplot(111) #top leftonthreshold = 12
#ax1 = fig.add_subplot(212) #top leftonthreshold = 12
onthreshold = 19
idx_off = np.where(df.pOut<onthreshold)
idx_on = np.where(df.pOut>onthreshold)
#ax.plot(df.Time.iloc[idx_off],df.pOut.iloc[idx_off], ls ='',marker='.',c = '#F54942', label= '$p_{False}$')
#ax.plot(df.Time.iloc[idx_on],df.pOut.iloc[idx_on], ls ='',marker='.',c = '#00AB3B', label= '$p_{True}$')
#ax1.fill_between(df.Time, 0, 30, where=df.pOut > 15, #pout on
# facecolor='#CDFADD')
#ax1.fill_between(df.Time, 0, 30, where=df.pOut < 15, #pout on
# facecolor='#F9DAD9')
ax0.plot(df.Time,df.pOut,linewidth = 1., label = '$p_{out}$', c = 'k')
ax0.plot(df.Time,df.pG2, c = '#E0B05E', label= '$p_{G1}$', linewidth=1)
ax0.plot(df.Time,df.pG1, c = '#5299DE', label= '$p_{G2}$', linewidth=1)
ax0.xaxis.set_tick_params(labelsize=ticks_size)
ax0.yaxis.set_tick_params(labelsize=ticks_size)
#ax1.xaxis.set_tick_params(labelsize=ticks_size)
#ax1.yaxis.set_tick_params(labelsize=ticks_size)
#ax.set_xticks((.25,.75,1.25,1.75))
#ax.set_xticklabels(('$.25$', '$.75$', '$1.25$','$1.5$'))
ax0.spines['right'].set_visible(False)
ax0.spines['top'].set_visible(False)
ax0.spines['left'].set_visible(True)
ax0.spines['bottom'].set_visible(True)
ax0.grid(False)
#ax[0].set_xlabel("Time (s)",fontsize=labelfontsize)
ax0.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
ax0.set_xlabel("Time (s)",fontsize=int(labelfontsize))
leg = ax0.legend(fontsize=legendfont,loc='upper right',ncol=3, bbox_to_anchor=(1.15, 1.25))
#ax1.spines['right'].set_visible(False)
#ax1.spines['top'].set_visible(False)
#ax1.spines['left'].set_visible(True)
#ax1.spines['bottom'].set_visible(True)
#ax0.set_ylim(-3,55)
#ax1.set_ylim(-3,40)
#ax1.grid(False)
#ax1.set_xlabel("Time (s)",fontsize=int(labelfontsize))
#ax1.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
#leg = ax1.legend(fontsize=int(legendfont),loc=2,ncol=3, bbox_to_anchor=(0.0, 1.5))
plt.tight_layout()
plt.savefig(result_folder+'\\4BoolORplot.png', dpi=dpi,transparent=transparentsave)
Fig4SingleBoolean_230920_V1
Fig4AND_230921_V0
Fig4OR_230921_V0
Figure S16¶
In [19]:
exceldfolder = Location + r'\instron\forcedisplacement45kPa.is_tcyclic_RawData'
TimesInstron = []
PossInstron = []
FsInstron = []
instronnames = ['Specimen_RawData_1','Specimen_RawData_2','Specimen_RawData_3',
'Specimen_RawData_4','Specimen_RawData_5',]
for instroname in instronnames:
dfinstron = pd.read_csv(exceldfolder+'\\'+instroname+'.csv',skiprows=1, sep=';')
dfinstron = dfinstron.rename(columns={'(s)': 'Time', '(mm)': 'Pos', '(N)':'F'})
# Display the first few rows of the DataFrame
dfinstron = dfinstron.replace(',', '.', regex=True)
dfinstron = dfinstron.apply(pd.to_numeric)
TimesInstron.append(dfinstron.Time)
PossInstron.append(dfinstron.Pos)
FsInstron.append(dfinstron.F)
import cmcrameri.cm as cmc
from matplotlib import gridspec
expname_ = 'ForcePressureDisplacementGripper'
cmap_force = matplotlib.cm.get_cmap('Greens')
expidxs = [18,19,20,21,22]
ts = [] #separated times before and after peak
ps = [] #separated pressure
prefs = [] #baseline pressure
pmaxs = []
ds = [] #separated position
for k in range(len(TimesInstron)):
#print(k,TimesInstron[k].max())
expidx = expidxs[k]
df = data[0][expidx]
df["MPX100-10"] = df["MPX100-10"]/1000
expname = data[1]['Samplename'][expidx]
print(expname)
#df["MPX100-10"] = df["MPX100-10"]/1000
#preparing data, converting to kPa the SSCDP sensors, than dividing by 1000 to get kPa
ref = df["MPX100-10"].min()
df = df[df.Time>=TimesInstron[k].min()]
df = df[df.Time<=TimesInstron[k].max()]
prefs.append(ref)
ps.append(df["MPX100-10"]-prefs[-1])
pmaxs.append(ps[-1].max())
ts.append(df.Time)
rgbas_force = []
for k in range(len(TimesInstron)):
rgbas_force.append(cmap_force((0+ps[k][5800])/50))
fig = plt.figure(figsize=[sizehalfcol,sizehalfcol*1.25])
ax0 = fig.add_subplot(311) #top left
ax1 = fig.add_subplot(312) #top left
ax2 = fig.add_subplot(313) #top left
#ax3 = fig.add_subplot(144) #top left
axs = [ax0,ax1,ax2]
for k in [3,1,2,0,4]:
ax1.plot(ts[k],ps[k],color=rgbas_force[k])
ax2.plot(ts[k],ps[k]-ps[k].iloc[8000],label='$p_{\\mathrm{in}}$ = %.1f kPa'%(ps[k][5800]),
color=rgbas_force[k])
ax0.plot(TimesInstron[k],PossInstron[k], color= 'k',alpha=.6)
for ax in axs:
ax.xaxis.set_tick_params(labelsize=int(ticks_size))
ax.yaxis.set_tick_params(labelsize=int(ticks_size))
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
ax.set_xlim(8,71)
ax.grid(False)
ax0.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax1.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
ax2.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax2.set_ylabel("$\Delta p $ (kPa)",fontsize=int(labelfontsize))
ax1.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax0.set_ylabel("Position (mm)",fontsize=int(labelfontsize))
ax2.set_ylim(-1,3)
ax2.legend(ncol=2,fontsize=legendfont-1.5,loc='upper left',bbox_to_anchor=(0.0, 1., 0.2, 0.5))
plt.tight_layout()
plt.savefig(result_folder+'\\%s_tab1.png'%(expname_), dpi=dpi,transparent=transparentsave)
plt.show()
idx = 0
len(TimesInstron[idx][:-8]),len(ts[idx].iloc[::100])
#to synch data
cutoffs = [8,6,9,8,8]
fig = plt.figure(figsize=[sizehalfcol,sizehalfcol*1.25])
ax0 = fig.add_subplot(311) #top left
ax1 = fig.add_subplot(312) #top left
ax2 = fig.add_subplot(313) #top left
#ax3 = fig.add_subplot(144) #top left
axs = [ax0,ax1,ax2]
for k in [3,1,2,0,4]:
ax0.plot(PossInstron[k],FsInstron[k],color=rgbas_force[k])
ax1.plot(ps[k].iloc[::100],FsInstron[k][:-cutoffs[k]],color=rgbas_force[k])#-ps[k].iloc[8000])
im = ax2.scatter(ps[k].iloc[::100].max()-ps[k].iloc[8000],FsInstron[k][:-cutoffs[k]].min(),marker='.',
color=rgbas_force[k])#-ps[k].iloc[8000])
#ax1.plot(TimesInstron[k],PossInstron[k], color= 'k',alpha=.6)
for ax in axs:
ax.xaxis.set_tick_params(labelsize=int(ticks_size))
ax.yaxis.set_tick_params(labelsize=int(ticks_size))
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
#ax.set_xlim(8,75)
ax.grid(False)
#ax0.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax0.set_ylabel("Force (N)",fontsize=int(labelfontsize))
ax1.set_ylabel("Force (N)",fontsize=int(labelfontsize))
ax2.set_ylabel("Peak Force (N)",fontsize=int(labelfontsize))
ax2.set_xlabel("Peak Pressure (kPa)",fontsize=int(labelfontsize))
#ax1.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax0.set_xlabel("Position (mm)",fontsize=int(labelfontsize))
ax1.set_xlabel("Pressure (kPa)",fontsize=int(labelfontsize))
#ax1.set_ylim(-1,3)
#ax2.set_ylim(-1,3)
plt.tight_layout()
plt.savefig(result_folder+'\\%s_tab2.png'%(expname_), dpi=dpi,transparent=transparentsave)
plt.show()
fig = plt.figure(figsize=[sizehalfcol*.75,sizehalfcol*.5])
ax0 = fig.add_subplot(111) #top left
#ax1 = fig.add_subplot(312) #top left
#ax2 = fig.add_subplot(313) #top left
#ax3 = fig.add_subplot(144) #top left
axs = [ax0]
for k in [3,1,2,0,4]:
idx_maxslope = np.argmax(np.diff(ps[k].iloc[::100]))
maxsensitivity = np.asarray(ps[k].iloc[::100])[idx_maxslope] #kPa/mm
ax0.plot(PossInstron[k][:-cutoffs[k]],ps[k].iloc[::100],color=rgbas_force[k],
label='%.1f$\\frac{kPa}{mm}$'%(maxsensitivity))
#ax1.plot(TimesInstron[k],PossInstron[k], color= 'k',alpha=.6)
for ax in axs:
ax.xaxis.set_tick_params(labelsize=int(ticks_size))
ax.yaxis.set_tick_params(labelsize=int(ticks_size))
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
#ax.set_xlim(8,75)
ax.grid(False)
#ax0.set_xlabel("Time (s)",fontsize=int(labelfontsize))
#ax0.legend(fontsize=legendfont,ncol=2)
ax0.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
#ax1.set_ylabel("Force (N)",fontsize=int(labelfontsize))
#ax2.set_ylabel("Peak Force (N)",fontsize=int(labelfontsize))
#ax2.set_xlabel("Peak Pressure (kPa)",fontsize=int(labelfontsize))
#ax1.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax0.set_xlabel("Position (mm)",fontsize=int(labelfontsize))
#ax1.set_xlabel("Pressure (kPa)",fontsize=int(labelfontsize))
#ax1.set_ylim(-1,3)
ax0.set_ylim(18,50)
ax0.set_xlim(-.25,-32)
plt.tight_layout()
plt.savefig(result_folder+'\\%s_tab3.png'%(expname_), dpi=dpi,transparent=transparentsave)
plt.show()
forcedisplacement45kPa forcedisplacement30kPa forcedisplacement40kPa forcedisplacement25kPa forcedisplacement50kPa
Figure S17¶
In [20]:
#merge df and dfbis
expidx = 10
df1 = data[0][expidx]
print(data[1]['Samplename'][expidx])
tfinal1 = df1.Time.iloc[-1]
expidx = 11
df2 = data[0][expidx]
print(data[1]['Samplename'][expidx])
df2.Time += tfinal1
df = pd.concat([df1,df2],ignore_index =True)
fs = data[1]['Samplerate'][expidx] # in Hz
df["pSD"] = (((df["SSCDP30-9"])*2/2.5)*101.3250)
df["pG"] = (((df["SSCDP15-4"])/2.5)*101.3250)
df["Q"] = df["AWM20-12"]
rising_edges_tot = np.asarray(df.Time.iloc[rising_edge(df['DigOut-1'],1)])
radii = [.31,.31,.31,.31,.31, ##mm
0.42,0.42,0.42,0.42,0.42,
.7,.7,.7,.7,.7,
.8,.8,.8,.8,.8,
0.0000000000001,
.23,.23,.23,.23,.23,
.27,.27,.27,.27,.27]
lengths = [0,0,0,0,0, #0 = 2.54/2, 1/2.54/4
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0,
0,
1,1,1,1,1,
1,1,1,1,1,]
waitingtimes = []
bufferpre = 2
rising_edges = [rising_edges_tot[2],rising_edges_tot[3],rising_edges_tot[4],rising_edges_tot[5],rising_edges_tot[6], #lavander
rising_edges_tot[9],rising_edges_tot[10],rising_edges_tot[11],rising_edges_tot[12],rising_edges_tot[13], #white
rising_edges_tot[14],rising_edges_tot[15],rising_edges_tot[16],rising_edges_tot[17],rising_edges_tot[18], #blue
rising_edges_tot[19],rising_edges_tot[20],rising_edges_tot[21],rising_edges_tot[22],rising_edges_tot[23], #purple
rising_edges_tot[25],rising_edges_tot[26],rising_edges_tot[27],rising_edges_tot[28],rising_edges_tot[29], #green
rising_edges_tot[30],rising_edges_tot[31],rising_edges_tot[32],rising_edges_tot[33],rising_edges_tot[34], #yellow
]
startidx = np.where(df.Time == rising_edges_tot[19])[0][0]
endidx = startidx+200*fs
SDpressures = []
Gpressures = []
SDflow = []
for i in range(5):
startidx = np.where(df.Time == rising_edges[i])[0][0]
endidx = startidx+10*fs
SDpressures.append(np.asarray(df.pSD[startidx-fs*bufferpre:endidx]))
Gpressures.append(np.asarray(df.pG[startidx-fs*bufferpre:endidx]))
SDflow.append(np.asarray(df.Q[startidx-fs*bufferpre:endidx]))
#evaluate averages and stds
SDflow_avg = np.mean(SDflow,axis=0)
SDpressures_avg = np.mean(SDpressures,axis=0)
Gpressures_avg = np.mean(Gpressures,axis=0)
SDflow_std = np.std(SDflow,axis=0)
SDpressures_std = np.std(SDpressures,axis=0)
Gpressures_std = np.std(Gpressures,axis=0)
idxclosed = np.where(SDflow_avg<.001)[0][-1]
idxopen = np.where(SDflow_avg>SDflow_avg.max()*.95)[0][0]
tmemorylavander = (idxopen-idxclosed)/fs
fig= plt.figure(figsize=[int(sizehalfcol),int(sizehalfcol*3/2)])
fig.suptitle('$Radius = .31$mm, $L = 12.7$mm',fontsize=10)
ax1 = fig.add_subplot(211) #top left
#ax2 = fig.add_subplot(212) #top left
ax3 = ax1.twinx()
ax3.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx],SDflow_avg,
ls = '-', color = 'royalblue', label= '$Q_{SD}$')
ax3.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx], SDflow_avg-SDflow_std, SDflow_avg+SDflow_std,
color='royalblue',alpha=.5)
ax1.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx],SDpressures_avg,
ls = '-', color = 'gray', label= '$p_{SD}$')
ax1.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx-fs*bufferpre], SDpressures_avg-SDpressures_std, SDpressures_avg+SDpressures_std,
color='gray',alpha=.5)
ax1.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx],Gpressures_avg,
ls = '-', color = 'k', label= '$p_{G}$')
ax1.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx], Gpressures_avg-Gpressures_std, Gpressures_avg+Gpressures_std,
color='k',alpha=.5)
#ax2.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx-fs*bufferpre],SDpressures_avg/SDflow_avg,
# ls = '-', color = 'k', label= '$R_{SD}$')
#ax2.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx-fs*bufferpre], SDpressures_avg/SDflow_avg+SDpressures_std+SDflow_std, SDflow_avg/SDpressures_avg-SDpressures_std-SDflow_std,
# color='k',alpha=.5)
ax1.axvspan(0, tmemorylavander,
alpha=0.3, color='silver')
ax1.legend(fontsize=legendfont,bbox_to_anchor=(.9, .5))
ax3.legend(fontsize=legendfont,bbox_to_anchor=(.91, .26))
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
#ax2.spines['right'].set_visible(False)
#ax2.spines['top'].set_visible(False)
#ax2.spines['left'].set_visible(True)
#ax2.spines['bottom'].set_visible(True)
#ax2.grid(False)
ax3.spines['right'].set_visible(False)
ax3.spines['top'].set_visible(False)
ax3.spines['right'].set_visible(True)
ax3.spines['bottom'].set_visible(True)
ax3.grid(False)
ax1.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax1.set_ylabel("$p$ (kPa)",fontsize=int(labelfontsize))
ax3.set_ylabel("$Q$ (SLPM)",fontsize=int(labelfontsize),color='royalblue')
ax3.tick_params(colors='royalblue', which='both') # 'both' refers to minor and major axes
ax1.xaxis.set_tick_params(labelsize=int(ticks_size))
ax1.yaxis.set_tick_params(labelsize=int(ticks_size))
ax3.xaxis.set_tick_params(labelsize=int(ticks_size))
ax3.yaxis.set_tick_params(labelsize=int(ticks_size))
plt.tight_layout()
#ax.set_ylim(-5,60)
plt.savefig(result_folder+'\\S3_30.png', dpi=dpi,transparent=transparentsave)
SDlavander = SDflow_avg
SDlavanderstd = SDflow_std
Glavander = Gpressures_avg
Glavanderstd = Gpressures_std
Tlavander = df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx]
bufferpre = 2
SDpressures = []
Gpressures = []
SDflow = []
for i in range(5,10):
startidx = np.where(df.Time == rising_edges[i])[0][0]
endidx = startidx+5*fs
SDpressures.append(np.asarray(df.pSD[startidx-fs*bufferpre:endidx]))
Gpressures.append(np.asarray(df.pG[startidx-fs*bufferpre:endidx]))
SDflow.append(np.asarray(df.Q[startidx-fs*bufferpre:endidx]))
#evaluate averages and stds
SDflow_avg = np.mean(SDflow,axis=0)
SDpressures_avg = np.mean(SDpressures,axis=0)
Gpressures_avg = np.mean(Gpressures,axis=0)
SDflow_std = np.std(SDflow,axis=0)
SDpressures_std = np.std(SDpressures,axis=0)
Gpressures_std = np.std(Gpressures,axis=0)
idxclosed = np.where(SDflow_avg<.001)[0][-1]
idxopen = np.where(SDflow_avg>SDflow_avg.max()*.95)[0][0]
tmemorywhite = (idxopen-idxclosed)/fs
fig= plt.figure(figsize=[int(sizehalfcol),int(sizehalfcol*3/2)])
fig.suptitle('Radius = .42mm, Length = 12.7mm',fontsize=10)
ax1 = fig.add_subplot(211) #top left
#ax2 = fig.add_subplot(212) #top left
ax3 = ax1.twinx()
ax3.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx],SDflow_avg,
ls = '-', color = 'royalblue', label= '$Q_{SD}$')
ax3.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx], SDflow_avg-SDflow_std, SDflow_avg+SDflow_std,
color='royalblue',alpha=.5)
ax1.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx],SDpressures_avg,
ls = '-', color = 'gray', label= '$p_{SD}$')
ax1.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx], SDpressures_avg-SDpressures_std, SDpressures_avg+SDpressures_std,
color='gray',alpha=.5)
ax1.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx],Gpressures_avg,
ls = '-', color = 'k', label= '$p_{G}$')
ax1.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx], Gpressures_avg-Gpressures_std, Gpressures_avg+Gpressures_std,
color='k',alpha=.5)
#ax2.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx-fs*bufferpre],SDpressures_avg/SDflow_avg,
# ls = '-', color = 'k', label= '$R_{SD}$')
#ax2.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx-fs*bufferpre], SDpressures_avg/SDflow_avg+SDpressures_std+SDflow_std, SDflow_avg/SDpressures_avg-SDpressures_std-SDflow_std,
# color='k',alpha=.5)
ax1.axvspan(0, tmemorywhite,
alpha=0.3, color='silver')
ax1.legend(fontsize=legendfont,bbox_to_anchor=(.9, .5))
ax3.legend(fontsize=legendfont,bbox_to_anchor=(.91, .26))
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
#ax2.spines['right'].set_visible(False)
#ax2.spines['top'].set_visible(False)
#ax2.spines['left'].set_visible(True)
#ax2.spines['bottom'].set_visible(True)
#ax2.grid(False)
ax3.spines['right'].set_visible(False)
ax3.spines['top'].set_visible(False)
ax3.spines['right'].set_visible(True)
ax3.spines['bottom'].set_visible(True)
ax3.grid(False)
ax1.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax1.set_ylabel("$p$ (kPa)",fontsize=int(labelfontsize))
ax3.set_ylabel("$Q$ (SLPM)",fontsize=int(labelfontsize),color='royalblue')
ax3.tick_params(colors='royalblue', which='both') # 'both' refers to minor and major axes
ax1.xaxis.set_tick_params(labelsize=int(ticks_size))
ax1.yaxis.set_tick_params(labelsize=int(ticks_size))
ax3.xaxis.set_tick_params(labelsize=int(ticks_size))
ax3.yaxis.set_tick_params(labelsize=int(ticks_size))
plt.tight_layout()
#ax.set_ylim(-5,60)
plt.savefig(result_folder+'\\S3_27.png', dpi=dpi,transparent=transparentsave)
SDwhite = SDflow_avg
SDwhitestd = SDflow_std
Gwhite = Gpressures_avg
Gwhitestd = Gpressures_std
Twhite = df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx]
bufferpre = 1
SDpressures = []
Gpressures = []
SDflow = []
for i in range(11,15):
startidx = np.where(df.Time == rising_edges[i])[0][0]
endidx = startidx+2*fs
SDpressures.append(np.asarray(df.pSD[startidx-fs*bufferpre:endidx]))
Gpressures.append(np.asarray(df.pG[startidx-fs*bufferpre:endidx]))
SDflow.append(np.asarray(df.Q[startidx-fs*bufferpre:endidx]))
#evaluate averages and stds
SDflow_avg = np.mean(SDflow,axis=0)
SDpressures_avg = np.mean(SDpressures,axis=0)
Gpressures_avg = np.mean(Gpressures,axis=0)
SDflow_std = np.std(SDflow,axis=0)
SDpressures_std = np.std(SDpressures,axis=0)
Gpressures_std = np.std(Gpressures,axis=0)
idxclosed = np.where(SDflow_avg<.001)[0][-1]
idxopen = np.where(SDflow_avg>SDflow_avg.max()*.95)[0][0]
tmemoryblue = (idxopen-idxclosed)/fs
fig= plt.figure(figsize=[int(sizehalfcol),int(sizehalfcol*3/2)])
fig.suptitle('Radius = .7mm, Length = 12.7mm',fontsize=10)
ax1 = fig.add_subplot(211) #top left
#ax2 = fig.add_subplot(212) #top left
ax3 = ax1.twinx()
ax3.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx],SDflow_avg,
ls = '-', color = 'royalblue', label= '$Q_{SD}$')
ax3.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx], SDflow_avg-SDflow_std, SDflow_avg+SDflow_std,
color='royalblue',alpha=.5)
ax1.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx],SDpressures_avg,
ls = '-', color = 'gray', label= '$p_{SD}$')
ax1.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx], SDpressures_avg-SDpressures_std, SDpressures_avg+SDpressures_std,
color='gray',alpha=.5)
ax1.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx],Gpressures_avg,
ls = '-', color = 'k', label= '$p_{G}$')
ax1.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx], Gpressures_avg-Gpressures_std, Gpressures_avg+Gpressures_std,
color='k',alpha=.5)
#ax2.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx-fs*bufferpre],SDpressures_avg/SDflow_avg,
# ls = '-', color = 'k', label= '$R_{SD}$')
#ax2.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx-fs*bufferpre], SDpressures_avg/SDflow_avg+SDpressures_std+SDflow_std, SDflow_avg/SDpressures_avg-SDpressures_std-SDflow_std,
# color='k',alpha=.5)
ax1.axvspan(0, tmemoryblue,
alpha=0.3, color='silver')
ax1.legend(fontsize=legendfont,bbox_to_anchor=(.9, .5))
ax3.legend(fontsize=legendfont,bbox_to_anchor=(.91, .26))
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
#ax2.spines['right'].set_visible(False)
#ax2.spines['top'].set_visible(False)
#ax2.spines['left'].set_visible(True)
#ax2.spines['bottom'].set_visible(True)
#ax2.grid(False)
ax3.spines['right'].set_visible(False)
ax3.spines['top'].set_visible(False)
ax3.spines['right'].set_visible(True)
ax3.spines['bottom'].set_visible(True)
ax3.grid(False)
ax1.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax1.set_ylabel("$p$ (kPa)",fontsize=int(labelfontsize))
ax3.set_ylabel("$Q$ (SLPM)",fontsize=int(labelfontsize),color='royalblue')
ax3.tick_params(colors='royalblue', which='both') # 'both' refers to minor and major axes
ax1.xaxis.set_tick_params(labelsize=int(ticks_size))
ax1.yaxis.set_tick_params(labelsize=int(ticks_size))
ax3.xaxis.set_tick_params(labelsize=int(ticks_size))
ax3.yaxis.set_tick_params(labelsize=int(ticks_size))
plt.tight_layout()
#ax.set_ylim(-5,60)
plt.savefig(result_folder+'\\S3_22.png', dpi=dpi,transparent=transparentsave)
SDblue = SDflow_avg
SDbluestd = SDflow_std
Gblue = Gpressures_avg
Gbluestd = Gpressures_std
Tblue = df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx]
bufferpre = 1
SDpressures = []
Gpressures = []
SDflow = []
for i in range(15,20):
startidx = np.where(df.Time == rising_edges[i])[0][0]
endidx = startidx+2*fs
SDpressures.append(np.asarray(df.pSD[startidx-fs*bufferpre:endidx]))
Gpressures.append(np.asarray(df.pG[startidx-fs*bufferpre:endidx]))
SDflow.append(np.asarray(df.Q[startidx-fs*bufferpre:endidx]))
#evaluate averages and stds
SDflow_avg = np.mean(SDflow,axis=0)
SDpressures_avg = np.mean(SDpressures,axis=0)
Gpressures_avg = np.mean(Gpressures,axis=0)
SDflow_std = np.std(SDflow,axis=0)
SDpressures_std = np.std(SDpressures,axis=0)
Gpressures_std = np.std(Gpressures,axis=0)
idxclosed = np.where(SDflow_avg<.001)[0][-1]
idxopen = np.where(SDflow_avg>SDflow_avg.max()*.95)[0][0]
tmemorypurple = (idxopen-idxclosed)/fs
fig= plt.figure(figsize=[int(sizehalfcol),int(sizehalfcol*3/2)])
fig.suptitle('Radius = .8mm, Length = 12.7mm',fontsize=10)
ax1 = fig.add_subplot(211) #top left
#ax2 = fig.add_subplot(212) #top left
ax3 = ax1.twinx()
ax3.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx],SDflow_avg,
ls = '-', color = 'royalblue', label= '$Q_{SD}$')
ax3.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx], SDflow_avg-SDflow_std, SDflow_avg+SDflow_std,
color='royalblue',alpha=.5)
ax1.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx],SDpressures_avg,
ls = '-', color = 'gray', label= '$p_{SD}$')
ax1.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx], SDpressures_avg-SDpressures_std, SDpressures_avg+SDpressures_std,
color='gray',alpha=.5)
ax1.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx],Gpressures_avg,
ls = '-', color = 'k', label= '$p_{G}$')
ax1.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx], Gpressures_avg-Gpressures_std, Gpressures_avg+Gpressures_std,
color='k',alpha=.5)
ax1.axvspan(0, tmemorypurple,
alpha=0.3, color='silver')
#ax2.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx-fs*bufferpre],SDpressures_avg/SDflow_avg,
# ls = '-', color = 'k', label= '$R_{SD}$')
#ax2.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx-fs*bufferpre], SDpressures_avg/SDflow_avg+SDpressures_std+SDflow_std, SDflow_avg/SDpressures_avg-SDpressures_std-SDflow_std,
# color='k',alpha=.5)
ax1.legend(fontsize=legendfont,bbox_to_anchor=(.9, .5))
ax3.legend(fontsize=legendfont,bbox_to_anchor=(.91, .26))
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
#ax2.spines['right'].set_visible(False)
#ax2.spines['top'].set_visible(False)
#ax2.spines['left'].set_visible(True)
#ax2.spines['bottom'].set_visible(True)
#ax2.grid(False)
ax3.spines['right'].set_visible(False)
ax3.spines['top'].set_visible(False)
ax3.spines['right'].set_visible(True)
ax3.spines['bottom'].set_visible(True)
ax3.grid(False)
ax1.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax1.set_ylabel("$p$ (kPa)",fontsize=int(labelfontsize))
ax3.set_ylabel("$Q$ (SLPM)",fontsize=int(labelfontsize),color='royalblue')
ax3.tick_params(colors='royalblue', which='both') # 'both' refers to minor and major axes
ax1.xaxis.set_tick_params(labelsize=int(ticks_size))
ax1.yaxis.set_tick_params(labelsize=int(ticks_size))
ax3.xaxis.set_tick_params(labelsize=int(ticks_size))
ax3.yaxis.set_tick_params(labelsize=int(ticks_size))
plt.tight_layout()
#ax.set_ylim(-5,60)
plt.savefig(result_folder+'\\S3_21.png', dpi=dpi,transparent=transparentsave)
SDpurple = SDflow_avg
SDpurplestd = SDflow_std
Gpurple = Gpressures_avg
Gpurplestd = Gpressures_std
Tpurple = df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx]
expidx = 11
df = data[0][expidx]
print( data[1]['Samplename'][expidx])
fs = data[1]['Samplerate'][expidx] # in Hz
df["pSD"] = (((df["SSCDP30-9"])*2/2.5)*101.3250)
df["pG"] = (((df["SSCDP15-4"])/2.5)*101.3250)
df["Q"] = df["AWM20-12"]
rising_edges = np.asarray(df.Time.iloc[rising_edge(df['DigOut-1'],1)])
idxclosed = np.where(SDflow_avg>0.01)[0][-1]
idxopen = np.where(SDflow_avg>SDflow_avg.max()*.95)[0][0]
print(idxclosed- idxopen)
bufferpre = 1
SDpressures = []
Gpressures = []
SDflow = []
for i in range(5,10):
print(i)
startidx = np.where(df.Time == rising_edges[i])[0][0]
endidx = startidx+50*fs
SDpressures.append(np.asarray(df.pSD[startidx-fs*bufferpre:endidx]))
Gpressures.append(np.asarray(df.pG[startidx-fs*bufferpre:endidx]))
SDflow.append(np.asarray(df.Q[startidx-fs*bufferpre:endidx]))
#evaluate averages and stds
SDflow_avg = np.mean(SDflow,axis=0)
SDpressures_avg = np.mean(SDpressures,axis=0)
Gpressures_avg = np.mean(Gpressures,axis=0)
SDflow_std = np.std(SDflow,axis=0)
SDpressures_std = np.std(SDpressures,axis=0)
Gpressures_std = np.std(Gpressures,axis=0)
idxclosed = np.where(SDflow_avg>0.01)[0][-1]
idxopen = np.where(SDflow_avg>SDflow_avg.max()*.99)[0][0]
tmemorygreen = -(idxopen-idxclosed)/fs
fig= plt.figure(figsize=[int(sizehalfcol),int(sizehalfcol*3/2)])
fig.suptitle('Radius = .27mm, Length = 6.35$mm',fontsize=10)
ax1 = fig.add_subplot(211) #top left
#ax2 = fig.add_subplot(212) #top left
ax3 = ax1.twinx()
ax3.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx],SDflow_avg,
ls = '-', color = 'royalblue', label= '$Q_{SD}$')
ax3.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx], SDflow_avg-SDflow_std, SDflow_avg+SDflow_std,
color='royalblue',alpha=.5)
ax1.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx],SDpressures_avg,
ls = '-', color = 'gray', label= '$p_{SD}$')
ax1.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx], SDpressures_avg-SDpressures_std, SDpressures_avg+SDpressures_std,
color='gray',alpha=.5)
ax1.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx],Gpressures_avg,
ls = '-', color = 'k', label= '$p_{G}$')
ax1.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx], Gpressures_avg-Gpressures_std, Gpressures_avg+Gpressures_std,
color='k',alpha=.5)
#ax2.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx-fs*bufferpre],SDpressures_avg/SDflow_avg,
# ls = '-', color = 'k', label= '$R_{SD}$')
#ax2.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx-fs*bufferpre], SDpressures_avg/SDflow_avg+SDpressures_std+SDflow_std, SDflow_avg/SDpressures_avg-SDpressures_std-SDflow_std,
# color='k',alpha=.5)
ax1.axvspan(0, tmemorygreen,
alpha=0.3, color='silver')
ax1.legend(fontsize=legendfont,bbox_to_anchor=(.5, .55))
ax3.legend(fontsize=legendfont,bbox_to_anchor=(1, .3))
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
#ax2.spines['right'].set_visible(False)
#ax2.spines['top'].set_visible(False)
#ax2.spines['left'].set_visible(True)
#ax2.spines['bottom'].set_visible(True)
#ax2.grid(False)
ax3.spines['right'].set_visible(False)
ax3.spines['top'].set_visible(False)
ax3.spines['right'].set_visible(True)
ax3.spines['bottom'].set_visible(True)
ax3.grid(False)
ax1.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax1.set_ylabel("$p$ (kPa)",fontsize=int(labelfontsize))
ax3.set_ylabel("$Q$ (SLPM)",fontsize=int(labelfontsize),color='royalblue')
ax3.tick_params(colors='royalblue', which='both') # 'both' refers to minor and major axes
ax1.xaxis.set_tick_params(labelsize=int(ticks_size))
ax1.yaxis.set_tick_params(labelsize=int(ticks_size))
#ax2.xaxis.set_tick_params(labelsize=int(ticks_size))
#ax2.yaxis.set_tick_params(labelsize=int(ticks_size))
ax3.xaxis.set_tick_params(labelsize=int(ticks_size))
ax3.yaxis.set_tick_params(labelsize=int(ticks_size))
plt.tight_layout()
#ax.set_ylim(-5,60)
plt.savefig(result_folder+'\\S3_34.png', dpi=dpi,transparent=transparentsave)
SDgreen = SDflow_avg
SDgreenstd = SDflow_std
Ggreen = Gpressures_avg
Ggreenstd = Gpressures_std
Tgreen = df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx]
bufferpre = 2
SDpressures = []
Gpressures = []
SDflow = []
for i in range(10,15):
print(i)
startidx = np.where(df.Time == rising_edges[i])[0][0]
endidx = startidx+38*fs
SDpressures.append(np.asarray(df.pSD[startidx-fs*bufferpre:endidx]))
Gpressures.append(np.asarray(df.pG[startidx-fs*bufferpre:endidx]))
SDflow.append(np.asarray(df.Q[startidx-fs*bufferpre:endidx]))
#evaluate averages and stds
SDflow_avg = np.mean(SDflow,axis=0)
SDpressures_avg = np.mean(SDpressures,axis=0)
Gpressures_avg = np.mean(Gpressures,axis=0)
SDflow_std = np.std(SDflow,axis=0)
SDpressures_std = np.std(SDpressures,axis=0)
Gpressures_std = np.std(Gpressures,axis=0)
idxclosed = np.where(SDflow_avg>0.001)[0][-1]
idxopen = np.where(SDflow_avg>SDflow_avg.max()*.95)[0][0]
tmemoryyellow = (idxopen-idxclosed)/fs
fig= plt.figure(figsize=[int(sizehalfcol),int(sizehalfcol*3/2)])
fig.suptitle('Radius = .23mm, Length = 6.35mm',fontsize=10)
ax1 = fig.add_subplot(211) #top left
#ax2 = fig.add_subplot(212) #top left
ax3 = ax1.twinx()
ax3.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx],SDflow_avg,
ls = '-', color = 'royalblue', label= '$Q_{SD}$')
ax3.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx], SDflow_avg-SDflow_std, SDflow_avg+SDflow_std,
color='royalblue',alpha=.5)
ax1.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx],SDpressures_avg,
ls = '-', color = 'gray', label= '$p_{SD}$')
ax1.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx], SDpressures_avg-SDpressures_std, SDpressures_avg+SDpressures_std,
color='gray',alpha=.5)
ax1.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx],Gpressures_avg,
ls = '-', color = 'k', label= '$p_{G}$')
ax1.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx], Gpressures_avg-Gpressures_std, Gpressures_avg+Gpressures_std,
color='k',alpha=.5)
#ax2.plot(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx-fs*bufferpre],SDpressures_avg/SDflow_avg,
# ls = '-', color = 'k', label= '$R_{SD}$')
#ax2.fill_between(df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx-fs*bufferpre], SDpressures_avg/SDflow_avg+SDpressures_std+SDflow_std, SDflow_avg/SDpressures_avg-SDpressures_std-SDflow_std,
# color='k',alpha=.5)
ax1.axvspan(0, - tmemoryyellow,
alpha=0.3, color='silver')
ax1.legend(fontsize=legendfont,bbox_to_anchor=(.73, .5))
ax3.legend(fontsize=legendfont,bbox_to_anchor=(.91, .26))
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
#ax2.spines['right'].set_visible(False)
#ax2.spines['top'].set_visible(False)
#ax2.spines['left'].set_visible(True)
#ax2.spines['bottom'].set_visible(True)
#ax2.grid(False)
ax3.spines['right'].set_visible(False)
ax3.spines['top'].set_visible(False)
ax3.spines['right'].set_visible(True)
ax3.spines['bottom'].set_visible(True)
ax3.grid(False)
ax1.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax1.set_ylabel("$p$ (kPa)",fontsize=int(labelfontsize))
ax3.set_ylabel("$Q$ (SLPM)",fontsize=int(labelfontsize),color='royalblue')
ax3.tick_params(colors='royalblue', which='both') # 'both' refers to minor and major axes
ax1.xaxis.set_tick_params(labelsize=int(ticks_size))
ax1.yaxis.set_tick_params(labelsize=int(ticks_size))
#ax2.xaxis.set_tick_params(labelsize=int(ticks_size))
#ax2.yaxis.set_tick_params(labelsize=int(ticks_size))
ax3.xaxis.set_tick_params(labelsize=int(ticks_size))
ax3.yaxis.set_tick_params(labelsize=int(ticks_size))
plt.tight_layout()
#ax.set_ylim(-5,60)
plt.savefig(result_folder+'\\S3_36.png', dpi=dpi,transparent=transparentsave)
SDyellow = SDflow_avg
SDyellowstd = SDflow_std
Gyellow = Gpressures_avg
Gyellowstd = Gpressures_std
Tyellow = df.Time[startidx-fs*bufferpre:endidx]-df.Time[startidx]
###From here global data analysis
lengs = [2.54/2,2.54/2,2.54/2,2.54/2,2.54/4,2.54/4]*10
radii = [.31,.42,.7,.8,.27,.23]
times = [tmemorylavander,tmemorywhite,tmemoryblue,tmemorypurple,tmemorygreen,-tmemoryyellow]
times = [tmemorylavander,tmemorywhite,tmemoryblue,tmemorypurple,tmemorygreen,-tmemoryyellow]
plt.show()
fig= plt.figure(figsize=[sizehalfcol*2/3,sizehalfcol*3/4])
ax = fig.add_subplot(111) #top left
ax.scatter(np.divide(radii,1)[:-2],times[:-2], marker='o',color='k', label='Length = %.2fmm'%(2.54*10/2), s=10)
ax.scatter(np.divide(radii,1)[-2:],times[-2:], marker='^',color='k', label='Length = %.2fmm'%(2.54*10/4), s=10)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
ax.grid(False)
ax.set_xlabel("Radius (mm)",fontsize=int(labelfontsize))
ax.set_ylabel("$t_{\\mathrm{memory}} (s)$",fontsize=int(labelfontsize))
plt.tight_layout()
#plt.legend(fontsize=legendfont)
#ax.set_ylim(-5,60)
ax.xaxis.set_tick_params(labelsize=int(ticks_size))
ax.yaxis.set_tick_params(labelsize=int(ticks_size))
plt.legend(fontsize=ticks_size, loc='upper right')#)
plt.savefig(result_folder+'\\S3_memory.png', dpi=dpi,transparent=transparentsave)
def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):
new_cmap = colors.LinearSegmentedColormap.from_list(
'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),
cmap(np.linspace(minval, maxval, n)))
return new_cmap
from matplotlib import colors
###########################
#And now summing up plots
###########################
Qtracks = [SDgreen, SDyellow, SDlavander, SDwhite, SDblue, SDpurple] #flows
Qstdtracks = [SDgreenstd, SDyellowstd, SDlavanderstd, SDwhitestd, SDbluestd, SDpurplestd]
Gtracks = [Ggreen, Gyellow, Glavander, Gwhite, Gblue, Gpurple] #pressures
Gstdtracks = [Ggreenstd, Gyellowstd, Glavanderstd, Gwhitestd, Gbluestd, Gpurplestd]
Ttracks = [Tgreen, Tyellow, Tlavander, Twhite, Tblue, Tpurple]
cmap_flow = matplotlib.cm.get_cmap('viridis')#cmc.buda#matplotlib.cm.get_cmap('Blues')
#cmap_flow = matplotlib.cm.get_cmap('Greens_r')
cmap_G = matplotlib.cm.get_cmap('Greys_r')
cmap_flow_trunc = truncate_colormap(cmap_flow, minval=.1, maxval=.99, n=256)
cmap_G_trunc = truncate_colormap(cmap_G, minval=.2, maxval=.7, n=256)
rgbas_Q = []
rgbas_G = []
for k in range(len(Qtracks)):
rgbas_Q.append(cmap_flow_trunc(k/len(Qtracks)))
rgbas_G.append(cmap_G_trunc(k/len(Qtracks)))
lengssorted = [2.54/4,2.54/4,2.54/2,2.54/2,2.54/2,2.54/2]*10
radiisorted = [.23,.27,.31,.42,.7,.8,]
fig= plt.figure(figsize=[int(sizehalfcol)*1.5,int(sizehalfcol)*1.35])
ax = fig.add_subplot(211) #top left
ax2 = fig.add_subplot(212) #top left
for i in range(len(Qtracks)):
ax.plot(Ttracks[i],Qtracks[i], color=rgbas_Q[i], label='Length = %.2fmm, Radius=%.2fmm'%(lengssorted[i]*10, radiisorted[i]) )
ax.fill_between(Ttracks[i], Qtracks[i]-Qstdtracks[i], Qtracks[i]+Qstdtracks[i],
color=rgbas_Q[i],alpha=.5)
ax2.plot(Ttracks[i],Gtracks[i], color=rgbas_Q[i] )
ax2.fill_between(Ttracks[i], Gtracks[i]-Gstdtracks[i], Gtracks[i]+Qstdtracks[i],
color=rgbas_Q[i],alpha=.5)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
ax.grid(False)
ax.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax.set_ylabel("$Q$ (SLPM)",fontsize=int(labelfontsize))
ax.set_xlim(0,40)
ax.set_ylim(0,7)
ax2.spines['right'].set_visible(False)
ax2.spines['top'].set_visible(False)
ax2.spines['left'].set_visible(True)
ax2.spines['bottom'].set_visible(True)
ax2.grid(False)
ax2.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax2.set_ylabel("$p_{\\mathrm{G}}$ (kPa)",fontsize=int(labelfontsize))
ax2.set_xlim(0,40)
#ax2.set_ylim(0,7)
ax.xaxis.set_tick_params(labelsize=int(ticks_size))
ax.yaxis.set_tick_params(labelsize=int(ticks_size))
ax2.xaxis.set_tick_params(labelsize=int(ticks_size))
ax2.yaxis.set_tick_params(labelsize=int(ticks_size))
plt.tight_layout(h_pad=10)
handles, labels = ax.get_legend_handles_labels()
fig.legend(handles, labels,bbox_to_anchor=(.9, 1.25),ncol=2,fontsize=legendfont*.725)
plt.savefig(result_folder+'\\S3_memory_flowpressure.png', dpi=dpi,transparent=transparentsave,bbox_inches='tight')
Supplementary3_NO_memory Supplementary3_NO_memory_bis Supplementary3_NO_memory_bis 1819 5 6 7 8 9 10 11 12 13 14
Figure S18¶
In [21]:
df = data[0][12]
print(data[1]['Samplename'][12])
fs = data[1]['Samplerate'][12] # in Hz
df["pSD"] = (((df["SSCDP30-9"])*2/2.5)*101.3250)
df["pG"] = (((df["SSCDP15-4"])/2.5)*101.3250)
df["Q"] = df["AWM20-12"]
rising_edges = np.asarray(df.Time.iloc[rising_edge(df['DigOut-1'],1)])
rising_edges[0] -= df.Time.iloc[0]
df.Time = df.Time - df.Time.iloc[0]
t0 = df.Time.iloc[np.where(np.asarray(abs(df.Time - rising_edges[0]))<.0005 )[0][0]]
plt.show()
fig= plt.figure(figsize=[int(sizehalfcol),int(sizehalfcol)])
ax1 = fig.add_subplot(311) #top left
ax2 = fig.add_subplot(312) #top left
ax3 = fig.add_subplot(313) #top left
ax1.plot(df.Time-t0, df.pSD, color = 'gray')
ax2.plot(df.Time-t0, df.pG, color = 'k')
ax3.plot(df.Time-t0, df.Q, color = 'royalblue')
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
ax2.spines['right'].set_visible(False)
ax2.spines['top'].set_visible(False)
ax2.spines['left'].set_visible(True)
ax2.spines['bottom'].set_visible(True)
ax2.grid(False)
ax3.spines['right'].set_visible(False)
ax3.spines['top'].set_visible(False)
ax3.spines['left'].set_visible(True)
ax3.spines['bottom'].set_visible(True)
ax3.grid(False)
ax3.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax1.set_ylabel("$p_{\\mathrm{SD}}$ (kPa)",fontsize=int(labelfontsize))
ax2.set_ylabel("$p_{\\mathrm{G}}$ (kPa)",fontsize=int(labelfontsize))
ax3.set_ylabel("$Q_{\\mathrm{SD}}$ (SLPM)",fontsize=int(labelfontsize))
ax1.xaxis.set_tick_params(labelsize=int(ticks_size))
ax1.yaxis.set_tick_params(labelsize=int(ticks_size))
ax2.xaxis.set_tick_params(labelsize=int(ticks_size))
ax2.yaxis.set_tick_params(labelsize=int(ticks_size))
ax3.xaxis.set_tick_params(labelsize=int(ticks_size))
ax3.yaxis.set_tick_params(labelsize=int(ticks_size))
ax1.set_xlim(20,600)
ax2.set_xlim(20,600)
ax3.set_xlim(20,600)
ax3.set_ylim(-.2,1)
ax1.vlines(t0,0, np.max(df.pSD), ls = '--', color='gray')
ax2.vlines(t0,0, np.max(df.pG), ls = '--', color='gray')
ax3.vlines(t0,0, 1, ls = '--', color='gray')
plt.savefig(result_folder+'\\S3_longmemory_flowpressure_singlecol.png', dpi=dpi,transparent=transparentsave)
Supplementary3_NO_memory_tris
Figure S19¶
In [22]:
from matplotlib import colors
from matplotlib.colors import LogNorm
import scipy.ndimage
from scipy.ndimage.filters import gaussian_filter
from matplotlib.ticker import LogFormatter
#data = FluidicSetupFunctions.LoadData(Foldernames=Foldernames, Location = Location)
expidx = 14
df = data[0][expidx]
expname = data[1]['Samplename'][expidx]
print(expname)
fs = data[1]['Samplerate'][expidx] # in Hz
df["pG_freq"] = df["MPX700-2"] /1000
df["Q"] = (df["AWM20-1"])
df['pValvePre'] = (((df["SSCDP05-3"])*2/2.5)*101.3250)
df["pValvePost"] = df["MPX100-11"] /1000
df['pAct'] = (((df["SSCDP15-9"])*2/2.5)*101.3250)
df['pG_ampl'] = (((df["SSCDP15-4"])*2/2.5)*101.3250)
legendfont = 11 # 9
labelfontsize = 11 # 9
ticks_size=9 # 7
rising_edges = np.asarray(df.Time.iloc[rising_edge(df['DigOut-1'],1)])+10
falling_edges = rising_edges+20 #20s from spicy
falling_edges[-32:-24] = rising_edges[-32:-24]+40
falling_edges[-24:-16] = rising_edges[-24:-16]+120
falling_edges[-16:-8] = rising_edges[-16:-8]+300
falling_edges[-8:] = rising_edges[-8:]+300
#falling_edges[-2*7:-1*7] = rising_edges[-2*7:-1*7] + 45 #7 runs per settings of pgatefrq
#falling_edges[-1*7:] = rising_edges[-1*7:] + 120 #7 runs per settings of pgatefrq
rising_edges = rising_edges +10
print(df.Time.max())
legendfont = 11 # 9
labelfontsize = 11 # 9
ticks_size=9 # 7
pActMaxAmplAvg = []
pActMaxPeakPeakAmplAvg = []
pActDeltaTAvg = []
pGfreqAvg = []
pGAmplAvg = []
pActMaxAmplStd = []
pActMaxPeakPeakAmplStd = []
pActDeltaTStd = []
pGfreqStd = []
pGAmplStd = []
nfailed =0
lw = 1
for i in range(len(rising_edges)):
# print(i)
#print(rising_edges[i],falling_edges[i], end='\r')
dftemp = df[(df.Time>rising_edges[i]) & (df.Time<falling_edges[i])]
freqpeaks, _ = find_peaks(dftemp.pValvePost, height=(30, 90))
amplpeaks, _ = find_peaks(dftemp.pAct, height=(dftemp.pAct.max()*.85, dftemp.pAct.max()*1.05))
minimavalue_peaks, _ = find_peaks(dftemp.pAct, height=(dftemp.pAct.min()*.9, dftemp.pAct.min()*1.5),width=10)
pActDeltaTAvg.append(np.mean(np.diff(np.asarray(dftemp.Time.iloc[freqpeaks]))))
pActDeltaTStd.append(np.std(np.diff(np.asarray(dftemp.Time.iloc[freqpeaks]))))
pActMaxAmplAvg.append(np.mean(np.asarray(dftemp.pAct.iloc[amplpeaks])))
pActMaxAmplStd.append(np.std(np.asarray(dftemp.pAct.iloc[amplpeaks])))
ppaverage = np.mean(np.asarray(dftemp.pAct.iloc[amplpeaks])) - np.mean(np.asarray(dftemp.pAct.iloc[minimavalue_peaks]))
ppstd = np.std(np.asarray(dftemp.pAct.iloc[amplpeaks])) + np.std(np.asarray(dftemp.pAct.iloc[minimavalue_peaks]))
if len(minimavalue_peaks)==0:
# print('foundnan, minimalpeaks failed')
ppaverage = np.mean(np.asarray(dftemp.pAct.iloc[amplpeaks]))
ppstd = np.mean(np.asarray(dftemp.pAct.iloc[amplpeaks]))/2
nfailed+=1
# print(ppaverage)
pActMaxPeakPeakAmplAvg.append(ppaverage)
pActMaxPeakPeakAmplStd.append(ppstd)
pGfreqAvg.append(np.mean(np.asarray(dftemp.pG_freq)))
pGfreqStd.append(np.std(np.asarray(dftemp.pG_freq)))
pGAmplAvg.append(np.mean(np.asarray(dftemp.pG_ampl)))
pGAmplStd.append(np.std(np.asarray(dftemp.pG_ampl)))
freqdata = np.divide(1,np.asarray(pActDeltaTAvg).reshape((19,8)))
cutidx = 7
resultdf = pd.DataFrame([pActMaxAmplAvg,pActDeltaTAvg,pGfreqAvg,pGAmplAvg,pActMaxAmplStd,pActDeltaTStd,pGfreqStd,pGAmplStd,pActMaxPeakPeakAmplAvg,pActMaxPeakPeakAmplStd]).T
sigmagaussian = 2
datafreq=gaussian_filter(freqdata, sigmagaussian)
def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):
new_cmap = colors.LinearSegmentedColormap.from_list(
'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),
cmap(np.linspace(minval, maxval, n)))
return new_cmap
#imola_truc = truncate_colormap(cmc.bamako, minval=0.0, maxval=.9, n=256)
imola_truc = truncate_colormap(cmc.imola, minval=0, maxval=1, n=256)
lipari_trunc = truncate_colormap(cmc.lipari, minval=0, maxval=1, n=256)
cmap_trunc = truncate_colormap(cmc.tokyo, minval=0, maxval=1, n=256)
cmap2 = imola_truc #time
cmap_discr = lipari_trunc #nsteps
cmap3 = cmap_trunc #nsteps
norm = colors.BoundaryNorm(np.linspace(0,20, 100), cmap_discr.N)
norm2 = colors.BoundaryNorm(np.linspace(0,10, 100), cmap2.N)
norm3 = colors.BoundaryNorm(np.linspace(0,10, 100), cmap3.N)
rgbas_P = []
rgbas_PP = []
rgbas_DeltaT = []
for k in range(len(pActMaxAmplAvg)):
rgbas_P.append(cmap2(pActMaxAmplAvg[k]/np.max(pActMaxAmplAvg)))
rgbas_PP.append(cmap_discr(pActMaxPeakPeakAmplAvg[k]/np.max(pActMaxPeakPeakAmplAvg)))
rgbas_DeltaT.append(cmap_discr(pActDeltaTAvg[k]/np.max(pActDeltaTAvg)))
if True: #SupplementaryPlot
fig= plt.figure(figsize=[int(sizehalfcol)*2,int(sizehalfcol)*.9])
ax1 = fig.add_subplot(131) #top left
ax2 = fig.add_subplot(132) #top left
ax3 = fig.add_subplot(133) #top left
ax1.set_title("$p_{Act.}$ (kPa)", fontsize=ticks_size)
im0 = ax1.imshow(np.asarray(pActMaxAmplAvg).reshape((19,8)), cmap=cmap2, vmin=np.min(pActMaxAmplAvg), vmax=np.max(pActMaxAmplAvg)+2, origin='lower',
interpolation='nearest', aspect='.75')
ax2.set_title("$f_{Act.}$ (Hz)", fontsize=ticks_size)
im1 = ax2.imshow(freqdata, cmap=cmap_discr,
norm=LogNorm(vmin=np.min(freqdata), vmax=np.max(freqdata)+2),
#vmin=np.min(freqdata), vmax=np.max(freqdata)+2,
origin='lower',aspect='.75' )
ax3.set_title("$\\Delta p_{Act.}$ (kPa)", fontsize=ticks_size)
im2 = ax3.imshow(np.asarray(pActMaxPeakPeakAmplAvg).reshape((19,8)), cmap=cmap3, vmin=np.min(pActMaxPeakPeakAmplAvg), vmax=np.max(pActMaxPeakPeakAmplAvg)+2, origin='lower',
interpolation='nearest', aspect='.75')
#norm=LogNorm(vmin=0.01, vmax=40), origin='lower')
ax1.xaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax2.xaxis.set_tick_params(labelsize=ticks_size)
ax2.yaxis.set_tick_params(labelsize=ticks_size)
ax3.xaxis.set_tick_params(labelsize=ticks_size)
ax3.yaxis.set_tick_params(labelsize=ticks_size)
ax1.xaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
ax1.set_xlabel("$p_{G,Ampl.}$ (kPa)",fontsize=labelfontsize)
ax1.set_ylabel("$p_{G,\,f}$ (kPa)",fontsize=labelfontsize)
ax2.xaxis.set_tick_params(labelsize=ticks_size)
ax2.yaxis.set_tick_params(labelsize=ticks_size)
ax2.yaxis.set_tick_params(labelsize=ticks_size)
ax2.spines['right'].set_visible(False)
ax2.spines['top'].set_visible(False)
ax2.spines['left'].set_visible(True)
ax2.spines['bottom'].set_visible(True)
ax2.grid(False)
ax2.set_xlabel("$p_{G,Ampl.}$ (kPa)",fontsize=labelfontsize)
ax2.set_ylabel("$p_{G,\,f}$ (kPa)",fontsize=labelfontsize)
ax3.xaxis.set_tick_params(labelsize=ticks_size)
ax3.yaxis.set_tick_params(labelsize=ticks_size)
ax3.yaxis.set_tick_params(labelsize=ticks_size)
ax3.spines['right'].set_visible(False)
ax3.spines['top'].set_visible(False)
ax3.spines['left'].set_visible(True)
ax3.spines['bottom'].set_visible(True)
ax3.grid(False)
ax3.set_xlabel("$p_{G,Ampl.}$ (kPa)",fontsize=labelfontsize)
ax3.set_ylabel("$p_{G,\,f}$ (kPa)",fontsize=labelfontsize)
cbar0 = plt.colorbar(im0, ax=ax1,ticks=np.linspace(np.min(pActMaxAmplAvg), np.max(pActMaxAmplAvg)+2, 6, 6), format = '%d',fraction=0.079, pad=0.04)
cbar1 = plt.colorbar(im1,ax=ax2,
ticks=[0.01,0.05,.1,.5,1,2,4],#np.linspace(np.min(freqdata), np.max(freqdata)+.5, 5),
fraction=0.079, pad=0.04, format='%.2f')
cbar2 = plt.colorbar(im2, ax=ax3,ticks=np.linspace(np.min(pActMaxPeakPeakAmplAvg), np.max(pActMaxPeakPeakAmplAvg)+2, 5, 6), format = '%d',fraction=0.079, pad=0.04)
cbar0.ax.tick_params(labelsize=ticks_size)
cbar1.ax.tick_params(labelsize=ticks_size)
cbar2.ax.tick_params(labelsize=ticks_size)
#cbar0.set_label('$(kPa)$', rotation=-0, fontsize = labelfontsize, labelpad=5)
#cbar1.set_label('$(s)$', rotation=-0, fontsize = labelfontsize, labelpad=5)
ax1.set_xticks((0,3,7))
ax1.set_yticks((0,4,8,12,16))
ax1.set_xticklabels(('0','15','30'), rotation=30)
ax1.set_yticklabels(('0','20','40', '60', '80'), rotation=30)
ax2.set_xticks((0,3,7))
ax2.set_yticks((0,4,8,12,16))
ax2.set_xticklabels(('0','15','30'), rotation=30)
ax2.set_yticklabels(('0','20','40', '60', '80'), rotation=30)
ax3.set_xticks((0,3,7))
ax3.set_yticks((0,4,8,12,16))
ax3.set_xticklabels(('0','15','30'), rotation=30)
ax3.set_yticklabels(('0','20','40', '60', '80'), rotation=30)
#ax1.set_xlim(.5,6.5)
#ax2.set_xlim(.5,6.5)
#ax1.set_ylim(0,15)
#ax2.set_ylim(0,15)
#ax3.set_ylim(0,15)
plt.savefig(result_folder+'\\Ampl&FreqControlV6_heatmaps_new.png', dpi=dpi,transparent=transparentsave, bbox_inches = 'tight')
VariablesAmplitude&Frequencyv06 10015.4
Figure S20¶
In [23]:
from matplotlib import colors
df = data[0][7]
print(data[1]['Samplename'][7])
df['p2'] = (7/1000)*df["MPX100-10"] #was a 7bar sensor, pre hyst valve
df['p1'] = (7/1000)*df["MPX100-4"] #was a 7bar sensortselect = 37 #selecting time of experimentInputP = df.PREG.iloc[-3000:].mean()
#preparing data, converting to kPa the SSCDP sensors
VAs = [.1,.2,.3,.1,.2,.3,.1,.1]
VBs = [.75,.75,.75,1.15,1.15,1.15,.2,.3]
tselectstarts = [40,137,239,433,510,622,831,900]
tselectends = [74.5,176.5,282,485,565,672,845,922]
nsteps = [6,4,3,9,5,4,3,4]
dfs = []
deltaTloops = []
def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):
new_cmap = colors.LinearSegmentedColormap.from_list(
'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),
cmap(np.linspace(minval, maxval, n)))
return new_cmap
#imola_truc = truncate_colormap(cmc.bamako, minval=0.0, maxval=.9, n=256)
#imola_truc = truncate_colormap(matplotlib.cm.get_cmap('viridis'), minval=0.0, maxval=.9, n=256)
cmapdiscrdata = truncate_colormap(cmc.nuuk, minval=0.0, maxval=.9, n=256)
lipari_trunc = truncate_colormap(cmc.lipari, minval=0, maxval=.8, n=256)
discrdiff = truncate_colormap(cmc.vik, minval=0, maxval=.8, n=256)
cmap2 = cmapdiscrdata #time
cmap_discr = lipari_trunc #nsteps
cmap_discrDiff = discrdiff
norm = colors.BoundaryNorm(np.arange(2, 10.5, 1), cmap_discr.N)
norm2 = colors.BoundaryNorm(np.linspace(3,10.5, 256), cmap2.N)
norm3 = colors.BoundaryNorm(np.linspace(-2,2, 256), cmap2.N)
#norm3 = colors.BoundaryNorm(np.arange(-2, 2, 1), cmap2.N)
sizemaker = 400
fig= plt.figure(figsize=[int(sizehalfcol)*2,int(sizehalfcol*1.75)])
#fig= plt.figure(figsize=[int(5),int(5)])
ax0 = fig.add_subplot(131) #top left
ax1 = fig.add_subplot(132) #top left
ax2 = fig.add_subplot(133) #top left
for exp in range(len(VAs)):
#select df of experiment
dftemp = df[df.Time>tselectstarts[exp]]
dftemp = dftemp[dftemp.Time<tselectends[exp]]
#process peaks
peaks, _ = find_peaks(dftemp.p2, height=(31, 40), prominence=2)
deltaTloop = (np.asarray(dftemp.Time.iloc[peaks][1:]) - np.asarray(dftemp.Time.iloc[peaks][:-1]) ).mean()
if len(str(VBs[exp])[1:])==2:
dfs.append(['$V_{1}=%.1f L$, $V_{2}=%.1f L$'%(VAs[exp],VBs[exp]), dftemp,nsteps[exp],deltaTloop])
else:
dfs.append(['$V_{1}=%.1f L$, $V_{2}=%.2f L$'%(VAs[exp],VBs[exp]), dftemp,nsteps[exp],deltaTloop])
deltaTloops.append(deltaTloop)
matForloopNsteps = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
matForloopDeltaT = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
matPredictionNstep = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
matPredictionDeltaT = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
for idx in range(len(VAs)):
idxVA = np.where(VAs[idx]==np.unique(VAs))[0][0]
idxVB = np.where(VBs[idx]==np.unique(VBs))[0][0]
matForloopNsteps[idxVB][idxVA] = nsteps[idx]
matForloopDeltaT[idxVB][idxVA] = deltaTloops[idx]
matPredictionNstep[idxVB][idxVA] = (32/38)*VBs[idx]/VAs[idx]
matPredictionDeltaT[idxVB][idxVA] = (3e4)*(VAs[idx]*10*1e-4) / (8.3145 *293 * 1.4e-3)# #DeltaP*V[L]/(RTQ)* 0.029/(1.125*8.3145*293* 2 ) * 60
#Mask out missing for loop data
matForloopNsteps = np.ma.masked_where(matForloopNsteps==0, matForloopNsteps)
matForloopDeltaT = np.ma.masked_where(matForloopDeltaT==0, matForloopDeltaT)
matPredictionNstep = np.ma.masked_where(matPredictionNstep==0, matPredictionNstep)
matPredictionDeltaT = np.ma.masked_where(matPredictionDeltaT==0, matPredictionDeltaT)
im0 = ax0.imshow(matForloopNsteps,cmap=cmap_discr, origin ='lower', vmin=2,vmax=10)
im1 = ax1.imshow(matPredictionNstep,cmap=cmap2, origin ='lower', vmin=2,vmax=11)
im2 = ax2.imshow(matForloopNsteps-matPredictionNstep,cmap=cmap_discrDiff, origin ='lower', vmin=-3,vmax=3)
ax0.set_title('$N_{exp}$', fontsize=labelfontsize)
ax1.set_title('$N_{model}$', fontsize=labelfontsize)
ax2.set_title('$N_{exp} - N_{model}$', fontsize=labelfontsize)
ax0.xaxis.set_tick_params(labelsize=ticks_size)
ax0.yaxis.set_tick_params(labelsize=ticks_size)
ax0.spines['right'].set_visible(False)
ax0.spines['top'].set_visible(False)
ax0.spines['left'].set_visible(True)
ax0.spines['bottom'].set_visible(True)
ax0.grid(False)
ax0.set_xlabel("$V_{1}$ (L)",fontsize=labelfontsize)
ax0.set_ylabel("$V_{2}$ (L)",fontsize=labelfontsize)
ax1.xaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
ax1.set_xlabel("$V_{1}$ (L)",fontsize=labelfontsize)
#ax1.set_ylabel("$V_{2} (L)$",fontsize=labelfontsize, )
ax2.xaxis.set_tick_params(labelsize=ticks_size)
ax2.yaxis.set_tick_params(labelsize=ticks_size)
ax2.spines['right'].set_visible(False)
ax2.spines['top'].set_visible(False)
ax2.spines['left'].set_visible(True)
ax2.spines['bottom'].set_visible(True)
ax2.grid(False)
ax2.set_xlabel("$V_{1}$ (L)",fontsize=labelfontsize)
#ax2.set_ylabel("$V_{2} (L)$",fontsize=labelfontsize, )
cbar0 = plt.colorbar(im0, ax=ax0,ticks=np.linspace(2.5, 10.5, 9), format = '%d',fraction=0.06, pad=0.04)
cbar1 = plt.colorbar(im1, ax=ax1,ticks=np.linspace(2.5, 10.5, 9),format = '%d',fraction=0.06, pad=0.04)
cbar2 = plt.colorbar(im2, ax=ax2,format = '%d',ticks=np.linspace(-2, 2, 7),fraction=0.06, pad=0.04)
cbar0.ax.tick_params(labelsize=labelfontsize)
cbar1.ax.tick_params(labelsize=labelfontsize)
cbar2.ax.tick_params(labelsize=labelfontsize)
cbar0.set_label('$(\,-\,)$', rotation=-0, fontsize = labelfontsize, labelpad=10)
cbar1.set_label('$(\,-\,)$', rotation=-0, fontsize = labelfontsize, labelpad=10)
cbar2.set_label('$(\,-\,)$', rotation=-0, fontsize = labelfontsize, labelpad=10)
ax0.set_xticks((0,1,2))
ax0.set_xticklabels(('$.1$','$.2$', '$.3$'))
ax0.set_yticks((0,1,2,3))
ax0.set_yticklabels(('$.2$','$.3$', '$.75$', '$1.15$'))
ax1.set_xticks((0,1,2))
ax1.set_xticklabels(('$.1$','$.2$', '$.3$'))
ax1.set_yticks((0,1,2,3))
ax1.set_yticklabels(('$.2$','$.3$', '$.75$', '$1.15$'))
ax2.set_xticks((0,1,2))
ax2.set_xticklabels(('$.1$','$.2$', '$.3$'))
ax2.set_yticks((0,1,2,3))
ax2.set_yticklabels(('$.2$','$.3$', '$.75$', '$1.15$'))
labelx = -0.3 # axes coords
#ax0.text(0,0,'$\\gamma$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax1.text(0,0,'$\\gamma$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax0.text(0,3,'$\\alpha$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax1.text(0,3,'$\\alpha$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax0.text(2,3,'$\\beta$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax1.text(2,3,'$\\beta$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax0.scatter(0,0,marker='*',color='white') #gamma
#ax1.scatter(0,0,marker='*',color='white')
#ax0.scatter(0,3,marker='o',color='white') #alfa
#ax1.scatter(0,3,marker='o',color='white')
#ax0.scatter(2,3,marker='^',color='white') #beta
#ax1.scatter(2,3,marker='^',color='white')
#ax0.yaxis.set_label_coords(labelx, 0.5)
#ax1.yaxis.set_label_coords(labelx, 0.5)
#ax0.set_xlim(.08,.31)
#ax0.set_ylim(.1,1.25)
#ax[1].set_ylim(.1,1.25)
plt.subplots_adjust(hspace=-.05)
#plt.tight_layout()
plt.savefig(result_folder+'\\3ChangingVolumesSI_N.png', dpi=dpi,transparent=transparentsave,bbox_inches = 'tight')
plt.show()
from matplotlib import colors
df = data[0][7]
df['p2'] = (7/1000)*df["MPX100-10"] #was a 7bar sensor, pre hyst valve
df['p1'] = (7/1000)*df["MPX100-4"] #was a 7bar sensortselect = 37 #selecting time of experimentInputP = df.PREG.iloc[-3000:].mean()
#preparing data, converting to kPa the SSCDP sensors
VAs = [.1,.2,.3,.1,.2,.3,.1,.1]
VBs = [.75,.75,.75,1.15,1.15,1.15,.2,.3]
tselectstarts = [40,137,239,433,510,622,831,900]
tselectends = [74.5,176.5,282,485,565,672,845,922]
nsteps = [6,4,3,9,5,4,3,4]
dfs = []
deltaTloops = []
def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):
new_cmap = colors.LinearSegmentedColormap.from_list(
'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),
cmap(np.linspace(minval, maxval, n)))
return new_cmap
#imola_truc = truncate_colormap(cmc.bamako, minval=0.0, maxval=.9, n=256)
imola_truc = truncate_colormap(matplotlib.cm.get_cmap('viridis'), minval=0.0, maxval=.9, n=256)
cmapdiscrdata = truncate_colormap(cmc.turku, minval=0.0, maxval=.9, n=256)
lipari_trunc = truncate_colormap(cmc.lipari, minval=0, maxval=.8, n=256)
discrdiff = truncate_colormap(cmc.cork, minval=0, maxval=.8, n=256)
cmapTmodel = truncate_colormap(cmc.batlow, minval=0, maxval=.8, n=256)
cmap2 = imola_truc #time
cmap_discr = lipari_trunc #nsteps
cmap_discrDiff = discrdiff
norm = colors.BoundaryNorm(np.arange(2, 10.5, 1), cmap_discr.N)
norm2 = colors.BoundaryNorm(np.linspace(3,10.5, 256), cmap2.N)
norm3 = colors.BoundaryNorm(np.linspace(-2,2, 256), cmap2.N)
sizemaker = 400
fig= plt.figure(figsize=[int(sizehalfcol)*2,int(sizehalfcol*1.75)])
#fig= plt.figure(figsize=[int(5),int(5)])
ax0 = fig.add_subplot(131) #top left
ax1 = fig.add_subplot(132) #top left
ax2 = fig.add_subplot(133) #top left
for exp in range(len(VAs)):
#select df of experiment
dftemp = df[df.Time>tselectstarts[exp]]
dftemp = dftemp[dftemp.Time<tselectends[exp]]
#process peaks
peaks, _ = find_peaks(dftemp.p2, height=(31, 40), prominence=2)
deltaTloop = (np.asarray(dftemp.Time.iloc[peaks][1:]) - np.asarray(dftemp.Time.iloc[peaks][:-1]) ).mean()
if len(str(VBs[exp])[1:])==2:
dfs.append(['$V_{1}=%.1f L$, $V_{2}=%.1f L$'%(VAs[exp],VBs[exp]), dftemp,nsteps[exp],deltaTloop])
else:
dfs.append(['$V_{1}=%.1f L$, $V_{2}=%.2f L$'%(VAs[exp],VBs[exp]), dftemp,nsteps[exp],deltaTloop])
deltaTloops.append(deltaTloop)
matForloopNsteps = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
matForloopDeltaT = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
matPredictionNstep = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
matPredictionDeltaT = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
for idx in range(len(VAs)):
idxVA = np.where(VAs[idx]==np.unique(VAs))[0][0]
idxVB = np.where(VBs[idx]==np.unique(VBs))[0][0]
matForloopNsteps[idxVB][idxVA] = nsteps[idx]
matForloopDeltaT[idxVB][idxVA] = deltaTloops[idx]
matPredictionNstep[idxVB][idxVA] = (32/38)*VBs[idx]/VAs[idx]
matPredictionDeltaT[idxVB][idxVA] = (3e4)*(VAs[idx]*10*1e-4) / (8.3145 *293 * 1.4e-3)# #DeltaP*V[L]/(RTQ)* 0.029/(1.125*8.3145*293* 2 ) * 60
#Mask out missing for loop data
matForloopNsteps = np.ma.masked_where(matForloopNsteps==0, matForloopNsteps)
matForloopDeltaT = np.ma.masked_where(matForloopDeltaT==0, matForloopDeltaT)
matPredictionNstep = np.ma.masked_where(matPredictionNstep==0, matPredictionNstep)
matPredictionDeltaT = np.ma.masked_where(matPredictionDeltaT==0, matPredictionDeltaT)
predictedDeltaT = np.multiply(matForloopNsteps,matPredictionDeltaT) #multiply by Npredict to get actual DeltaT
im0 = ax0.imshow(matForloopDeltaT,cmap=cmap2, origin ='lower', vmin=0,vmax=11)
im1 = ax1.imshow(predictedDeltaT,cmap=cmapTmodel, origin ='lower', vmin=0,vmax=11)
im2 = ax2.imshow(matForloopDeltaT-predictedDeltaT,cmap=cmap_discrDiff, origin ='lower', vmin=-2,vmax=2)
ax0.set_title('$\\Delta T_{exp}$', fontsize=labelfontsize)
ax1.set_title('$\\Delta T_{model}$', fontsize=labelfontsize)
ax2.set_title('$\\Delta T_{exp} - \\Delta T_{model}$', fontsize=labelfontsize)
ax0.xaxis.set_tick_params(labelsize=ticks_size)
ax0.yaxis.set_tick_params(labelsize=ticks_size)
ax0.spines['right'].set_visible(False)
ax0.spines['top'].set_visible(False)
ax0.spines['left'].set_visible(True)
ax0.spines['bottom'].set_visible(True)
ax0.grid(False)
ax0.set_xlabel("$V_{1}$ (L)",fontsize=labelfontsize)
ax0.set_ylabel("$V_{2}$ (L)",fontsize=labelfontsize)
ax1.xaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
ax1.set_xlabel("$V_{1}$ (L)",fontsize=labelfontsize)
#ax1.set_ylabel("$V_{2} (L)$",fontsize=labelfontsize, )
ax2.xaxis.set_tick_params(labelsize=ticks_size)
ax2.yaxis.set_tick_params(labelsize=ticks_size)
ax2.spines['right'].set_visible(False)
ax2.spines['top'].set_visible(False)
ax2.spines['left'].set_visible(True)
ax2.spines['bottom'].set_visible(True)
ax2.grid(False)
ax2.set_xlabel("$V_{1}$ (L)",fontsize=labelfontsize)
#ax2.set_ylabel("$V_{2} (L)$",fontsize=labelfontsize, )
cbar0 = plt.colorbar(im0, ax=ax0,ticks=np.linspace(2.5, 10.5, 9), format = '%.1f',fraction=0.06, pad=0.04)
cbar1 = plt.colorbar(im1, ax=ax1,ticks=np.linspace(2.5, 10.5, 9),format = '%.1f',fraction=0.06, pad=0.04)
cbar2 = plt.colorbar(im2, ax=ax2,format = '%.1f',ticks=np.linspace(-2, 2, 7),fraction=0.06, pad=0.04)
cbar0.ax.tick_params(labelsize=labelfontsize)
cbar1.ax.tick_params(labelsize=labelfontsize)
cbar2.ax.tick_params(labelsize=labelfontsize)
cbar0.set_label('$(\,$s$\,)$', rotation=-0, fontsize = labelfontsize, labelpad=5)
cbar1.set_label('$(\,$s$\,)$', rotation=-0, fontsize = labelfontsize, labelpad=5)
cbar2.set_label('$(\,$s$\,)$', rotation=-0, fontsize = labelfontsize, labelpad=5)
ax0.set_xticks((0,1,2))
ax0.set_xticklabels(('$.1$','$.2$', '$.3$'))
ax0.set_yticks((0,1,2,3))
ax0.set_yticklabels(('$.2$','$.3$', '$.75$', '$1.15$'))
ax1.set_xticks((0,1,2))
ax1.set_xticklabels(('$.1$','$.2$', '$.3$'))
ax1.set_yticks((0,1,2,3))
ax1.set_yticklabels(('$.2$','$.3$', '$.75$', '$1.15$'))
ax2.set_xticks((0,1,2))
ax2.set_xticklabels(('$.1$','$.2$', '$.3$'))
ax2.set_yticks((0,1,2,3))
ax2.set_yticklabels(('$.2$','$.3$', '$.75$', '$1.15$'))
labelx = -0.3 # axes coords
#ax0.text(0,0,'$\\gamma$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax1.text(0,0,'$\\gamma$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax0.text(0,3,'$\\alpha$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax1.text(0,3,'$\\alpha$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax0.text(2,3,'$\\beta$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax1.text(2,3,'$\\beta$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax0.scatter(0,0,marker='*',color='white') #gamma
#ax1.scatter(0,0,marker='*',color='white')
#ax0.scatter(0,3,marker='o',color='white') #alfa
#ax1.scatter(0,3,marker='o',color='white')
#ax0.scatter(2,3,marker='^',color='white') #beta
#ax1.scatter(2,3,marker='^',color='white')
#ax0.yaxis.set_label_coords(labelx, 0.5)
#ax1.yaxis.set_label_coords(labelx, 0.5)
#ax0.set_xlim(.08,.31)
#ax0.set_ylim(.1,1.25)
#ax[1].set_ylim(.1,1.25)
plt.subplots_adjust(hspace=-.05)
#plt.tight_layout()
plt.savefig(result_folder+'\\3ChangingVolumesSI_DeltaT.png', dpi=dpi,transparent=transparentsave,bbox_inches = 'tight')
Fig3_20230922_V2
Figure S21¶
In [24]:
from matplotlib import colors
df = data[0][7]
print(data[1]['Samplename'][7])
df['p2'] = (7/1000)*df["MPX100-10"] #was a 7bar sensor, pre hyst valve
df['p1'] = (7/1000)*df["MPX100-4"] #was a 7bar sensortselect = 37 #selecting time of experimentInputP = df.PREG.iloc[-3000:].mean()
#preparing data, converting to kPa the SSCDP sensors
VAs = [.1,.2,.3,.1,.2,.3,.1,.1]
VBs = [.75,.75,.75,1.15,1.15,1.15,.2,.3]
tselectstarts = [40,137,239,433,510,622,831,900]
tselectends = [74.5,176.5,282,485,565,672,845,922]
nsteps = [6,4,3,9,5,4,3,4]
dfs = []
deltaTloops = []
def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):
new_cmap = colors.LinearSegmentedColormap.from_list(
'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),
cmap(np.linspace(minval, maxval, n)))
return new_cmap
#imola_truc = truncate_colormap(cmc.bamako, minval=0.0, maxval=.9, n=256)
imola_truc = truncate_colormap(matplotlib.cm.get_cmap('viridis'), minval=0.0, maxval=.9, n=256)
lipari_trunc = truncate_colormap(cmc.lipari, minval=0, maxval=.8, n=256)
cmap2 = imola_truc #time
cmap_discr = lipari_trunc #nsteps
norm = colors.BoundaryNorm(np.arange(2, 10.5, 1), cmap_discr.N)
norm2 = colors.BoundaryNorm(np.linspace(3,10.5, 256), cmap2.N)
sizemaker = 400
fig= plt.figure(figsize=[int(sizehalfcol)*1.1,int(sizehalfcol*1.25)])
#fig= plt.figure(figsize=[int(5),int(5)])
ax0 = fig.add_subplot(221) #top left
ax1 = fig.add_subplot(224) #top left
for exp in range(len(VAs)):
#select df of experiment
dftemp = df[df.Time>tselectstarts[exp]]
dftemp = dftemp[dftemp.Time<tselectends[exp]]
#process peaks
peaks, _ = find_peaks(dftemp.p2, height=(31, 40), prominence=2)
deltaTloop = (np.asarray(dftemp.Time.iloc[peaks][1:]) - np.asarray(dftemp.Time.iloc[peaks][:-1]) ).mean()
if len(str(VBs[exp])[1:])==2:
dfs.append(['$V_{1}=%.1f L$, $V_{2}=%.1f L$'%(VAs[exp],VBs[exp]), dftemp,nsteps[exp],deltaTloop])
else:
dfs.append(['$V_{1}=%.1f L$, $V_{2}=%.2f L$'%(VAs[exp],VBs[exp]), dftemp,nsteps[exp],deltaTloop])
deltaTloops.append(deltaTloop)
matForloopNsteps = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
matForloopDeltaT = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
matPredictionNstep = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
matPredictionDeltaT = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
for idx in range(len(VAs)):
idxVA = np.where(VAs[idx]==np.unique(VAs))[0][0]
idxVB = np.where(VBs[idx]==np.unique(VBs))[0][0]
matForloopNsteps[idxVB][idxVA] = nsteps[idx]
matForloopDeltaT[idxVB][idxVA] = deltaTloops[idx]
matPredictionNstep[idxVB][idxVA] = (32/38)*VBs[idx]/VAs[idx]
matPredictionDeltaT[idxVB][idxVA] = (30)*VAs[idx] * 0.029/(1.125*8.3145*293* 2 )
#Mask out missing for loop data
matForloopNsteps = np.ma.masked_where(matForloopNsteps==0, matForloopNsteps)
matForloopDeltaT = np.ma.masked_where(matForloopDeltaT==0, matForloopDeltaT)
matPredictionNstep = np.ma.masked_where(matPredictionNstep==0, matPredictionNstep)
im0 = ax0.imshow(matForloopNsteps,cmap=cmap_discr, origin ='lower', vmin=2,vmax=10)
im1 = ax1.imshow(matForloopDeltaT,cmap=cmap2, origin ='lower', vmin=2,vmax=11)
ax0.xaxis.set_tick_params(labelsize=ticks_size)
ax0.yaxis.set_tick_params(labelsize=ticks_size)
ax0.spines['right'].set_visible(False)
ax0.spines['top'].set_visible(False)
ax0.spines['left'].set_visible(True)
ax0.spines['bottom'].set_visible(True)
ax0.grid(False)
ax0.set_xlabel("$V_{1} ($L$)$",fontsize=labelfontsize)
ax0.set_ylabel("$V_{2} ($L$)$",fontsize=labelfontsize)
ax1.xaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
#ax0.set_xlabel("$V_{1} (L)$",fontsize=labelfontsize)
ax1.set_xlabel("$V_{1} ($L$)$",fontsize=labelfontsize)
#ax1.set_ylabel("$V_{2} (L)$",fontsize=labelfontsize, )
cbar0 = plt.colorbar(im0, ax=ax0,ticks=np.linspace(2.5, 10.5, 9), format = '%d',fraction=0.06, pad=-5.04,orientation='horizontal')
cbar1 = plt.colorbar(im1, ax=ax1,format = '%d',ticks=np.linspace(2.5, 11, 6),fraction=0.06, pad=-5.04,orientation='horizontal')
cbar0.ax.tick_params(labelsize=labelfontsize)
cbar1.ax.tick_params(labelsize=labelfontsize)
cbar0.set_label('$($-$)$', rotation=-0, fontsize = labelfontsize, labelpad=8)
cbar1.set_label('$($s$)$', rotation=-0, fontsize = labelfontsize, labelpad=8)
ax0.set_xticks((0,1,2))
ax0.set_xticklabels(('$.1$','$.2$', '$.3$'))
ax0.set_yticks((0,1,2,3))
ax0.set_yticklabels(('$.2$','$.3$', '$.75$', '$1.15$'))
ax1.set_xticks((0,1,2))
ax1.set_xticklabels(('$.1$','$.2$', '$.3$'))
ax1.set_yticks((0,1,2,3))
ax1.set_yticklabels(('','', '', ''))
labelx = -0.3 # axes coords
#ax0.text(0,0,'$\\gamma$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax1.text(0,0,'$\\gamma$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax0.text(0,3,'$\\alpha$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax1.text(0,3,'$\\alpha$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax0.text(2,3,'$\\beta$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
#ax1.text(2,3,'$\\beta$',horizontalalignment='center',verticalalignment = 'center',color='white',fontsize=labelfontsize)
ax0.scatter(0,0,marker='*',color='white') #gamma
ax1.scatter(0,0,marker='*',color='white')
ax0.scatter(0,3,marker='o',color='white') #alfa
ax1.scatter(0,3,marker='o',color='white')
ax0.scatter(2,3,marker='^',color='white') #beta
ax1.scatter(2,3,marker='^',color='white')
#ax0.yaxis.set_label_coords(labelx, 0.5)
#ax1.yaxis.set_label_coords(labelx, 0.5)
#ax0.set_xlim(.08,.31)
#ax0.set_ylim(.1,1.25)
#ax[1].set_ylim(.1,1.25)
plt.subplots_adjust(hspace=-.05)
#plt.tight_layout()
plt.savefig(result_folder+'\\3ChangingVolumesnew.png', dpi=dpi,transparent=transparentsave,bbox_inches = 'tight')
plt.show()
df = data[0][7]
df['p2'] = (7/1000)*df["MPX100-10"] #was a 7bar sensor, pre hyst valve
df['p1'] = (7/1000)*df["MPX100-4"] #was a 7bar sensortselect = 37 #selecting time of experimentInputP = df.PREG.iloc[-3000:].mean()
#preparing data, converting to kPa the SSCDP sensors
VAs = [.1,.2,.3,.1,.2,.3,.1,.1]
VBs = [.75,.75,.75,1.15,1.15,1.15,.2,.3]
tselectstarts = [40,137,239,433,510,622,831,900]
tselectends = [74.5,176.5,282,485,565,672,845,922]
nsteps = [6,4,3,9,5,4,3,4]
dfs = []
deltaTloops = []
def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):
new_cmap = colors.LinearSegmentedColormap.from_list(
'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),
cmap(np.linspace(minval, maxval, n)))
return new_cmap
#imola_truc = truncate_colormap(cmc.bamako, minval=0.0, maxval=.9, n=256)
imola_truc = truncate_colormap(matplotlib.cm.get_cmap('viridis'), minval=0.0, maxval=.9, n=256)
cmapdiscrdata = truncate_colormap(cmc.turku, minval=0.0, maxval=.9, n=256)
lipari_trunc = truncate_colormap(cmc.lipari, minval=0, maxval=.8, n=256)
discrdiff = truncate_colormap(cmc.cork, minval=0, maxval=.8, n=256)
cmapTmodel = truncate_colormap(cmc.batlow, minval=0, maxval=.8, n=256)
cmap2 = imola_truc #time
cmap_discr = lipari_trunc #nsteps
cmap_discrDiff = discrdiff
norm = colors.BoundaryNorm(np.arange(2, 10.5, 1), cmap_discr.N)
norm2 = colors.BoundaryNorm(np.linspace(3,10.5, 256), cmap2.N)
norm3 = colors.BoundaryNorm(np.linspace(-2,2, 256), cmap2.N)
sizemaker = 400
fig= plt.figure(figsize=[int(sizehalfcol)*2,int(sizehalfcol*1.75)])
#fig= plt.figure(figsize=[int(5),int(5)])
for exp in range(len(VAs)):
#select df of experiment
dftemp = df[df.Time>tselectstarts[exp]]
dftemp = dftemp[dftemp.Time<tselectends[exp]]
#process peaks
peaks, _ = find_peaks(dftemp.p2, height=(31, 40), prominence=2)
deltaTloop = (np.asarray(dftemp.Time.iloc[peaks][1:]) - np.asarray(dftemp.Time.iloc[peaks][:-1]) ).mean()
if len(str(VBs[exp])[1:])==2:
dfs.append(['$V_{1}=%.1f L$, $V_{2}=%.1f L$'%(VAs[exp],VBs[exp]), dftemp,nsteps[exp],deltaTloop])
else:
dfs.append(['$V_{1}=%.1f L$, $V_{2}=%.2f L$'%(VAs[exp],VBs[exp]), dftemp,nsteps[exp],deltaTloop])
deltaTloops.append(deltaTloop)
matForloopNsteps = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
matForloopDeltaT = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
matPredictionNstep = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
matPredictionDeltaT = np.zeros(shape=[len(np.unique(VAs)), len(np.unique(VBs))]).T
for idx in range(len(VAs)):
idxVA = np.where(VAs[idx]==np.unique(VAs))[0][0]
idxVB = np.where(VBs[idx]==np.unique(VBs))[0][0]
matForloopNsteps[idxVB][idxVA] = nsteps[idx]
matForloopDeltaT[idxVB][idxVA] = deltaTloops[idx]
matPredictionNstep[idxVB][idxVA] = (32/38)*VBs[idx]/VAs[idx]
matPredictionDeltaT[idxVB][idxVA] = (3e4)*(VAs[idx]*10*1e-4) / (8.3145 *293 * 1.4e-3)# #DeltaP*V[L]/(RTQ)* 0.029/(1.125*8.3145*293* 2 ) * 60
#Mask out missing for loop data
matForloopNsteps = np.ma.masked_where(matForloopNsteps==0, matForloopNsteps)
matForloopDeltaT = np.ma.masked_where(matForloopDeltaT==0, matForloopDeltaT)
matPredictionNstep = np.ma.masked_where(matPredictionNstep==0, matPredictionNstep)
matPredictionDeltaT = np.ma.masked_where(matPredictionDeltaT==0, matPredictionDeltaT)
predictedDeltaT = np.multiply(matForloopNsteps,matPredictionDeltaT) #multiply by Npredict to get actual DeltaT
fig= plt.figure(figsize=[int(sizehalfcol)*1.25,int(sizehalfcol*3/4)*1.65])
ax0 = fig.add_subplot(311)
ax1 = fig.add_subplot(312)
ax2 = fig.add_subplot(313)
forexampleidx = 3
n2loops = int(deltaTloops[forexampleidx]*data[1]['Samplerate'][15])*2
ax0.plot(dfs[forexampleidx][1].Time.iloc[0:n2loops] - dfs[forexampleidx][1].Time.iloc[0],dfs[forexampleidx][1].p1.iloc[0:n2loops], color='red', linewidth = 1 , label = '$p_{1}$')
ax0.plot(dfs[forexampleidx][1].Time.iloc[0:n2loops] - dfs[forexampleidx][1].Time.iloc[0],dfs[forexampleidx][1].p2.iloc[0:n2loops], color='royalblue', linewidth = 1, label = '$p_{2}$')
forexampleidx = 5
n2loops = int(deltaTloops[forexampleidx]*data[1]['Samplerate'][15])*2
ax1.plot(dfs[forexampleidx][1].Time.iloc[0:n2loops] - dfs[forexampleidx][1].Time.iloc[0],dfs[forexampleidx][1].p1.iloc[0:n2loops], color='red', linewidth = 1 , label = '$p_{1}$')
ax1.plot(dfs[forexampleidx][1].Time.iloc[0:n2loops] - dfs[forexampleidx][1].Time.iloc[0],dfs[forexampleidx][1].p2.iloc[0:n2loops], color='royalblue', linewidth = 1, label = '$p_{2}$')
forexampleidx = 6
n2loops = int(deltaTloops[forexampleidx]*data[1]['Samplerate'][15])*2
ax2.plot(dfs[forexampleidx][1].Time.iloc[0:n2loops] - dfs[forexampleidx][1].Time.iloc[0],dfs[forexampleidx][1].p1.iloc[0:n2loops], color='red', linewidth = 1 , label = '$p_{1}$')
ax2.plot(dfs[forexampleidx][1].Time.iloc[0:n2loops] - dfs[forexampleidx][1].Time.iloc[0],dfs[forexampleidx][1].p2.iloc[0:n2loops], color='royalblue', linewidth = 1, label = '$p_{2}$')
ax0.xaxis.set_tick_params(labelsize=ticks_size)
ax1.xaxis.set_tick_params(labelsize=ticks_size)
ax2.xaxis.set_tick_params(labelsize=ticks_size)
ax0.yaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax2.yaxis.set_tick_params(labelsize=ticks_size)
ax0.spines['right'].set_visible(False)
ax0.spines['top'].set_visible(False)
ax0.spines['left'].set_visible(True)
ax0.spines['bottom'].set_visible(True)
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax2.spines['right'].set_visible(False)
ax2.spines['top'].set_visible(False)
ax2.spines['left'].set_visible(True)
ax2.spines['bottom'].set_visible(True)
#ax0.text(0,60,'$\\alpha$',fontsize=labelfontsize,color='k')
#ax1.text(0,60,'$\\beta$',fontsize=labelfontsize,color='k')
#ax2.text(0,60,'$\\gamma$',fontsize=labelfontsize,color='k')
ax0.scatter(0,60,marker='o',color='gray') #gamma
ax1.scatter(0,60,marker='^',color='gray') #alfa
ax2.scatter(0,60,marker='*',color='gray') #beta
ax0.grid(False)
ax1.grid(False)
ax2.grid(False)
ax0.set_xlabel("Time (s)",fontsize=labelfontsize)
ax1.set_xlabel("Time (s)",fontsize=labelfontsize)
ax2.set_xlabel("Time (s)",fontsize=labelfontsize)
ax0.set_ylabel("Pressure (kPa)",fontsize=labelfontsize)
ax1.set_ylabel("Pressure (kPa)",fontsize=labelfontsize)
ax2.set_ylabel("Pressure (kPa)",fontsize=labelfontsize)
leg = ax0.legend(fontsize=legendfont,loc=2,ncol=2, bbox_to_anchor=(0.0, 1.65))
ax0.set_ylim(-3,70)
ax1.set_ylim(-3,70)
ax2.set_ylim(-3,70)
#plt.tight_layout()
plt.savefig(result_folder+'\\3ChangingVolumesPressTracks.png', dpi=dpi,transparent=transparentsave)
Fig3_20230922_V2
<Figure size 600x600 with 0 Axes>
In [ ]:
In [ ]:
Figure S23¶
In [25]:
import cmcrameri.cm as cmc
from matplotlib import gridspec
expname_ = 'RetrieverReview'
tevent = 325.5#500.65
cmap_force = matplotlib.cm.get_cmap('Greens')
expidxs = [24]
expidx = expidxs[0]
df = data[0][expidx]
expname = data[1]['Samplename'][expidx]
print(expname)
fs = data[1]['Samplerate'][expidx] # in Hz
df['pBendingS'] = df["MPX100-3"]/1000
df['pBending'] = df["MPX100-11"]/1000
df["pLinear"] = (((df["SSCDP15-9"])*2/2.5)*101.3250) #used the 2bar here
df["pLinearS"] = df["MPX100-10"] /1000 #
df['pFeedback'] = df["MPX100-2"] /1000
fig= plt.figure(figsize=[int(sizehalfcol)*2,int(sizehalfcol)*1.5])
ax1 = fig.add_subplot(231) #top left
ax2 = fig.add_subplot(232) #top left
ax3 = fig.add_subplot(233) #top left
ax4 = fig.add_subplot(234) #top left
ax5 = fig.add_subplot(235) #top left
ax6 = fig.add_subplot(236) #top left
axs = [ax1,ax2,ax3,ax4,ax5,ax6]
linewidth = .5
tstart = tevent-5
tend = tevent+5
#toprow
ax1.plot(df.Time,df.pBending, color=colorBdark2, linewidth=linewidth, label = '$p_{\\mathrm{Bending}}$')
ax1.plot(df.Time,df.pBendingS,color=colorBdark2,ls='--', linewidth=linewidth, label = '$p_{\\mathrm{S,Bending}}$')
#
ax2.plot(df.Time,df.pLinear, color='royalblue', linewidth=linewidth, label = '$p_{\\mathrm{Linear}}$')
ax2.plot(df.Time,df.pLinearS,color='royalblue',ls='--', linewidth=linewidth, label = '$p_{\\mathrm{D,Linear}}$')
ax3.plot(df.Time,df.pFeedback, color='red', linewidth=linewidth, label = '$p_{\\mathrm{Feedback}}$')
ax1.vlines(tevent,df.pBending.min(),df.pBending.max(), ls='--', color='k',linewidth=linewidth,zorder=4)
ax2.vlines(tevent,df.pLinear.min(),df.pLinear.max(), ls='--', color='k',linewidth=linewidth,zorder=4)
ax3.vlines(tevent,df.pFeedback.min(),df.pFeedback.max(), ls='--', color='k',linewidth=linewidth,zorder=4)
#bottomrow
ax4.plot(df.Time,df.pBending, color=colorBdark2, linewidth=linewidth, label = '$p_{\\mathrm{Bending}}$')
ax4.plot(df.Time,df.pBendingS,color=colorBdark2,ls='--', linewidth=linewidth, label = '$p_{\\mathrm{S,Bending}}$')
#
ax5.plot(df.Time,df.pLinear, color='royalblue', linewidth=linewidth, label = '$p_{\\mathrm{Linear}}$')
ax5.plot(df.Time,df.pLinearS,color='royalblue',ls='--', linewidth=linewidth, label = '$p_{\\mathrm{D,Linear}}$')
ax6.plot(df.Time,df.pFeedback, color='red', linewidth=linewidth, label = '$p_{\\mathrm{Feedback}}$')
ax4.vlines(tevent,df.pBending.min(),df.pBending.max(), ls='--', color='k',linewidth=linewidth,zorder=4)
ax5.vlines(tevent,df.pLinear.min(),df.pLinear.max(), ls='--', color='k',linewidth=linewidth,zorder=4)
ax6.vlines(tevent,df.pFeedback.min(),df.pFeedback.max(), ls='--', color='k',linewidth=linewidth,zorder=4)
ax1.set_xlim(tstart-20,tend+60)
ax2.set_xlim(tstart-20,tend+60)
ax3.set_xlim(tstart-20,tend+60)
ax4.set_xlim(tstart,tend)
ax5.set_xlim(tstart,tend)
ax6.set_xlim(tstart,tend)
for ax in [ax1,ax2,ax3]:
ax.axvspan(tstart,tend,color='k',alpha=.1)
ax.axvspan(tstart-20,tevent,ymax=df.pBending.max(),color='red',alpha=0.05)
ax.axvspan(tevent,tend+60,ymax=df.pBending.max(),color='green',alpha=0.05)
for ax in [ax4,ax5,ax6]:
#ax.axvspan(tstart,tend,color='k',alpha=.1)
ax.axvspan(tstart,tevent,ymax=df.pBending.max(),color='red',alpha=0.05)
ax.axvspan(tevent,tend,ymax=df.pBending.max(),color='green',alpha=0.05)
for ax in axs:
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
ax.grid(False)
ax.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax.set_ylabel("$p$(kPa)",fontsize=int(labelfontsize))
ax1.legend(fontsize=legendfont, ncol=1,loc='upper left',bbox_to_anchor=(0, 1.4))
ax2.legend(fontsize=legendfont, ncol=1,loc='upper left',bbox_to_anchor=(0, 1.4))
ax3.legend(fontsize=legendfont, ncol=1,loc='upper left',bbox_to_anchor=(0, 1.4))
plt.tight_layout()
ax3.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax1.set_ylabel("$p$(kPa)",fontsize=int(labelfontsize))
ax2.set_ylabel("$p$(kPa)",fontsize=int(labelfontsize))
ax3.set_ylabel("$p$(kPa)",fontsize=int(labelfontsize))
plt.savefig(result_folder+'\\%s_eventSI.png'%(expname), dpi=dpi,transparent=transparentsave, bbox_inches = 'tight')
Retriever4Review_take4
Figure S24¶
In [26]:
expidx = 16
df = data[0][expidx]
expname = data[1]['Samplename'][expidx]
print(expname)
fs = data[1]['Samplerate'][expidx] # in Hz
#df["pG_freq"] = df["MPX700-2"] /1000
#df["Q"] = (df["AWM20-1"])
#df['pValvePre'] = (((df["SSCDP05-3"])*2/2.5)*101.3250)
df["pAct"] = df["MPX100-4"] /1000
#df['pAct'] = (((df["SSCDP15-9"])*2/2.5)*101.3250)
df['pGate'] = (((df["SSCDP05-9"])*2/2.5)*.5*101.3250) #used sscdp15 instead
start_exp = 1070 #physical starting point of experiment in video
start_exp = 1030 #physical starting point of experiment in video
df = df[df.Time>start_exp]
tevent = np.where(df.pAct==df.pAct.max())[0][0]
tevent = 1092
fig= plt.figure(figsize=[int(sizehalfcol)*1,int(sizehalfcol)*.5])
ax1 = fig.add_subplot(111) #top left
ax1.plot(df.Time-tevent, df.pAct, color = colorBdark2, label = '$p_{Gripper}$', linewidth = .6)
ax1.plot(df.Time-tevent, df.pGate, color='k', label = '$p_{G}$', linewidth = .6)
ax1.hlines(70,-60,65, ls = '--', color= 'gray', linewidth=.6)
ax1.xaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.yaxis.set_tick_params(labelsize=ticks_size)
ax1.spines['right'].set_visible(False)
ax1.spines['top'].set_visible(False)
ax1.spines['left'].set_visible(True)
ax1.spines['bottom'].set_visible(True)
ax1.grid(False)
#ax1.set_title('$p_{In}=%.1f kPa$'%(pstart_avg[-1]), fontsize=labelfontsize)
ax1.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax1.set_ylabel(" Pressure (kPa)",fontsize=int(labelfontsize))
ax1.legend(ncol=1, fontsize=labelfontsize, loc = 'center left')
plt.savefig(result_folder+'\\%s.png'%(expname), dpi=dpi,transparent=transparentsave)
Venus0
In [ ]:
In [ ]:
Figure S25¶
In [ ]:
In [27]:
import cmcrameri.cm as cmc
from matplotlib import gridspec
expname_ = 'IfElse'
popen = 68
cmap_force = matplotlib.cm.get_cmap('Greens')
expidxs = [23]
expidx = expidxs[0]
df = data[0][expidx]
expname = data[1]['Samplename'][expidx]
print(expname)
df["pIn"] = df["MPX100-10"]/1000
df["pHyst"] = df["MPX100-11"]/1000
df["pElse"] = df["MPX100-2"]/1000
df["pIf"] = df["MPX100-4"]/1000
#preparing data, converting to kPa the SSCDP sensors, than dividing by 1000 to get kPa
color1 = '#3A41E1'
color2 = '#1FE021'
color3 = '#E12720'
fig = plt.figure(figsize=[sizehalfcol*1.8,sizehalfcol*.9])
ax0 = fig.add_subplot(221) #top left
ax1 = fig.add_subplot(222) #top left
ax2 = fig.add_subplot(212) #top left
#ax3 = fig.add_subplot(144) #top left
axs = [ax0,ax1,ax2]
if True:
ax0.hlines(popen,0, df.Time.max(),ls='--',color='grey',label='$\\Delta p_{\\mathrm{open}}$')
ax1.hlines(popen,0, df.Time.max(),ls='--',color='grey',label='$\\Delta p_{\\mathrm{open}}$')
ax2.hlines(popen,0, df.Time.max(),ls='--',color='grey',label='$\\Delta p_{\\mathrm{open}}$')
#ax0.plot(df.Time,df.pIn, color= 'k',alpha=.6, label = '$p_{\\mathrm{In}}$')
ax0.plot(df.Time,df.pHyst, color= color1,alpha=.8, label = '$p_{\\mathrm{SHV}}$')
ax0.plot(df.Time,df.pIf, color= color2,alpha=.8, label = '$p_{\\mathrm{If}}$')
ax0.plot(df.Time,df.pElse, color= color3,alpha=.8, label = '$p_{\\mathrm{Else}}$')
#ax1.plot(df.Time,df.pIn, color= 'k',alpha=.6, label = '$p_{\\mathrm{In}}$')
ax1.plot(df.Time,df.pHyst, color= color1,alpha=.8, label = '$p_{\\mathrm{SHV}}$')
ax1.plot(df.Time,df.pIf, color= color2,alpha=.8, label = '$p_{\\mathrm{If}}$')
ax1.plot(df.Time,df.pElse, color= color3,alpha=.8, label = '$p_{\\mathrm{Else}}$')
#ax2.plot(df.Time,df.pIn, color= 'k',alpha=.6, label = '$p_{\\mathrm{In}}$')
ax2.plot(df.Time,df.pHyst, color= color1,alpha=.8, label = '$p_{\\mathrm{SHV}}$')
ax2.plot(df.Time,df.pIf, color= color2,alpha=.8, label = '$p_{\\mathrm{If}}$')
ax2.plot(df.Time,df.pElse, color= color3,alpha=.8, label = '$p_{\\mathrm{Else}}$')
for ax in axs:
ax.xaxis.set_tick_params(labelsize=int(ticks_size))
ax.yaxis.set_tick_params(labelsize=int(ticks_size))
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
#ax.set_xlim(8,71)
ax.grid(False)
ax0.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
ax1.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
ax0.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax1.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax2.set_xlabel("Time (s)",fontsize=int(labelfontsize))
ax2.set_ylabel("Pressure (kPa)",fontsize=int(labelfontsize))
#ax2.set_yscale('log')
ax2.legend(fontsize=legendfont,ncol=2)
plt.tight_layout()
ax0.set_xlim(50,68)
ax0.set_ylim(-1,75)
ax1.set_ylim(-1,75)
ax2.set_ylim(-1,75)
ax1.set_xlim(70,130)
ax2.set_xlim(205,300)
#ax1.set_xlim(205,230)
plt.savefig(result_folder+'\\%s.png'%(expname_), dpi=dpi,transparent=transparentsave)
plt.show()
IfElse2
Figure S26¶
In [32]:
idxexp = 0
print(data[1]['Samplename'][idxexp])
df = data[0][idxexp]
df = df[df.Time>10]
df = df[df.Time<300]
#preparing data, converting to kPa the SSCDP sensors, than dividing by 1000 to get kPa
df["pA"] = (((df["SSCDP15-4"])/2.5)*101.3250) #here it was used 2Bar DP
df["pB"] = (((df["SSCDP15-9"])/2.5)*101.3250) #here it was used 2Bar DP
dpi = 200
transparentsave=True
TITLES=False
colorA = '#d37a5a'#'#894a41' #BrownBaloon
colorB = '#b4e181'#'#7fb553' #GreenActuator
Timestart = 165.4
Timeend = 189
lwA = 6
lwB = 6
Timestart = 162.4
Timeend = 173
fig= plt.figure(figsize=[int(sizehalfcol),int(sizehalfcol)*.5])
ax = fig.add_subplot(111) #top left
ax.plot(df.Time,df.pA, label="$p_A$",color='k', linewidth=2)
ax.plot(df.Time,df.pB, label="$p_B$",color=colorB, linewidth=2)
ax.xaxis.set_tick_params(labelsize=ticks_size)
ax.yaxis.set_tick_params(labelsize=ticks_size)
ax.yaxis.set_tick_params(labelsize=ticks_size)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
ax.grid(False)
ax.set_xlim(Timestart,Timeend)
ax.set_xlabel("Time (s)",fontsize=labelfontsize)
ax.set_ylabel("Pressure (kPa)",fontsize=labelfontsize)
ax.tick_params(axis='x', labelsize=ticks_size)
ax.tick_params(axis='y', labelsize=ticks_size)
ax.legend(fontsize=legendfont, loc = 'upper center', ncol=2,bbox_to_anchor=(.5, 1.4))
plt.savefig(result_folder+'\\simplePcontrol2.png', dpi=dpi,transparent=transparentsave)
Timestart = 182
Timeend = 189
fig= plt.figure(figsize=[int(sizehalfcol),int(sizehalfcol)*.5])
ax = fig.add_subplot(111) #top left
ax.plot(df.Time,df.pA, label="$p_A$",color='k', linewidth=2)
ax.plot(df.Time,df.pB, label="$p_B$",color=colorB, linewidth=2)
ax.xaxis.set_tick_params(labelsize=ticks_size)
ax.yaxis.set_tick_params(labelsize=ticks_size)
ax.yaxis.set_tick_params(labelsize=ticks_size)
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
ax.grid(False)
ax.legend(fontsize=legendfont, loc = 'upper center', ncol=2,bbox_to_anchor=(.5, 1.1))
ax.set_xlim(182,189)
ax.set_xlabel("Time (s)",fontsize=labelfontsize)
ax.set_ylabel("Pressure (kPa)",fontsize=labelfontsize)
ax.tick_params(axis='x', labelsize=ticks_size)
ax.tick_params(axis='y', labelsize=ticks_size)
plt.savefig(result_folder+'\\simplePcontrol2_fail.png', dpi=dpi,transparent=transparentsave)
PressureControl
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: