Repository navigation
Expand file tree
/
Copy pathplot_optimal_solution.py
More file actions
55 lines (41 loc) · 1.86 KB
/
Copy pathplot_optimal_solution.py
File metadata and controls
55 lines (41 loc) · 1.86 KB
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
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import numpy as np
np.random.seed(1998)
from parameter_estimation import read_files
def plot(unique_letters, model_predictions):
in_silico_data = read_files("exp_data_fruc_HMF")
# This takes the first column from each entry of the dictionary and puts it into another dictionary
initial_conditions = {}
for key, value in in_silico_data.items():
aa = "ic_" + key[-1]
initial_conditions[aa] = value[0]
num_exp = len(initial_conditions)
timesteps = 30
time = np.linspace(0, 2, timesteps)
t = [0, np.max(time)]
t_eval = list(time)
species = list(sorted(unique_letters))
color_1 = cm.plasma(np.linspace(0, 1, 3))
marker = ['o' for i in range(3)]
# Plotting the in-silico data for visualisation
for i in range(num_exp):
fig, ax = plt.subplots()
# ax.set_title("Experiment " + str(i + 1))
ax.set_ylabel("Concentrations $(M)$", fontsize = 18)
ax.set_xlabel("Time $(h)$", fontsize = 18)
ax.spines["right"].set_visible(False)
ax.spines["top"].set_visible(False)
ax.tick_params(axis = 'both', which = 'major', labelsize = 18)
for j in np.array([0, 1, -1]):
y = in_silico_data["exp_" + str(i + 1)][:, j]
yy = model_predictions["exp_" + str(i + 1)][:, j]
if j == -1:
ax.plot(time, y, marker[j], markersize = 4, label = 'C', color = color_1[j])
ax.plot(time, yy, '-', color = color_1[j])
else:
ax.plot(time, y, marker[j], markersize = 4, label = species[j], color = color_1[j])
ax.plot(time, yy, '-', color = color_1[j])
ax.grid(alpha = 0.5)
ax.legend(loc='upper right', fontsize = 15)
plt.show()