-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathext_visualize.py
155 lines (128 loc) · 7.69 KB
/
ext_visualize.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
"""
Created by:
@author: Elias Obreque
@Date: 3/14/2021 1:49 PM
"""
import json
import matplotlib.pyplot as plt
from tools.Viewer import *
def get_performance(folder_file_name):
with open(folder_file_name) as file:
data = json.load(file)
name_thrusters = []
temp = data
performance_data = [temp['mean_pos'], temp['mean_vel'], temp['std_pos'], temp['std_vel']]
n_thrusters = len(performance_data[0])
name_thrusters.append(int(2))
return performance_data, n_thrusters, name_thrusters
# Alt-noise
folder_name = "logs/Only_GA_all/regressive/"
folder_name += "2022-02-20T14-41-53/"
file_name = "eva_reg_performance_data.json"
performance_data_regressive_alt, n_thrusters_regressive_alt, _ = get_performance(folder_name + file_name)
folder_name = "logs/Only_GA_all/progressive/"
folder_name += "2022-02-20T14-48-33/"
file_name = "eva_pro_performance_data.json"
performance_data_progressive_alt, n_thrusters_progressive_alt, _ = get_performance(folder_name + file_name)
folder_name = "logs/Only_GA_all/neutral/"
folder_name += "2022-02-20T14-48-52/"
file_name = "eva_neu_performance_data.json"
performance_data_constant_alt, n_thrusters_constant_alt, _ = get_performance(folder_name + file_name)
def plot_errorbar_performance(n_thrusters_constant_, performance_data_constant_,
n_thrusters_progressive_, performance_data_progressive_,
n_thrusters_regressive_, performance_data_regressive_):
fig_perf, axs_perf = plt.subplots(2, 1, sharex=True)
axs_perf[0].set_ylabel('Landing position [m]')
axs_perf[0].grid()
lw_data = 0.8
reg_color = 'r'
pro_color = 'b'
con_color = 'g'
axs_perf[0].errorbar(np.arange(1, 1 + n_thrusters_regressive_), np.array(performance_data_regressive_)[0],
yerr=np.array(performance_data_regressive_)[2], fmt='-', capsize=5, color=reg_color,
ecolor=reg_color, label='regressive', lw=lw_data)
axs_perf[0].errorbar(np.arange(1, 1 + n_thrusters_progressive_), np.array(performance_data_progressive_)[0],
yerr=np.array(performance_data_progressive_)[2], fmt='-', capsize=5, color=pro_color,
ecolor=pro_color, label='Progressive', lw=lw_data)
axs_perf[0].errorbar(np.arange(1, 1 + n_thrusters_constant_), np.array(performance_data_constant_)[0],
yerr=np.array(performance_data_constant_)[2], fmt='-', capsize=5, color=con_color,
ecolor=con_color, label='Neutral', lw=lw_data)
axs_perf[1].set_ylabel('Landing velocity [m/s]')
axs_perf[1].set_xlabel('Number of thrusters')
axs_perf[1].grid()
axs_perf[1].errorbar(np.arange(1, 1 + n_thrusters_regressive_), np.array(performance_data_regressive_)[1],
yerr=np.array(performance_data_regressive_)[3], fmt='-', capsize=5, ecolor=reg_color,
color=reg_color, label='regressive', lw=lw_data)
axs_perf[1].errorbar(np.arange(1, 1 + n_thrusters_progressive_), np.array(performance_data_progressive_)[1],
yerr=np.array(performance_data_progressive_)[3], fmt='-', capsize=5, ecolor=pro_color,
color=pro_color, label='Progressive', lw=lw_data)
axs_perf[1].errorbar(np.arange(1, 1 + n_thrusters_constant_), np.array(performance_data_constant_)[1],
yerr=np.array(performance_data_constant_)[3], fmt='-', capsize=5, ecolor=con_color,
color=con_color, label='Neutral', lw=lw_data)
# plt.legend(bbox_to_anchor=(1.05, 1.0), loc='upper left')
plt.legend()
plt.tight_layout()
return
def plot_velocity_errorbar_performance(n_thrusters_constant_, performance_data_constant_,
n_thrusters_progressive_, performance_data_progressive_,
n_thrusters_regressive_, performance_data_regressive_):
lw_data = 0.8
reg_color = 'r'
pro_color = 'b'
con_color = 'g'
fig_perf = plt.figure()
plt.ylabel('Landing velocity [m/s]')
plt.xlabel('Number of thrusters')
plt.grid()
plt.errorbar(np.arange(1, 1 + n_thrusters_regressive_), np.array(performance_data_regressive_)[1],
yerr=np.array(performance_data_regressive_)[3], fmt='-', capsize=5, ecolor=reg_color,
color=reg_color, label='regressive', lw=lw_data)
plt.errorbar(np.arange(1, 1 + n_thrusters_progressive_), np.array(performance_data_progressive_)[1],
yerr=np.array(performance_data_progressive_)[3], fmt='-', capsize=5, ecolor=pro_color,
color=pro_color, label='Progressive', lw=lw_data)
plt.errorbar(np.arange(1, 1 + n_thrusters_constant_), np.array(performance_data_constant_)[1],
yerr=np.array(performance_data_constant_)[3], fmt='-', capsize=5, ecolor=con_color,
color=con_color, label='Neutral', lw=lw_data)
plt.legend()
plt.tight_layout()
fig_perf.savefig("./logs/comparison.png", dpi=300, bbox_inches='tight')
fig_perf.savefig("./logs/comparison.eps", format='eps', bbox_inches='tight')
return
def plot_std_performance(n_thrusters_constant_, performance_data_constant_,
n_thrusters_progressive_, performance_data_progressive_,
n_thrusters_regressive_, performance_data_regressive_):
lw_data = 0.8
reg_color = 'r'
pro_color = 'b'
con_color = 'g'
fig_perf_std, axs_perf_std = plt.subplots(2, 1, sharex=True)
axs_perf_std[0].set_ylabel('Std of Position [m]')
axs_perf_std[0].grid()
axs_perf_std[0].plot(np.arange(1, 1 + n_thrusters_regressive_), np.array(performance_data_regressive_)[2],
'-o', color=reg_color, lw=lw_data, label='regressive')
axs_perf_std[0].plot(np.arange(1, 1 + n_thrusters_progressive_), np.array(performance_data_progressive_)[2],
'-o', color=pro_color, lw=lw_data,label='Progressive')
axs_perf_std[0].plot(np.arange(1, 1 + n_thrusters_constant_), np.array(performance_data_constant_)[2],
'-o', color=con_color, lw=lw_data,label='Neutral')
axs_perf_std[1].set_xlabel('Number of thrusters')
axs_perf_std[1].set_ylabel('std of Velocity [m/s]')
axs_perf_std[1].plot(np.arange(1, 1 + n_thrusters_regressive_), np.array(performance_data_regressive_)[3],
'-o', color=reg_color, lw=lw_data,label='regressive')
axs_perf_std[1].plot(np.arange(1, 1 + n_thrusters_progressive_), np.array(performance_data_progressive_)[3],
'-o', color=pro_color, lw=lw_data,label='Progressive')
axs_perf_std[1].plot(np.arange(1, 1 + n_thrusters_constant_), np.array(performance_data_constant_)[3],
'-o', color=con_color, lw=lw_data,label='Neutral')
axs_perf_std[1].grid()
plt.legend()
plt.tight_layout()
plot_errorbar_performance(n_thrusters_constant_alt, performance_data_constant_alt,
n_thrusters_progressive_alt, performance_data_progressive_alt,
n_thrusters_regressive_alt, performance_data_regressive_alt)
plot_std_performance(n_thrusters_constant_alt, performance_data_constant_alt,
n_thrusters_progressive_alt, performance_data_progressive_alt,
n_thrusters_regressive_alt, performance_data_regressive_alt)
plot_velocity_errorbar_performance(n_thrusters_constant_alt, performance_data_constant_alt,
n_thrusters_progressive_alt, performance_data_progressive_alt,
n_thrusters_regressive_alt, performance_data_regressive_alt)
plt.show()