-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotter.py
74 lines (45 loc) · 1.99 KB
/
plotter.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
#! /usr/bin/python3
import numpy as np
import matplotlib.pyplot as plt
import sys
### arguments
filename = "computed_data.csv"
folder = str(sys.argv[1])
### lecture de computed_data.csv et creation d'une matrice file
file = np.genfromtxt(folder+filename, delimiter = ', ', dtype = None)
csvLen = file.shape[0]
### plot mean power over 7 sec and energy use over time
fig, (p1, p2) = plt.subplots(2)
meanPPower = np.array([])
meanTPower =np.array([])
for i in range(1, csvLen-5):
meanPPower = np.append(meanPPower, [(file[i-3, 11] + file[i-2, 11] + file[i-1, 11] + file[i, 11] + file[i+1, 11] + file[i+2, 11] + file[i+3, 11]) / 7])
for i in range(1, csvLen-5):
meanTPower = np.append(meanTPower, [(file[i-3, 13] + file[i-2, 13] + file[i-1, 13] + file[i, 13] + file[i+1, 13] + file[i+2, 13] + file[i+3, 13]) / 7])
#p1.plot(np.arange(3, csvLen - 3), meanPPower, label="Power output (slope only)") ### utilisé seulement pour certains graphes
p1.plot(np.arange(3, csvLen - 3), meanTPower, label="Power output")
#p2.plot(np.arange(0,csvLen), file[:, 12], label="Potential energy") ### utilisé seulement pour certains graphes
p2.plot(np.arange(0,csvLen), file[:, 14], label="Energy")
plt.xlabel("Time [s]")
p1.set_ylabel("Power [W]")
p2.set_ylabel("Energy [Wh]")
p1.grid()
p2.grid()
plt.savefig(folder + "power_energy.svg", format="svg")
plt.clf()
### deviation from reference point
plt.scatter(file[:, 0] - file[0, 0], file[:, 2] - file[0, 2], c=np.linspace(0, 1, csvLen), cmap="plasma")
plt.xlabel("Deviation relative to reference point, axis E [m]")
plt.ylabel("Deviation relative to reference point, axis N [m]")
plt.gca().set_aspect('equal', adjustable='box')
plt.grid()
plt.savefig(folder + "gps_deviation.svg", format="svg")
plt.clf()
### altimetric profile
plt.plot(np.arange(0,csvLen), file[:,15])
plt.grid()
plt.title("Altitude variation from start point, across time")
plt.xlabel("Time [s]")
plt.ylabel("Altitude profile [m]")
plt.savefig(folder + "altimetric_profile.svg", format="svg")
plt.clf()