diff --git a/schainpy2/Graphics/schainPlot.py b/schainpy2/Graphics/schainPlot.py index 7be80e0..5708045 100644 --- a/schainpy2/Graphics/schainPlot.py +++ b/schainpy2/Graphics/schainPlot.py @@ -9,7 +9,7 @@ class Figure: __isDriverOpen = False __isFigureOpen = False __isConfig = False - + __counter = 0 drvObj = None driver = None idfigure = None @@ -43,6 +43,7 @@ class Figure: self.__isDriverOpen = False self.__isFigureOpen = False self.__isConfig = False + self.__counter = 0 self.drvObj = Driver(driver, idfigure, xw, yw, wintitle, overplot, colormap, colorbar) self.driver = driver @@ -107,7 +108,7 @@ class Figure: self.drvObj.driver.save(filename) - def plot1DArray(self, data1D, x=None, channelList=None, xmin=None, xmax=None, minvalue=None, maxvalue=None, figuretitle=None, save=False, gpath='./'): + def plot1DArray(self, data1D, x=None, channelList=None, xmin=None, xmax=None, minvalue=None, maxvalue=None, figuretitle=None, save=False, gpath='./', ratio=1): nx, ny = data1D.shape @@ -146,7 +147,7 @@ class Figure: self.__newPage() - for channel in channelList: + for channel in range(len(channelList)): frameObj = self.frameObjList[channel] frameObj.init(xmin=self.xmin, xmax=self.xmax, @@ -155,20 +156,25 @@ class Figure: minvalue=self.minvalue, maxvalue=self.maxvalue) - for channel in channelList: + for channel in range(len(channelList)): dataCh = data1D[channel,:] frameObj = self.frameObjList[channel] frameObj.plot(x, dataCh) self.__refresh() - if save: - path = gpath - now = datetime.datetime.now() - file = "scope_img%02d_%d_%d.png"%(self.idfigure, time.mktime(now.timetuple()), now.microsecond) - filename = os.path.join(path,file) - self.save(filename) + if self.__counter == 0: + path = gpath + now = datetime.datetime.now() + file = "plot_img%02d_%d_%d.png"%(self.idfigure, time.mktime(now.timetuple()), now.microsecond) + filename = os.path.join(path,file) + self.save(filename) + self.__counter += 1 + + if self.__counter == ratio: + self.__counter = 0 + self.__closePage() @@ -188,6 +194,7 @@ class Figure: deltax=None, save=False, gpath='./', + ratio=1, cleardata=False, *args): @@ -223,7 +230,7 @@ class Figure: self.__newPage() self.__isFigureOpen = True - for channel in channelList: + for channel in range(len(channelList)): if len(args) != 0: value = args[0][channel] else: value = args @@ -240,13 +247,27 @@ class Figure: value) - for channel in channelList: + for channel in range(len(channelList)): dataCh = data[channel,:] frameObj = self.frameObjList[channel] frameObj.plot(x, y, dataCh) self.__refresh() + + if save: + if self.__counter == 0: + path = gpath + now = datetime.datetime.now() + file = "pcolor_img%02d_%d_%d.png"%(self.idfigure, time.mktime(now.timetuple()), now.microsecond) + filename = os.path.join(path,file) + self.save(filename) + self.__counter += 1 + + if self.__counter == ratio: + self.__counter = 0 + + if cleardata == True: self.__closePage() self.__isFigureOpen = False diff --git a/schainpy2/Graphics/schainPlotTypes.py b/schainpy2/Graphics/schainPlotTypes.py index e6b6cf8..e60a23e 100644 --- a/schainpy2/Graphics/schainPlotTypes.py +++ b/schainpy2/Graphics/schainPlotTypes.py @@ -62,6 +62,11 @@ class CrossSpc(Figure): class CrossSpcFrame(Frame): + xi = None + xw = None + yi = None + yw = None + alpha = None def __init__(self): self.drvObj = drvObj self.idframe = idframe @@ -72,6 +77,12 @@ class CrossSpcFrame(Frame): self.colorbar = colorbar self.showprofile = showprofile + self.xi = 0. + self.xw = 0. + self.yi = 0. + self.yw = 0. + self.alpha = 1. + self.createPlots() def createPlots(self): @@ -84,7 +95,7 @@ class CrossSpcFrame(Frame): plotObjList.append(plotObj) if self.showprofile: - xi, yi, xw, yw = self.getScreenPos(idplot) + xi, yi, xw, yw = self.getScreenPosGraph1(idplot) type = "pwbox" title = "" xlabel = "dB" @@ -96,20 +107,36 @@ class CrossSpcFrame(Frame): self.plotObjList = plotObjList - def getScreenPos(self,idplot): - pass +# def getScreenPos(self,idplot): +# pass - def getScreenPosMainPlot(self): - xi = 0.15 + def getScreenPos(self, diplot): + + xi = self.xi + xw = self.xw if self.showprofile: - xw = 0.55 + width = 0.55 + xw += width + + + + + self.xi = 0.15 + idplot*self.alpha + + if self.showprofile: + width = 0.55 + self.xw += width else: - xw = 0.65 + width = 0.65 + self.xw += width if self.colorbar: - xw = xw - 0.06 + self.xw = self.xw - 0.06 + + + self.alpha = self.xw yi = 0.20; yw = 0.75 @@ -117,9 +144,18 @@ class CrossSpcFrame(Frame): def getScreenPosGraph1(self): if self.colorbar: - xi = 0.65 + 0.08 + xi = self.xw + 0.08 else: - xi = 0.75 + 0.05 + xi = self.xw + 0.05 + + xw = xi + 0.2 + + self.alpha = xw + + if self.colorbar: + self.xi = 0.65 + 0.08 + else: + self.xi = 0.75 + 0.05 xw = xi + 0.2 @@ -211,7 +247,8 @@ class SpcFrame(Frame): title = "" xlabel = "dB" ylabel = "" - plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel) + szchar = 0.70 + plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel, szchar) plotObjList.append(plotObj) self.plotObjList = plotObjList @@ -319,7 +356,7 @@ class RTIFigure(Figure): minvalue = None maxvalue = None xrangestepinsecs = None - + timefmt=None def __init__(self, idfigure, nframes, wintitle, driver, colormap="br_green", colorbar= True, showprofile=False): Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar) @@ -339,29 +376,24 @@ class RTIFigure(Figure): cdatetime = datetime.datetime.utcfromtimestamp(x) mindatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,self.starttime.hour,self.starttime.minute,self.starttime.second) - if ((xrangestep == 0) or (xrangestep == None)): - maxdatetime = datetime.datetime(cdatetime.year,cdatetime.month,cdatetime.day,self.endtime.hour,self.endtime.minute,self.endtime.second) - self.xrangestepinsecs = time.mktime(maxdatetime.timetuple()) - time.mktime(mindatetime.timetuple()) - npoints = 1000. - if xrangestep == 1: - maxdatetime = mindatetime + datetime.timedelta(hours=1) - self.xrangestepinsecs = 60*60. - npoints = 500. - if xrangestep == 2: - maxdatetime = mindatetime + datetime.timedelta(minutes=1) - self.xrangestepinsecs = 60. - npoints = 250. - if xrangestep == 3: - maxdatetime = mindatetime + datetime.timedelta(seconds=1) - self.xrangestepinsecs = 1. - npoints = 125. + + maxdatetime = mindatetime + datetime.timedelta(seconds=xrangestep) + self.xrangestepinsecs = xrangestep xmin = time.mktime(mindatetime.timetuple()) xmax = time.mktime(maxdatetime.timetuple()) - deltax1 = (xmax-xmin) / npoints -# deltax = timeInterval + if self.xrangestepinsecs<=60.: + self.timefmt="%H:%M:%S" + + if self.xrangestepinsecs>0. and self.xrangestepinsecs<=1200.: + self.timefmt="%H:%M:%S" + + if self.xrangestepinsecs>1200. and self.xrangestepinsecs<=86400.: + self.timefmt="%H:%M" + if self.xrangestepinsecs>86400.: + self.timefmt="%y:%m:%d:%H" if ymin == None: ymin = numpy.min(y) if ymax == None: ymax = numpy.max(y) @@ -385,14 +417,8 @@ class RTIFigure(Figure): cdatetime = datetime.datetime.utcfromtimestamp(x) if ((cdatetime.time()>=self.starttime) and (cdatetime.time()