-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsupplementaryFigure2a-d.py
171 lines (135 loc) · 4.83 KB
/
supplementaryFigure2a-d.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# -*- coding: utf-8 -*-
"""
@author: Daniel Koch
This code reproduces the results shown in supplementary figure 2 (a)-(d) from the study:
Koch D, Nandan A, Ramesan G, Tyukin I, Gorban A, Koseska A (2024):
Ghost channels and ghost cycles guiding long transients in dynamical systems
In: Physical Review Letters (forthcoming)
IMPORTANT:
The files "functions.py" and "models.py" need to be in the same folder as this script
and the following files to be in the subfolder 'data':
- simdat_HC4_noisy_30runs.npy
- simdat_GC4_noisy_30runs.npy
If necessary, run code for figure 3 first to generate these files.
"""
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm
import functions as fun
import models
import os
import sys
os.chdir(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(os.path.join( os.path.dirname( __file__ ), '..' ))
# some plotting settings
plt.rcParams.update(
{
'text.usetex': False,
'font.family': 'stixgeneral',
'mathtext.fontset': 'stix',
}
)
inCm = 1/2.54
norm = plt.Normalize(0,8)
cmap=cm.get_cmap('RdPu_r')
sm = plt.cm.ScalarMappable(norm=norm, cmap=cmap)
x0s = np.linspace(0.515,0.95,6)
y0s = (lambda y: 1 - y)(x0s)
ICs = np.asarray([x0s, y0s]).T
sigmaValues = [0.0001,0.0002,0.0005,0.001,0.002,0.005,0.01,0.02,0.05,0.1,0.2]
nruns = 30
#%% Supplementary figure 2 (a,b) - plotting
simulations = np.load('data\\simdat_HC4_noisy_30runs.npy')
X = np.linspace(0,5, 20)
Y = np.linspace(0,5, 20)
grid = np.meshgrid(X, Y)
idcs = [0,3,6,9]
fig = plt.figure(figsize=(17.2*inCm,10*inCm))
for i in range(len(idcs)):
plt.subplot(2,4,i+1)
idx = idcs[i]
ax = plt.gca()
fun.plot_streamline(ax,models.sys_HC4,[],10, grid,0.9)
ax.set_title( '$\sigma = $'+str(sigmaValues[idx]),fontsize=10)
ax.set_xlabel('x',fontsize=10);plt.ylabel('y',fontsize=10)
for ic in range(5):
col = np.asarray(cmap(norm(ic))[0:3])
for ii in range(3):
ax.plot(simulations[idx,ic,ii,1,:],simulations[idx,ic,ii,2,:],lw=0.5,color=col)
ax.scatter(simulations[idx,ic,ii,1,0],simulations[idx,ic,ii,2,0],marker='o',color=col,s=30,edgecolors='black')
ax.set_box_aspect(1)
ax.xaxis.set_tick_params(labelsize=8)
ax.yaxis.set_tick_params(labelsize=8)
ax.set_xlim(0,5)
ax.set_ylim(0,5)
plt.xticks([0,1,2,3,4,5])
plt.yticks([0,1,2,3,4,5])
plt.subplot(2,4,i+5)
ax = plt.gca()
plt.xlabel('time (a.u.)',fontsize=10);plt.ylabel('x',fontsize=10)
for ic in range(5):
col = np.asarray(cmap(norm(ic))[0:3])
for ii in range(3):
ax.plot(simulations[idx,ic,ii,0,:],simulations[idx,ic,ii,1,:],color=col,lw=0.5)
ax.set_box_aspect(1/2)
ax.xaxis.set_tick_params(labelsize=8)
ax.yaxis.set_tick_params(labelsize=8)
ax.set_xlim(-10,500)
plt.xticks([0,500])
if i != 3:
ax.set_ylim(0,6)
plt.yticks([0,2.5,5])
else:
ax.set_ylim(-10,10)
plt.tight_layout()
plt.subplots_adjust(top=0.962,
bottom=0.038,
left=0.06,
right=0.985,
hspace=0.0,
wspace=0.41)
#%% Supplementary figure 2 (c,d) - plotting
simulations = np.load('data\\simdat_GC4_noisy_30runs.npy')
idcs = [0,3,6,9]
fig = plt.figure(figsize=(17.2*inCm,10*inCm))
for i in range(len(idcs)):
plt.subplot(2,4,i+1)
idx = idcs[i]
ax = plt.gca()
fun.plot_streamline(ax,models.sys_ghost4,[] ,10, grid, 1)
ax.set_title( '$\sigma = $'+str(sigmaValues[idx]),fontsize=10)
ax.set_xlabel('x',fontsize=10);plt.ylabel('y',fontsize=10)
for ic in range(5):
col = np.asarray(cmap(norm(ic))[0:3])
for ii in range(3):
ax.plot(simulations[idx,ic,ii,1,:],simulations[idx,ic,ii,2,:],lw=0.5,color=col)
ax.scatter(simulations[idx,ic,ii,1,0],simulations[idx,ic,ii,2,0],marker='o',color=col,s=30,edgecolors='black')
ax.set_box_aspect(1)
ax.xaxis.set_tick_params(labelsize=8)
ax.yaxis.set_tick_params(labelsize=8)
ax.set_xlim(0,5)
ax.set_ylim(0,5)
plt.xticks([0,1,2,3,4,5])
plt.yticks([0,1,2,3,4,5])
plt.subplot(2,4,i+5)
ax = plt.gca()
plt.xlabel('time (a.u.)',fontsize=10);plt.ylabel('x',fontsize=10)
for ic in range(5):
col = np.asarray(cmap(norm(ic))[0:3])
for ii in range(3):
ax.plot(simulations[idx,ic,ii,0,:],simulations[idx,ic,ii,1,:],color=col,lw=0.7)
ax.set_box_aspect(1/2)
ax.xaxis.set_tick_params(labelsize=8)
ax.yaxis.set_tick_params(labelsize=8)
ax.set_xlim(-10,500)
plt.xticks([0,500])
if i != 3:
ax.set_ylim(0,6)
plt.yticks([0,2.5,5])
plt.tight_layout()
plt.subplots_adjust(top=0.962,
bottom=0.038,
left=0.06,
right=0.985,
hspace=0.0,
wspace=0.41)