-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraph.py
44 lines (31 loc) · 1.12 KB
/
graph.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
import matplotlib.pyplot as plt
import os
import numpy as np
import sys
#data = np.genfromtxt('./datos/{}'.format(os.listdir('./datos')[int(choice)]), delimiter=',')
"""
BITS, TEMPERATURE
"""
def graph_stadistic(data):
data = np.genfromtxt(data, delimiter=',')
column = data[:, 1]
mean = np.mean(column)
peaks = []
for i in column:
if i > mean + 0.4 or i < mean - 0.4:
peaks.append(i)
plt.plot(column)
plt.xlabel('N° de muestra')
plt.ylabel('Temp')
#plt.ylim(-20, 80)
coefficient_of_variation = (np.std(column) / np.mean(column)) * 100
plt.plot([], [], ' ', label='Media de la temperatura: ' + str(np.mean(column)) + '°C')
plt.plot([], [], ' ', label='Coeficiente de variación: ' + str(coefficient_of_variation) + '%')
plt.plot([], [], ' ', label="Número de Muestras: " + str(len(column)) + " Número de peaks: " + str(len(peaks)))
plt.plot([], [], ' ', label= "±" + str(max(data[:, 1]) - min(data[:, 1])) + '°C')
plt.legend()
plt.show()
if len(sys.argv) > 1:
graph_stadistic(sys.argv[1])
else:
print("Usage: python graph.py <file>")