The requested changes are too big and content was truncated. Show full diff
@@ -1,1254 +1,1229 | |||
|
1 | 1 | # Copyright (c) 2012-2021 Jicamarca Radio Observatory |
|
2 | 2 | # All rights reserved. |
|
3 | 3 | # |
|
4 | 4 | # Distributed under the terms of the BSD 3-clause license. |
|
5 | 5 | """Classes to plot Spectra data |
|
6 | 6 | |
|
7 | 7 | """ |
|
8 | 8 | |
|
9 | 9 | import os |
|
10 | 10 | import numpy |
|
11 | 11 | |
|
12 | 12 | from schainpy.model.graphics.jroplot_base import Plot, plt, log |
|
13 | 13 | |
|
14 | 14 | |
|
15 | 15 | class SpectraPlot(Plot): |
|
16 | 16 | ''' |
|
17 | 17 | Plot for Spectra data |
|
18 | 18 | ''' |
|
19 | 19 | |
|
20 | 20 | CODE = 'spc' |
|
21 | 21 | colormap = 'jet' |
|
22 | 22 | plot_type = 'pcolor' |
|
23 | 23 | buffering = False |
|
24 | 24 | |
|
25 | 25 | def setup(self): |
|
26 | 26 | |
|
27 | 27 | self.nplots = len(self.data.channels) |
|
28 | 28 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) |
|
29 | 29 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
|
30 | 30 | self.height = 2.6 * self.nrows |
|
31 | 31 | self.cb_label = 'dB' |
|
32 | 32 | if self.showprofile: |
|
33 | 33 | self.width = 4 * self.ncols |
|
34 | 34 | else: |
|
35 | 35 | self.width = 3.5 * self.ncols |
|
36 | 36 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) |
|
37 | 37 | self.ylabel = 'Range [km]' |
|
38 | 38 | |
|
39 | 39 | def update(self, dataOut): |
|
40 | 40 | |
|
41 | 41 | data = {} |
|
42 | 42 | meta = {} |
|
43 | 43 | spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor) |
|
44 | 44 | data['spc'] = spc |
|
45 | 45 | data['rti'] = dataOut.getPower() |
|
46 | 46 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) |
|
47 | 47 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) |
|
48 | 48 | |
|
49 | 49 | if self.CODE == 'spc_moments': |
|
50 | 50 | data['moments'] = dataOut.moments |
|
51 | # data['spc'] = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor) | |
|
52 | 51 | if self.CODE == 'gaussian_fit': |
|
53 | # data['moments'] = dataOut.moments | |
|
54 | 52 | data['gaussfit'] = dataOut.DGauFitParams |
|
55 | # data['spc'] = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor) | |
|
56 | 53 | |
|
57 | 54 | return data, meta |
|
58 | 55 | |
|
59 | 56 | def plot(self): |
|
60 | 57 | |
|
61 | #print(self.xaxis) | |
|
62 | #exit(1) | |
|
63 | 58 | if self.xaxis == "frequency": |
|
64 | 59 | x = self.data.xrange[0] |
|
65 | 60 | self.xlabel = "Frequency (kHz)" |
|
66 | 61 | elif self.xaxis == "time": |
|
67 | 62 | x = self.data.xrange[1] |
|
68 | 63 | self.xlabel = "Time (ms)" |
|
69 | 64 | else: |
|
70 | 65 | x = self.data.xrange[2] |
|
71 | 66 | self.xlabel = "Velocity (m/s)" |
|
72 | 67 | |
|
73 | 68 | if (self.CODE == 'spc_moments') | (self.CODE == 'gaussian_fit'): |
|
74 | 69 | x = self.data.xrange[2] |
|
75 | 70 | self.xlabel = "Velocity (m/s)" |
|
76 | 71 | |
|
77 | 72 | self.titles = [] |
|
78 | 73 | |
|
79 | 74 | y = self.data.yrange |
|
80 | 75 | self.y = y |
|
81 | 76 | |
|
82 | 77 | data = self.data[-1] |
|
83 | 78 | z = data['spc'] |
|
84 | 79 | |
|
85 | 80 | self.CODE2 = 'spc_oblique' |
|
86 | 81 | |
|
87 | 82 | |
|
88 | 83 | for n, ax in enumerate(self.axes): |
|
89 | 84 | noise = data['noise'][n] |
|
90 | 85 | if self.CODE == 'spc_moments': |
|
91 | 86 | mean = data['moments'][n, 1] |
|
92 | 87 | if self.CODE == 'gaussian_fit': |
|
93 | # mean = data['moments'][n, 1] | |
|
94 | 88 | gau0 = data['gaussfit'][n][2,:,0] |
|
95 | 89 | gau1 = data['gaussfit'][n][2,:,1] |
|
96 | 90 | if ax.firsttime: |
|
97 | 91 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
98 | 92 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
99 | 93 | self.zmin = self.zmin if self.zmin else numpy.nanmin(z) |
|
100 | 94 | self.zmax = self.zmax if self.zmax else numpy.nanmax(z) |
|
101 | #print(numpy.shape(x)) | |
|
102 | 95 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
103 | 96 | vmin=self.zmin, |
|
104 | 97 | vmax=self.zmax, |
|
105 | 98 | cmap=plt.get_cmap(self.colormap) |
|
106 | 99 | ) |
|
107 | 100 | |
|
108 | 101 | if self.showprofile: |
|
109 | 102 | ax.plt_profile = self.pf_axes[n].plot( |
|
110 | 103 | data['rti'][n], y)[0] |
|
111 | 104 | ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y, |
|
112 | 105 | color="k", linestyle="dashed", lw=1)[0] |
|
113 | 106 | if self.CODE == 'spc_moments': |
|
114 | 107 | ax.plt_mean = ax.plot(mean, y, color='k', lw=1)[0] |
|
115 | 108 | if self.CODE == 'gaussian_fit': |
|
116 | 109 | ax.plt_gau0 = ax.plot(gau0, y, color='r', lw=1)[0] |
|
117 | 110 | ax.plt_gau1 = ax.plot(gau1, y, color='y', lw=1)[0] |
|
118 | 111 | else: |
|
119 | 112 | ax.plt.set_array(z[n].T.ravel()) |
|
120 | 113 | if self.showprofile: |
|
121 | 114 | ax.plt_profile.set_data(data['rti'][n], y) |
|
122 | 115 | ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y) |
|
123 | 116 | if self.CODE == 'spc_moments': |
|
124 | 117 | ax.plt_mean.set_data(mean, y) |
|
125 | 118 | if self.CODE == 'gaussian_fit': |
|
126 | 119 | ax.plt_gau0.set_data(gau0, y) |
|
127 | 120 | ax.plt_gau1.set_data(gau1, y) |
|
128 | 121 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) |
|
129 | 122 | |
|
130 | 123 | class SpectraObliquePlot(Plot): |
|
131 | 124 | ''' |
|
132 | 125 | Plot for Spectra data |
|
133 | 126 | ''' |
|
134 | 127 | |
|
135 | CODE = 'spc' | |
|
128 | CODE = 'spc_oblique' | |
|
136 | 129 | colormap = 'jet' |
|
137 | 130 | plot_type = 'pcolor' |
|
138 | 131 | |
|
139 | 132 | def setup(self): |
|
140 | 133 | self.xaxis = "oblique" |
|
141 | 134 | self.nplots = len(self.data.channels) |
|
142 | 135 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) |
|
143 | 136 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
|
144 | 137 | self.height = 2.6 * self.nrows |
|
145 | 138 | self.cb_label = 'dB' |
|
146 | 139 | if self.showprofile: |
|
147 | 140 | self.width = 4 * self.ncols |
|
148 | 141 | else: |
|
149 | 142 | self.width = 3.5 * self.ncols |
|
150 | 143 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) |
|
151 | 144 | self.ylabel = 'Range [km]' |
|
152 | 145 | |
|
146 | def update(self, dataOut): | |
|
147 | ||
|
148 | data = {} | |
|
149 | meta = {} | |
|
150 | spc = 10*numpy.log10(dataOut.data_spc/dataOut.normFactor) | |
|
151 | data['spc'] = spc | |
|
152 | data['rti'] = dataOut.getPower() | |
|
153 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) | |
|
154 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) | |
|
155 | ||
|
156 | data['shift1'] = dataOut.Oblique_params[0][1] | |
|
157 | data['shift2'] = dataOut.Oblique_params[0][4] | |
|
158 | data['shift1_error'] = dataOut.Oblique_param_errors[0][1] | |
|
159 | data['shift2_error'] = dataOut.Oblique_param_errors[0][4] | |
|
160 | ||
|
161 | return data, meta | |
|
162 | ||
|
153 | 163 | def plot(self): |
|
154 | 164 | |
|
155 | #print(self.xaxis) | |
|
156 | #exit(1) | |
|
157 | 165 | if self.xaxis == "frequency": |
|
158 | 166 | x = self.data.xrange[0] |
|
159 | 167 | self.xlabel = "Frequency (kHz)" |
|
160 | 168 | elif self.xaxis == "time": |
|
161 | 169 | x = self.data.xrange[1] |
|
162 | 170 | self.xlabel = "Time (ms)" |
|
163 | 171 | else: |
|
164 | 172 | x = self.data.xrange[2] |
|
165 | 173 | self.xlabel = "Velocity (m/s)" |
|
166 | 174 | |
|
167 | if self.CODE == 'spc_moments': | |
|
168 | x = self.data.xrange[2] | |
|
169 | self.xlabel = "Velocity (m/s)" | |
|
170 | ||
|
171 | 175 | self.titles = [] |
|
172 | #self.xlabel = "Velocidad (m/s)" | |
|
173 | #self.ylabel = 'Rango (km)' | |
|
174 | ||
|
175 | 176 | |
|
176 |
y = self.data. |
|
|
177 | y = self.data.yrange | |
|
177 | 178 | self.y = y |
|
178 | 179 | z = self.data['spc'] |
|
179 | 180 | |
|
180 | self.CODE2 = 'spc_oblique' | |
|
181 | ||
|
182 | ||
|
183 | 181 | for n, ax in enumerate(self.axes): |
|
184 | 182 | noise = self.data['noise'][n][-1] |
|
185 | if self.CODE == 'spc_moments': | |
|
186 | mean = self.data['moments'][n, :, 1, :][-1] | |
|
187 | if self.CODE2 == 'spc_oblique': | |
|
188 |
|
|
|
189 | shift2 = self.data.shift2 | |
|
183 | shift1 = self.data['shift1'] | |
|
184 | shift2 = self.data['shift2'] | |
|
185 | err1 = self.data['shift1_error'] | |
|
186 | err2 = self.data['shift2_error'] | |
|
190 | 187 | if ax.firsttime: |
|
191 | 188 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
192 | 189 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
193 | 190 | self.zmin = self.zmin if self.zmin else numpy.nanmin(z) |
|
194 | 191 | self.zmax = self.zmax if self.zmax else numpy.nanmax(z) |
|
195 | #print(numpy.shape(x)) | |
|
196 | 192 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
197 | 193 | vmin=self.zmin, |
|
198 | 194 | vmax=self.zmax, |
|
199 | 195 | cmap=plt.get_cmap(self.colormap) |
|
200 | 196 | ) |
|
201 | 197 | |
|
202 | 198 | if self.showprofile: |
|
203 | 199 | ax.plt_profile = self.pf_axes[n].plot( |
|
204 | 200 | self.data['rti'][n][-1], y)[0] |
|
205 | 201 | ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y, |
|
206 | 202 | color="k", linestyle="dashed", lw=1)[0] |
|
207 | if self.CODE == 'spc_moments': | |
|
208 | ax.plt_mean = ax.plot(mean, y, color='k')[0] | |
|
209 | ||
|
210 | if self.CODE2 == 'spc_oblique': | |
|
211 | #ax.plt_shift1 = ax.plot(shift1, y, color='k', marker='x', linestyle='None', markersize=0.5)[0] | |
|
212 | #ax.plt_shift2 = ax.plot(shift2, y, color='m', marker='x', linestyle='None', markersize=0.5)[0] | |
|
213 | self.ploterr1 = ax.errorbar(shift1, y, xerr=self.data.shift1_error,fmt='k^',elinewidth=0.2,marker='x',linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2) | |
|
214 | self.ploterr2 = ax.errorbar(shift2, y, xerr=self.data.shift2_error,fmt='m^',elinewidth=0.2,marker='x',linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2) | |
|
215 | ||
|
203 | ||
|
204 | self.ploterr1 = ax.errorbar(shift1, y, xerr=err1, fmt='k^', elinewidth=0.2, marker='x', linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2) | |
|
205 | self.ploterr2 = ax.errorbar(shift2, y, xerr=err2, fmt='m^',elinewidth=0.2,marker='x',linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2) | |
|
216 | 206 | else: |
|
217 | 207 | self.ploterr1.remove() |
|
218 | 208 | self.ploterr2.remove() |
|
219 | 209 | ax.plt.set_array(z[n].T.ravel()) |
|
220 | 210 | if self.showprofile: |
|
221 | 211 | ax.plt_profile.set_data(self.data['rti'][n][-1], y) |
|
222 | 212 | ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y) |
|
223 | if self.CODE == 'spc_moments': | |
|
224 | ax.plt_mean.set_data(mean, y) | |
|
225 | if self.CODE2 == 'spc_oblique': | |
|
226 | #ax.plt_shift1.set_data(shift1, y) | |
|
227 | #ax.plt_shift2.set_data(shift2, y) | |
|
228 | #ax.clf() | |
|
229 | self.ploterr1 = ax.errorbar(shift1, y, xerr=self.data.shift1_error,fmt='k^',elinewidth=0.2,marker='x',linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2) | |
|
230 | self.ploterr2 = ax.errorbar(shift2, y, xerr=self.data.shift2_error,fmt='m^',elinewidth=0.2,marker='x',linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2) | |
|
213 | self.ploterr1 = ax.errorbar(shift1, y, xerr=err1, fmt='k^',elinewidth=0.2,marker='x',linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2) | |
|
214 | self.ploterr2 = ax.errorbar(shift2, y, xerr=err2, fmt='m^',elinewidth=0.2,marker='x',linestyle='None',markersize=0.5,capsize=0.3,markeredgewidth=0.2) | |
|
231 | 215 | |
|
232 | 216 | self.titles.append('CH {}: {:3.2f}dB'.format(n, noise)) |
|
233 | #self.titles.append('{}'.format('Velocidad Doppler')) | |
|
217 | ||
|
234 | 218 | |
|
235 | 219 | class CrossSpectraPlot(Plot): |
|
236 | 220 | |
|
237 | 221 | CODE = 'cspc' |
|
238 | 222 | colormap = 'jet' |
|
239 | 223 | plot_type = 'pcolor' |
|
240 | 224 | zmin_coh = None |
|
241 | 225 | zmax_coh = None |
|
242 | 226 | zmin_phase = None |
|
243 | 227 | zmax_phase = None |
|
244 | 228 | |
|
245 | 229 | def setup(self): |
|
246 | 230 | |
|
247 | 231 | self.ncols = 4 |
|
248 | 232 | self.nplots = len(self.data.pairs) * 2 |
|
249 | 233 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
|
250 | 234 | self.width = 3.1 * self.ncols |
|
251 | 235 | self.height = 5 * self.nrows |
|
252 | 236 | self.ylabel = 'Range [km]' |
|
253 | 237 | self.showprofile = False |
|
254 | 238 | self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) |
|
255 | 239 | |
|
256 | 240 | def update(self, dataOut): |
|
257 | 241 | |
|
258 | 242 | data = {} |
|
259 | 243 | meta = {} |
|
260 | 244 | |
|
261 | 245 | spc = dataOut.data_spc |
|
262 | 246 | cspc = dataOut.data_cspc |
|
263 | 247 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) |
|
264 | 248 | meta['pairs'] = dataOut.pairsList |
|
265 | 249 | |
|
266 | 250 | tmp = [] |
|
267 | 251 | |
|
268 | 252 | for n, pair in enumerate(meta['pairs']): |
|
269 | 253 | out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) |
|
270 | 254 | coh = numpy.abs(out) |
|
271 | 255 | phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi |
|
272 | 256 | tmp.append(coh) |
|
273 | 257 | tmp.append(phase) |
|
274 | 258 | |
|
275 | 259 | data['cspc'] = numpy.array(tmp) |
|
276 | 260 | |
|
277 | 261 | return data, meta |
|
278 | 262 | |
|
279 | 263 | def plot(self): |
|
280 | 264 | |
|
281 | 265 | if self.xaxis == "frequency": |
|
282 | 266 | x = self.data.xrange[0] |
|
283 | 267 | self.xlabel = "Frequency (kHz)" |
|
284 | 268 | elif self.xaxis == "time": |
|
285 | 269 | x = self.data.xrange[1] |
|
286 | 270 | self.xlabel = "Time (ms)" |
|
287 | 271 | else: |
|
288 | 272 | x = self.data.xrange[2] |
|
289 | 273 | self.xlabel = "Velocity (m/s)" |
|
290 | 274 | |
|
291 | 275 | self.titles = [] |
|
292 | 276 | |
|
293 | 277 | y = self.data.yrange |
|
294 | 278 | self.y = y |
|
295 | 279 | |
|
296 | 280 | data = self.data[-1] |
|
297 | 281 | cspc = data['cspc'] |
|
298 | 282 | |
|
299 | 283 | for n in range(len(self.data.pairs)): |
|
300 | 284 | pair = self.data.pairs[n] |
|
301 | 285 | coh = cspc[n*2] |
|
302 | 286 | phase = cspc[n*2+1] |
|
303 | 287 | ax = self.axes[2 * n] |
|
304 | 288 | if ax.firsttime: |
|
305 | 289 | ax.plt = ax.pcolormesh(x, y, coh.T, |
|
306 | 290 | vmin=0, |
|
307 | 291 | vmax=1, |
|
308 | 292 | cmap=plt.get_cmap(self.colormap_coh) |
|
309 | 293 | ) |
|
310 | 294 | else: |
|
311 | 295 | ax.plt.set_array(coh.T.ravel()) |
|
312 | 296 | self.titles.append( |
|
313 | 297 | 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
314 | 298 | |
|
315 | 299 | ax = self.axes[2 * n + 1] |
|
316 | 300 | if ax.firsttime: |
|
317 | 301 | ax.plt = ax.pcolormesh(x, y, phase.T, |
|
318 | 302 | vmin=-180, |
|
319 | 303 | vmax=180, |
|
320 | 304 | cmap=plt.get_cmap(self.colormap_phase) |
|
321 | 305 | ) |
|
322 | 306 | else: |
|
323 | 307 | ax.plt.set_array(phase.T.ravel()) |
|
324 | 308 | self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1])) |
|
325 | 309 | |
|
326 | 310 | |
|
327 | 311 | class CrossSpectra4Plot(Plot): |
|
328 | 312 | |
|
329 | 313 | CODE = 'cspc' |
|
330 | 314 | colormap = 'jet' |
|
331 | 315 | plot_type = 'pcolor' |
|
332 | 316 | zmin_coh = None |
|
333 | 317 | zmax_coh = None |
|
334 | 318 | zmin_phase = None |
|
335 | 319 | zmax_phase = None |
|
336 | 320 | |
|
337 | 321 | def setup(self): |
|
338 | 322 | |
|
339 | 323 | self.ncols = 4 |
|
340 | 324 | self.nrows = len(self.data.pairs) |
|
341 | 325 | self.nplots = self.nrows * 4 |
|
342 | 326 | self.width = 3.1 * self.ncols |
|
343 | 327 | self.height = 5 * self.nrows |
|
344 | 328 | self.ylabel = 'Range [km]' |
|
345 | 329 | self.showprofile = False |
|
346 | 330 | self.plots_adjust.update({'left': 0.08, 'right': 0.92, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) |
|
347 | 331 | |
|
348 | 332 | def plot(self): |
|
349 | 333 | |
|
350 | 334 | if self.xaxis == "frequency": |
|
351 | 335 | x = self.data.xrange[0] |
|
352 | 336 | self.xlabel = "Frequency (kHz)" |
|
353 | 337 | elif self.xaxis == "time": |
|
354 | 338 | x = self.data.xrange[1] |
|
355 | 339 | self.xlabel = "Time (ms)" |
|
356 | 340 | else: |
|
357 | 341 | x = self.data.xrange[2] |
|
358 | 342 | self.xlabel = "Velocity (m/s)" |
|
359 | 343 | |
|
360 | 344 | self.titles = [] |
|
361 | 345 | |
|
362 | 346 | |
|
363 | 347 | y = self.data.heights |
|
364 | 348 | self.y = y |
|
365 | 349 | nspc = self.data['spc'] |
|
366 | 350 | #print(numpy.shape(self.data['spc'])) |
|
367 | 351 | spc = self.data['cspc'][0] |
|
368 | 352 | #print(numpy.shape(nspc)) |
|
369 | 353 | #exit() |
|
370 | 354 | #nspc[1,:,:] = numpy.flip(nspc[1,:,:],axis=0) |
|
371 | 355 | #print(numpy.shape(spc)) |
|
372 | 356 | #exit() |
|
373 | 357 | cspc = self.data['cspc'][1] |
|
374 | 358 | |
|
375 | 359 | #xflip=numpy.flip(x) |
|
376 | 360 | #print(numpy.shape(cspc)) |
|
377 | 361 | #exit() |
|
378 | 362 | |
|
379 | 363 | for n in range(self.nrows): |
|
380 | 364 | noise = self.data['noise'][:,-1] |
|
381 | 365 | pair = self.data.pairs[n] |
|
382 | 366 | #print(pair) |
|
383 | 367 | #exit() |
|
384 | 368 | ax = self.axes[4 * n] |
|
385 | 369 | if ax.firsttime: |
|
386 | 370 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
387 | 371 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
388 | 372 | self.zmin = self.zmin if self.zmin else numpy.nanmin(nspc) |
|
389 | 373 | self.zmax = self.zmax if self.zmax else numpy.nanmax(nspc) |
|
390 | 374 | ax.plt = ax.pcolormesh(x , y , nspc[pair[0]].T, |
|
391 | 375 | vmin=self.zmin, |
|
392 | 376 | vmax=self.zmax, |
|
393 | 377 | cmap=plt.get_cmap(self.colormap) |
|
394 | 378 | ) |
|
395 | 379 | else: |
|
396 | 380 | #print(numpy.shape(nspc[pair[0]].T)) |
|
397 | 381 | #exit() |
|
398 | 382 | ax.plt.set_array(nspc[pair[0]].T.ravel()) |
|
399 | 383 | self.titles.append('CH {}: {:3.2f}dB'.format(pair[0], noise[pair[0]])) |
|
400 | 384 | |
|
401 | 385 | ax = self.axes[4 * n + 1] |
|
402 | 386 | |
|
403 | 387 | if ax.firsttime: |
|
404 | 388 | ax.plt = ax.pcolormesh(x , y, numpy.flip(nspc[pair[1]],axis=0).T, |
|
405 | 389 | vmin=self.zmin, |
|
406 | 390 | vmax=self.zmax, |
|
407 | 391 | cmap=plt.get_cmap(self.colormap) |
|
408 | 392 | ) |
|
409 | 393 | else: |
|
410 | 394 | |
|
411 | 395 | ax.plt.set_array(numpy.flip(nspc[pair[1]],axis=0).T.ravel()) |
|
412 | 396 | self.titles.append('CH {}: {:3.2f}dB'.format(pair[1], noise[pair[1]])) |
|
413 | 397 | |
|
414 | 398 | out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) |
|
415 | 399 | coh = numpy.abs(out) |
|
416 | 400 | phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi |
|
417 | 401 | |
|
418 | 402 | ax = self.axes[4 * n + 2] |
|
419 | 403 | if ax.firsttime: |
|
420 | 404 | ax.plt = ax.pcolormesh(x, y, numpy.flip(coh,axis=0).T, |
|
421 | 405 | vmin=0, |
|
422 | 406 | vmax=1, |
|
423 | 407 | cmap=plt.get_cmap(self.colormap_coh) |
|
424 | 408 | ) |
|
425 | 409 | else: |
|
426 | 410 | ax.plt.set_array(numpy.flip(coh,axis=0).T.ravel()) |
|
427 | 411 | self.titles.append( |
|
428 | 412 | 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
429 | 413 | |
|
430 | 414 | ax = self.axes[4 * n + 3] |
|
431 | 415 | if ax.firsttime: |
|
432 | 416 | ax.plt = ax.pcolormesh(x, y, numpy.flip(phase,axis=0).T, |
|
433 | 417 | vmin=-180, |
|
434 | 418 | vmax=180, |
|
435 | 419 | cmap=plt.get_cmap(self.colormap_phase) |
|
436 | 420 | ) |
|
437 | 421 | else: |
|
438 | 422 | ax.plt.set_array(numpy.flip(phase,axis=0).T.ravel()) |
|
439 | 423 | self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1])) |
|
440 | 424 | |
|
441 | 425 | |
|
442 | 426 | class CrossSpectra2Plot(Plot): |
|
443 | 427 | |
|
444 | 428 | CODE = 'cspc' |
|
445 | 429 | colormap = 'jet' |
|
446 | 430 | plot_type = 'pcolor' |
|
447 | 431 | zmin_coh = None |
|
448 | 432 | zmax_coh = None |
|
449 | 433 | zmin_phase = None |
|
450 | 434 | zmax_phase = None |
|
451 | 435 | |
|
452 | 436 | def setup(self): |
|
453 | 437 | |
|
454 | 438 | self.ncols = 1 |
|
455 | 439 | self.nrows = len(self.data.pairs) |
|
456 | 440 | self.nplots = self.nrows * 1 |
|
457 | 441 | self.width = 3.1 * self.ncols |
|
458 | 442 | self.height = 5 * self.nrows |
|
459 | 443 | self.ylabel = 'Range [km]' |
|
460 | 444 | self.showprofile = False |
|
461 | 445 | self.plots_adjust.update({'left': 0.22, 'right': .90, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) |
|
462 | 446 | |
|
463 | 447 | def plot(self): |
|
464 | 448 | |
|
465 | 449 | if self.xaxis == "frequency": |
|
466 | 450 | x = self.data.xrange[0] |
|
467 | 451 | self.xlabel = "Frequency (kHz)" |
|
468 | 452 | elif self.xaxis == "time": |
|
469 | 453 | x = self.data.xrange[1] |
|
470 | 454 | self.xlabel = "Time (ms)" |
|
471 | 455 | else: |
|
472 | 456 | x = self.data.xrange[2] |
|
473 | 457 | self.xlabel = "Velocity (m/s)" |
|
474 | 458 | |
|
475 | 459 | self.titles = [] |
|
476 | 460 | |
|
477 | 461 | |
|
478 | 462 | y = self.data.heights |
|
479 | 463 | self.y = y |
|
480 | 464 | #nspc = self.data['spc'] |
|
481 | 465 | #print(numpy.shape(self.data['spc'])) |
|
482 | 466 | #spc = self.data['cspc'][0] |
|
483 | 467 | #print(numpy.shape(spc)) |
|
484 | 468 | #exit() |
|
485 | 469 | cspc = self.data['cspc'][1] |
|
486 | 470 | #print(numpy.shape(cspc)) |
|
487 | 471 | #exit() |
|
488 | 472 | |
|
489 | 473 | for n in range(self.nrows): |
|
490 | 474 | noise = self.data['noise'][:,-1] |
|
491 | 475 | pair = self.data.pairs[n] |
|
492 | 476 | #print(pair) #exit() |
|
493 | 477 | |
|
494 | 478 | |
|
495 | 479 | |
|
496 | 480 | out = cspc[n]# / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) |
|
497 | 481 | |
|
498 | 482 | #print(out[:,53]) |
|
499 | 483 | #exit() |
|
500 | 484 | cross = numpy.abs(out) |
|
501 | 485 | z = cross/self.data.nFactor |
|
502 | 486 | #print("here") |
|
503 | 487 | #print(dataOut.data_spc[0,0,0]) |
|
504 | 488 | #exit() |
|
505 | 489 | |
|
506 | 490 | cross = 10*numpy.log10(z) |
|
507 | 491 | #print(numpy.shape(cross)) |
|
508 | 492 | #print(cross[0,:]) |
|
509 | 493 | #print(self.data.nFactor) |
|
510 | 494 | #exit() |
|
511 | 495 | #phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi |
|
512 | 496 | |
|
513 | 497 | ax = self.axes[1 * n] |
|
514 | 498 | if ax.firsttime: |
|
515 | 499 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
516 | 500 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
517 | 501 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) |
|
518 | 502 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) |
|
519 | 503 | ax.plt = ax.pcolormesh(x, y, cross.T, |
|
520 | 504 | vmin=self.zmin, |
|
521 | 505 | vmax=self.zmax, |
|
522 | 506 | cmap=plt.get_cmap(self.colormap) |
|
523 | 507 | ) |
|
524 | 508 | else: |
|
525 | 509 | ax.plt.set_array(cross.T.ravel()) |
|
526 | 510 | self.titles.append( |
|
527 | 511 | 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
528 | 512 | |
|
529 | 513 | |
|
530 | 514 | class CrossSpectra3Plot(Plot): |
|
531 | 515 | |
|
532 | 516 | CODE = 'cspc' |
|
533 | 517 | colormap = 'jet' |
|
534 | 518 | plot_type = 'pcolor' |
|
535 | 519 | zmin_coh = None |
|
536 | 520 | zmax_coh = None |
|
537 | 521 | zmin_phase = None |
|
538 | 522 | zmax_phase = None |
|
539 | 523 | |
|
540 | 524 | def setup(self): |
|
541 | 525 | |
|
542 | 526 | self.ncols = 3 |
|
543 | 527 | self.nrows = len(self.data.pairs) |
|
544 | 528 | self.nplots = self.nrows * 3 |
|
545 | 529 | self.width = 3.1 * self.ncols |
|
546 | 530 | self.height = 5 * self.nrows |
|
547 | 531 | self.ylabel = 'Range [km]' |
|
548 | 532 | self.showprofile = False |
|
549 | 533 | self.plots_adjust.update({'left': 0.22, 'right': .90, 'wspace': 0.5, 'hspace':0.4, 'top':0.95, 'bottom': 0.08}) |
|
550 | 534 | |
|
551 | 535 | def plot(self): |
|
552 | 536 | |
|
553 | 537 | if self.xaxis == "frequency": |
|
554 | 538 | x = self.data.xrange[0] |
|
555 | 539 | self.xlabel = "Frequency (kHz)" |
|
556 | 540 | elif self.xaxis == "time": |
|
557 | 541 | x = self.data.xrange[1] |
|
558 | 542 | self.xlabel = "Time (ms)" |
|
559 | 543 | else: |
|
560 | 544 | x = self.data.xrange[2] |
|
561 | 545 | self.xlabel = "Velocity (m/s)" |
|
562 | 546 | |
|
563 | 547 | self.titles = [] |
|
564 | 548 | |
|
565 | 549 | |
|
566 | 550 | y = self.data.heights |
|
567 | 551 | self.y = y |
|
568 | 552 | #nspc = self.data['spc'] |
|
569 | 553 | #print(numpy.shape(self.data['spc'])) |
|
570 | 554 | #spc = self.data['cspc'][0] |
|
571 | 555 | #print(numpy.shape(spc)) |
|
572 | 556 | #exit() |
|
573 | 557 | cspc = self.data['cspc'][1] |
|
574 | 558 | #print(numpy.shape(cspc)) |
|
575 | 559 | #exit() |
|
576 | 560 | |
|
577 | 561 | for n in range(self.nrows): |
|
578 | 562 | noise = self.data['noise'][:,-1] |
|
579 | 563 | pair = self.data.pairs[n] |
|
580 | 564 | #print(pair) #exit() |
|
581 | 565 | |
|
582 | 566 | |
|
583 | 567 | |
|
584 | 568 | out = cspc[n]# / numpy.sqrt(spc[pair[0]] * spc[pair[1]]) |
|
585 | 569 | |
|
586 | 570 | #print(out[:,53]) |
|
587 | 571 | #exit() |
|
588 | 572 | cross = numpy.abs(out) |
|
589 | 573 | z = cross/self.data.nFactor |
|
590 | 574 | cross = 10*numpy.log10(z) |
|
591 | 575 | |
|
592 | 576 | out_r= out.real/self.data.nFactor |
|
593 | 577 | #out_r = 10*numpy.log10(out_r) |
|
594 | 578 | |
|
595 | 579 | out_i= out.imag/self.data.nFactor |
|
596 | 580 | #out_i = 10*numpy.log10(out_i) |
|
597 | 581 | #print(numpy.shape(cross)) |
|
598 | 582 | #print(cross[0,:]) |
|
599 | 583 | #print(self.data.nFactor) |
|
600 | 584 | #exit() |
|
601 | 585 | #phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi |
|
602 | 586 | |
|
603 | 587 | ax = self.axes[3 * n] |
|
604 | 588 | if ax.firsttime: |
|
605 | 589 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
606 | 590 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
607 | 591 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) |
|
608 | 592 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) |
|
609 | 593 | ax.plt = ax.pcolormesh(x, y, cross.T, |
|
610 | 594 | vmin=self.zmin, |
|
611 | 595 | vmax=self.zmax, |
|
612 | 596 | cmap=plt.get_cmap(self.colormap) |
|
613 | 597 | ) |
|
614 | 598 | else: |
|
615 | 599 | ax.plt.set_array(cross.T.ravel()) |
|
616 | 600 | self.titles.append( |
|
617 | 601 | 'Cross Spectra Power Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
618 | 602 | |
|
619 | 603 | ax = self.axes[3 * n + 1] |
|
620 | 604 | if ax.firsttime: |
|
621 | 605 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
622 | 606 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
623 | 607 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) |
|
624 | 608 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) |
|
625 | 609 | ax.plt = ax.pcolormesh(x, y, out_r.T, |
|
626 | 610 | vmin=-1.e6, |
|
627 | 611 | vmax=0, |
|
628 | 612 | cmap=plt.get_cmap(self.colormap) |
|
629 | 613 | ) |
|
630 | 614 | else: |
|
631 | 615 | ax.plt.set_array(out_r.T.ravel()) |
|
632 | 616 | self.titles.append( |
|
633 | 617 | 'Cross Spectra Real Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
634 | 618 | |
|
635 | 619 | ax = self.axes[3 * n + 2] |
|
636 | 620 | |
|
637 | 621 | |
|
638 | 622 | if ax.firsttime: |
|
639 | 623 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
640 | 624 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
641 | 625 | self.zmin = self.zmin if self.zmin else numpy.nanmin(cross) |
|
642 | 626 | self.zmax = self.zmax if self.zmax else numpy.nanmax(cross) |
|
643 | 627 | ax.plt = ax.pcolormesh(x, y, out_i.T, |
|
644 | 628 | vmin=-1.e6, |
|
645 | 629 | vmax=1.e6, |
|
646 | 630 | cmap=plt.get_cmap(self.colormap) |
|
647 | 631 | ) |
|
648 | 632 | else: |
|
649 | 633 | ax.plt.set_array(out_i.T.ravel()) |
|
650 | 634 | self.titles.append( |
|
651 | 635 | 'Cross Spectra Imag Ch{} * Ch{}'.format(pair[0], pair[1])) |
|
652 | 636 | |
|
653 | 637 | class RTIPlot(Plot): |
|
654 | 638 | ''' |
|
655 | 639 | Plot for RTI data |
|
656 | 640 | ''' |
|
657 | 641 | |
|
658 | 642 | CODE = 'rti' |
|
659 | 643 | colormap = 'jet' |
|
660 | 644 | plot_type = 'pcolorbuffer' |
|
661 | 645 | |
|
662 | 646 | def setup(self): |
|
663 | 647 | self.xaxis = 'time' |
|
664 | 648 | self.ncols = 1 |
|
665 | 649 | self.nrows = len(self.data.channels) |
|
666 | 650 | self.nplots = len(self.data.channels) |
|
667 | 651 | self.ylabel = 'Range [km]' |
|
668 | 652 | self.xlabel = 'Time' |
|
669 | 653 | self.cb_label = 'dB' |
|
670 | 654 | self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.1, 'right':0.95}) |
|
671 | 655 | self.titles = ['{} Channel {}'.format( |
|
672 | 656 | self.CODE.upper(), x) for x in range(self.nrows)] |
|
673 | 657 | |
|
674 | 658 | def update(self, dataOut): |
|
675 | 659 | |
|
676 | 660 | data = {} |
|
677 | 661 | meta = {} |
|
678 | 662 | data['rti'] = dataOut.getPower() |
|
679 | 663 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) |
|
680 | 664 | |
|
681 | 665 | return data, meta |
|
682 | 666 | |
|
683 | 667 | def plot(self): |
|
684 | 668 | self.x = self.data.times |
|
685 | 669 | self.y = self.data.yrange |
|
686 | 670 | self.z = self.data[self.CODE] |
|
687 | 671 | |
|
688 | 672 | self.z = numpy.ma.masked_invalid(self.z) |
|
689 | 673 | |
|
690 | 674 | if self.decimation is None: |
|
691 | 675 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
692 | 676 | else: |
|
693 | 677 | x, y, z = self.fill_gaps(*self.decimate()) |
|
694 | 678 | |
|
695 | 679 | for n, ax in enumerate(self.axes): |
|
696 | 680 | self.zmin = self.zmin if self.zmin else numpy.min(self.z) |
|
697 | 681 | self.zmax = self.zmax if self.zmax else numpy.max(self.z) |
|
698 | 682 | if ax.firsttime: |
|
699 | 683 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
700 | 684 | vmin=self.zmin, |
|
701 | 685 | vmax=self.zmax, |
|
702 | 686 | cmap=plt.get_cmap(self.colormap) |
|
703 | 687 | ) |
|
704 | 688 | if self.showprofile: |
|
705 | 689 | ax.plot_profile = self.pf_axes[n].plot( |
|
706 | 690 | self.data['rti'][n][-1], self.y)[0] |
|
707 | 691 | ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(self.data['noise'][n][-1], len(self.y)), self.y, |
|
708 | 692 | color="k", linestyle="dashed", lw=1)[0] |
|
709 | 693 | else: |
|
710 | 694 | ax.collections.remove(ax.collections[0]) |
|
711 | 695 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
712 | 696 | vmin=self.zmin, |
|
713 | 697 | vmax=self.zmax, |
|
714 | 698 | cmap=plt.get_cmap(self.colormap) |
|
715 | 699 | ) |
|
716 | 700 | if self.showprofile: |
|
717 | 701 | ax.plot_profile.set_data(self.data['rti'][n][-1], self.y) |
|
718 | 702 | ax.plot_noise.set_data(numpy.repeat( |
|
719 | 703 | self.data['noise'][n][-1], len(self.y)), self.y) |
|
720 | 704 | |
|
721 | 705 | |
|
722 | 706 | class SpectrogramPlot(Plot): |
|
723 | 707 | ''' |
|
724 | 708 | Plot for Spectrogram data |
|
725 | 709 | ''' |
|
726 | 710 | |
|
727 | 711 | CODE = 'spectrogram' |
|
728 | 712 | colormap = 'binary' |
|
729 | 713 | plot_type = 'pcolorbuffer' |
|
730 | 714 | |
|
731 | 715 | def setup(self): |
|
732 | 716 | self.xaxis = 'time' |
|
733 | 717 | self.ncols = 1 |
|
734 | 718 | self.nrows = len(self.data.channels) |
|
735 | 719 | self.nplots = len(self.data.channels) |
|
736 | #print(self.dataOut.heightList) | |
|
737 | #self.ylabel = 'Range [km]' | |
|
738 | 720 | self.xlabel = 'Time' |
|
739 | 721 | self.cb_label = 'dB' |
|
740 | 722 | self.plots_adjust.update({'hspace':1.2, 'left': 0.1, 'bottom': 0.12, 'right':0.95}) |
|
741 | 723 | self.titles = ['{} Channel {} \n H = {} km ({} - {})'.format( |
|
742 | 724 | self.CODE.upper(), x, self.data.heightList[self.data.hei], self.data.heightList[self.data.hei],self.data.heightList[self.data.hei]+(self.data.DH*self.data.nProfiles)) for x in range(self.nrows)] |
|
743 | 725 | |
|
744 | 726 | def plot(self): |
|
727 | ||
|
745 | 728 | self.x = self.data.times |
|
746 | #self.y = self.data.heights | |
|
747 | 729 | self.z = self.data[self.CODE] |
|
748 | 730 | self.y = self.data.xrange[0] |
|
749 | #import time | |
|
750 | #print(time.ctime(self.x)) | |
|
751 | ||
|
752 | ''' | |
|
753 | print(numpy.shape(self.x)) | |
|
754 | print(numpy.shape(self.y)) | |
|
755 | print(numpy.shape(self.z)) | |
|
756 | ''' | |
|
731 | ||
|
757 | 732 | self.ylabel = "Frequency (kHz)" |
|
758 | 733 | |
|
759 | 734 | self.z = numpy.ma.masked_invalid(self.z) |
|
760 | 735 | |
|
761 | 736 | if self.decimation is None: |
|
762 | 737 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
763 | 738 | else: |
|
764 | 739 | x, y, z = self.fill_gaps(*self.decimate()) |
|
765 | 740 | |
|
766 | 741 | for n, ax in enumerate(self.axes): |
|
767 | 742 | self.zmin = self.zmin if self.zmin else numpy.min(self.z) |
|
768 | 743 | self.zmax = self.zmax if self.zmax else numpy.max(self.z) |
|
769 | 744 | data = self.data[-1] |
|
770 | 745 | if ax.firsttime: |
|
771 | 746 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
772 | 747 | vmin=self.zmin, |
|
773 | 748 | vmax=self.zmax, |
|
774 | 749 | cmap=plt.get_cmap(self.colormap) |
|
775 | 750 | ) |
|
776 | 751 | if self.showprofile: |
|
777 | 752 | ax.plot_profile = self.pf_axes[n].plot( |
|
778 | 753 | data['rti'][n], self.y)[0] |
|
779 | 754 | ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(data['noise'][n], len(self.y)), self.y, |
|
780 | 755 | color="k", linestyle="dashed", lw=1)[0] |
|
781 | 756 | else: |
|
782 | 757 | ax.collections.remove(ax.collections[0]) |
|
783 | 758 | ax.plt = ax.pcolormesh(x, y, z[n].T, |
|
784 | 759 | vmin=self.zmin, |
|
785 | 760 | vmax=self.zmax, |
|
786 | 761 | cmap=plt.get_cmap(self.colormap) |
|
787 | 762 | ) |
|
788 | 763 | if self.showprofile: |
|
789 | 764 | ax.plot_profile.set_data(data['rti'][n], self.y) |
|
790 | 765 | ax.plot_noise.set_data(numpy.repeat( |
|
791 | 766 | data['noise'][n], len(self.y)), self.y) |
|
792 | 767 | |
|
793 | 768 | |
|
794 | 769 | class CoherencePlot(RTIPlot): |
|
795 | 770 | ''' |
|
796 | 771 | Plot for Coherence data |
|
797 | 772 | ''' |
|
798 | 773 | |
|
799 | 774 | CODE = 'coh' |
|
800 | 775 | |
|
801 | 776 | def setup(self): |
|
802 | 777 | self.xaxis = 'time' |
|
803 | 778 | self.ncols = 1 |
|
804 | 779 | self.nrows = len(self.data.pairs) |
|
805 | 780 | self.nplots = len(self.data.pairs) |
|
806 | 781 | self.ylabel = 'Range [km]' |
|
807 | 782 | self.xlabel = 'Time' |
|
808 | 783 | self.plots_adjust.update({'hspace':0.6, 'left': 0.1, 'bottom': 0.1,'right':0.95}) |
|
809 | 784 | if self.CODE == 'coh': |
|
810 | 785 | self.cb_label = '' |
|
811 | 786 | self.titles = [ |
|
812 | 787 | 'Coherence Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs] |
|
813 | 788 | else: |
|
814 | 789 | self.cb_label = 'Degrees' |
|
815 | 790 | self.titles = [ |
|
816 | 791 | 'Phase Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs] |
|
817 | 792 | |
|
818 | 793 | def update(self, dataOut): |
|
819 | 794 | |
|
820 | 795 | data = {} |
|
821 | 796 | meta = {} |
|
822 | 797 | data['coh'] = dataOut.getCoherence() |
|
823 | 798 | meta['pairs'] = dataOut.pairsList |
|
824 | 799 | |
|
825 | 800 | return data, meta |
|
826 | 801 | |
|
827 | 802 | class PhasePlot(CoherencePlot): |
|
828 | 803 | ''' |
|
829 | 804 | Plot for Phase map data |
|
830 | 805 | ''' |
|
831 | 806 | |
|
832 | 807 | CODE = 'phase' |
|
833 | 808 | colormap = 'seismic' |
|
834 | 809 | |
|
835 | 810 | def update(self, dataOut): |
|
836 | 811 | |
|
837 | 812 | data = {} |
|
838 | 813 | meta = {} |
|
839 | 814 | data['phase'] = dataOut.getCoherence(phase=True) |
|
840 | 815 | meta['pairs'] = dataOut.pairsList |
|
841 | 816 | |
|
842 | 817 | return data, meta |
|
843 | 818 | |
|
844 | 819 | class NoisePlot(Plot): |
|
845 | 820 | ''' |
|
846 | 821 | Plot for noise |
|
847 | 822 | ''' |
|
848 | 823 | |
|
849 | 824 | CODE = 'noise' |
|
850 | 825 | plot_type = 'scatterbuffer' |
|
851 | 826 | |
|
852 | 827 | def setup(self): |
|
853 | 828 | self.xaxis = 'time' |
|
854 | 829 | self.ncols = 1 |
|
855 | 830 | self.nrows = 1 |
|
856 | 831 | self.nplots = 1 |
|
857 | 832 | self.ylabel = 'Intensity [dB]' |
|
858 | 833 | self.xlabel = 'Time' |
|
859 | 834 | self.titles = ['Noise'] |
|
860 | 835 | self.colorbar = False |
|
861 | 836 | self.plots_adjust.update({'right': 0.85 }) |
|
862 | 837 | |
|
863 | 838 | def update(self, dataOut): |
|
864 | 839 | |
|
865 | 840 | data = {} |
|
866 | 841 | meta = {} |
|
867 | 842 | data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor).reshape(dataOut.nChannels, 1) |
|
868 | 843 | meta['yrange'] = numpy.array([]) |
|
869 | 844 | |
|
870 | 845 | return data, meta |
|
871 | 846 | |
|
872 | 847 | def plot(self): |
|
873 | 848 | |
|
874 | 849 | x = self.data.times |
|
875 | 850 | xmin = self.data.min_time |
|
876 | 851 | xmax = xmin + self.xrange * 60 * 60 |
|
877 | 852 | Y = self.data['noise'] |
|
878 | 853 | |
|
879 | 854 | if self.axes[0].firsttime: |
|
880 | 855 | self.ymin = numpy.nanmin(Y) - 5 |
|
881 | 856 | self.ymax = numpy.nanmax(Y) + 5 |
|
882 | 857 | for ch in self.data.channels: |
|
883 | 858 | y = Y[ch] |
|
884 | 859 | self.axes[0].plot(x, y, lw=1, label='Ch{}'.format(ch)) |
|
885 | 860 | plt.legend(bbox_to_anchor=(1.18, 1.0)) |
|
886 | 861 | else: |
|
887 | 862 | for ch in self.data.channels: |
|
888 | 863 | y = Y[ch] |
|
889 | 864 | self.axes[0].lines[ch].set_data(x, y) |
|
890 | 865 | |
|
891 | 866 | self.ymin = numpy.nanmin(Y) - 5 |
|
892 | 867 | self.ymax = numpy.nanmax(Y) + 10 |
|
893 | 868 | |
|
894 | 869 | |
|
895 | 870 | class PowerProfilePlot(Plot): |
|
896 | 871 | |
|
897 | 872 | CODE = 'pow_profile' |
|
898 | 873 | plot_type = 'scatter' |
|
899 | 874 | |
|
900 | 875 | def setup(self): |
|
901 | 876 | |
|
902 | 877 | self.ncols = 1 |
|
903 | 878 | self.nrows = 1 |
|
904 | 879 | self.nplots = 1 |
|
905 | 880 | self.height = 4 |
|
906 | 881 | self.width = 3 |
|
907 | 882 | self.ylabel = 'Range [km]' |
|
908 | 883 | self.xlabel = 'Intensity [dB]' |
|
909 | 884 | self.titles = ['Power Profile'] |
|
910 | 885 | self.colorbar = False |
|
911 | 886 | |
|
912 | 887 | def update(self, dataOut): |
|
913 | 888 | |
|
914 | 889 | data = {} |
|
915 | 890 | meta = {} |
|
916 | 891 | data[self.CODE] = dataOut.getPower() |
|
917 | 892 | |
|
918 | 893 | return data, meta |
|
919 | 894 | |
|
920 | 895 | def plot(self): |
|
921 | 896 | |
|
922 | 897 | y = self.data.yrange |
|
923 | 898 | self.y = y |
|
924 | 899 | |
|
925 | 900 | x = self.data[-1][self.CODE] |
|
926 | 901 | |
|
927 | 902 | if self.xmin is None: self.xmin = numpy.nanmin(x)*0.9 |
|
928 | 903 | if self.xmax is None: self.xmax = numpy.nanmax(x)*1.1 |
|
929 | 904 | |
|
930 | 905 | if self.axes[0].firsttime: |
|
931 | 906 | for ch in self.data.channels: |
|
932 | 907 | self.axes[0].plot(x[ch], y, lw=1, label='Ch{}'.format(ch)) |
|
933 | 908 | plt.legend() |
|
934 | 909 | else: |
|
935 | 910 | for ch in self.data.channels: |
|
936 | 911 | self.axes[0].lines[ch].set_data(x[ch], y) |
|
937 | 912 | |
|
938 | 913 | |
|
939 | 914 | class SpectraCutPlot(Plot): |
|
940 | 915 | |
|
941 | 916 | CODE = 'spc_cut' |
|
942 | 917 | plot_type = 'scatter' |
|
943 | 918 | buffering = False |
|
944 | 919 | |
|
945 | 920 | def setup(self): |
|
946 | 921 | |
|
947 | 922 | self.nplots = len(self.data.channels) |
|
948 | 923 | self.ncols = int(numpy.sqrt(self.nplots) + 0.9) |
|
949 | 924 | self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9) |
|
950 | 925 | self.width = 3.4 * self.ncols + 1.5 |
|
951 | 926 | self.height = 3 * self.nrows |
|
952 | 927 | self.ylabel = 'Power [dB]' |
|
953 | 928 | self.colorbar = False |
|
954 | 929 | self.plots_adjust.update({'left':0.1, 'hspace':0.3, 'right': 0.75, 'bottom':0.08}) |
|
955 | 930 | |
|
956 | 931 | def update(self, dataOut): |
|
957 | 932 | |
|
958 | 933 | data = {} |
|
959 | 934 | meta = {} |
|
960 | 935 | spc = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor) |
|
961 | 936 | data['spc'] = spc |
|
962 | 937 | meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) |
|
963 | 938 | if self.CODE == 'cut_gaussian_fit': |
|
964 | 939 | data['gauss_fit0'] = 10*numpy.log10(dataOut.GaussFit0/dataOut.normFactor) |
|
965 | 940 | data['gauss_fit1'] = 10*numpy.log10(dataOut.GaussFit1/dataOut.normFactor) |
|
966 | 941 | return data, meta |
|
967 | 942 | |
|
968 | 943 | def plot(self): |
|
969 | 944 | if self.xaxis == "frequency": |
|
970 | 945 | x = self.data.xrange[0][1:] |
|
971 | 946 | self.xlabel = "Frequency (kHz)" |
|
972 | 947 | elif self.xaxis == "time": |
|
973 | 948 | x = self.data.xrange[1] |
|
974 | 949 | self.xlabel = "Time (ms)" |
|
975 | 950 | else: |
|
976 | 951 | x = self.data.xrange[2][:-1] |
|
977 | 952 | self.xlabel = "Velocity (m/s)" |
|
978 | 953 | |
|
979 | 954 | if self.CODE == 'cut_gaussian_fit': |
|
980 | 955 | x = self.data.xrange[2][:-1] |
|
981 | 956 | self.xlabel = "Velocity (m/s)" |
|
982 | 957 | |
|
983 | 958 | self.titles = [] |
|
984 | 959 | |
|
985 | 960 | y = self.data.yrange |
|
986 | 961 | data = self.data[-1] |
|
987 | 962 | z = data['spc'] |
|
988 | 963 | |
|
989 | 964 | if self.height_index: |
|
990 | 965 | index = numpy.array(self.height_index) |
|
991 | 966 | else: |
|
992 | 967 | index = numpy.arange(0, len(y), int((len(y))/9)) |
|
993 | 968 | |
|
994 | 969 | for n, ax in enumerate(self.axes): |
|
995 | 970 | if self.CODE == 'cut_gaussian_fit': |
|
996 | 971 | gau0 = data['gauss_fit0'] |
|
997 | 972 | gau1 = data['gauss_fit1'] |
|
998 | 973 | if ax.firsttime: |
|
999 | 974 | self.xmax = self.xmax if self.xmax else numpy.nanmax(x) |
|
1000 | 975 | self.xmin = self.xmin if self.xmin else -self.xmax |
|
1001 | 976 | self.ymin = self.ymin if self.ymin else numpy.nanmin(z) |
|
1002 | 977 | self.ymax = self.ymax if self.ymax else numpy.nanmax(z) |
|
1003 | 978 | ax.plt = ax.plot(x, z[n, :, index].T, lw=0.25) |
|
1004 | 979 | if self.CODE == 'cut_gaussian_fit': |
|
1005 | 980 | ax.plt_gau0 = ax.plot(x, gau0[n, :, index].T, lw=1, linestyle='-.') |
|
1006 | 981 | for i, line in enumerate(ax.plt_gau0): |
|
1007 | 982 | line.set_color(ax.plt[i].get_color()) |
|
1008 | 983 | ax.plt_gau1 = ax.plot(x, gau1[n, :, index].T, lw=1, linestyle='--') |
|
1009 | 984 | for i, line in enumerate(ax.plt_gau1): |
|
1010 | 985 | line.set_color(ax.plt[i].get_color()) |
|
1011 | 986 | labels = ['Range = {:2.1f}km'.format(y[i]) for i in index] |
|
1012 | 987 | self.figures[0].legend(ax.plt, labels, loc='center right') |
|
1013 | 988 | else: |
|
1014 | 989 | for i, line in enumerate(ax.plt): |
|
1015 | 990 | line.set_data(x, z[n, :, index[i]].T) |
|
1016 | 991 | for i, line in enumerate(ax.plt_gau0): |
|
1017 | 992 | line.set_data(x, gau0[n, :, index[i]].T) |
|
1018 | 993 | line.set_color(ax.plt[i].get_color()) |
|
1019 | 994 | for i, line in enumerate(ax.plt_gau1): |
|
1020 | 995 | line.set_data(x, gau1[n, :, index[i]].T) |
|
1021 | 996 | line.set_color(ax.plt[i].get_color()) |
|
1022 | 997 | self.titles.append('CH {}'.format(n)) |
|
1023 | 998 | |
|
1024 | 999 | |
|
1025 | 1000 | class BeaconPhase(Plot): |
|
1026 | 1001 | |
|
1027 | 1002 | __isConfig = None |
|
1028 | 1003 | __nsubplots = None |
|
1029 | 1004 | |
|
1030 | 1005 | PREFIX = 'beacon_phase' |
|
1031 | 1006 | |
|
1032 | 1007 | def __init__(self): |
|
1033 | 1008 | Plot.__init__(self) |
|
1034 | 1009 | self.timerange = 24*60*60 |
|
1035 | 1010 | self.isConfig = False |
|
1036 | 1011 | self.__nsubplots = 1 |
|
1037 | 1012 | self.counter_imagwr = 0 |
|
1038 | 1013 | self.WIDTH = 800 |
|
1039 | 1014 | self.HEIGHT = 400 |
|
1040 | 1015 | self.WIDTHPROF = 120 |
|
1041 | 1016 | self.HEIGHTPROF = 0 |
|
1042 | 1017 | self.xdata = None |
|
1043 | 1018 | self.ydata = None |
|
1044 | 1019 | |
|
1045 | 1020 | self.PLOT_CODE = BEACON_CODE |
|
1046 | 1021 | |
|
1047 | 1022 | self.FTP_WEI = None |
|
1048 | 1023 | self.EXP_CODE = None |
|
1049 | 1024 | self.SUB_EXP_CODE = None |
|
1050 | 1025 | self.PLOT_POS = None |
|
1051 | 1026 | |
|
1052 | 1027 | self.filename_phase = None |
|
1053 | 1028 | |
|
1054 | 1029 | self.figfile = None |
|
1055 | 1030 | |
|
1056 | 1031 | self.xmin = None |
|
1057 | 1032 | self.xmax = None |
|
1058 | 1033 | |
|
1059 | 1034 | def getSubplots(self): |
|
1060 | 1035 | |
|
1061 | 1036 | ncol = 1 |
|
1062 | 1037 | nrow = 1 |
|
1063 | 1038 | |
|
1064 | 1039 | return nrow, ncol |
|
1065 | 1040 | |
|
1066 | 1041 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1067 | 1042 | |
|
1068 | 1043 | self.__showprofile = showprofile |
|
1069 | 1044 | self.nplots = nplots |
|
1070 | 1045 | |
|
1071 | 1046 | ncolspan = 7 |
|
1072 | 1047 | colspan = 6 |
|
1073 | 1048 | self.__nsubplots = 2 |
|
1074 | 1049 | |
|
1075 | 1050 | self.createFigure(id = id, |
|
1076 | 1051 | wintitle = wintitle, |
|
1077 | 1052 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
1078 | 1053 | heightplot = self.HEIGHT+self.HEIGHTPROF, |
|
1079 | 1054 | show=show) |
|
1080 | 1055 | |
|
1081 | 1056 | nrow, ncol = self.getSubplots() |
|
1082 | 1057 | |
|
1083 | 1058 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
1084 | 1059 | |
|
1085 | 1060 | def save_phase(self, filename_phase): |
|
1086 | 1061 | f = open(filename_phase,'w+') |
|
1087 | 1062 | f.write('\n\n') |
|
1088 | 1063 | f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n') |
|
1089 | 1064 | f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' ) |
|
1090 | 1065 | f.close() |
|
1091 | 1066 | |
|
1092 | 1067 | def save_data(self, filename_phase, data, data_datetime): |
|
1093 | 1068 | f=open(filename_phase,'a') |
|
1094 | 1069 | timetuple_data = data_datetime.timetuple() |
|
1095 | 1070 | day = str(timetuple_data.tm_mday) |
|
1096 | 1071 | month = str(timetuple_data.tm_mon) |
|
1097 | 1072 | year = str(timetuple_data.tm_year) |
|
1098 | 1073 | hour = str(timetuple_data.tm_hour) |
|
1099 | 1074 | minute = str(timetuple_data.tm_min) |
|
1100 | 1075 | second = str(timetuple_data.tm_sec) |
|
1101 | 1076 | f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n') |
|
1102 | 1077 | f.close() |
|
1103 | 1078 | |
|
1104 | 1079 | def plot(self): |
|
1105 | 1080 | log.warning('TODO: Not yet implemented...') |
|
1106 | 1081 | |
|
1107 | 1082 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', |
|
1108 | 1083 | xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None, |
|
1109 | 1084 | timerange=None, |
|
1110 | 1085 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
1111 | 1086 | server=None, folder=None, username=None, password=None, |
|
1112 | 1087 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1113 | 1088 | |
|
1114 | 1089 | if dataOut.flagNoData: |
|
1115 | 1090 | return dataOut |
|
1116 | 1091 | |
|
1117 | 1092 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): |
|
1118 | 1093 | return |
|
1119 | 1094 | |
|
1120 | 1095 | if pairsList == None: |
|
1121 | 1096 | pairsIndexList = dataOut.pairsIndexList[:10] |
|
1122 | 1097 | else: |
|
1123 | 1098 | pairsIndexList = [] |
|
1124 | 1099 | for pair in pairsList: |
|
1125 | 1100 | if pair not in dataOut.pairsList: |
|
1126 | 1101 | raise ValueError("Pair %s is not in dataOut.pairsList" %(pair)) |
|
1127 | 1102 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
1128 | 1103 | |
|
1129 | 1104 | if pairsIndexList == []: |
|
1130 | 1105 | return |
|
1131 | 1106 | |
|
1132 | 1107 | # if len(pairsIndexList) > 4: |
|
1133 | 1108 | # pairsIndexList = pairsIndexList[0:4] |
|
1134 | 1109 | |
|
1135 | 1110 | hmin_index = None |
|
1136 | 1111 | hmax_index = None |
|
1137 | 1112 | |
|
1138 | 1113 | if hmin != None and hmax != None: |
|
1139 | 1114 | indexes = numpy.arange(dataOut.nHeights) |
|
1140 | 1115 | hmin_list = indexes[dataOut.heightList >= hmin] |
|
1141 | 1116 | hmax_list = indexes[dataOut.heightList <= hmax] |
|
1142 | 1117 | |
|
1143 | 1118 | if hmin_list.any(): |
|
1144 | 1119 | hmin_index = hmin_list[0] |
|
1145 | 1120 | |
|
1146 | 1121 | if hmax_list.any(): |
|
1147 | 1122 | hmax_index = hmax_list[-1]+1 |
|
1148 | 1123 | |
|
1149 | 1124 | x = dataOut.getTimeRange() |
|
1150 | 1125 | |
|
1151 | 1126 | thisDatetime = dataOut.datatime |
|
1152 | 1127 | |
|
1153 | 1128 | title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1154 | 1129 | xlabel = "Local Time" |
|
1155 | 1130 | ylabel = "Phase (degrees)" |
|
1156 | 1131 | |
|
1157 | 1132 | update_figfile = False |
|
1158 | 1133 | |
|
1159 | 1134 | nplots = len(pairsIndexList) |
|
1160 | 1135 | #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList))) |
|
1161 | 1136 | phase_beacon = numpy.zeros(len(pairsIndexList)) |
|
1162 | 1137 | for i in range(nplots): |
|
1163 | 1138 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
1164 | 1139 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0) |
|
1165 | 1140 | powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0) |
|
1166 | 1141 | powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0) |
|
1167 | 1142 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) |
|
1168 | 1143 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi |
|
1169 | 1144 | |
|
1170 | 1145 | if dataOut.beacon_heiIndexList: |
|
1171 | 1146 | phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList]) |
|
1172 | 1147 | else: |
|
1173 | 1148 | phase_beacon[i] = numpy.average(phase) |
|
1174 | 1149 | |
|
1175 | 1150 | if not self.isConfig: |
|
1176 | 1151 | |
|
1177 | 1152 | nplots = len(pairsIndexList) |
|
1178 | 1153 | |
|
1179 | 1154 | self.setup(id=id, |
|
1180 | 1155 | nplots=nplots, |
|
1181 | 1156 | wintitle=wintitle, |
|
1182 | 1157 | showprofile=showprofile, |
|
1183 | 1158 | show=show) |
|
1184 | 1159 | |
|
1185 | 1160 | if timerange != None: |
|
1186 | 1161 | self.timerange = timerange |
|
1187 | 1162 | |
|
1188 | 1163 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
1189 | 1164 | |
|
1190 | 1165 | if ymin == None: ymin = 0 |
|
1191 | 1166 | if ymax == None: ymax = 360 |
|
1192 | 1167 | |
|
1193 | 1168 | self.FTP_WEI = ftp_wei |
|
1194 | 1169 | self.EXP_CODE = exp_code |
|
1195 | 1170 | self.SUB_EXP_CODE = sub_exp_code |
|
1196 | 1171 | self.PLOT_POS = plot_pos |
|
1197 | 1172 | |
|
1198 | 1173 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1199 | 1174 | self.isConfig = True |
|
1200 | 1175 | self.figfile = figfile |
|
1201 | 1176 | self.xdata = numpy.array([]) |
|
1202 | 1177 | self.ydata = numpy.array([]) |
|
1203 | 1178 | |
|
1204 | 1179 | update_figfile = True |
|
1205 | 1180 | |
|
1206 | 1181 | #open file beacon phase |
|
1207 | 1182 | path = '%s%03d' %(self.PREFIX, self.id) |
|
1208 | 1183 | beacon_file = os.path.join(path,'%s.txt'%self.name) |
|
1209 | 1184 | self.filename_phase = os.path.join(figpath,beacon_file) |
|
1210 | 1185 | #self.save_phase(self.filename_phase) |
|
1211 | 1186 | |
|
1212 | 1187 | |
|
1213 | 1188 | #store data beacon phase |
|
1214 | 1189 | #self.save_data(self.filename_phase, phase_beacon, thisDatetime) |
|
1215 | 1190 | |
|
1216 | 1191 | self.setWinTitle(title) |
|
1217 | 1192 | |
|
1218 | 1193 | |
|
1219 | 1194 | title = "Phase Plot %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1220 | 1195 | |
|
1221 | 1196 | legendlabels = ["Pair (%d,%d)"%(pair[0], pair[1]) for pair in dataOut.pairsList] |
|
1222 | 1197 | |
|
1223 | 1198 | axes = self.axesList[0] |
|
1224 | 1199 | |
|
1225 | 1200 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
1226 | 1201 | |
|
1227 | 1202 | if len(self.ydata)==0: |
|
1228 | 1203 | self.ydata = phase_beacon.reshape(-1,1) |
|
1229 | 1204 | else: |
|
1230 | 1205 | self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1))) |
|
1231 | 1206 | |
|
1232 | 1207 | |
|
1233 | 1208 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
1234 | 1209 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, |
|
1235 | 1210 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
1236 | 1211 | XAxisAsTime=True, grid='both' |
|
1237 | 1212 | ) |
|
1238 | 1213 | |
|
1239 | 1214 | self.draw() |
|
1240 | 1215 | |
|
1241 | 1216 | if dataOut.ltctime >= self.xmax: |
|
1242 | 1217 | self.counter_imagwr = wr_period |
|
1243 | 1218 | self.isConfig = False |
|
1244 | 1219 | update_figfile = True |
|
1245 | 1220 | |
|
1246 | 1221 | self.save(figpath=figpath, |
|
1247 | 1222 | figfile=figfile, |
|
1248 | 1223 | save=save, |
|
1249 | 1224 | ftp=ftp, |
|
1250 | 1225 | wr_period=wr_period, |
|
1251 | 1226 | thisDatetime=thisDatetime, |
|
1252 | 1227 | update_figfile=update_figfile) |
|
1253 | 1228 | |
|
1254 | 1229 | return dataOut |
@@ -1,1156 +1,1126 | |||
|
1 | 1 | |
|
2 | 2 | import os |
|
3 | import time | |
|
4 | import math | |
|
3 | 5 | import datetime |
|
4 | 6 | import numpy |
|
5 | 7 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecorator #YONG |
|
6 | 8 | |
|
7 | 9 | from .jroplot_spectra import RTIPlot, NoisePlot |
|
8 | 10 | |
|
9 | 11 | from schainpy.utils import log |
|
10 | 12 | from .plotting_codes import * |
|
11 | 13 | |
|
12 | 14 | from schainpy.model.graphics.jroplot_base import Plot, plt |
|
13 | 15 | |
|
14 | 16 | import matplotlib.pyplot as plt |
|
15 | 17 | import matplotlib.colors as colors |
|
16 | ||
|
17 | import time | |
|
18 | import math | |
|
19 | ||
|
20 | ||
|
21 | 18 | from matplotlib.ticker import MultipleLocator |
|
22 | 19 | |
|
23 | 20 | |
|
24 | ||
|
25 | 21 | class RTIDPPlot(RTIPlot): |
|
26 | 22 | |
|
27 | ''' | |
|
28 | Plot for RTI Double Pulse Experiment | |
|
23 | '''Plot for RTI Double Pulse Experiment | |
|
29 | 24 | ''' |
|
30 | 25 | |
|
31 | 26 | CODE = 'RTIDP' |
|
32 | 27 | colormap = 'jro' |
|
33 | 28 | plot_name = 'RTI' |
|
34 | 29 | |
|
35 | #cb_label = 'Ne Electron Density (1/cm3)' | |
|
36 | ||
|
37 | 30 | def setup(self): |
|
38 | 31 | self.xaxis = 'time' |
|
39 | 32 | self.ncols = 1 |
|
40 | 33 | self.nrows = 3 |
|
41 | 34 | self.nplots = self.nrows |
|
42 | 35 | #self.height=10 |
|
43 | 36 | if self.showSNR: |
|
44 | 37 | self.nrows += 1 |
|
45 | 38 | self.nplots += 1 |
|
46 | 39 | |
|
47 | 40 | self.ylabel = 'Height [km]' |
|
48 | 41 | self.xlabel = 'Time (LT)' |
|
49 | 42 | |
|
50 | 43 | self.cb_label = 'Intensity (dB)' |
|
51 | 44 | |
|
52 | ||
|
53 | #self.cb_label = cb_label | |
|
54 | ||
|
55 | 45 | self.titles = ['{} Channel {}'.format( |
|
56 | 46 | self.plot_name.upper(), '0x1'),'{} Channel {}'.format( |
|
57 | 47 | self.plot_name.upper(), '0'),'{} Channel {}'.format( |
|
58 | 48 | self.plot_name.upper(), '1')] |
|
59 | 49 | |
|
50 | def update(self, dataOut): | |
|
60 | 51 | |
|
61 | def plot(self): | |
|
62 | ||
|
63 | self.data.normalize_heights() | |
|
64 | self.x = self.data.times | |
|
65 | self.y = self.data.heights[0:self.data.NDP] | |
|
52 | data = {} | |
|
53 | meta = {} | |
|
54 | data[self.CODE] = dataOut.data_for_RTI_DP | |
|
55 | data['NRANGE'] = dataOut.NDP | |
|
66 | 56 | |
|
67 | if self.showSNR: | |
|
68 | self.z = numpy.concatenate( | |
|
69 | (self.data[self.CODE], self.data['snr']) | |
|
70 | ) | |
|
71 | else: | |
|
57 | return data, meta | |
|
72 | 58 | |
|
73 | self.z = self.data[self.CODE] | |
|
74 | #print(numpy.max(self.z[0,0:])) | |
|
59 | def plot(self): | |
|
75 | 60 | |
|
61 | self.x = self.data.times | |
|
62 | self.y = self.data.yrange[0: self.data['NRANGE']] | |
|
63 | self.z = self.data[self.CODE] | |
|
76 | 64 | self.z = numpy.ma.masked_invalid(self.z) |
|
77 | 65 | |
|
78 | 66 | if self.decimation is None: |
|
79 | 67 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
80 | 68 | else: |
|
81 | 69 | x, y, z = self.fill_gaps(*self.decimate()) |
|
82 | 70 | |
|
83 | 71 | for n, ax in enumerate(self.axes): |
|
84 | 72 | |
|
85 | ||
|
86 | 73 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
87 | 74 | self.z[1][0,12:40]) |
|
88 | 75 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
89 | 76 | self.z[1][0,12:40]) |
|
90 | 77 | |
|
91 | ||
|
92 | ||
|
93 | 78 | if ax.firsttime: |
|
94 | 79 | |
|
95 | 80 | if self.zlimits is not None: |
|
96 | 81 | self.zmin, self.zmax = self.zlimits[n] |
|
97 | 82 | |
|
98 | ||
|
99 | 83 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
100 | 84 | vmin=self.zmin, |
|
101 | 85 | vmax=self.zmax, |
|
102 | 86 | cmap=self.cmaps[n] |
|
103 | 87 | ) |
|
104 | #plt.tight_layout() | |
|
105 | 88 | else: |
|
106 | 89 | if self.zlimits is not None: |
|
107 | 90 | self.zmin, self.zmax = self.zlimits[n] |
|
108 | 91 | ax.collections.remove(ax.collections[0]) |
|
109 | 92 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
110 | 93 | vmin=self.zmin, |
|
111 | 94 | vmax=self.zmax, |
|
112 | 95 | cmap=self.cmaps[n] |
|
113 | 96 | ) |
|
114 | #plt.tight_layout() | |
|
115 | 97 | |
|
116 | 98 | |
|
117 | 99 | class RTILPPlot(RTIPlot): |
|
118 | 100 | |
|
119 | 101 | ''' |
|
120 | 102 | Plot for RTI Long Pulse |
|
121 | 103 | ''' |
|
122 | 104 | |
|
123 | 105 | CODE = 'RTILP' |
|
124 | 106 | colormap = 'jro' |
|
125 | 107 | plot_name = 'RTI LP' |
|
126 | 108 | |
|
127 | #cb_label = 'Ne Electron Density (1/cm3)' | |
|
128 | ||
|
129 | 109 | def setup(self): |
|
130 | 110 | self.xaxis = 'time' |
|
131 | 111 | self.ncols = 1 |
|
132 | 112 | self.nrows = 4 |
|
133 | 113 | self.nplots = self.nrows |
|
134 | 114 | if self.showSNR: |
|
135 | 115 | self.nrows += 1 |
|
136 | 116 | self.nplots += 1 |
|
137 | 117 | |
|
138 | 118 | self.ylabel = 'Height [km]' |
|
139 | 119 | self.xlabel = 'Time (LT)' |
|
140 | 120 | |
|
141 | 121 | self.cb_label = 'Intensity (dB)' |
|
142 | 122 | |
|
143 | ||
|
144 | ||
|
145 | #self.cb_label = cb_label | |
|
146 | ||
|
147 | 123 | self.titles = ['{} Channel {}'.format( |
|
148 | 124 | self.plot_name.upper(), '0'),'{} Channel {}'.format( |
|
149 | 125 | self.plot_name.upper(), '1'),'{} Channel {}'.format( |
|
150 | 126 | self.plot_name.upper(), '2'),'{} Channel {}'.format( |
|
151 | 127 | self.plot_name.upper(), '3')] |
|
152 | 128 | |
|
153 | 129 | |
|
154 | 130 | def plot(self): |
|
155 | 131 | |
|
156 | 132 | self.data.normalize_heights() |
|
157 | 133 | self.x = self.data.times |
|
158 | 134 | self.y = self.data.heights[0:self.data.NRANGE] |
|
159 | 135 | |
|
160 | 136 | if self.showSNR: |
|
161 | 137 | self.z = numpy.concatenate( |
|
162 | 138 | (self.data[self.CODE], self.data['snr']) |
|
163 | 139 | ) |
|
164 | 140 | else: |
|
165 | 141 | |
|
166 | 142 | self.z = self.data[self.CODE] |
|
167 | 143 | #print(numpy.max(self.z[0,0:])) |
|
168 | 144 | |
|
169 | 145 | self.z = numpy.ma.masked_invalid(self.z) |
|
170 | 146 | |
|
171 | 147 | if self.decimation is None: |
|
172 | 148 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
173 | 149 | else: |
|
174 | 150 | x, y, z = self.fill_gaps(*self.decimate()) |
|
175 | 151 | |
|
176 | 152 | for n, ax in enumerate(self.axes): |
|
177 | 153 | |
|
178 | ||
|
179 | 154 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
180 | 155 | self.z[1][0,12:40]) |
|
181 | 156 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
182 | 157 | self.z[1][0,12:40]) |
|
183 | 158 | |
|
184 | 159 | if ax.firsttime: |
|
185 | 160 | |
|
186 | 161 | if self.zlimits is not None: |
|
187 | 162 | self.zmin, self.zmax = self.zlimits[n] |
|
188 | 163 | |
|
189 | 164 | |
|
190 | 165 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
191 | 166 | vmin=self.zmin, |
|
192 | 167 | vmax=self.zmax, |
|
193 | 168 | cmap=self.cmaps[n] |
|
194 | 169 | ) |
|
195 | 170 | #plt.tight_layout() |
|
196 | 171 | else: |
|
197 | 172 | if self.zlimits is not None: |
|
198 | 173 | self.zmin, self.zmax = self.zlimits[n] |
|
199 | 174 | ax.collections.remove(ax.collections[0]) |
|
200 | 175 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
201 | 176 | vmin=self.zmin, |
|
202 | 177 | vmax=self.zmax, |
|
203 | 178 | cmap=self.cmaps[n] |
|
204 | 179 | ) |
|
205 | 180 | #plt.tight_layout() |
|
206 | 181 | |
|
207 | 182 | |
|
208 | 183 | class DenRTIPlot(RTIPlot): |
|
209 | 184 | |
|
210 | 185 | ''' |
|
211 | 186 | Plot for Den |
|
212 | 187 | ''' |
|
213 | 188 | |
|
214 | 189 | CODE = 'denrti' |
|
215 | 190 | colormap = 'jro' |
|
216 | 191 | plot_name = 'Electron Density' |
|
217 | 192 | |
|
218 | 193 | #cb_label = 'Ne Electron Density (1/cm3)' |
|
219 | 194 | |
|
220 | 195 | def setup(self): |
|
221 | 196 | self.xaxis = 'time' |
|
222 | 197 | self.ncols = 1 |
|
223 | 198 | self.nrows = self.data.shape(self.CODE)[0] |
|
224 | 199 | self.nplots = self.nrows |
|
225 | 200 | if self.showSNR: |
|
226 | 201 | self.nrows += 1 |
|
227 | 202 | self.nplots += 1 |
|
228 | 203 | |
|
229 | 204 | self.ylabel = 'Height [km]' |
|
230 | 205 | self.xlabel = 'Time (LT)' |
|
231 | 206 | |
|
232 | 207 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) |
|
233 | 208 | |
|
234 | 209 | if self.CODE == 'denrti' or self.CODE=='denrtiLP': |
|
235 | 210 | self.cb_label = r'$\mathrm{N_e}$ Electron Density ($\mathrm{1/cm^3}$)' |
|
236 | 211 | |
|
237 | 212 | #self.cb_label = cb_label |
|
238 | 213 | if not self.titles: |
|
239 | 214 | self.titles = self.data.parameters \ |
|
240 | 215 | if self.data.parameters else ['{}'.format(self.plot_name)] |
|
241 | 216 | if self.showSNR: |
|
242 | 217 | self.titles.append('SNR') |
|
243 | 218 | |
|
244 | 219 | def plot(self): |
|
245 | 220 | |
|
246 | 221 | self.data.normalize_heights() |
|
247 | 222 | self.x = self.data.times |
|
248 | 223 | self.y = self.data.heights |
|
249 | 224 | |
|
250 | 225 | |
|
251 | 226 | |
|
252 | 227 | if self.showSNR: |
|
253 | 228 | self.z = numpy.concatenate( |
|
254 | 229 | (self.data[self.CODE], self.data['snr']) |
|
255 | 230 | ) |
|
256 | 231 | else: |
|
257 | 232 | self.z = self.data[self.CODE] |
|
258 | 233 | |
|
259 | 234 | self.z = numpy.ma.masked_invalid(self.z) |
|
260 | 235 | |
|
261 | 236 | if self.decimation is None: |
|
262 | 237 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
263 | 238 | else: |
|
264 | 239 | x, y, z = self.fill_gaps(*self.decimate()) |
|
265 | 240 | |
|
266 | 241 | for n, ax in enumerate(self.axes): |
|
267 | 242 | |
|
268 | 243 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
269 | 244 | self.z[n]) |
|
270 | 245 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
271 | 246 | self.z[n]) |
|
272 | 247 | |
|
273 | 248 | if ax.firsttime: |
|
274 | 249 | |
|
275 | 250 | if self.zlimits is not None: |
|
276 | 251 | self.zmin, self.zmax = self.zlimits[n] |
|
277 | 252 | if numpy.log10(self.zmin)<0: |
|
278 | 253 | self.zmin=1 |
|
279 | 254 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
280 | 255 | vmin=self.zmin, |
|
281 | 256 | vmax=self.zmax, |
|
282 | 257 | cmap=self.cmaps[n], |
|
283 | 258 | norm=colors.LogNorm() |
|
284 | 259 | ) |
|
285 | 260 | #plt.tight_layout() |
|
286 | 261 | |
|
287 | 262 | else: |
|
288 | 263 | if self.zlimits is not None: |
|
289 | 264 | self.zmin, self.zmax = self.zlimits[n] |
|
290 | 265 | ax.collections.remove(ax.collections[0]) |
|
291 | 266 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
292 | 267 | vmin=self.zmin, |
|
293 | 268 | vmax=self.zmax, |
|
294 | 269 | cmap=self.cmaps[n], |
|
295 | 270 | norm=colors.LogNorm() |
|
296 | 271 | ) |
|
297 | 272 | #plt.tight_layout() |
|
298 | 273 | |
|
299 | 274 | |
|
300 | 275 | |
|
301 | 276 | class DenRTILPPlot(DenRTIPlot): |
|
302 | 277 | |
|
303 | 278 | ''' |
|
304 | 279 | Plot for Electron Temperature |
|
305 | 280 | ''' |
|
306 | 281 | |
|
307 | 282 | CODE = 'denrtiLP' |
|
308 | 283 | colormap = 'jro' |
|
309 | 284 | plot_name = 'Electron Density' |
|
310 | 285 | |
|
311 | 286 | |
|
312 | 287 | class ETempRTIPlot(RTIPlot): |
|
313 | 288 | |
|
314 | 289 | ''' |
|
315 | 290 | Plot for Electron Temperature |
|
316 | 291 | ''' |
|
317 | 292 | |
|
318 | 293 | CODE = 'ETemp' |
|
319 | 294 | colormap = 'jet' |
|
320 | 295 | plot_name = 'Electron Temperature' |
|
321 | 296 | |
|
322 | 297 | #cb_label = 'Ne Electron Density (1/cm3)' |
|
323 | 298 | |
|
324 | 299 | def setup(self): |
|
325 | 300 | self.xaxis = 'time' |
|
326 | 301 | self.ncols = 1 |
|
327 | 302 | self.nrows = self.data.shape(self.CODE)[0] |
|
328 | 303 | self.nplots = self.nrows |
|
329 | 304 | if self.showSNR: |
|
330 | 305 | self.nrows += 1 |
|
331 | 306 | self.nplots += 1 |
|
332 | 307 | |
|
333 | 308 | self.ylabel = 'Height [km]' |
|
334 | 309 | self.xlabel = 'Time (LT)' |
|
335 | 310 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) |
|
336 | 311 | if self.CODE == 'ETemp' or self.CODE == 'ETempLP': |
|
337 | 312 | self.cb_label = 'Electron Temperature (K)' |
|
338 | 313 | if self.CODE == 'ITemp' or self.CODE == 'ITempLP': |
|
339 | 314 | self.cb_label = 'Ion Temperature (K)' |
|
340 | 315 | |
|
341 | 316 | |
|
342 | 317 | if not self.titles: |
|
343 | 318 | self.titles = self.data.parameters \ |
|
344 | 319 | if self.data.parameters else ['{}'.format(self.plot_name)] |
|
345 | 320 | if self.showSNR: |
|
346 | 321 | self.titles.append('SNR') |
|
347 | 322 | |
|
348 | 323 | def plot(self): |
|
349 | 324 | |
|
350 | 325 | self.data.normalize_heights() |
|
351 | 326 | self.x = self.data.times |
|
352 | 327 | self.y = self.data.heights |
|
353 | 328 | |
|
354 | 329 | if self.showSNR: |
|
355 | 330 | self.z = numpy.concatenate( |
|
356 | 331 | (self.data[self.CODE], self.data['snr']) |
|
357 | 332 | ) |
|
358 | 333 | else: |
|
359 | 334 | self.z = self.data[self.CODE] |
|
360 | 335 | |
|
361 | 336 | self.z = numpy.ma.masked_invalid(self.z) |
|
362 | 337 | |
|
363 | 338 | if self.decimation is None: |
|
364 | 339 | x, y, z = self.fill_gaps(self.x, self.y, self.z) |
|
365 | 340 | else: |
|
366 | 341 | x, y, z = self.fill_gaps(*self.decimate()) |
|
367 | 342 | |
|
368 | 343 | for n, ax in enumerate(self.axes): |
|
369 | 344 | |
|
370 | 345 | self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
371 | 346 | self.z[n]) |
|
372 | 347 | self.zmin = self.zmin if self.zmin is not None else numpy.min( |
|
373 | 348 | self.z[n]) |
|
374 | 349 | |
|
375 | 350 | if ax.firsttime: |
|
376 | 351 | |
|
377 | 352 | if self.zlimits is not None: |
|
378 | 353 | self.zmin, self.zmax = self.zlimits[n] |
|
379 | 354 | |
|
380 | 355 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
381 | 356 | vmin=self.zmin, |
|
382 | 357 | vmax=self.zmax, |
|
383 | 358 | cmap=self.cmaps[n] |
|
384 | 359 | ) |
|
385 | 360 | #plt.tight_layout() |
|
386 | 361 | |
|
387 | 362 | else: |
|
388 | 363 | if self.zlimits is not None: |
|
389 | 364 | self.zmin, self.zmax = self.zlimits[n] |
|
390 | 365 | ax.collections.remove(ax.collections[0]) |
|
391 | 366 | ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n], |
|
392 | 367 | vmin=self.zmin, |
|
393 | 368 | vmax=self.zmax, |
|
394 | 369 | cmap=self.cmaps[n] |
|
395 | 370 | ) |
|
396 | 371 | #plt.tight_layout() |
|
397 | 372 | |
|
398 | 373 | |
|
399 | 374 | |
|
400 | 375 | class ITempRTIPlot(ETempRTIPlot): |
|
401 | 376 | |
|
402 | 377 | ''' |
|
403 | 378 | Plot for Ion Temperature |
|
404 | 379 | ''' |
|
405 | 380 | |
|
406 | 381 | CODE = 'ITemp' |
|
407 | 382 | colormap = 'jet' |
|
408 | 383 | plot_name = 'Ion Temperature' |
|
409 | 384 | |
|
410 | 385 | |
|
411 | 386 | class ElectronTempLPPlot(ETempRTIPlot): |
|
412 | 387 | |
|
413 | 388 | ''' |
|
414 | 389 | Plot for Electron Temperature LP |
|
415 | 390 | ''' |
|
416 | 391 | |
|
417 | 392 | CODE = 'ETempLP' |
|
418 | 393 | colormap = 'jet' |
|
419 | 394 | plot_name = 'Electron Temperature' |
|
420 | 395 | |
|
421 | 396 | |
|
422 | 397 | class IonTempLPPlot(ETempRTIPlot): |
|
423 | 398 | |
|
424 | 399 | ''' |
|
425 | 400 | Plot for Ion Temperature LP |
|
426 | 401 | ''' |
|
427 | 402 | |
|
428 | 403 | CODE = 'ITempLP' |
|
429 | 404 | colormap = 'jet' |
|
430 | 405 | plot_name = 'Ion Temperature' |
|
431 | 406 | |
|
432 | 407 | |
|
433 | 408 | class HFracRTIPlot(ETempRTIPlot): |
|
434 | 409 | |
|
435 | 410 | ''' |
|
436 | 411 | Plot for H+ LP |
|
437 | 412 | ''' |
|
438 | 413 | |
|
439 | 414 | CODE = 'HFracLP' |
|
440 | 415 | colormap = 'jet' |
|
441 | 416 | plot_name = 'H+ Frac' |
|
442 | 417 | |
|
443 | 418 | |
|
444 | 419 | class HeFracRTIPlot(ETempRTIPlot): |
|
445 | 420 | |
|
446 | 421 | ''' |
|
447 | 422 | Plot for He+ LP |
|
448 | 423 | ''' |
|
449 | 424 | |
|
450 | 425 | CODE = 'HeFracLP' |
|
451 | 426 | colormap = 'jet' |
|
452 | 427 | plot_name = 'He+ Frac' |
|
453 | 428 | |
|
454 | 429 | |
|
455 | 430 | class TempsDPPlot(Plot): |
|
456 | 431 | ''' |
|
457 | 432 | Plot for Electron - Ion Temperatures |
|
458 | 433 | ''' |
|
459 | 434 | |
|
460 | 435 | CODE = 'tempsDP' |
|
461 | 436 | plot_name = 'Temperatures' |
|
462 | 437 | plot_type = 'scatterbuffer' |
|
463 | 438 | |
|
464 | 439 | |
|
465 | 440 | def setup(self): |
|
466 | 441 | |
|
467 | 442 | self.ncols = 1 |
|
468 | 443 | self.nrows = 1 |
|
469 | 444 | self.nplots = 1 |
|
470 | 445 | self.ylabel = 'Range [km]' |
|
471 | 446 | self.xlabel = 'Temperature (K)' |
|
472 | 447 | self.width = 3.5 |
|
473 | 448 | self.height = 5.5 |
|
474 | 449 | self.colorbar = False |
|
475 | 450 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) |
|
476 | 451 | if not self.titles: |
|
477 | 452 | self.titles = self.data.parameters \ |
|
478 | 453 | if self.data.parameters else ['{}'.format(self.CODE.upper())] |
|
479 | 454 | |
|
480 | 455 | def plot(self): |
|
481 | 456 | |
|
482 | 457 | self.x = self.data['tempsDP'][:,-1] |
|
483 | 458 | self.y = self.data.heights[0:self.data.NSHTS] |
|
484 | 459 | |
|
485 | 460 | self.xmin = -100 |
|
486 | 461 | self.xmax = 5000 |
|
487 | 462 | ax = self.axes[0] |
|
488 | 463 | |
|
489 | 464 | if ax.firsttime: |
|
490 | 465 | |
|
491 | 466 | ax.errorbar(self.x, self.y, xerr=self.data.ete2, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') |
|
492 | 467 | ax.errorbar(self.data.ti2, self.y, fmt='k^', xerr=self.data.eti2,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') |
|
493 | 468 | plt.legend(loc='lower right') |
|
494 | 469 | self.ystep_given = 50 |
|
495 | 470 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
496 | 471 | ax.grid(which='minor') |
|
497 | 472 | #plt.tight_layout() |
|
498 | 473 | |
|
499 | 474 | |
|
500 | 475 | else: |
|
501 | 476 | self.clear_figures() |
|
502 | 477 | ax.errorbar(self.x, self.y, xerr=self.data.ete2, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') |
|
503 | 478 | ax.errorbar(self.data.ti2, self.y, fmt='k^', xerr=self.data.eti2,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') |
|
504 | 479 | plt.legend(loc='lower right') |
|
505 | 480 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
506 | 481 | #plt.tight_layout() |
|
507 | 482 | |
|
508 | 483 | |
|
509 | 484 | class TempsHPPlot(Plot): |
|
510 | 485 | ''' |
|
511 | 486 | Plot for Temperatures Hybrid Experiment |
|
512 | 487 | ''' |
|
513 | 488 | |
|
514 | 489 | CODE = 'temps_LP' |
|
515 | 490 | plot_name = 'Temperatures' |
|
516 | 491 | plot_type = 'scatterbuffer' |
|
517 | 492 | |
|
518 | 493 | |
|
519 | 494 | def setup(self): |
|
520 | 495 | |
|
521 | 496 | self.ncols = 1 |
|
522 | 497 | self.nrows = 1 |
|
523 | 498 | self.nplots = 1 |
|
524 | 499 | self.ylabel = 'Range [km]' |
|
525 | 500 | self.xlabel = 'Temperature (K)' |
|
526 | 501 | self.width = 3.5 |
|
527 | 502 | self.height = 6.5 |
|
528 | 503 | self.colorbar = False |
|
529 | 504 | if not self.titles: |
|
530 | 505 | self.titles = self.data.parameters \ |
|
531 | 506 | if self.data.parameters else ['{}'.format(self.CODE.upper())] |
|
532 | 507 | |
|
533 | 508 | def plot(self): |
|
534 | 509 | |
|
535 | 510 | self.x = self.data['temps_LP'][:,-1] |
|
536 | 511 | self.y = self.data.heights[0:self.data.NACF] |
|
537 | 512 | self.xmin = -100 |
|
538 | 513 | self.xmax = 4500 |
|
539 | 514 | ax = self.axes[0] |
|
540 | 515 | |
|
541 | 516 | if ax.firsttime: |
|
542 | 517 | |
|
543 | 518 | ax.errorbar(self.x, self.y, xerr=self.data.ete, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') |
|
544 | 519 | ax.errorbar(self.data.ti, self.y, fmt='k^', xerr=self.data.eti,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') |
|
545 | 520 | plt.legend(loc='lower right') |
|
546 | 521 | self.ystep_given = 200 |
|
547 | 522 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
548 | 523 | ax.grid(which='minor') |
|
549 | 524 | #plt.tight_layout() |
|
550 | 525 | |
|
551 | 526 | |
|
552 | 527 | else: |
|
553 | 528 | self.clear_figures() |
|
554 | 529 | ax.errorbar(self.x, self.y, xerr=self.data.ete, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='Te') |
|
555 | 530 | ax.errorbar(self.data.ti, self.y, fmt='k^', xerr=self.data.eti,elinewidth=1.0,color='b',linewidth=2.0, label='Ti') |
|
556 | 531 | plt.legend(loc='lower right') |
|
557 | 532 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
558 | 533 | #plt.tight_layout() |
|
559 | 534 | |
|
560 | 535 | |
|
561 | 536 | class FracsHPPlot(Plot): |
|
562 | 537 | ''' |
|
563 | 538 | Plot for Composition LP |
|
564 | 539 | ''' |
|
565 | 540 | |
|
566 | 541 | CODE = 'fracs_LP' |
|
567 | 542 | plot_name = 'Composition' |
|
568 | 543 | plot_type = 'scatterbuffer' |
|
569 | 544 | |
|
570 | 545 | |
|
571 | 546 | def setup(self): |
|
572 | 547 | |
|
573 | 548 | self.ncols = 1 |
|
574 | 549 | self.nrows = 1 |
|
575 | 550 | self.nplots = 1 |
|
576 | 551 | self.ylabel = 'Range [km]' |
|
577 | 552 | self.xlabel = 'Frac' |
|
578 | 553 | self.width = 3.5 |
|
579 | 554 | self.height = 6.5 |
|
580 | 555 | self.colorbar = False |
|
581 | 556 | if not self.titles: |
|
582 | 557 | self.titles = self.data.parameters \ |
|
583 | 558 | if self.data.parameters else ['{}'.format(self.CODE.upper())] |
|
584 | 559 | |
|
585 | 560 | def plot(self): |
|
586 | 561 | |
|
587 | 562 | self.x = self.data['fracs_LP'][:,-1] |
|
588 | 563 | self.y = self.data.heights[0:self.data.NACF] |
|
589 | 564 | |
|
590 | 565 | self.xmin = 0 |
|
591 | 566 | self.xmax = 1 |
|
592 | 567 | ax = self.axes[0] |
|
593 | 568 | |
|
594 | 569 | if ax.firsttime: |
|
595 | 570 | |
|
596 | 571 | ax.errorbar(self.x, self.y[self.data.cut:], xerr=self.data.eph, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='H+') |
|
597 | 572 | ax.errorbar(self.data.phe, self.y[self.data.cut:], fmt='k^', xerr=self.data.ephe,elinewidth=1.0,color='b',linewidth=2.0, label='He+') |
|
598 | 573 | plt.legend(loc='lower right') |
|
599 | 574 | self.xstep_given = 0.2 |
|
600 | 575 | self.ystep_given = 200 |
|
601 | 576 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
602 | 577 | ax.grid(which='minor') |
|
603 | 578 | #plt.tight_layout() |
|
604 | 579 | |
|
605 | 580 | |
|
606 | 581 | else: |
|
607 | 582 | self.clear_figures() |
|
608 | 583 | ax.errorbar(self.x, self.y[self.data.cut:], xerr=self.data.eph, fmt='r^',elinewidth=1.0,color='b',linewidth=2.0, label='H+') |
|
609 | 584 | ax.errorbar(self.data.phe, self.y[self.data.cut:], fmt='k^', xerr=self.data.ephe,elinewidth=1.0,color='b',linewidth=2.0, label='He+') |
|
610 | 585 | plt.legend(loc='lower right') |
|
611 | 586 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
612 | 587 | #plt.tight_layout() |
|
613 | 588 | |
|
614 | 589 | |
|
615 | 590 | |
|
616 | 591 | class EDensityPlot(Plot): |
|
617 | 592 | ''' |
|
618 | 593 | Plot for electron density |
|
619 | 594 | ''' |
|
620 | 595 | |
|
621 | 596 | CODE = 'den' |
|
622 | 597 | plot_name = 'Electron Density' |
|
623 | 598 | plot_type = 'scatterbuffer' |
|
624 | 599 | |
|
625 | 600 | |
|
626 | 601 | def setup(self): |
|
627 | 602 | |
|
628 | 603 | self.ncols = 1 |
|
629 | 604 | self.nrows = 1 |
|
630 | 605 | self.nplots = 1 |
|
631 | 606 | self.ylabel = 'Range [km]' |
|
632 | 607 | self.xlabel = r'$\mathrm{N_e}$ Electron Density ($\mathrm{1/cm^3}$)' |
|
633 | 608 | self.width = 4 |
|
634 | 609 | self.height = 6.5 |
|
635 | 610 | self.colorbar = False |
|
636 | 611 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) |
|
637 | 612 | if not self.titles: |
|
638 | 613 | self.titles = self.data.parameters \ |
|
639 | 614 | if self.data.parameters else ['{}'.format(self.CODE.upper())] |
|
640 | 615 | |
|
641 | 616 | def plot(self): |
|
642 | 617 | |
|
643 | 618 | |
|
644 | 619 | self.x = self.data[self.CODE] |
|
645 | 620 | self.y = self.data.heights |
|
646 | 621 | self.xmin = 1000 |
|
647 | 622 | self.xmax = 10000000 |
|
648 | 623 | ax = self.axes[0] |
|
649 | 624 | |
|
650 | 625 | if ax.firsttime: |
|
651 | 626 | self.autoxticks=False |
|
652 | 627 | #if self.CODE=='den': |
|
653 | 628 | ax.errorbar(self.data.dphi, self.y[:self.data.NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) |
|
654 | 629 | #ax.errorbar(self.data.dphi, self.y[:self.data.NSHTS], xerr=self.data.sdn1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) |
|
655 | 630 | |
|
656 | 631 | ax.errorbar(self.x[:,-1], self.y[:self.data.NSHTS], fmt='k^-', xerr=self.data.sdp2,elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2) |
|
657 | 632 | #else: |
|
658 | 633 | #ax.errorbar(self.data.dphi[:self.data.cut], self.y[:self.data.cut], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) |
|
659 | 634 | #ax.errorbar(self.x[:self.data.cut,-1], self.y[:self.data.cut], fmt='k^-', xerr=self.data.sdp2[:self.data.cut],elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2) |
|
660 | 635 | |
|
661 | 636 | if self.CODE=='denLP': |
|
662 | 637 | ax.errorbar(self.data.ne[self.data.cut:], self.y[self.data.cut:], xerr=self.data.ene[self.data.cut:], fmt='r^-',elinewidth=1.0,color='r',linewidth=1.0, label='LP Profile',markersize=2) |
|
663 | 638 | |
|
664 | 639 | plt.legend(loc='upper right') |
|
665 | 640 | ax.set_xscale("log", nonposx='clip') |
|
666 | 641 | grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50) |
|
667 | 642 | self.ystep_given=100 |
|
668 | 643 | if self.CODE=='denLP': |
|
669 | 644 | self.ystep_given=200 |
|
670 | 645 | ax.set_yticks(grid_y_ticks,minor=True) |
|
671 | 646 | ax.grid(which='minor') |
|
672 | 647 | #plt.tight_layout() |
|
673 | 648 | |
|
674 | 649 | |
|
675 | 650 | |
|
676 | 651 | else: |
|
677 | 652 | |
|
678 | 653 | self.clear_figures() |
|
679 | 654 | #if self.CODE=='den': |
|
680 | 655 | ax.errorbar(self.data.dphi, self.y[:self.data.NSHTS], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) |
|
681 | 656 | #ax.errorbar(self.data.dphi, self.y[:self.data.NSHTS], xerr=self.data.sdn1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) |
|
682 | 657 | |
|
683 | 658 | ax.errorbar(self.x[:,-1], self.y[:self.data.NSHTS], fmt='k^-', xerr=self.data.sdp2,elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2) |
|
684 | 659 | ax.errorbar(self.x[:,-2], self.y[:self.data.NSHTS], elinewidth=1.0,color='r',linewidth=0.5,linestyle="dashed") |
|
685 | 660 | #else: |
|
686 | 661 | #ax.errorbar(self.data.dphi[:self.data.cut], self.y[:self.data.cut], xerr=1, fmt='h-',elinewidth=1.0,color='g',linewidth=1.0, label='Faraday Profile',markersize=2) |
|
687 | 662 | #ax.errorbar(self.x[:self.data.cut,-1], self.y[:self.data.cut], fmt='k^-', xerr=self.data.sdp2[:self.data.cut],elinewidth=1.0,color='b',linewidth=1.0, label='Power Profile',markersize=2) |
|
688 | 663 | #ax.errorbar(self.x[:self.data.cut,-2], self.y[:self.data.cut], elinewidth=1.0,color='r',linewidth=0.5,linestyle="dashed") |
|
689 | 664 | |
|
690 | 665 | if self.CODE=='denLP': |
|
691 | 666 | ax.errorbar(self.data.ne[self.data.cut:], self.y[self.data.cut:], fmt='r^-', xerr=self.data.ene[self.data.cut:],elinewidth=1.0,color='r',linewidth=1.0, label='LP Profile',markersize=2) |
|
692 | 667 | |
|
693 | 668 | ax.set_xscale("log", nonposx='clip') |
|
694 | 669 | grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50) |
|
695 | 670 | ax.set_yticks(grid_y_ticks,minor=True) |
|
696 | 671 | ax.grid(which='minor') |
|
697 | 672 | plt.legend(loc='upper right') |
|
698 | 673 | #plt.tight_layout() |
|
699 | 674 | |
|
700 | 675 | class FaradayAnglePlot(Plot): |
|
701 | 676 | ''' |
|
702 | 677 | Plot for electron density |
|
703 | 678 | ''' |
|
704 | 679 | |
|
705 | 680 | CODE = 'FaradayAngle' |
|
706 | 681 | plot_name = 'Faraday Angle' |
|
707 | 682 | plot_type = 'scatterbuffer' |
|
708 | 683 | |
|
709 | 684 | |
|
710 | 685 | def setup(self): |
|
711 | 686 | |
|
712 | 687 | self.ncols = 1 |
|
713 | 688 | self.nrows = 1 |
|
714 | 689 | self.nplots = 1 |
|
715 | 690 | self.ylabel = 'Range [km]' |
|
716 | 691 | self.xlabel = 'Faraday Angle (º)' |
|
717 | 692 | self.width = 4 |
|
718 | 693 | self.height = 6.5 |
|
719 | 694 | self.colorbar = False |
|
720 | 695 | if not self.titles: |
|
721 | 696 | self.titles = self.data.parameters \ |
|
722 | 697 | if self.data.parameters else ['{}'.format(self.CODE.upper())] |
|
723 | 698 | |
|
724 | 699 | def plot(self): |
|
725 | 700 | |
|
726 | 701 | |
|
727 | 702 | self.x = self.data[self.CODE] |
|
728 | 703 | self.y = self.data.heights |
|
729 | 704 | self.xmin = -180 |
|
730 | 705 | self.xmax = 180 |
|
731 | 706 | ax = self.axes[0] |
|
732 | 707 | |
|
733 | 708 | if ax.firsttime: |
|
734 | 709 | self.autoxticks=False |
|
735 | 710 | #if self.CODE=='den': |
|
736 | 711 | ax.plot(self.x, self.y,marker='o',color='g',linewidth=1.0,markersize=2) |
|
737 | 712 | |
|
738 | 713 | grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50) |
|
739 | 714 | self.ystep_given=100 |
|
740 | 715 | if self.CODE=='denLP': |
|
741 | 716 | self.ystep_given=200 |
|
742 | 717 | ax.set_yticks(grid_y_ticks,minor=True) |
|
743 | 718 | ax.grid(which='minor') |
|
744 | 719 | #plt.tight_layout() |
|
745 | 720 | else: |
|
746 | 721 | |
|
747 | 722 | self.clear_figures() |
|
748 | 723 | #if self.CODE=='den': |
|
749 | 724 | #print(numpy.shape(self.x)) |
|
750 | 725 | ax.plot(self.x[:,-1], self.y, marker='o',color='g',linewidth=1.0, markersize=2) |
|
751 | 726 | |
|
752 | 727 | grid_y_ticks=numpy.arange(numpy.nanmin(self.y),numpy.nanmax(self.y),50) |
|
753 | 728 | ax.set_yticks(grid_y_ticks,minor=True) |
|
754 | 729 | ax.grid(which='minor') |
|
755 | 730 | |
|
756 | 731 | class EDensityHPPlot(EDensityPlot): |
|
757 | 732 | |
|
758 | 733 | ''' |
|
759 | 734 | Plot for Electron Density Hybrid Experiment |
|
760 | 735 | ''' |
|
761 | 736 | |
|
762 | 737 | CODE = 'denLP' |
|
763 | 738 | plot_name = 'Electron Density' |
|
764 | 739 | plot_type = 'scatterbuffer' |
|
765 | 740 | |
|
766 | 741 | |
|
767 | 742 | class ACFsPlot(Plot): |
|
768 | 743 | ''' |
|
769 | 744 | Plot for ACFs Double Pulse Experiment |
|
770 | 745 | ''' |
|
771 | 746 | |
|
772 | 747 | CODE = 'acfs' |
|
773 | 748 | plot_name = 'ACF' |
|
774 | 749 | plot_type = 'scatterbuffer' |
|
775 | 750 | |
|
776 | 751 | |
|
777 | 752 | def setup(self): |
|
778 | 753 | #self.xaxis = 'time' |
|
779 | 754 | self.ncols = 1 |
|
780 | 755 | self.nrows = 1 |
|
781 | 756 | self.nplots = 1 |
|
782 | 757 | self.ylabel = 'Range [km]' |
|
783 | 758 | self.xlabel = 'lags (ms)' |
|
784 | 759 | self.width = 3.5 |
|
785 | 760 | self.height = 6 |
|
786 | 761 | self.colorbar = False |
|
787 | 762 | self.plots_adjust.update({'wspace': 0.8, 'hspace':0.2, 'left': 0.2, 'right': 0.9, 'bottom': 0.18}) |
|
788 | 763 | if not self.titles: |
|
789 | 764 | self.titles = self.data.parameters \ |
|
790 | 765 | if self.data.parameters else ['{}'.format(self.CODE.upper())] |
|
791 | 766 | |
|
792 | 767 | def plot(self): |
|
793 | 768 | |
|
794 | 769 | self.x = self.data.lags_to_plot |
|
795 | 770 | self.y = self.data['acfs'][:,-1] |
|
796 | 771 | |
|
797 | 772 | |
|
798 | 773 | self.xmin = 0.0 |
|
799 | 774 | self.xmax = 2.0 |
|
800 | 775 | |
|
801 | 776 | ax = self.axes[0] |
|
802 | 777 | |
|
803 | 778 | if ax.firsttime: |
|
804 | 779 | |
|
805 | 780 | for i in range(self.data.NSHTS): |
|
806 | 781 | x_aux = numpy.isfinite(self.x[i,:]) |
|
807 | 782 | y_aux = numpy.isfinite(self.y[i,:]) |
|
808 | 783 | yerr_aux = numpy.isfinite(self.data.acfs_error_to_plot[i,:]) |
|
809 | 784 | x_igcej_aux = numpy.isfinite(self.data.x_igcej_to_plot[i,:]) |
|
810 | 785 | y_igcej_aux = numpy.isfinite(self.data.y_igcej_to_plot[i,:]) |
|
811 | 786 | x_ibad_aux = numpy.isfinite(self.data.x_ibad_to_plot[i,:]) |
|
812 | 787 | y_ibad_aux = numpy.isfinite(self.data.y_ibad_to_plot[i,:]) |
|
813 | 788 | if self.x[i,:][~numpy.isnan(self.x[i,:])].shape[0]>2: |
|
814 | 789 | ax.errorbar(self.x[i,x_aux], self.y[i,y_aux], yerr=self.data.acfs_error_to_plot[i,x_aux],color='b',marker='o',linewidth=1.0,markersize=2) |
|
815 | 790 | ax.plot(self.data.x_igcej_to_plot[i,x_igcej_aux],self.data.y_igcej_to_plot[i,y_igcej_aux],'x',color='red',markersize=2) |
|
816 | 791 | ax.plot(self.data.x_ibad_to_plot[i,x_ibad_aux],self.data.y_ibad_to_plot[i,y_ibad_aux],'X',color='red',markersize=2) |
|
817 | 792 | |
|
818 | 793 | self.xstep_given = (self.xmax-self.xmin)/(self.data.DPL-1) |
|
819 | 794 | self.ystep_given = 50 |
|
820 | 795 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
821 | 796 | ax.grid(which='minor') |
|
822 | 797 | |
|
823 | 798 | |
|
824 | 799 | |
|
825 | 800 | else: |
|
826 | 801 | self.clear_figures() |
|
827 | 802 | |
|
828 | 803 | for i in range(self.data.NSHTS): |
|
829 | 804 | x_aux = numpy.isfinite(self.x[i,:]) |
|
830 | 805 | y_aux = numpy.isfinite(self.y[i,:]) |
|
831 | 806 | yerr_aux = numpy.isfinite(self.data.acfs_error_to_plot[i,:]) |
|
832 | 807 | x_igcej_aux = numpy.isfinite(self.data.x_igcej_to_plot[i,:]) |
|
833 | 808 | y_igcej_aux = numpy.isfinite(self.data.y_igcej_to_plot[i,:]) |
|
834 | 809 | x_ibad_aux = numpy.isfinite(self.data.x_ibad_to_plot[i,:]) |
|
835 | 810 | y_ibad_aux = numpy.isfinite(self.data.y_ibad_to_plot[i,:]) |
|
836 | 811 | if self.x[i,:][~numpy.isnan(self.x[i,:])].shape[0]>2: |
|
837 | 812 | ax.errorbar(self.x[i,x_aux], self.y[i,y_aux], yerr=self.data.acfs_error_to_plot[i,x_aux],linewidth=1.0,markersize=2,color='b',marker='o') |
|
838 | 813 | ax.plot(self.data.x_igcej_to_plot[i,x_igcej_aux],self.data.y_igcej_to_plot[i,y_igcej_aux],'x',color='red',markersize=2) |
|
839 | 814 | ax.plot(self.data.x_ibad_to_plot[i,x_ibad_aux],self.data.y_ibad_to_plot[i,y_ibad_aux],'X',color='red',markersize=2) |
|
840 | 815 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
841 | 816 | |
|
842 | 817 | |
|
843 | 818 | |
|
844 | 819 | |
|
845 | 820 | class ACFsLPPlot(Plot): |
|
846 | 821 | ''' |
|
847 | 822 | Plot for ACFs Double Pulse Experiment |
|
848 | 823 | ''' |
|
849 | 824 | |
|
850 | 825 | CODE = 'acfs_LP' |
|
851 | 826 | plot_name = 'ACF' |
|
852 | 827 | plot_type = 'scatterbuffer' |
|
853 | 828 | |
|
854 | 829 | |
|
855 | 830 | def setup(self): |
|
856 | 831 | #self.xaxis = 'time' |
|
857 | 832 | self.ncols = 1 |
|
858 | 833 | self.nrows = 1 |
|
859 | 834 | self.nplots = 1 |
|
860 | 835 | self.ylabel = 'Range [km]' |
|
861 | 836 | self.xlabel = 'lags (ms)' |
|
862 | 837 | self.width = 3.5 |
|
863 | 838 | self.height = 7 |
|
864 | 839 | self.colorbar = False |
|
865 | 840 | if not self.titles: |
|
866 | 841 | self.titles = self.data.parameters \ |
|
867 | 842 | if self.data.parameters else ['{}'.format(self.CODE.upper())] |
|
868 | 843 | |
|
869 | 844 | |
|
870 | 845 | |
|
871 | 846 | def plot(self): |
|
872 | 847 | |
|
873 | 848 | self.x = self.data.lags_LP_to_plot |
|
874 | 849 | self.y = self.data['acfs_LP'][:,-1] |
|
875 | 850 | |
|
876 | 851 | self.xmin = 0.0 |
|
877 | 852 | self.xmax = 1.5 |
|
878 | 853 | |
|
879 | 854 | ax = self.axes[0] |
|
880 | 855 | |
|
881 | 856 | if ax.firsttime: |
|
882 | 857 | |
|
883 | 858 | for i in range(self.data.NACF): |
|
884 | 859 | x_aux = numpy.isfinite(self.x[i,:]) |
|
885 | 860 | y_aux = numpy.isfinite(self.y[i,:]) |
|
886 | 861 | yerr_aux = numpy.isfinite(self.data.errors[i,:]) |
|
887 | 862 | |
|
888 | 863 | if self.x[i,:][~numpy.isnan(self.x[i,:])].shape[0]>2: |
|
889 | 864 | ax.errorbar(self.x[i,x_aux], self.y[i,y_aux], yerr=self.data.errors[i,x_aux],color='b',linewidth=1.0,markersize=2,ecolor='r') |
|
890 | 865 | |
|
891 | 866 | #self.xstep_given = (self.xmax-self.xmin)/(self.data.NLAG-1) |
|
892 | 867 | self.xstep_given=0.3 |
|
893 | 868 | self.ystep_given = 200 |
|
894 | 869 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
895 | 870 | ax.grid(which='minor') |
|
896 | 871 | |
|
897 | 872 | else: |
|
898 | 873 | self.clear_figures() |
|
899 | 874 | |
|
900 | 875 | for i in range(self.data.NACF): |
|
901 | 876 | x_aux = numpy.isfinite(self.x[i,:]) |
|
902 | 877 | y_aux = numpy.isfinite(self.y[i,:]) |
|
903 | 878 | yerr_aux = numpy.isfinite(self.data.errors[i,:]) |
|
904 | 879 | |
|
905 | 880 | if self.x[i,:][~numpy.isnan(self.x[i,:])].shape[0]>2: |
|
906 | 881 | ax.errorbar(self.x[i,x_aux], self.y[i,y_aux], yerr=self.data.errors[i,x_aux],color='b',linewidth=1.0,markersize=2,ecolor='r') |
|
907 | 882 | |
|
908 | 883 | ax.yaxis.set_minor_locator(MultipleLocator(15)) |
|
909 | 884 | |
|
910 | 885 | |
|
911 | 886 | class CrossProductsPlot(Plot): |
|
912 | 887 | ''' |
|
913 | 888 | Plot for cross products |
|
914 | 889 | ''' |
|
915 | 890 | |
|
916 | 891 | CODE = 'crossprod' |
|
917 | 892 | plot_name = 'Cross Products' |
|
918 | 893 | plot_type = 'scatterbuffer' |
|
919 | 894 | |
|
920 | ||
|
921 | 895 | def setup(self): |
|
922 | 896 | |
|
923 | 897 | self.ncols = 3 |
|
924 | 898 | self.nrows = 1 |
|
925 | 899 | self.nplots = 3 |
|
926 | 900 | self.ylabel = 'Range [km]' |
|
927 | ||
|
928 | 901 | self.width = 3.5*self.nplots |
|
929 | 902 | self.height = 5.5 |
|
930 | 903 | self.colorbar = False |
|
931 | 904 | self.titles = [] |
|
932 | 905 | |
|
933 |
def |
|
|
934 | ||
|
935 | self.x = self.data['crossprod'][:,-1,:,:,:,:] | |
|
936 | ||
|
906 | def update(self, dataOut): | |
|
937 | 907 | |
|
908 | data = {} | |
|
909 | meta = {} | |
|
938 | 910 | |
|
911 | data['crossprod'] = dataOut.crossprods | |
|
912 | data['NDP'] = dataOut.NDP | |
|
939 | 913 | |
|
940 | self.y = self.data.heights[0:self.data.NDP] | |
|
914 | return data, meta | |
|
941 | 915 | |
|
916 | def plot(self): | |
|
942 | 917 | |
|
918 | self.x = self.data['crossprod'][:,-1,:,:,:,:] | |
|
919 | self.y = self.data.heights[0:self.data['NDP']] | |
|
943 | 920 | |
|
944 | 921 | for n, ax in enumerate(self.axes): |
|
945 | 922 | |
|
946 | 923 | self.xmin=numpy.min(numpy.concatenate((self.x[n][0,20:30,0,0],self.x[n][1,20:30,0,0],self.x[n][2,20:30,0,0],self.x[n][3,20:30,0,0]))) |
|
947 | 924 | self.xmax=numpy.max(numpy.concatenate((self.x[n][0,20:30,0,0],self.x[n][1,20:30,0,0],self.x[n][2,20:30,0,0],self.x[n][3,20:30,0,0]))) |
|
948 | 925 | |
|
949 | ||
|
950 | 926 | if ax.firsttime: |
|
951 | 927 | |
|
952 | 928 | self.autoxticks=False |
|
953 | 929 | if n==0: |
|
954 | 930 | label1='kax' |
|
955 | 931 | label2='kay' |
|
956 | 932 | label3='kbx' |
|
957 | 933 | label4='kby' |
|
958 | 934 | self.xlimits=[(self.xmin,self.xmax)] |
|
959 | 935 | elif n==1: |
|
960 | 936 | label1='kax2' |
|
961 | 937 | label2='kay2' |
|
962 | 938 | label3='kbx2' |
|
963 | 939 | label4='kby2' |
|
964 | 940 | self.xlimits.append((self.xmin,self.xmax)) |
|
965 | 941 | elif n==2: |
|
966 | 942 | label1='kaxay' |
|
967 | 943 | label2='kbxby' |
|
968 | 944 | label3='kaxbx' |
|
969 | 945 | label4='kaxby' |
|
970 | 946 | self.xlimits.append((self.xmin,self.xmax)) |
|
971 | 947 | |
|
972 | ||
|
973 | 948 | ax.plotline1 = ax.plot(self.x[n][0,:,0,0], self.y, color='r',linewidth=2.0, label=label1) |
|
974 | 949 | ax.plotline2 = ax.plot(self.x[n][1,:,0,0], self.y, color='k',linewidth=2.0, label=label2) |
|
975 | 950 | ax.plotline3 = ax.plot(self.x[n][2,:,0,0], self.y, color='b',linewidth=2.0, label=label3) |
|
976 | 951 | ax.plotline4 = ax.plot(self.x[n][3,:,0,0], self.y, color='m',linewidth=2.0, label=label4) |
|
977 | 952 | ax.legend(loc='upper right') |
|
978 | 953 | ax.set_xlim(self.xmin, self.xmax) |
|
979 | 954 | self.titles.append('{}'.format(self.plot_name.upper())) |
|
980 | #plt.tight_layout() | |
|
981 | ||
|
982 | 955 | |
|
983 | 956 | else: |
|
984 | 957 | |
|
985 | 958 | if n==0: |
|
986 | 959 | self.xlimits=[(self.xmin,self.xmax)] |
|
987 | 960 | else: |
|
988 | 961 | self.xlimits.append((self.xmin,self.xmax)) |
|
989 | 962 | |
|
990 | 963 | ax.set_xlim(self.xmin, self.xmax) |
|
991 | 964 | |
|
992 | ||
|
993 | 965 | ax.plotline1[0].set_data(self.x[n][0,:,0,0],self.y) |
|
994 | 966 | ax.plotline2[0].set_data(self.x[n][1,:,0,0],self.y) |
|
995 | 967 | ax.plotline3[0].set_data(self.x[n][2,:,0,0],self.y) |
|
996 | 968 | ax.plotline4[0].set_data(self.x[n][3,:,0,0],self.y) |
|
997 | 969 | self.titles.append('{}'.format(self.plot_name.upper())) |
|
998 | #plt.tight_layout() | |
|
999 | ||
|
1000 | 970 | |
|
1001 | 971 | |
|
1002 | 972 | class CrossProductsLPPlot(Plot): |
|
1003 | 973 | ''' |
|
1004 | 974 | Plot for cross products LP |
|
1005 | 975 | ''' |
|
1006 | 976 | |
|
1007 | 977 | CODE = 'crossprodlp' |
|
1008 | 978 | plot_name = 'Cross Products LP' |
|
1009 | 979 | plot_type = 'scatterbuffer' |
|
1010 | 980 | |
|
1011 | 981 | |
|
1012 | 982 | def setup(self): |
|
1013 | 983 | |
|
1014 | 984 | self.ncols = 2 |
|
1015 | 985 | self.nrows = 1 |
|
1016 | 986 | self.nplots = 2 |
|
1017 | 987 | self.ylabel = 'Range [km]' |
|
1018 | 988 | self.xlabel = 'dB' |
|
1019 | 989 | self.width = 3.5*self.nplots |
|
1020 | 990 | self.height = 5.5 |
|
1021 | 991 | self.colorbar = False |
|
1022 | 992 | self.titles = [] |
|
1023 | 993 | self.plotline_array=numpy.zeros((2,self.data.NLAG),dtype=object) |
|
1024 | 994 | def plot(self): |
|
1025 | 995 | |
|
1026 | 996 | |
|
1027 | 997 | self.x = self.data[self.CODE][:,-1,:,:] |
|
1028 | 998 | |
|
1029 | 999 | |
|
1030 | 1000 | self.y = self.data.heights[0:self.data.NRANGE] |
|
1031 | 1001 | |
|
1032 | 1002 | |
|
1033 | 1003 | label_array=numpy.array(['lag '+ str(x) for x in range(self.data.NLAG)]) |
|
1034 | 1004 | color_array=['r','k','g','b','c','m','y','orange','steelblue','purple','peru','darksalmon','grey','limegreen','olive','midnightblue'] |
|
1035 | 1005 | |
|
1036 | 1006 | |
|
1037 | 1007 | for n, ax in enumerate(self.axes): |
|
1038 | 1008 | |
|
1039 | 1009 | self.xmin=30 |
|
1040 | 1010 | self.xmax=70 |
|
1041 | 1011 | #print(self.x[0,12:15,n]) |
|
1042 | 1012 | #input() |
|
1043 | 1013 | #self.xmin=numpy.min(numpy.concatenate((self.x[0,:,n],self.x[1,:,n]))) |
|
1044 | 1014 | #self.xmax=numpy.max(numpy.concatenate((self.x[0,:,n],self.x[1,:,n]))) |
|
1045 | 1015 | |
|
1046 | 1016 | #print("before",self.plotline_array) |
|
1047 | 1017 | |
|
1048 | 1018 | if ax.firsttime: |
|
1049 | 1019 | |
|
1050 | 1020 | self.autoxticks=False |
|
1051 | 1021 | |
|
1052 | 1022 | |
|
1053 | 1023 | for i in range(self.data.NLAG): |
|
1054 | 1024 | #print(i) |
|
1055 | 1025 | #print(numpy.shape(self.x)) |
|
1056 | 1026 | self.plotline_array[n,i], = ax.plot(self.x[i,:,n], self.y, color=color_array[i],linewidth=1.0, label=label_array[i]) |
|
1057 | 1027 | #ax.plotline1 = ax.plot(self.x[0,:,n], self.y, color='r',linewidth=2.0, label=label_array[0]) |
|
1058 | 1028 | #ax.plotline2 = ax.plot(self.x[n][1,:,0,0], self.y, color='k',linewidth=2.0, label=label2) |
|
1059 | 1029 | #ax.plotline3 = ax.plot(self.x[n][2,:,0,0], self.y, color='b',linewidth=2.0, label=label3) |
|
1060 | 1030 | #ax.plotline4 = ax.plot(self.x[n][3,:,0,0], self.y, color='m',linewidth=2.0, label=label4) |
|
1061 | 1031 | |
|
1062 | 1032 | |
|
1063 | 1033 | #print(self.plotline_array) |
|
1064 | 1034 | |
|
1065 | 1035 | |
|
1066 | 1036 | |
|
1067 | 1037 | ax.legend(loc='upper right') |
|
1068 | 1038 | ax.set_xlim(self.xmin, self.xmax) |
|
1069 | 1039 | if n==0: |
|
1070 | 1040 | self.titles.append('{} CH0'.format(self.plot_name.upper())) |
|
1071 | 1041 | if n==1: |
|
1072 | 1042 | self.titles.append('{} CH1'.format(self.plot_name.upper())) |
|
1073 | 1043 | |
|
1074 | 1044 | #plt.tight_layout() |
|
1075 | 1045 | |
|
1076 | 1046 | else: |
|
1077 | 1047 | #print(self.plotline_array) |
|
1078 | 1048 | for i in range(self.data.NLAG): |
|
1079 | 1049 | |
|
1080 | 1050 | self.plotline_array[n,i].set_data(self.x[i,:,n],self.y) |
|
1081 | 1051 | |
|
1082 | 1052 | |
|
1083 | 1053 | |
|
1084 | 1054 | #ax.plotline1[0].set_data(self.x[n][0,:,0,0],self.y) |
|
1085 | 1055 | #ax.plotline2[0].set_data(self.x[n][1,:,0,0],self.y) |
|
1086 | 1056 | #ax.plotline3[0].set_data(self.x[n][2,:,0,0],self.y) |
|
1087 | 1057 | #ax.plotline4[0].set_data(self.x[n][3,:,0,0],self.y) |
|
1088 | 1058 | |
|
1089 | 1059 | if n==0: |
|
1090 | 1060 | self.titles.append('{} CH0'.format(self.plot_name.upper())) |
|
1091 | 1061 | if n==1: |
|
1092 | 1062 | self.titles.append('{} CH1'.format(self.plot_name.upper())) |
|
1093 | 1063 | |
|
1094 | 1064 | #plt.tight_layout() |
|
1095 | 1065 | |
|
1096 | 1066 | |
|
1097 | 1067 | class NoiseDPPlot(NoisePlot): |
|
1098 | 1068 | ''' |
|
1099 | 1069 | Plot for noise Double Pulse |
|
1100 | 1070 | ''' |
|
1101 | 1071 | |
|
1102 | 1072 | CODE = 'noisedp' |
|
1103 | 1073 | plot_name = 'Noise' |
|
1104 | 1074 | plot_type = 'scatterbuffer' |
|
1105 | 1075 | |
|
1106 | 1076 | |
|
1107 | 1077 | class XmitWaveformPlot(Plot): |
|
1108 | 1078 | ''' |
|
1109 | 1079 | Plot for xmit waveform |
|
1110 | 1080 | ''' |
|
1111 | 1081 | |
|
1112 | 1082 | CODE = 'xmit' |
|
1113 | 1083 | plot_name = 'Xmit Waveform' |
|
1114 | 1084 | plot_type = 'scatterbuffer' |
|
1115 | 1085 | |
|
1116 | 1086 | |
|
1117 | 1087 | def setup(self): |
|
1118 | 1088 | |
|
1119 | 1089 | self.ncols = 1 |
|
1120 | 1090 | self.nrows = 1 |
|
1121 | 1091 | self.nplots = 1 |
|
1122 | 1092 | self.ylabel = '' |
|
1123 | 1093 | self.xlabel = 'Number of Lag' |
|
1124 | 1094 | self.width = 5.5 |
|
1125 | 1095 | self.height = 3.5 |
|
1126 | 1096 | self.colorbar = False |
|
1127 | 1097 | if not self.titles: |
|
1128 | 1098 | self.titles = self.data.parameters \ |
|
1129 | 1099 | if self.data.parameters else ['{}'.format(self.plot_name.upper())] |
|
1130 | 1100 | |
|
1131 | 1101 | def plot(self): |
|
1132 | 1102 | |
|
1133 | 1103 | self.x = numpy.arange(0,self.data.NLAG,1,'float32') |
|
1134 | 1104 | self.y = self.data['xmit'][:,-1,:] |
|
1135 | 1105 | |
|
1136 | 1106 | self.xmin = 0 |
|
1137 | 1107 | self.xmax = self.data.NLAG-1 |
|
1138 | 1108 | self.ymin = -1.0 |
|
1139 | 1109 | self.ymax = 1.0 |
|
1140 | 1110 | ax = self.axes[0] |
|
1141 | 1111 | |
|
1142 | 1112 | if ax.firsttime: |
|
1143 | 1113 | ax.plotline0=ax.plot(self.x,self.y[0,:],color='blue') |
|
1144 | 1114 | ax.plotline1=ax.plot(self.x,self.y[1,:],color='red') |
|
1145 | 1115 | secax=ax.secondary_xaxis(location=0.5) |
|
1146 | 1116 | secax.xaxis.tick_bottom() |
|
1147 | 1117 | secax.tick_params( labelleft=False, labeltop=False, |
|
1148 | 1118 | labelright=False, labelbottom=False) |
|
1149 | 1119 | |
|
1150 | 1120 | self.xstep_given = 3 |
|
1151 | 1121 | self.ystep_given = .25 |
|
1152 | 1122 | secax.set_xticks(numpy.linspace(self.xmin, self.xmax, 6)) #only works on matplotlib.version>3.2 |
|
1153 | 1123 | |
|
1154 | 1124 | else: |
|
1155 | 1125 | ax.plotline0[0].set_data(self.x,self.y[0,:]) |
|
1156 | 1126 | ax.plotline1[0].set_data(self.x,self.y[1,:]) |
@@ -1,22 +1,22 | |||
|
1 | 1 | ''' |
|
2 | 2 | |
|
3 | 3 | $Author: murco $ |
|
4 | 4 | $Id: Processor.py 1 2012-11-12 18:56:07Z murco $ |
|
5 | 5 | ''' |
|
6 | 6 | |
|
7 | 7 | from .jroproc_voltage import * |
|
8 | 8 | from .jroproc_spectra import * |
|
9 | 9 | from .jroproc_heispectra import * |
|
10 | 10 | from .jroproc_amisr import * |
|
11 | 11 | from .jroproc_correlation import * |
|
12 | 12 | from .jroproc_parameters import * |
|
13 | 13 | from .jroproc_spectra_lags import * |
|
14 | 14 | from .jroproc_spectra_acf import * |
|
15 | 15 | from .bltrproc_parameters import * |
|
16 | 16 | from .pxproc_parameters import * |
|
17 | 17 | |
|
18 | 18 | |
|
19 | 19 | ###########DP########### |
|
20 | 20 | from .jroproc_voltage_lags import * |
|
21 | 21 | ###########DP########### |
|
22 | from .jroproc_spectra_lags_faraday import * | |
|
22 | # from .jroproc_spectra_lags_faraday import * |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
General Comments 0
You need to be logged in to leave comments.
Login now