-
Notifications
You must be signed in to change notification settings - Fork 0
/
exp5-6-realizations.py
95 lines (76 loc) · 2.8 KB
/
exp5-6-realizations.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# %%
import pandas as pd
import numpy as np
import matplotlib as mpl
mpl.rc('text', usetex=True)
mpl.rc('font', family='serif')
mpl.rc('font', size=10)
def mav(x, w=100):
return np.convolve(x, np.ones(w), 'valid') / w
# %%
# file with data from the experiment
# Note: header=6 is for NetLogo data
exp_1_desc = 'exp5-realization_non-eq_weights'
# exp_2_desc = 'exp6-realization_non-eq_weights'
exp_3_desc = 'exp6a-realization_non-eq_weights'
exp_4_desc = 'exp6b-realization_non-eq_weights'
exp_desc = 'v3w-exp5-6'
df_1 = pd.read_csv(exp_1_desc + '.csv', header=6)
# df_2 = pd.read_csv(exp_2_desc + '.csv', header=6)
df_3 = pd.read_csv(exp_3_desc + '.csv', header=6)
df_4 = pd.read_csv(exp_4_desc + '.csv', header=6)
# %%
# select variables for the analysis
# this depends on the experiment
# variables
# 1st is different for each plot
# 2nd and 3rd vars provide axes for plots
# 4th variable is visualized
# variant 1
# v = ['mobility-prob', 'patch-infection-weight', 'patch-contamination-prob','mean-infected']
# variant 2
v = ['patch-heal-prob', '[step]', '%infected']
vl = [r'$\delta_c$', 'step', 'percentage of infected']
# selection for plotting
# selected values of the 1st variable
# mrs = [0.1, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.6, 0.75, 0.9, 1]
# var0s = [0, 0.03, 0.07, 0.1, 0.15, 0.2, 0.3, 0.45, 0.5]
# var0s = [0, 0.02, 0.03, 0.07, 0.12, 0.15]
var0s = [0, 0.02, 0.04, 0.06, 0.08, 0.10, 0.12, 0.15, 0.50]
# %%
fig = mpl.figure.Figure(figsize=(6, 4.5))
# levels = [1,10,20,30,40,50,60,70]
skip = 200
for i, v0 in enumerate(var0s):
axs = fig.add_subplot(331 + i);
plot_data_1 = df_1[df_1[v[0]] == v0][[v[1], v[2]]].to_numpy()
# plot_data_2 = df_2[df_2[v[0]] == v0][[v[1], v[2]]].to_numpy()
plot_data_3 = df_3[df_3[v[0]] == v0][[v[1], v[2]]].to_numpy()
plot_data_4 = df_4[df_4[v[0]] == v0][[v[1], v[2]]].to_numpy()
axs.plot(mav(plot_data_1.T[1]), color='black', linestyle='--', lw=0.75)
# axs.plot(mav(plot_data_2.T[1]), color='green', linestyle='-', lw=0.75)
axs.plot(mav(plot_data_3.T[1]), color='blue', linestyle='-.', lw=0.75)
axs.plot(mav(plot_data_4.T[1]), color='green', linestyle='-', lw=0.75)
axs.set_ylim([-5, 100])
axs.set_xlim([-200, 10000])
axs.set_xticks([0, 3500, 7000, 10000])
axs.set_yticks([0, 25, 50, 75, 100])
axs.set_title('abcdefghi'[i] + ') ' + vl[0] + "={:.2f}".format(v0))
axs.grid(True, linestyle=':', linewidth=0.5, c='k')
if i not in [6, 7, 8]:
axs.set_xticklabels([])
if i not in [0, 3, 6]:
axs.set_yticklabels([])
if i == 7:
axs.set_xlabel(vl[1])
if i == 3:
axs.set_ylabel(vl[2])
# %%
fig.tight_layout()
display(fig)
# %%
fName = "plot_" + exp_desc + ".pdf"
print("INFO] Saving " + fName)
fig.savefig(fName, format="pdf", bbox_inches='tight')