##// END OF EJS Templates
Optimizacion de graficos con buffer, el buffer se crea en la clase Axes del modulo figure.py, se agrega el metodo pcolorbuffer....
Daniel Valdez -
r318:2312df9eac7d
parent child
Show More
@@ -183,7 +183,7 class Axes:
183 fig = None
183 fig = None
184 ax = None
184 ax = None
185 plot = None
185 plot = None
186
186 __missing = 1E30
187 __firsttime = None
187 __firsttime = None
188
188
189 __showprofile = False
189 __showprofile = False
@@ -195,6 +195,9 class Axes:
195 zmin = None
195 zmin = None
196 zmax = None
196 zmax = None
197
197
198 x_buffer = None
199 z_buffer = None
200
198 def __init__(self, *args):
201 def __init__(self, *args):
199
202
200 """
203 """
@@ -212,6 +215,9 class Axes:
212 self.__firsttime = True
215 self.__firsttime = True
213 self.idlineList = []
216 self.idlineList = []
214
217
218 self.x_buffer = numpy.array([])
219 self.z_buffer = numpy.array([])
220
215 def setText(self, text):
221 def setText(self, text):
216
222
217 self.__driver.setAxesText(self.ax, text)
223 self.__driver.setAxesText(self.ax, text)
@@ -411,4 +417,75 class Axes:
411 ylabel=ylabel,
417 ylabel=ylabel,
412 title=title)
418 title=title)
413
419
420 def pcolorbuffer(self, x, y, z,
421 xmin=None, xmax=None,
422 ymin=None, ymax=None,
423 zmin=None, zmax=None,
424 xlabel='', ylabel='',
425 title='', rti = False, colormap='jet',
426 **kwargs):
427
428
429 if self.__firsttime:
430 self.z_buffer = z
431 self.x_buffer = numpy.hstack((self.x_buffer, x))
432
433 if xmin == None: xmin = numpy.nanmin(x)
434 if xmax == None: xmax = numpy.nanmax(x)
435 if ymin == None: ymin = numpy.nanmin(y)
436 if ymax == None: ymax = numpy.nanmax(y)
437 if zmin == None: zmin = numpy.nanmin(z)
438 if zmax == None: zmax = numpy.nanmax(z)
439
440
441 self.plot = self.__driver.createPcolor(self.ax, self.x_buffer, y, z,
442 xmin, xmax,
443 ymin, ymax,
444 zmin, zmax,
445 xlabel=xlabel,
446 ylabel=ylabel,
447 title=title,
448 colormap=colormap,
449 **kwargs)
450
451 if self.xmin == None: self.xmin = xmin
452 if self.xmax == None: self.xmax = xmax
453 if self.ymin == None: self.ymin = ymin
454 if self.ymax == None: self.ymax = ymax
455 if self.zmin == None: self.zmin = zmin
456 if self.zmax == None: self.zmax = zmax
457
458 self.__firsttime = False
459 return
460
461 if rti:
462 if x[0]>self.x_buffer[-1]:
463 gap = z.copy()
464 gap[:] = self.__missing
465 self.z_buffer = numpy.hstack((self.z_buffer, gap))
466 self.z_buffer = numpy.ma.masked_inside(self.z_buffer,0.99*self.__missing,1.01*self.__missing)
467 self.x_buffer = numpy.hstack((self.x_buffer, x))
468
469 else:
470 self.x_buffer = numpy.hstack((self.x_buffer, x[-1]))
471
472 self.z_buffer = numpy.hstack((self.z_buffer, z))
473
474 newydim = len(y)
475
476 # self.z_buffer = numpy.ma.masked_inside(self.z_buffer,0.99*self.__missing,1.01*self.__missing)
477
478 z_buffer = self.z_buffer.reshape(-1,newydim)
479
480 self.__driver.addpcolorbuffer(self.ax, self.x_buffer, y, z_buffer, self.zmin, self.zmax,
481 xlabel=xlabel,
482 ylabel=ylabel,
483 title=title,
484 colormap=colormap)
485 return
486
487 self.__driver.pcolor(self.plot, z,
488 xlabel=xlabel,
489 ylabel=ylabel,
490 title=title)
414 No newline at end of file
491
@@ -223,7 +223,13 def addpcolor(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap=
223
223
224 printLabels(ax, xlabel, ylabel, title)
224 printLabels(ax, xlabel, ylabel, title)
225
225
226 # ax.collections.remove(ax.collections[0])
226 ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
227
228 def addpcolorbuffer(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'):
229
230 printLabels(ax, xlabel, ylabel, title)
231
232 ax.collections.remove(ax.collections[0])
227
233
228 ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
234 ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap))
229
235
@@ -312,7 +312,7 class RTIPlot(Figure):
312 title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
312 title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
313 axes = self.axesList[i*self.__nsubplots]
313 axes = self.axesList[i*self.__nsubplots]
314 zdB = avgdB[i].reshape((1,-1))
314 zdB = avgdB[i].reshape((1,-1))
315 axes.pcolor(x, y, zdB,
315 axes.pcolorbuffer(x, y, zdB,
316 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
316 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
317 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
317 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
318 ticksize=9, cblabel='', cbsize="1%")
318 ticksize=9, cblabel='', cbsize="1%")
@@ -816,7 +816,7 class CoherenceMap(Figure):
816
816
817 title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
817 title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
818 axes = self.axesList[i*self.__nsubplots*2]
818 axes = self.axesList[i*self.__nsubplots*2]
819 axes.pcolor(x, y, z,
819 axes.pcolorbuffer(x, y, z,
820 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1,
820 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1,
821 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
821 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
822 ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%")
822 ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%")
@@ -838,7 +838,7 class CoherenceMap(Figure):
838
838
839 title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
839 title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
840 axes = self.axesList[i*self.__nsubplots*2 + counter]
840 axes = self.axesList[i*self.__nsubplots*2 + counter]
841 axes.pcolor(x, y, z,
841 axes.pcolorbuffer(x, y, z,
842 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180,
842 xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180,
843 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
843 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
844 ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%")
844 ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%")
General Comments 0
You need to be logged in to leave comments. Login now