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