|
@@
-37,7
+37,6
class PlotData(Operation, Process):
|
|
37
|
self.dataOut = None
|
|
37
|
self.dataOut = None
|
|
38
|
self.isConfig = False
|
|
38
|
self.isConfig = False
|
|
39
|
self.figure = None
|
|
39
|
self.figure = None
|
|
40
|
self.figure2 = None #JM modificatiom
|
|
|
|
|
41
|
self.axes = []
|
|
40
|
self.axes = []
|
|
42
|
self.localtime = kwargs.pop('localtime', True)
|
|
41
|
self.localtime = kwargs.pop('localtime', True)
|
|
43
|
self.show = kwargs.get('show', True)
|
|
42
|
self.show = kwargs.get('show', True)
|
|
@@
-60,6
+59,15
class PlotData(Operation, Process):
|
|
60
|
self.times = []
|
|
59
|
self.times = []
|
|
61
|
#self.interactive = self.kwargs['parent']
|
|
60
|
#self.interactive = self.kwargs['parent']
|
|
62
|
|
|
61
|
|
|
|
|
|
62
|
'''
|
|
|
|
|
63
|
this new parameter is created to plot data from varius channels at different figures
|
|
|
|
|
64
|
1. crear una lista de figuras donde se puedan plotear las figuras,
|
|
|
|
|
65
|
2. dar las opciones de configuracion a cada figura, estas opciones son iguales para ambas figuras
|
|
|
|
|
66
|
3. probar?
|
|
|
|
|
67
|
'''
|
|
|
|
|
68
|
self.ind_plt_ch = kwargs.get('ind_plt_ch', False)
|
|
|
|
|
69
|
self.figurelist = None
|
|
|
|
|
70
|
|
|
63
|
|
|
71
|
|
|
64
|
def fill_gaps(self, x_buffer, y_buffer, z_buffer):
|
|
72
|
def fill_gaps(self, x_buffer, y_buffer, z_buffer):
|
|
65
|
|
|
73
|
|
|
@@
-94,37
+102,42
class PlotData(Operation, Process):
|
|
94
|
def __plot(self):
|
|
102
|
def __plot(self):
|
|
95
|
|
|
103
|
|
|
96
|
print 'plotting...{}'.format(self.CODE)
|
|
104
|
print 'plotting...{}'.format(self.CODE)
|
|
97
|
|
|
105
|
if self.ind_plt_ch is False : #standard
|
|
98
|
if self.show:
|
|
106
|
if self.show:
|
|
99
|
self.figure.show()
|
|
107
|
self.figure.show()
|
|
100
|
self.figure2.show()
|
|
108
|
self.plot()
|
|
101
|
|
|
109
|
plt.tight_layout()
|
|
102
|
self.plot()
|
|
110
|
self.figure.canvas.manager.set_window_title('{} {} - {}'.format(self.title, self.CODE.upper(),
|
|
103
|
plt.tight_layout()
|
|
|
|
|
104
|
|
|
|
|
|
105
|
# self.figure.canvas.manager.set_window_title('{} {} - Date:{}'.format(self.title, self.CODE.upper(),
|
|
|
|
|
106
|
# datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')))
|
|
|
|
|
107
|
# self.figure2.canvas.manager.set_window_title('{} {} - Date:{}'.format(self.title, self.CODE.upper(),
|
|
|
|
|
108
|
# datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')))
|
|
|
|
|
109
|
# =======
|
|
|
|
|
110
|
self.figure.canvas.manager.set_window_title('{} {} - {}'.format(self.title, self.CODE.upper(),
|
|
|
|
|
111
|
datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d')))
|
|
111
|
datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d')))
|
|
112
|
self.figure2.canvas.manager.set_window_title('{} {} - {}'.format(self.title, self.CODE.upper(),
|
|
112
|
else :
|
|
113
|
datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d')))
|
|
113
|
for n, eachfigure in enumerate(self.figurelist):
|
|
114
|
|
|
114
|
if self.show:
|
|
|
|
|
115
|
eachfigure.show()
|
|
|
|
|
116
|
self.plot() # ok? como elijo que figura?
|
|
|
|
|
117
|
plt.tight_layout()
|
|
|
|
|
118
|
eachfigure.canvas.manager.set_window_title('{} {} - {}'.format(self.title[n], self.CODE.upper(),
|
|
|
|
|
119
|
datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d')))
|
|
115
|
|
|
120
|
|
|
116
|
if self.save:
|
|
121
|
if self.save:
|
|
117
|
figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE,
|
|
122
|
if self.ind_plt_ch is False : #standard
|
|
118
|
datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
|
|
123
|
figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE,
|
|
119
|
print 'Saving figure: {}'.format(figname)
|
|
124
|
datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
|
|
120
|
self.figure.savefig(figname)
|
|
125
|
print 'Saving figure: {}'.format(figname)
|
|
121
|
figname2 = os.path.join(self.save, '{}_{}2.png'.format(self.CODE,
|
|
126
|
self.figure.savefig(figname)
|
|
122
|
datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
|
|
127
|
else :
|
|
123
|
print 'Saving figure: {}'.format(figname2)
|
|
128
|
for n, eachfigure in enumerate(self.figurelist):
|
|
124
|
self.figure2.savefig(figname2)
|
|
129
|
#add specific name for each channel in channelList
|
|
125
|
|
|
130
|
figname = os.path.join(self.save, '{}_{}_{}.png'.format(self.titles[n],self.CODE,
|
|
126
|
self.figure.canvas.draw()
|
|
131
|
datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
|
|
127
|
self.figure2.canvas.draw()
|
|
132
|
|
|
|
|
|
133
|
print 'Saving figure: {}'.format(figname)
|
|
|
|
|
134
|
eachfigure.savefig(figname)
|
|
|
|
|
135
|
|
|
|
|
|
136
|
if self.ind_plt_ch is False :
|
|
|
|
|
137
|
self.figure.canvas.draw()
|
|
|
|
|
138
|
else :
|
|
|
|
|
139
|
for eachfigure in self.figurelist:
|
|
|
|
|
140
|
eachfigure.canvas.draw()
|
|
128
|
|
|
141
|
|
|
129
|
def plot(self):
|
|
142
|
def plot(self):
|
|
130
|
|
|
143
|
|
|
@@
-246,7
+259,6
class PlotSpectraData(PlotData):
|
|
246
|
z = self.data[self.CODE]
|
|
259
|
z = self.data[self.CODE]
|
|
247
|
|
|
260
|
|
|
248
|
for n, ax in enumerate(self.axes):
|
|
261
|
for n, ax in enumerate(self.axes):
|
|
249
|
|
|
|
|
|
250
|
if ax.firsttime:
|
|
262
|
if ax.firsttime:
|
|
251
|
self.xmax = self.xmax if self.xmax else np.nanmax(x)
|
|
263
|
self.xmax = self.xmax if self.xmax else np.nanmax(x)
|
|
252
|
self.xmin = self.xmin if self.xmin else -self.xmax
|
|
264
|
self.xmin = self.xmin if self.xmin else -self.xmax
|
|
@@
-484,95
+496,163
class PlotRTIData(PlotData):
|
|
484
|
self.ylabel = 'Range [Km]'
|
|
496
|
self.ylabel = 'Range [Km]'
|
|
485
|
self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList]
|
|
497
|
self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList]
|
|
486
|
|
|
498
|
|
|
487
|
if self.figure is None:
|
|
499
|
'''
|
|
488
|
self.figure = plt.figure(figsize=(self.width, self.height),
|
|
500
|
Logica:
|
|
489
|
edgecolor='k',
|
|
501
|
1) Si la variable ind_plt_ch es True, va a crear mas de 1 figura
|
|
490
|
facecolor='w')
|
|
502
|
2) guardamos "Figures" en una lista y "axes" en otra, quizas se deberia guardar el
|
|
491
|
else:
|
|
503
|
axis dentro de "Figures" como un diccionario.
|
|
492
|
self.figure.clf()
|
|
504
|
'''
|
|
493
|
self.axes = []
|
|
505
|
if self.ind_plt_ch is False: #standard mode
|
|
|
|
|
506
|
|
|
|
|
|
507
|
if self.figure is None: #solo para la priemra vez
|
|
|
|
|
508
|
self.figure = plt.figure(figsize=(self.width, self.height),
|
|
|
|
|
509
|
edgecolor='k',
|
|
|
|
|
510
|
facecolor='w')
|
|
|
|
|
511
|
else:
|
|
|
|
|
512
|
self.figure.clf()
|
|
|
|
|
513
|
self.axes = []
|
|
494
|
|
|
514
|
|
|
495
|
if self.figure2 is None:
|
|
|
|
|
496
|
self.figure2 = plt.figure(figsize=(self.width, self.height),
|
|
|
|
|
497
|
edgecolor='k',
|
|
|
|
|
498
|
facecolor='w')
|
|
|
|
|
499
|
else:
|
|
|
|
|
500
|
self.figure2.clf()
|
|
|
|
|
501
|
self.axes = []
|
|
|
|
|
502
|
|
|
515
|
|
|
503
|
ax = self.figure.add_subplot(1,1,1)
|
|
516
|
for n in range(self.nrows):
|
|
504
|
#ax = self.figure( n+1)
|
|
517
|
ax = self.figure.add_subplot(self.nrows, self.ncols, n+1)
|
|
505
|
ax.firsttime = True
|
|
518
|
#ax = self.figure(n+1)
|
|
506
|
self.axes.append(ax)
|
|
519
|
ax.firsttime = True
|
|
|
|
|
520
|
self.axes.append(ax)
|
|
507
|
|
|
521
|
|
|
508
|
ax = self.figure2.add_subplot(1,1,1)
|
|
522
|
else : #append one figure foreach channel in channelList
|
|
509
|
#ax = self.figure( n+1)
|
|
523
|
if self.figurelist == None:
|
|
510
|
ax.firsttime = True
|
|
524
|
self.figurelist = []
|
|
511
|
self.axes.append(ax)
|
|
525
|
for n in range(self.nrows):
|
|
512
|
# for n in range(self.nrows):
|
|
526
|
self.figure = plt.figure(figsize=(self.width, self.height),
|
|
513
|
# ax = self.figure.add_subplot(self.nrows, self.ncols, n+1)
|
|
527
|
edgecolor='k',
|
|
514
|
# #ax = self.figure( n+1)
|
|
528
|
facecolor='w')
|
|
515
|
# ax.firsttime = True
|
|
529
|
#add always one subplot
|
|
516
|
# self.axes.append(ax)
|
|
530
|
self.figurelist.append(self.figure)
|
|
|
|
|
531
|
|
|
|
|
|
532
|
else : # cada dia nuevo limpia el axes, pero mantiene el figure
|
|
|
|
|
533
|
for eachfigure in self.figurelist:
|
|
|
|
|
534
|
eachfigure.clf() # eliminaria todas las figuras de la lista?
|
|
|
|
|
535
|
self.axes = []
|
|
|
|
|
536
|
|
|
|
|
|
537
|
for eachfigure in self.figurelist:
|
|
|
|
|
538
|
ax = eachfigure.add_subplot(1,1,1) #solo 1 axis por figura
|
|
|
|
|
539
|
#ax = self.figure(n+1)
|
|
|
|
|
540
|
ax.firsttime = True
|
|
|
|
|
541
|
#Cada figura tiene un distinto puntero
|
|
|
|
|
542
|
self.axes.append(ax)
|
|
|
|
|
543
|
#plt.close(eachfigure)
|
|
517
|
|
|
544
|
|
|
518
|
|
|
545
|
|
|
519
|
def plot(self):
|
|
546
|
def plot(self):
|
|
520
|
|
|
547
|
|
|
521
|
self.x = np.array(self.times)
|
|
548
|
if self.ind_plt_ch is False: #standard mode
|
|
522
|
self.y = self.dataOut.getHeiRange()
|
|
549
|
self.x = np.array(self.times)
|
|
523
|
self.z = []
|
|
550
|
self.y = self.dataOut.getHeiRange()
|
|
524
|
|
|
551
|
self.z = []
|
|
525
|
for ch in range(self.nrows):
|
|
552
|
|
|
526
|
self.z.append([self.data[self.CODE][t][ch] for t in self.times])
|
|
553
|
for ch in range(self.nrows):
|
|
527
|
|
|
554
|
self.z.append([self.data[self.CODE][t][ch] for t in self.times])
|
|
528
|
self.z = np.array(self.z)
|
|
555
|
|
|
529
|
for n, ax in enumerate(self.axes):
|
|
556
|
self.z = np.array(self.z)
|
|
530
|
x, y, z = self.fill_gaps(*self.decimate())
|
|
557
|
for n, ax in enumerate(self.axes):
|
|
531
|
xmin = self.min_time
|
|
558
|
x, y, z = self.fill_gaps(*self.decimate())
|
|
532
|
xmax = xmin+self.xrange*60*60
|
|
559
|
xmin = self.min_time
|
|
533
|
self.zmin = self.zmin if self.zmin else np.min(self.z)
|
|
560
|
xmax = xmin+self.xrange*60*60
|
|
534
|
self.zmax = self.zmax if self.zmax else np.max(self.z)
|
|
561
|
self.zmin = self.zmin if self.zmin else np.min(self.z)
|
|
535
|
if ax.firsttime:
|
|
562
|
self.zmax = self.zmax if self.zmax else np.max(self.z)
|
|
536
|
self.ymin = self.ymin if self.ymin else np.nanmin(self.y)
|
|
563
|
if ax.firsttime:
|
|
537
|
self.ymax = self.ymax if self.ymax else np.nanmax(self.y)
|
|
564
|
self.ymin = self.ymin if self.ymin else np.nanmin(self.y)
|
|
538
|
plot = ax.pcolormesh(x, y, z[n].T,
|
|
565
|
self.ymax = self.ymax if self.ymax else np.nanmax(self.y)
|
|
539
|
vmin=self.zmin,
|
|
566
|
plot = ax.pcolormesh(x, y, z[n].T,
|
|
540
|
vmax=self.zmax,
|
|
567
|
vmin=self.zmin,
|
|
541
|
cmap=plt.get_cmap(self.colormap)
|
|
568
|
vmax=self.zmax,
|
|
542
|
)
|
|
569
|
cmap=plt.get_cmap(self.colormap)
|
|
543
|
divider = make_axes_locatable(ax)
|
|
570
|
)
|
|
544
|
cax = divider.new_horizontal(size='2%', pad=0.05)
|
|
571
|
divider = make_axes_locatable(ax)
|
|
545
|
#self.figure.add_axes(cax)
|
|
572
|
cax = divider.new_horizontal(size='2%', pad=0.05)
|
|
546
|
#self.figure2.add_axes(cax)
|
|
573
|
self.figure.add_axes(cax)
|
|
547
|
plt.colorbar(plot, cax)
|
|
574
|
plt.colorbar(plot, cax)
|
|
548
|
ax.set_ylim(self.ymin, self.ymax)
|
|
575
|
ax.set_ylim(self.ymin, self.ymax)
|
|
549
|
|
|
576
|
ax.xaxis.set_major_formatter(FuncFormatter(func))
|
|
550
|
ax.xaxis.set_major_formatter(FuncFormatter(func))
|
|
577
|
ax.xaxis.set_major_locator(LinearLocator(6))
|
|
551
|
ax.xaxis.set_major_locator(LinearLocator(6))
|
|
578
|
ax.set_ylabel(self.ylabel)
|
|
552
|
|
|
579
|
# if self.xmin is None:
|
|
553
|
ax.set_ylabel(self.ylabel)
|
|
580
|
# xmin = self.min_time
|
|
554
|
|
|
581
|
# else:
|
|
555
|
# if self.xmin is None:
|
|
582
|
# xmin = (datetime.datetime.combine(self.dataOut.datatime.date(),
|
|
556
|
# xmin = self.min_time
|
|
583
|
# datetime.time(self.xmin, 0, 0))-d1970).total_seconds()
|
|
557
|
# else:
|
|
584
|
ax.set_xlim(xmin, xmax)
|
|
558
|
# xmin = (datetime.datetime.combine(self.dataOut.datatime.date(),
|
|
585
|
ax.firsttime = False
|
|
559
|
# datetime.time(self.xmin, 0, 0))-d1970).total_seconds()
|
|
586
|
else:
|
|
560
|
|
|
587
|
ax.collections.remove(ax.collections[0])
|
|
561
|
ax.set_xlim(xmin, xmax)
|
|
588
|
ax.set_xlim(xmin, xmax)
|
|
562
|
ax.firsttime = False
|
|
589
|
plot = ax.pcolormesh(x, y, z[n].T,
|
|
563
|
else:
|
|
590
|
vmin=self.zmin,
|
|
564
|
ax.collections.remove(ax.collections[0])
|
|
591
|
vmax=self.zmax,
|
|
565
|
ax.set_xlim(xmin, xmax)
|
|
592
|
cmap=plt.get_cmap(self.colormap)
|
|
566
|
plot = ax.pcolormesh(x, y, z[n].T,
|
|
593
|
)
|
|
567
|
vmin=self.zmin,
|
|
594
|
ax.set_title('{} {}'.format(self.titles[n],
|
|
568
|
vmax=self.zmax,
|
|
595
|
datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')),
|
|
569
|
cmap=plt.get_cmap(self.colormap)
|
|
596
|
size=8)
|
|
570
|
)
|
|
597
|
|
|
571
|
ax.set_title('{} {}'.format(self.titles[n],
|
|
598
|
self.saveTime = self.min_time
|
|
572
|
datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')),
|
|
599
|
else :
|
|
573
|
size=8)
|
|
600
|
self.x = np.array(self.times)
|
|
574
|
|
|
601
|
self.y = self.dataOut.getHeiRange()
|
|
575
|
self.saveTime = self.min_time
|
|
602
|
self.z = []
|
|
|
|
|
603
|
|
|
|
|
|
604
|
for ch in range(self.nrows):
|
|
|
|
|
605
|
self.z.append([self.data[self.CODE][t][ch] for t in self.times])
|
|
|
|
|
606
|
|
|
|
|
|
607
|
self.z = np.array(self.z)
|
|
|
|
|
608
|
for n, eachfigure in enumerate(self.figurelist): #estaba ax in axes
|
|
|
|
|
609
|
|
|
|
|
|
610
|
x, y, z = self.fill_gaps(*self.decimate())
|
|
|
|
|
611
|
xmin = self.min_time
|
|
|
|
|
612
|
xmax = xmin+self.xrange*60*60
|
|
|
|
|
613
|
self.zmin = self.zmin if self.zmin else np.min(self.z)
|
|
|
|
|
614
|
self.zmax = self.zmax if self.zmax else np.max(self.z)
|
|
|
|
|
615
|
if self.axes[n].firsttime:
|
|
|
|
|
616
|
self.ymin = self.ymin if self.ymin else np.nanmin(self.y)
|
|
|
|
|
617
|
self.ymax = self.ymax if self.ymax else np.nanmax(self.y)
|
|
|
|
|
618
|
plot = self.axes[n].pcolormesh(x, y, z[n].T,
|
|
|
|
|
619
|
vmin=self.zmin,
|
|
|
|
|
620
|
vmax=self.zmax,
|
|
|
|
|
621
|
cmap=plt.get_cmap(self.colormap)
|
|
|
|
|
622
|
)
|
|
|
|
|
623
|
divider = make_axes_locatable(self.axes[n])
|
|
|
|
|
624
|
cax = divider.new_horizontal(size='2%', pad=0.05)
|
|
|
|
|
625
|
eachfigure.add_axes(cax)
|
|
|
|
|
626
|
#self.figure2.add_axes(cax)
|
|
|
|
|
627
|
plt.colorbar(plot, cax)
|
|
|
|
|
628
|
self.axes[n].set_ylim(self.ymin, self.ymax)
|
|
|
|
|
629
|
|
|
|
|
|
630
|
self.axes[n].xaxis.set_major_formatter(FuncFormatter(func))
|
|
|
|
|
631
|
self.axes[n].xaxis.set_major_locator(LinearLocator(6))
|
|
|
|
|
632
|
|
|
|
|
|
633
|
self.axes[n].set_ylabel(self.ylabel)
|
|
|
|
|
634
|
|
|
|
|
|
635
|
# if self.xmin is None:
|
|
|
|
|
636
|
# xmin = self.min_time
|
|
|
|
|
637
|
# else:
|
|
|
|
|
638
|
# xmin = (datetime.datetime.combine(self.dataOut.datatime.date(),
|
|
|
|
|
639
|
# datetime.time(self.xmin, 0, 0))-d1970).total_seconds()
|
|
|
|
|
640
|
|
|
|
|
|
641
|
self.axes[n].set_xlim(xmin, xmax)
|
|
|
|
|
642
|
self.axes[n].firsttime = False
|
|
|
|
|
643
|
else:
|
|
|
|
|
644
|
self.axes[n].collections.remove(self.axes[n].collections[0])
|
|
|
|
|
645
|
self.axes[n].set_xlim(xmin, xmax)
|
|
|
|
|
646
|
plot = self.axes[n].pcolormesh(x, y, z[n].T,
|
|
|
|
|
647
|
vmin=self.zmin,
|
|
|
|
|
648
|
vmax=self.zmax,
|
|
|
|
|
649
|
cmap=plt.get_cmap(self.colormap)
|
|
|
|
|
650
|
)
|
|
|
|
|
651
|
self.axes[n].set_title('{} {}'.format(self.titles[n],
|
|
|
|
|
652
|
datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S')),
|
|
|
|
|
653
|
size=8)
|
|
|
|
|
654
|
|
|
|
|
|
655
|
self.saveTime = self.min_time
|
|
576
|
|
|
656
|
|
|
577
|
|
|
657
|
|
|
578
|
class PlotCOHData(PlotRTIData):
|
|
658
|
class PlotCOHData(PlotRTIData):
|