-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_pose.py
122 lines (108 loc) · 4.53 KB
/
plot_pose.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
# -*- coding: utf-8 -*-
"""
Created on Fri May 19 15:48:59 2023
@author: Luca Rosignoli
Script to red a tms run and plot the pose evolution (x,y,z,rx,rx,rz) and their corrections.
"""
from tms_data_new import tms_data
import matplotlib.pyplot as plt
import os
import numpy as np
path = ''
timestamp = ''
#Load data
tms_run = tms_data(path, timestamp)
#pose sx plots
id_ref = tms_run.data['pose.sx']['#timestamp'][tms_run.data['pose.sx']['#timestamp']
== tms_run.data['ref.sx']['#timestamp'][0]
].index[0]
posesx_ref = tms_run.data['pose.sx'][tms_run.data['pose.sx']['#timestamp'] ==
tms_run.data['ref.sx']['#timestamp'][0]]
fig, axs = plt.subplots(2, 3, tight_layout=True)
fig.suptitle('LEFT', fontweight='bold')
for i, key in enumerate(zip(tms_run.data['pose.sx'].columns[1:],
tms_run.data['correction.sx'].columns[1:])):
if i <= 2:
j = 0
k = i
else:
j = 1
k = i-3
axs[j, k].scatter(tms_run.data['pose.sx']['#timestamp'][id_ref+1:],
tms_run.data['pose.sx'][key[0]][id_ref+1:].values-posesx_ref[key[0]].values[0],
marker='x',
s=1,
c='blue',
label = 'Pose')
if key[0] == 'z':
axs[j, k].scatter(np.arange(id_ref, len(tms_run.data['correction.sx'][key[1]])),
tms_run.data['correction.sx'][key[1]][id_ref:]+
tms_run.data['thermalz4.sx']['thermal_z4'][id_ref:],
marker='x',
s=1,
c='red',
label = 'Correction+ZTh')
else:
axs[j, k].scatter(np.arange(id_ref, len(tms_run.data['correction.sx'][key[1]])),
tms_run.data['correction.sx'][key[1]][id_ref:],
marker='x',
s=1,
c='red',
label = 'Correction')
axs[j, k].xaxis.set_major_locator(plt.MaxNLocator(5))
axs[j, k].set_xticks([])
axs[j, k].set_title(f'{key[0]}', fontweight='semibold')
axs[j, k].set_xlabel('Time')
if j == 0:
axs[j, k].set_ylabel('Deviation mm')
else:
axs[j, k].set_ylabel('Deviation arcsec')
axs[j, k].legend(fontsize='xx-small')
plt.savefig(os.path.join(path, f'plots/{timestamp}_sx_plots.png'), dpi=1000)
#pose dx plots
id_ref = tms_run.data['pose.dx']['#timestamp'][tms_run.data['pose.dx']['#timestamp']
== tms_run.data['ref.dx']['#timestamp'][0]
].index[0]
posedx_ref = tms_run.data['pose.dx'][tms_run.data['pose.dx']['#timestamp'] ==
tms_run.data['ref.dx']['#timestamp'][0]]
fig, axs = plt.subplots(2, 3, tight_layout=True)
fig.suptitle('RIGHT', fontweight='bold')
for i, key in enumerate(zip(tms_run.data['pose.dx'].columns[1:],
tms_run.data['correction.dx'].columns[1:])):
if i <= 2:
j = 0
k = i
else:
j = 1
k = i-3
axs[j, k].scatter(tms_run.data['pose.dx']['#timestamp'][id_ref+1:],
tms_run.data['pose.dx'][key[0]][id_ref+1:].values-posedx_ref[key[0]].values[0],
marker='x',
s=1,
c='blue',
label = 'Pose')
if key[0] == 'z':
axs[j, k].scatter(np.arange(id_ref, len(tms_run.data['correction.dx'][key[1]])),
tms_run.data['correction.dx'][key[1]][id_ref:]+
tms_run.data['thermalz4.dx']['thermal_z4'][id_ref:],
marker='x',
s=1,
c='red',
label = 'Correction+ZTh')
else:
axs[j, k].scatter(np.arange(id_ref, len(tms_run.data['correction.dx'][key[1]])),
tms_run.data['correction.dx'][key[1]][id_ref:],
marker='x',
s=1,
c='red',
label = 'Correction')
axs[j, k].xaxis.set_major_locator(plt.MaxNLocator(5))
axs[j, k].set_xticks([])
axs[j, k].set_title(f'{key[0]}', fontweight='semibold')
axs[j, k].set_xlabel('Time')
if j == 0:
axs[j, k].set_ylabel('Deviation mm')
else:
axs[j, k].set_ylabel('Deviation arcsec')
axs[j, k].legend(fontsize='xx-small')
plt.savefig(os.path.join(path, f'plots/{timestamp}_dx_plots.png'), dpi=1000)