Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
601 views
unlisted
ubuntu2404
Kernel: Python 3 (CoCalc)
import numpy as np import matplotlib.pyplot as plt import matplotlib.gridspec as gridspec
class exp: def __init__(self,run_id): self.dir = f'experiment_{run_id}/' self.run_id = run_id self.measure = np.loadtxt(self.dir+f'FINAL_measurement_experiment_{run_id}.txt') self.sim = np.loadtxt(self.dir+f'FINAL_simulation_experiment_{run_id}.txt') self.th = np.loadtxt(self.dir+f'FINAL_theory_mean_experiment_{run_id}.txt') self.th_low = np.loadtxt(self.dir+f'FINAL_theory_minus_experiment_{run_id}.txt') self.th_up = np.loadtxt(self.dir+f'FINAL_theory_plus_experiment_{run_id}.txt')
run_10 = exp(run_id=10) run_9 = exp(run_id=9) run_4 = exp(run_id=4)
# IC print('10 =', run_10.sim[0,1:]) print('9 =', run_9.sim[0,1:]) print('4 =', run_4.sim[0,1:]) print('10 =', run_10.measure[0,1:]) print('9 =', run_9.measure[0,1:]) print('4 =', run_4.measure[0,1:])
10 = [-0.93171052 -0.35533003 0.07520613] 9 = [-0.3167219 -0.93656054 0.15013792] 4 = [ 0.89528785 -0.12924107 0.426329 ] 10 = [ 0.13845473 -0.97947566 0.14648455] 9 = [-0.36483265 -0.92391107 0.11526265] 4 = [ 0.87689778 -0.10609994 0.46882094]
runs = [run_10,run_9,run_4] panel_labels = [r'$(a)$',r'$(b)$',r'$(c)$']
label_fontsize=9 marker_size=3 title_fontsize=12 letters_fontsize=8 xticks_fontsize=8 yticks_fontsize=8
scaling_factor = 1 fig = plt.figure(figsize=(7.3*scaling_factor, 9*scaling_factor)) n_panels = 3 plt.rcParams.update({'xtick.labelsize': xticks_fontsize, 'ytick.labelsize': yticks_fontsize}) #grid of 3 panels stacked vertically outer_gs = gridspec.GridSpec(n_panels, 1, height_ratios=[1]*n_panels,hspace=0.3) # --- Generate each panel --- for i in range(n_panels): #one experiment subplot inner_gs = gridspec.GridSpecFromSubplotSpec(3, 2,subplot_spec=outer_gs[i],wspace=0.1, hspace=0.1) # Create subplots for this panel axes = [] for r in range(3): for c in range(2): ax = fig.add_subplot(inner_gs[r, c]) ax.scatter(runs[i].measure[:,0],runs[i].measure[:,r+1],c='blue',zorder=10,s=marker_size) ax.plot(runs[i].sim[:,0],runs[i].sim[:,r+1],c='orange') if c == 1: ax.scatter(runs[i].th[0,0],runs[i].th[0,r+1],c='red',marker='*',zorder=10) ax.plot(runs[i].th[:,0],runs[i].th[:,r+1],c='k') ax.plot(runs[i].th_low[:,0],runs[i].th_low[:,r+1], '-', color='grey', alpha=0.3) ax.plot(runs[i].th_up[:,0],runs[i].th_up[:,r+1], '-', color='grey', alpha=0.3) ax.fill_between(runs[i].th_up[:,0], runs[i].th_up[:,r+1], runs[i].th_low[:,r+1], color='grey', alpha=0.3) if r==0: if c == 0: ax.set_title(r'$Full \ time \ series$',fontsize=label_fontsize,pad=0.0) else: ax.set_title(r'$Zoomed-in \ view$',fontsize=label_fontsize,pad=0.0) if c == 1: ax.set_xlim(0,np.amax(runs[i].measure[:,0])) ax.set_yticklabels([]) else: ax.set_xlim(0,500) ax.set_ylabel(rf'$n_{r+1}$',fontsize=label_fontsize) if r < 2: ax.set_yticks([-1,0,1]) ax.set_ylim(-1.1,1.1) else: ax.set_yticks([0,0.5,1]) ax.set_ylim(0.0,1.1) if r < 2: ax.set_xticklabels([]) if r == 2: ax.set_xlabel(r'$t\dot{\gamma}$',fontsize=label_fontsize,labelpad=0.25) axes.append(ax) ###add panel letters axes[0].text(-0.15, 1.2, panel_labels[i],transform=axes[0].transAxes,fontsize=letters_fontsize, fontweight='bold', va='top', ha='left') ###add panel titles axes[1].text(-19.5,1.5,rf"$Experiment \ {runs[i].run_id}$",fontsize=title_fontsize, fontweight='bold') # plt.tight_layout(rect=[0, 0.05, 1, 1]) #plt.show() plt.savefig('FIG2_NEW_IC.pdf', format='pdf', bbox_inches='tight', dpi=600)
Image in a Jupyter notebook
##select the remaining experiments supp_mat_runs = [exp(run_id=1),exp(run_id=2),exp(run_id=5),exp(run_id=6),exp(run_id=7),exp(run_id=8),exp(run_id=11)]
scaling_factor = 1 plt.rcParams.update({'xtick.labelsize': xticks_fontsize, 'ytick.labelsize': yticks_fontsize}) for supp_mat_run in supp_mat_runs: runs = [supp_mat_run] ###create figure fig = plt.figure(figsize=(7.3*scaling_factor, 3*scaling_factor)) n_panels = 1 #grid of n_panels panels stacked vertically outer_gs = gridspec.GridSpec(n_panels, 1, height_ratios=[1]*n_panels,hspace=0.3) # --- Generate each panel --- for i in range(n_panels): #one experiment subplot inner_gs = gridspec.GridSpecFromSubplotSpec(3, 2,subplot_spec=outer_gs[i],wspace=0.1, hspace=0.1) # Create subplots for this panel axes = [] for r in range(3): for c in range(2): ax = fig.add_subplot(inner_gs[r, c]) ax.scatter(runs[i].measure[:,0],runs[i].measure[:,r+1],c='blue',zorder=10,s=marker_size) ax.plot(runs[i].sim[:,0],runs[i].sim[:,r+1],c='orange') #if c == 1: ax.scatter(runs[i].th[0,0],runs[i].th[0,r+1],c='red',marker='*',zorder=10) ax.plot(runs[i].th[:,0],runs[i].th[:,r+1],c='k') ax.plot(runs[i].th_low[:,0],runs[i].th_low[:,r+1], '-', color='grey', alpha=0.3) ax.plot(runs[i].th_up[:,0],runs[i].th_up[:,r+1], '-', color='grey', alpha=0.3) ax.fill_between(runs[i].th_up[:,0], runs[i].th_up[:,r+1], runs[i].th_low[:,r+1], color='grey', alpha=0.3) if r==0: if c == 0: ax.set_title(r'$Full \ time \ series$',fontsize=label_fontsize,pad=0.0) else: ax.set_title(r'$Zoomed-in \ view$',fontsize=label_fontsize,pad=0.0) if c == 1: ax.set_xlim(0,np.amax(runs[i].measure[:,0])) ax.set_yticklabels([]) else: ax.set_xlim(0,500) ax.set_ylabel(rf'$n_{r+1}$',fontsize=label_fontsize) if r < 2: ax.set_yticks([-1,0,1]) ax.set_ylim(-1.1,1.1) else: ax.set_yticks([0,0.5,1]) ax.set_ylim(0.0,1.1) if r < 2: ax.set_xticklabels([]) if r == 2: ax.set_xlabel(r'$t\dot{\gamma}$',fontsize=label_fontsize,labelpad=0.25) axes.append(ax) ###add panel letters axes[0].text(-0.15, 1.2, panel_labels[i],transform=axes[0].transAxes,fontsize=letters_fontsize, fontweight='bold', va='top', ha='left') ###add panel titles axes[1].text(-19.5,1.5,rf"$Experiment \ {runs[i].run_id}$",fontsize=title_fontsize, fontweight='bold') # plt.tight_layout(rect=[0, 0.05, 1, 1]) #plt.show() plt.savefig(f'Supp_Mat_experiment_{runs[i].run_id}.pdf', format='pdf', bbox_inches='tight', dpi=600)
Image in a Jupyter notebookImage in a Jupyter notebookImage in a Jupyter notebookImage in a Jupyter notebookImage in a Jupyter notebookImage in a Jupyter notebookImage in a Jupyter notebook