Last change
on this file since 774 was
774,
checked in by moutardier, 6 years ago
|
add print_datas.py to exploit data creat with initialise_motore.py fonction and create graph
|
File size:
1.2 KB
|
Line | |
---|
1 | import matplotlib.pyplot as plt |
---|
2 | |
---|
3 | def float_list(l): |
---|
4 | L = [] |
---|
5 | for i in l: |
---|
6 | L.append(float(i)) |
---|
7 | return(L) |
---|
8 | |
---|
9 | def print_data(fichier): |
---|
10 | fichier = open(fichier, "r") |
---|
11 | A = fichier.read() |
---|
12 | L = [[],[],[],[],[]] |
---|
13 | a = "" |
---|
14 | l = 0 |
---|
15 | for i in A: |
---|
16 | if (i == " ") : |
---|
17 | if l == 0: |
---|
18 | L[0].append(a) |
---|
19 | l +=1 |
---|
20 | elif l == 1: |
---|
21 | L[1].append(a) |
---|
22 | #print(a) |
---|
23 | l += 1 |
---|
24 | elif l == 2: |
---|
25 | L[2].append(a) |
---|
26 | l += 1 |
---|
27 | elif l == 3: |
---|
28 | L[3].append(a) |
---|
29 | l += 1 |
---|
30 | else: |
---|
31 | L[4].append(a) |
---|
32 | l = 0 |
---|
33 | a = "" |
---|
34 | elif (i == "\n") : |
---|
35 | a = "" |
---|
36 | else: |
---|
37 | a += i |
---|
38 | fichier.close() |
---|
39 | |
---|
40 | for i in range(5): |
---|
41 | L[i] = float_list(L[i]) |
---|
42 | plt.plot(L[0],L[1], label = "BMP_ref") |
---|
43 | plt.plot(L[0],L[2], label = "BMP_impr") |
---|
44 | plt.plot(L[0],L[3], label = "BMP_ref") |
---|
45 | plt.plot(L[0],L[4], label = "BMP_impr") |
---|
46 | plt.legend() |
---|
47 | plt.ylabel("length in motor step") |
---|
48 | plt.ylabel("tension in V") |
---|
49 | plt.show() |
---|
50 | |
---|
51 | |
---|
52 | |
---|
53 | print_data("data/position_vs_tension_ch1-3_bpm_ref_ch2-4_bpm_impr_20180528_115159_0.txt") |
---|
Note: See
TracBrowser
for help on using the repository browser.