-
Notifications
You must be signed in to change notification settings - Fork 0
/
track_plots.py
209 lines (166 loc) · 6.19 KB
/
track_plots.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
import numpy as np
import matplotlib.pyplot as plt
def print_fft_naff(scripts, fft_x_list, naff_x_list, fft_y_list, naff_y_list):
plt.close('all')
plt.figure(1, figsize=(10,10))
plt.plot(scripts, fft_x_list, 'y')
plt.title('Prominent frequency (FFT-x plane)')
plt.xlabel('Number of turns')
plt.ylabel('Frequency')
plt.grid(True)
plt.figure(2, figsize=(10,10))
plt.plot(scripts, naff_x_list, 'm')
plt.title('Prominent frequency (NAFF-x plane)')
plt.xlabel('Number of turns')
plt.ylabel('Frequency')
plt.grid(True)
plt.figure(3, figsize=(10,10))
plt.plot(scripts, fft_y_list, 'r')
plt.title('Prominent frequency (FFT-y plane)')
plt.xlabel('Number of turns')
plt.ylabel('Frequency')
plt.grid(True)
plt.figure(4, figsize=(10,10))
plt.plot(scripts, naff_y_list, 'g')
plt.title('Prominent frequency (NAFF-y plane)')
plt.xlabel('Number of turns')
plt.ylabel('Frequency')
plt.grid(True)
plt.show()
#All the below are called by transformations.py
#plot (X,PX), (Y,PY), (T,PT) and also X,Y,T,PX,PY,PT over time
def track_all (X, Y, T, PX, PY, PT, N_part = 10):
plt.rc('text', usetex=True)
plt.rc('font', family='serif')
#plot coordinates
plt.close('all')
plt.figure(1, figsize = (8,8))
sp1 = plt.subplot(3,1,1)
plt.title(r'$Tracking (X)$') #(X,PX)
plt.xlabel(r'$X$')
plt.ylabel(r'$PX$')
plt.grid(True)
sp2 = plt.subplot(3,1,2, sharex=sp1)
plt.title(r'$Tracking (Y)$') #(Y,PY)
plt.xlabel(r'$Y$')
plt.ylabel(r'$PY$')
plt.grid(True)
sp3 = plt.subplot(3,1,3)
plt.title(r'$Tracking (T)$') #(T,PT)
plt.xlabel(r'$T$')
plt.ylabel(r'$T$')
plt.grid(True)
plt.subplots_adjust( hspace=0.5, wspace=0.9)
#coordinates vs time
plt.figure(2, figsize = (8,8))
spt1 = plt.subplot(3,1,1)
plt.title(r'$X$') #(X,t)
plt.ylabel(r'$X$')
plt.xlabel(r'$t$')
spt2 = plt.subplot(3,1,2, sharex=spt1)
plt.title(r'$Y$') #(Y,t)
plt.ylabel(r'Y')
plt.xlabel(r't')
spt3 = plt.subplot(3,1,3, sharex=spt1)
plt.title(r'$T$') #(T,t)
plt.ylabel(r'$T$')
plt.xlabel(r'$t$')
plt.subplots_adjust( hspace=0.5, wspace=0.9)
plt.figure(3, figsize = (8,8))
spp1 = plt.subplot(3,1,1)
plt.title(r'$PX$') #(PX,t)
plt.ylabel(r'$PX$')
plt.xlabel(r'$t$')
spp2 = plt.subplot(3,1,2, sharex=spt1)
plt.title(r'$PY$') #(PY,t)
plt.ylabel(r'$PY$')
plt.xlabel(r'$t$')
spp3 = plt.subplot(3,1,3, sharex=spt1)
plt.title(r'$PT$') #(PT,t)
plt.ylabel(r'$PT$')
plt.xlabel(r'$t$')
plt.subplots_adjust( hspace=0.5, wspace=0.9)
for i_part in range(N_part):
thicolor = plt.cm.rainbow(float(i_part)/float(N_part))
sp1.plot(X[i_part], PX[i_part], '.', color = thicolor)
sp2.plot(Y[i_part], PY[i_part], '.', color = thicolor)
sp3.plot(T[i_part], PT[i_part], '.', color = thicolor)
spt1.plot(X[i_part])
spt2.plot(Y[i_part])
spt3.plot(T[i_part])
spp1.plot(PX[i_part])
spp2.plot(PY[i_part])
spp3.plot(PT[i_part])
plt.show()
#Plots x and y coordinates vs the number of turns
def plot_turns(turn, x_objects, y_objects, N_part = 10):
plt.rc('text', usetex=True)
plt.rc('font', family='serif')
plt.close('all')
plt.figure(1)
#track particles in X and Y plane
spt1 = plt.subplot(3,1,1) #(X,N)
plt.title(r'$Tracking (X)$')
plt.xlabel(r'$Number$ $of$ $turns$')
plt.ylabel(r'$X$')
plt.grid(True)
spt2 = plt.subplot(3,1,2, sharex=spt1)
plt.title(r'$Tracking (Y)$') #(Y,N)
plt.xlabel(r'$Number$ $of$ $turns$')
plt.ylabel(r'$Y$')
plt.grid(True)
plt.subplots_adjust(top=0.9, bottom=-0.3, right=0.85, hspace=0.5, wspace=0.9)
for i_part in range(N_part):
thicolor = plt.cm.rainbow(float(i_part)/float(N_part))
spt1.plot(turn[i_part], x_objects[i_part], '.', color = thicolor)
spt2.plot(turn[i_part], y_objects[i_part], '.', color = thicolor)
plt.show()
#plot NAFF spectrum for all particles
def plot_naff(naff_X, amp_X, naff_Y, amp_Y):
plt.rc('text', usetex=True)
plt.rc('font', family='serif')
plt.figure()
plt.plot(naff_X, amp_X)
plt.suptitle(r'$NAFF$ $transformation$', fontsize = 16)
plt.title(r'$Amplitude$ $vs$ $Frequency$')
plt.xlabel(r'$Frequency$')
plt.ylabel(r'$Amplitude$')
plt.grid(True)
plt.show()
#plot spectrum (amplitude and phase) of the FFT for x and y planes
def print_fourier(f_X, f_Y, fft_X, fft_Y, N_part = 10):
plt.rc('text', usetex=True)
plt.rc('font', family='serif')
plt.close('all')
plt.figure()
plt.suptitle('FFT')
#X
sp1 = plt.subplot(4,2,1)
plt.title(r'$Amplitude$ $for$ $X$')
plt.xlabel(r'$Frequency$')
plt.ylabel(r'$Amplitude$')
plt.grid(True)
sp2 = plt.subplot(4,2,2, sharex=sp1)
plt.title(r'$Phase$ $for$ $X$')
plt.xlabel(r'$Frequency$')
plt.ylabel(r'$Phase$')
plt.grid(True)
#Y
sp3 = plt.subplot(4,2,3)
plt.title(r'$Amplitude$ $for$ $y$')
plt.xlabel(r'$Frequency$')
plt.ylabel(r'$Amplitude$')
plt.grid(True)
sp4 = plt.subplot(4,2,4, sharex=sp1)
plt.title(r'$Phase$ $for$ $y$')
plt.xlabel(r'$Frequency$')
plt.ylabel(r'$Phase$')
plt.grid(True)
plt.subplots_adjust(top=0.92, bottom=-0.85, right=0.85, hspace=0.5, wspace=0.5)
for i_part in xrange (N_part):
thicolor = plt.cm.rainbow(float(i_part)/float(N_part))
sp1.plot(f_X[i_part], abs(fft_X[i_part]), color = thicolor)
sp2.plot(f_X[i_part], np.angle(fft_X[i_part]), color = thicolor)
sp3.plot(f_Y[i_part], abs(fft_Y[i_part]), color = thicolor)
sp4.plot(f_Y[i_part], np.angle(fft_Y[i_part]), color = thicolor)
plt.show()