##// END OF EJS Templates
Issue Listo graficas separadas 90%
J Gomez -
r964:8705e001f101
parent child
Show More
@@ -37,7 +37,6 class PlotData(Operation, Process):
37 37 self.dataOut = None
38 38 self.isConfig = False
39 39 self.figure = None
40 self.figure2 = None #JM modificatiom
41 40 self.axes = []
42 41 self.localtime = kwargs.pop('localtime', True)
43 42 self.show = kwargs.get('show', True)
@@ -60,6 +59,15 class PlotData(Operation, Process):
60 59 self.times = []
61 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 72 def fill_gaps(self, x_buffer, y_buffer, z_buffer):
65 73
@@ -94,37 +102,42 class PlotData(Operation, Process):
94 102 def __plot(self):
95 103
96 104 print 'plotting...{}'.format(self.CODE)
97
105 if self.ind_plt_ch is False : #standard
98 106 if self.show:
99 107 self.figure.show()
100 self.figure2.show()
101
102 108 self.plot()
103 109 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 110 self.figure.canvas.manager.set_window_title('{} {} - {}'.format(self.title, self.CODE.upper(),
111 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 for n, eachfigure in enumerate(self.figurelist):
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(),
113 119 datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d')))
114 120
115
116 121 if self.save:
122 if self.ind_plt_ch is False : #standard
117 123 figname = os.path.join(self.save, '{}_{}.png'.format(self.CODE,
118 124 datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
119 125 print 'Saving figure: {}'.format(figname)
120 126 self.figure.savefig(figname)
121 figname2 = os.path.join(self.save, '{}_{}2.png'.format(self.CODE,
127 else :
128 for n, eachfigure in enumerate(self.figurelist):
129 #add specific name for each channel in channelList
130 figname = os.path.join(self.save, '{}_{}_{}.png'.format(self.titles[n],self.CODE,
122 131 datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S')))
123 print 'Saving figure: {}'.format(figname2)
124 self.figure2.savefig(figname2)
125 132
133 print 'Saving figure: {}'.format(figname)
134 eachfigure.savefig(figname)
135
136 if self.ind_plt_ch is False :
126 137 self.figure.canvas.draw()
127 self.figure2.canvas.draw()
138 else :
139 for eachfigure in self.figurelist:
140 eachfigure.canvas.draw()
128 141
129 142 def plot(self):
130 143
@@ -246,7 +259,6 class PlotSpectraData(PlotData):
246 259 z = self.data[self.CODE]
247 260
248 261 for n, ax in enumerate(self.axes):
249
250 262 if ax.firsttime:
251 263 self.xmax = self.xmax if self.xmax else np.nanmax(x)
252 264 self.xmin = self.xmin if self.xmin else -self.xmax
@@ -484,7 +496,15 class PlotRTIData(PlotData):
484 496 self.ylabel = 'Range [Km]'
485 497 self.titles = ['Channel {}'.format(x) for x in self.dataOut.channelList]
486 498
487 if self.figure is None:
499 '''
500 Logica:
501 1) Si la variable ind_plt_ch es True, va a crear mas de 1 figura
502 2) guardamos "Figures" en una lista y "axes" en otra, quizas se deberia guardar el
503 axis dentro de "Figures" como un diccionario.
504 '''
505 if self.ind_plt_ch is False: #standard mode
506
507 if self.figure is None: #solo para la priemra vez
488 508 self.figure = plt.figure(figsize=(self.width, self.height),
489 509 edgecolor='k',
490 510 facecolor='w')
@@ -492,32 +512,40 class PlotRTIData(PlotData):
492 512 self.figure.clf()
493 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):
517 ax = self.figure.add_subplot(self.nrows, self.ncols, n+1)
504 518 #ax = self.figure( n+1)
505 519 ax.firsttime = True
506 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
523 if self.figurelist == None:
524 self.figurelist = []
525 for n in range(self.nrows):
526 self.figure = plt.figure(figsize=(self.width, self.height),
527 edgecolor='k',
528 facecolor='w')
529 #add always one subplot
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
509 539 #ax = self.figure( n+1)
510 540 ax.firsttime = True
541 #Cada figura tiene un distinto puntero
511 542 self.axes.append(ax)
512 # for n in range(self.nrows):
513 # ax = self.figure.add_subplot(self.nrows, self.ncols, n+1)
514 # #ax = self.figure( n+1)
515 # ax.firsttime = True
516 # self.axes.append(ax)
543 #plt.close(eachfigure)
517 544
518 545
519 546 def plot(self):
520 547
548 if self.ind_plt_ch is False: #standard mode
521 549 self.x = np.array(self.times)
522 550 self.y = self.dataOut.getHeiRange()
523 551 self.z = []
@@ -542,22 +570,17 class PlotRTIData(PlotData):
542 570 )
543 571 divider = make_axes_locatable(ax)
544 572 cax = divider.new_horizontal(size='2%', pad=0.05)
545 #self.figure.add_axes(cax)
546 #self.figure2.add_axes(cax)
573 self.figure.add_axes(cax)
547 574 plt.colorbar(plot, cax)
548 575 ax.set_ylim(self.ymin, self.ymax)
549
550 576 ax.xaxis.set_major_formatter(FuncFormatter(func))
551 577 ax.xaxis.set_major_locator(LinearLocator(6))
552
553 578 ax.set_ylabel(self.ylabel)
554
555 579 # if self.xmin is None:
556 580 # xmin = self.min_time
557 581 # else:
558 582 # xmin = (datetime.datetime.combine(self.dataOut.datatime.date(),
559 583 # datetime.time(self.xmin, 0, 0))-d1970).total_seconds()
560
561 584 ax.set_xlim(xmin, xmax)
562 585 ax.firsttime = False
563 586 else:
@@ -573,6 +596,63 class PlotRTIData(PlotData):
573 596 size=8)
574 597
575 598 self.saveTime = self.min_time
599 else :
600 self.x = np.array(self.times)
601 self.y = self.dataOut.getHeiRange()
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 658 class PlotCOHData(PlotRTIData):
@@ -71,6 +71,7 if __name__ == '__main__':
71 71 op5.addParameter(name='zmin', value='-120', format='float')
72 72 op5.addParameter(name='zmax', value='120', format='float')
73 73 op5.addParameter(name='colormap', value='RdBu_r', format='str')
74 op5.addParameter(name='ind_plt_ch',value='1',format = 'bool')
74 75 """
75 76 op4 = proc1.addOperation(name='PlotSNRData1', optype='other')
76 77 op4.addParameter(name='wintitle', value='HF System SNR1', format='str')
@@ -1,1 +1,1
1 <Project description="HF_EXAMPLE" id="191" name="test01"><ReadUnit datatype="SpectraReader" id="1911" inputId="0" name="SpectraReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="SpectraReader" /><Parameter format="str" id="191112" name="path" value="/media/ci-81/Huancayo/DATA/hfradar_2016/pdata/sp1_f1" /><Parameter format="date" id="191113" name="startDate" value="2016/04/27" /><Parameter format="date" id="191114" name="endDate" value="2016/04/27" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="cursor" value="0" /><Parameter format="int" id="191119" name="skip" value="0" /><Parameter format="int" id="191120" name="delay" value="10" /><Parameter format="int" id="191121" name="walk" value="1" /><Parameter format="int" id="191122" name="online" value="0" /></Operation></ReadUnit><ProcUnit datatype="ParametersProc" id="1913" inputId="1911" name="ParametersProc"><Operation id="19131" name="run" priority="1" type="self" /><Operation id="19132" name="SpectralMoments" priority="2" type="other" /><Operation id="19133" name="PublishData" priority="3" type="other"><Parameter format="int" id="191331" name="zeromq" value="1" /></Operation></ProcUnit><ProcUnit datatype="Spectra" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="removeInterference" priority="2" type="self" /></ProcUnit></Project> No newline at end of file
1 <Project description="HF_EXAMPLE" id="191" name="test01"><ReadUnit datatype="SpectraReader" id="1911" inputId="0" name="SpectraReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="SpectraReader" /><Parameter format="str" id="191112" name="path" value="/media/ci-81/Huancayo/DATA/hfradar_2016/pdata/sp1_f1" /><Parameter format="date" id="191113" name="startDate" value="2016/04/23" /><Parameter format="date" id="191114" name="endDate" value="2016/04/23" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="cursor" value="9" /><Parameter format="int" id="191119" name="skip" value="16" /><Parameter format="int" id="191120" name="delay" value="10" /><Parameter format="int" id="191121" name="walk" value="1" /><Parameter format="int" id="191122" name="online" value="0" /></Operation></ReadUnit><ProcUnit datatype="ParametersProc" id="1913" inputId="1911" name="ParametersProc"><Operation id="19131" name="run" priority="1" type="self" /><Operation id="19132" name="SpectralMoments" priority="2" type="other" /><Operation id="19133" name="PublishData" priority="3" type="other"><Parameter format="int" id="191331" name="zeromq" value="1" /></Operation></ProcUnit><ProcUnit datatype="Spectra" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="removeInterference" priority="2" type="self" /></ProcUnit></Project> No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now