-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrajectory-plotter.py
137 lines (78 loc) · 3.52 KB
/
trajectory-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
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 13 09:25:19 2017
@author: anwaldt
"""
########################################################################################
# Start Stuff
########################################################################################
import argparse
import numpy as np
import matplotlib.pyplot as mpl
########################################################################################
# READ FILEs
########################################################################################
########################################################################################
# PLOT Amplitudes
########################################################################################
def plot_apmlitudes(sourceID):
AmpFile = 'gains'
#amplitudes = np.loadtxt(AmpFile, dtype='d', delimiter='\t')
amplitudes = np.loadtxt(AmpFile, delimiter='\t', usecols=(1,2,3,4))
paths = np.genfromtxt(AmpFile ,usecols=(0) ,dtype='str')
#mpl.style.use('default')
#fig, ax1 = mpl.subplots()
#ax1.set_xlabel('frame')
#ax1.set_ylabel('Partial amplitudes' ,color = [ 0.3, 0.3, 0.3])
#ax1.plot(amplitudes[:10,1], label='P_1', linewidth=0.5)
########################################################################################
# PLOT Amplitudes
########################################################################################
def plot_position_xy(file, startIDX,stopIDX):
print("Plotting x-y for: "+file)
positions = np.loadtxt(posFile, delimiter='\t', usecols=(0,2,3,4,5))
newAR = positions;
#newAR = newAR[startIDX:stopIDX,:]
# N = len(newAR)
#plot_position_xy(2,-1,-1)
mpl.style.use('default')
fig, ax1 = mpl.subplots()
ax1.set_xlabel('x')
ax1.set_ylabel('y' ,color = [ 0.3, 0.3, 0.3])
# Does not work for long trajectories
#for i in range(N-1):
# colIDX = i/N
# ax1.plot(newAR[i:i+2,2], newAR[i:i+2,3], linewidth=0.75, color= mpl.cm.jet(colIDX))
ax1.plot(newAR[:,2], newAR[:,3], linewidth=0.75)
# ax1.plot(newAR[startIDX:stopIDX,0], newAR[startIDX:stopIDX,3], linewidth=0.75)
fig.savefig(args.infile + '_XY_' + '.pdf')
return 0
def plot_position_X(newAR, startIDX,stopIDX):
mpl.style.use('default')
fig, ax1 = mpl.subplots()
ax1.set_xlabel('t')
ax1.set_ylabel('x' ,color = [ 0.3, 0.3, 0.3])
ax1.plot(newAR[startIDX:stopIDX,0], newAR[startIDX:stopIDX,2], linewidth=0.75)
fig.savefig(args.infile + '_X_' + '.pdf')
return 0
def plot_position_Y(newAR, startIDX,stopIDX):
mpl.style.use('default')
fig, ax1 = mpl.subplots()
ax1.set_xlabel('t')
ax1.set_ylabel('x' ,color = [ 0.3, 0.3, 0.3])
ax1.plot(newAR[startIDX:stopIDX,0], newAR[startIDX:stopIDX,3], linewidth=0.75)
fig.savefig(args.infile + '_Y_' + '.pdf')
return 0
########################################################################################
#
########################################################################################
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--infile",
help="filename for plot")
parser.add_argument("--p1")
parser.add_argument("--p2")
args = parser.parse_args()
posFile = args.infile
plot_position_xy(posFile, -1,-1)