Location: ECC_MSK (Rios et al. 1993) @ 1b1a07491a4d / Simulation / src / plotFig11_906.py

Author:
WeiweiAi <wai484@aucklanduni.ac.nz>
Date:
2022-07-28 12:05:55+12:00
Desc:
Fixed the link
Permanent Source URI:
https://models.cellml.org/workspace/8af/rawfile/1b1a07491a4d102536a3f7e25957ca2810d6ed76/Simulation/src/plotFig11_906.py

# importing modules
import sys as sys
import os 
import pandas as pd 
import matplotlib.pyplot as plt
# Getting the name of the directory where this file is present.
current = os.path.dirname(os.path.realpath(__file__))  # src
# Getting the parent directory name where the current directory is present.
parent = os.path.dirname(current) # Simulation
# Getting the grandparent directory name
gparent = os.path.dirname(parent) # RecruitmentSynchronization_SMCs
# The path where the plotExp.py is saved
mpath = gparent + '\\cellLib\\Scripts'
# appending a path
sys.path.append(mpath)
import plotExp
# The properties of traces
colors=plt.rcParams['axes.prop_cycle'].by_key()['color']
lines = ['-','--','-.',':']
markers = ['.',',','o','+','x','d']
# Figure file name and titles
figfiles=parent+'\\simFig11_906.png'
fig_title = 'Primary Fig 11 with 906 entry'
plot_title =['Reference -40, -26 mV','Perchlorate -63, -49 mV','','']
labels = ['Original','CellML -40 mV','CellML  -26 mV','Original','CellML -63 mV','CellML  -49 mV',
'Original','CellML -40 mV','CellML  -26 mV','Original','CellML -63 mV','CellML  -49 mV']
# Data source
dfolder_original=parent+'\\originalData\\'
ofilenames=['Fig11A_r.csv','Fig11A_p.csv','Fig11B_r.csv','Fig11B_p.csv']
dfilenames=['simFig11_r906_n40.csv','simFig11_p906_n63.csv','simFig11_r906_n40.csv','simFig11_p906_n63.csv',]
dfilenames_1=['simFig11_r906_n26.csv','simFig11_p906_n49.csv','simFig11_r906_n26.csv','simFig11_p906_n49.csv',]
dfolder_sim=parent+'\\simulatedData\\'
x_var_org ='x'
y_var_org ='Curve1'
x_vars_sim = ['t','t','t','t']
y_vars_sim = ['output_10/P_o','output_10/P_o','output_10/dQ','output_10/dQ']
x_label=['','','t (ms)','t (ms)']
y_label=['Open probability','Open probability','Charge current /ms','Charge current /ms']
Qmax=23.1
# Build the traces
number_trace = 3
number_plot = len(y_vars_sim)
trace = [[0] * number_trace for i in range(number_plot)]


for plotid, y_var_sim in enumerate(y_vars_sim):
   odata = pd.read_csv(dfolder_original+ofilenames[plotid])
   ox_data=odata[x_var_org].values
   oy_data=odata[y_var_org].values 
   ndata = pd.read_csv(dfolder_sim+dfilenames[plotid])
   ndata_1 = pd.read_csv(dfolder_sim+dfilenames_1[plotid])
   nx_data=ndata[x_vars_sim[plotid]].values-200
   if plotid==0:
      ny_data=ndata[y_vars_sim[plotid]].values/0.504850790072875
      ny_data_1=ndata_1[y_vars_sim[plotid]].values/0.504850790072875
   elif plotid==1:
      ny_data=ndata[y_vars_sim[plotid]].values/0.98322952985556
      ny_data_1=ndata_1[y_vars_sim[plotid]].values/0.98322952985556
   else:
      ny_data=ndata[y_vars_sim[plotid]].values 
      ny_data_1=ndata_1[y_vars_sim[plotid]].values 

   trace[plotid][0]={'dataX': ox_data, 'dataY': oy_data, 'lname': labels[plotid*3+0], 'linestyle':lines[1], 'marker':markers[0], 'linecolor':colors[0],'y2':False}
   trace[plotid][1]={'dataX': nx_data, 'dataY': ny_data, 'lname': labels[plotid*3+1], 'linestyle':lines[0], 'marker':None, 'linecolor':colors[1],'y2':False}
   trace[plotid][2]={'dataX': nx_data, 'dataY': ny_data_1, 'lname': labels[plotid*3+2], 'linestyle':lines[0], 'marker':None, 'linecolor':colors[3],'y2':False}
   
        
# Build the plots 
# maxH=8.75 inches, width 2.63-7.5
rows,cols = 2,2
left = 0.125  # the left side of the subplots of the figure,0.125
right = 0.9   # the right side of the subplots of the figure,0.9
bottom = 0.15  # the bottom of the subplots of the figure, 0.1
top = 0.75    # the top of the subplots of the figure 0.9
wspace = 0.5  # the amount of width reserved for space between subplots,
              # expressed as a fraction of the average axis width, 0.2
hspace = 0.25  # the amount of height reserved for space between subplots,
              # expressed as a fraction of the average axis height, 0.2
lgdfont, labelfont =10, 10
width, height= cols*3.5, rows*3
figs ={ 'width':width, 'height': height, 'rows': rows, 'cols': cols,'left':left,'bottom':bottom,'right':right,'top':top,'wspace': wspace,'hspace': hspace,'fig_title':fig_title,'title_y':1}

plots=[]
for id in range(4):    
   colid = id%2
   rowid = id//2
   if id == 0 or id == 1:
      lgdshow = True
      bbox_to_anchor = (0.5,1.45)      
   else:
      lgdshow = False
      bbox_to_anchor = None
       
   iplot={'rowid':rowid, 'colid':colid, 'xlabel': x_label[id], 'ylabel':y_label[id], 'twiny':False,    'ylabel2':y_label[id],'labelcolor':colors[1],
            'lgdshow': lgdshow, 'lgdloc':'center', 'bbox_to_anchor':bbox_to_anchor,'lgdncol': 1, 'lgdfont':lgdfont, 'labelfont': labelfont,  
            'setxlim': True, 'xmin':0, 'xmax': 200, 'setylim': False,'ymin':0, 'ymax':1, 'grid': True,    'gridaxis': 'both', 'plot_title': plot_title[id],
            'traces':trace[id]
            }   
   plots.append(iplot)

ids = range(len(y_vars_sim))   
subfigs={ids: plots for ids, plots in zip(ids, plots)}
fig,axs=plotExp.plotExp(figs,subfigs,figfiles)