##// END OF EJS Templates
Add MP150KmRTIPlot and several AverageDriftsPlot classes for testing the 150kM plotting.
imanay -
r1768:008ae31786c1
parent child
Show More
@@ -379,3 +379,234 class PolarMapPlot(Plot):
379 379 self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels]
380 380 self.titles = ['{} {}'.format(
381 381 self.data.parameters[x], title) for x in self.channels]
382
383 class MP150KmRTIPlot(Plot):
384 '''
385 Plot for data_xxxx object
386 '''
387
388 CODE = 'param'
389 colormap = 'viridis'
390 plot_type = 'pcolorbuffer'
391
392 def setup(self):
393 self.xaxis = 'time'
394 self.ncols = 1
395 self.nrows = self.data.shape('param')[0]
396 self.nplots = self.nrows
397 self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95, 'top': 0.95})
398
399 if not self.xlabel:
400 self.xlabel = 'Time'
401
402 self.ylabel = 'Range [km]'
403 if not self.titles:
404 self.titles = ['Param {}'.format(x) for x in range(self.nrows)]
405
406 def update(self, dataOut):
407 data = {
408 #'param' : numpy.concatenate([getattr(dataOut, attr) for attr in self.attr_data], axis=0)[0:3,:] # SNL, VERTICAL, ZONAL
409 'param' : dataOut.data_output[0:3,:] # SNL, VERTICAL, ZONAL
410 }
411
412 meta = {}
413
414 return data, meta
415
416 def plot(self):
417 # self.data.normalize_heights()
418 self.x = self.data.times
419 self.y = self.data.yrange
420 self.z = self.data['param']
421
422
423 self.z = numpy.ma.masked_invalid(self.z)
424
425 if self.decimation is None:
426 x, y, z = self.fill_gaps(self.x, self.y, self.z)
427 else:
428 x, y, z = self.fill_gaps(*self.decimate())
429
430 for n, ax in enumerate(self.axes):
431 self.zmax = self.zmax if self.zmax is not None else numpy.max(
432 self.z[n])
433 self.zmin = self.zmin if self.zmin is not None else numpy.min(
434 self.z[n])
435
436 if ax.firsttime:
437 if self.zlimits is not None:
438 self.zmin, self.zmax = self.zlimits[n]
439
440 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
441 vmin=self.zmin,
442 vmax=self.zmax,
443 cmap=self.cmaps[n]
444 )
445 else:
446 if self.zlimits is not None:
447 self.zmin, self.zmax = self.zlimits[n]
448 ax.plt.remove()
449 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
450 vmin=self.zmin,
451 vmax=self.zmax,
452 cmap=self.cmaps[n]
453 )
454
455 class AverageDriftsPlot_v2(Plot):
456 '''
457 Plot for average 150 Km echoes
458 '''
459
460 CODE = 'average'
461 plot_type = 'scatterbuffer'
462
463 def setup(self):
464 self.xaxis = 'time'
465 self.ncols = 1
466
467 self.nplots = 2
468 self.nrows = 2
469
470 self.ylabel = 'Velocity\nm/s'
471 self.xlabel = 'Local time'
472 #self.titles = ['VERTICAL VELOCITY: AVERAGE AND ERRORS', 'ZONAL VELOCITY: AVERAGE AND ERRORS']
473 self.titles = ['VERTICAL VELOCITY: AVERAGE', 'ZONAL VELOCITY: AVERAGE']
474
475 self.colorbar = False
476 self.plots_adjust.update({'hspace':0.5, 'left': 0.1, 'bottom': 0.1, 'right':0.95, 'top': 0.95 })
477
478
479 def update(self, dataOut):
480
481 data = {}
482 meta = {}
483
484 #data['average']= numpy.nanmean(dataOut.data_output[1:3,:], axis=1) # VERTICAL, ZONAL
485 data['average']= numpy.nanmean(dataOut.data_output[1:3,:], axis=1) # VERTICAL, ZONAL
486 data['error']= numpy.nanmean(dataOut.data_output[3:,:], axis=1) # ERROR VERTICAL, ERROR ZONAL
487 meta['yrange'] = numpy.array([])
488
489 return data, meta
490
491 def plot(self):
492
493 self.x = self.data.times
494 #self.xmin = self.data.min_time
495 #self.xmax = self.xmin + self.xrange * 60 * 60
496 self.y = self.data['average']
497 print('self.y:', self.y.shape)
498 self.y_error = self.data['error']
499 print('self.y_error:', self.y_error.shape)
500
501 for n, ax in enumerate(self.axes):
502 if ax.firsttime:
503 self.ymin = self.ymin if self.ymin is not None else -50
504 self.ymax = self.ymax if self.ymax is not None else 50
505 self.axes[n].plot(self.x, self.y[n], c='r', ls=':', lw=1)
506 else:
507 self.axes[n].lines[0].set_data(self.x, self.y[n])
508 '''
509 for n, ax in enumerate(self.axes):
510
511 if ax.firsttime:
512 self.ymin = self.ymin if self.ymin is not None else -50
513 self.ymax = self.ymax if self.ymax is not None else 50
514 ax.scatter(self.x, self.y[n], c='g', s=0.8)
515 #ax.errorbar(self.x, self.y[n], yerr = self.y_error[n,:], ecolor='r', elinewidth=0.2, fmt='|')
516 else:
517 ax.scatter(self.x, self.y[n], c='g', s=0.8)
518 #ax.errorbar(self.x, self.y[n], yerr = self.y_error[n,:], ecolor='r', elinewidth=0.2, fmt='|')
519 '''
520 class AverageDriftsPlot_bck(Plot):
521 '''
522 Plot for average 150 Km echoes
523 '''
524 CODE = 'average'
525 plot_type = 'scatterbuffer'
526
527 def setup(self):
528 self.xaxis = 'time'
529 self.ncols = 1
530 self.nplots = 2
531 self.nrows = 2
532 self.ylabel = 'Velocity\nm/s'
533 self.xlabel = 'Time'
534 self.titles = ['VERTICAL VELOCITY: AVERAGE', 'ZONAL VELOCITY: AVERAGE']
535 self.colorbar = False
536 self.plots_adjust.update({'hspace':0.5, 'left': 0.1, 'bottom': 0.1, 'right':0.95, 'top': 0.95 })
537
538
539
540 def update(self, dataOut):
541
542 data = {}
543 meta = {}
544 data['average']= numpy.nanmean(dataOut.data_output[1:3,:], axis=1) # VERTICAL, ZONAL
545 meta['yrange'] = numpy.array([])
546
547 return data, meta
548
549 def plot(self):
550
551 self.x = self.data.times
552 self.y = self.data['average']
553
554 for n, ax in enumerate(self.axes):
555 if ax.firsttime:
556
557 if self.zlimits is not None:
558 self.axes[n].set_ylim(self.zlimits[n])
559 self.axes[n].plot(self.x, self.y[n], c='r', ls='-', lw=1)
560 else:
561
562 if self.zlimits is not None:
563 ax.set_ylim((self.zlimits[n]))
564 self.axes[n].lines[0].set_data(self.x, self.y[n])
565
566 class AverageDriftsPlot(Plot):
567 '''
568 Plot for average 150 Km echoes
569 '''
570 CODE = 'average'
571 plot_type = 'scatterbuffer'
572
573 def setup(self):
574 self.xaxis = 'time'
575 self.ncols = 1
576 self.nplots = 2
577 self.nrows = 2
578 self.ylabel = 'Velocity\nm/s'
579 self.xlabel = 'Time'
580 self.titles = ['VERTICAL VELOCITY: AVERAGE', 'ZONAL VELOCITY: AVERAGE']
581 self.colorbar = False
582 self.plots_adjust.update({'hspace':0.5, 'left': 0.1, 'bottom': 0.1, 'right':0.95, 'top': 0.95 })
583
584
585
586 def update(self, dataOut):
587
588 data = {}
589 meta = {}
590 data['average']= dataOut.avg_output[0:2] # VERTICAL, ZONAL velocities
591 meta['yrange'] = numpy.array([])
592
593 return data, meta
594
595 def plot(self):
596
597 self.x = self.data.times
598 self.y = self.data['average']
599
600 for n, ax in enumerate(self.axes):
601
602 if ax.firsttime:
603
604 if self.zlimits is not None:
605 ax.set_ylim((self.zlimits[n]))
606 self.axes[n].plot(self.x, self.y[n], c='r', ls='-', lw=1)
607 else:
608
609 if self.zlimits is not None:
610 ax.set_ylim((self.zlimits[n]))
611 self.axes[n].lines[0].set_data(self.x, self.y[n])
612
General Comments 0
You need to be logged in to leave comments. Login now