diff --git a/schainpy/model/graphics/figure.py b/schainpy/model/graphics/figure.py index 65c44cf..f56322f 100644 --- a/schainpy/model/graphics/figure.py +++ b/schainpy/model/graphics/figure.py @@ -183,7 +183,7 @@ class Axes: fig = None ax = None plot = None - + __missing = 1E30 __firsttime = None __showprofile = False @@ -195,6 +195,9 @@ class Axes: zmin = None zmax = None + x_buffer = None + z_buffer = None + def __init__(self, *args): """ @@ -212,6 +215,9 @@ class Axes: self.__firsttime = True self.idlineList = [] + self.x_buffer = numpy.array([]) + self.z_buffer = numpy.array([]) + def setText(self, text): self.__driver.setAxesText(self.ax, text) @@ -410,5 +416,76 @@ class Axes: xlabel=xlabel, ylabel=ylabel, title=title) + + def pcolorbuffer(self, x, y, z, + xmin=None, xmax=None, + ymin=None, ymax=None, + zmin=None, zmax=None, + xlabel='', ylabel='', + title='', rti = False, colormap='jet', + **kwargs): + + if self.__firsttime: + self.z_buffer = z + self.x_buffer = numpy.hstack((self.x_buffer, x)) + + if xmin == None: xmin = numpy.nanmin(x) + if xmax == None: xmax = numpy.nanmax(x) + if ymin == None: ymin = numpy.nanmin(y) + if ymax == None: ymax = numpy.nanmax(y) + if zmin == None: zmin = numpy.nanmin(z) + if zmax == None: zmax = numpy.nanmax(z) + + + self.plot = self.__driver.createPcolor(self.ax, self.x_buffer, y, z, + xmin, xmax, + ymin, ymax, + zmin, zmax, + xlabel=xlabel, + ylabel=ylabel, + title=title, + colormap=colormap, + **kwargs) + + if self.xmin == None: self.xmin = xmin + if self.xmax == None: self.xmax = xmax + if self.ymin == None: self.ymin = ymin + if self.ymax == None: self.ymax = ymax + if self.zmin == None: self.zmin = zmin + if self.zmax == None: self.zmax = zmax + + self.__firsttime = False + return + + if rti: + if x[0]>self.x_buffer[-1]: + gap = z.copy() + gap[:] = self.__missing + self.z_buffer = numpy.hstack((self.z_buffer, gap)) + self.z_buffer = numpy.ma.masked_inside(self.z_buffer,0.99*self.__missing,1.01*self.__missing) + self.x_buffer = numpy.hstack((self.x_buffer, x)) + + else: + self.x_buffer = numpy.hstack((self.x_buffer, x[-1])) + + self.z_buffer = numpy.hstack((self.z_buffer, z)) + + newydim = len(y) + +# self.z_buffer = numpy.ma.masked_inside(self.z_buffer,0.99*self.__missing,1.01*self.__missing) + + z_buffer = self.z_buffer.reshape(-1,newydim) + + self.__driver.addpcolorbuffer(self.ax, self.x_buffer, y, z_buffer, self.zmin, self.zmax, + xlabel=xlabel, + ylabel=ylabel, + title=title, + colormap=colormap) + return + + self.__driver.pcolor(self.plot, z, + xlabel=xlabel, + ylabel=ylabel, + title=title) \ No newline at end of file diff --git a/schainpy/model/graphics/mpldriver.py b/schainpy/model/graphics/mpldriver.py index 536dadb..4a57143 100644 --- a/schainpy/model/graphics/mpldriver.py +++ b/schainpy/model/graphics/mpldriver.py @@ -223,7 +223,13 @@ def addpcolor(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap= printLabels(ax, xlabel, ylabel, title) -# ax.collections.remove(ax.collections[0]) + ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap)) + +def addpcolorbuffer(ax, x, y, z, zmin, zmax, xlabel='', ylabel='', title='', colormap='jet'): + + printLabels(ax, xlabel, ylabel, title) + + ax.collections.remove(ax.collections[0]) ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap)) diff --git a/schainpy/model/jroplot.py b/schainpy/model/jroplot.py index e605f76..eb09afa 100644 --- a/schainpy/model/jroplot.py +++ b/schainpy/model/jroplot.py @@ -312,7 +312,7 @@ class RTIPlot(Figure): title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) axes = self.axesList[i*self.__nsubplots] zdB = avgdB[i].reshape((1,-1)) - axes.pcolor(x, y, zdB, + axes.pcolorbuffer(x, y, zdB, xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, ticksize=9, cblabel='', cbsize="1%") @@ -816,7 +816,7 @@ class CoherenceMap(Figure): title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) axes = self.axesList[i*self.__nsubplots*2] - axes.pcolor(x, y, z, + axes.pcolorbuffer(x, y, z, xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") @@ -838,7 +838,7 @@ class CoherenceMap(Figure): title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) axes = self.axesList[i*self.__nsubplots*2 + counter] - axes.pcolor(x, y, z, + axes.pcolorbuffer(x, y, z, xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%")