diff --git a/schainpy/Graphics/SpectraPlot2.py b/schainpy/Graphics/SpectraPlot2.py new file mode 100644 index 0000000..a148390 --- /dev/null +++ b/schainpy/Graphics/SpectraPlot2.py @@ -0,0 +1,167 @@ +import numpy +import schainPlot + +class RTIFigure(schainPlot.Figure): + + __driverObj = None + __isDriverOpen = False + __isFigureOpen = False + __isConfig = False + __xw = None + __yw = None + + xmin = None + xmax = None + minvalue = None + maxvalue = None + + idfigure = None + nframes = None + wintitle = wintitle + colormap = None + driver = None + overplot = None + + frameObjList = [] + + def __init__(self, idfigure, wintitle, xw=600, yw=800, overplot=0, driver='xwin', colormap='br_green', *showGraphs): + + self.idfigure = idfigure + self.wintitle = wintitle + self.colormap = colormap + self.driver = driver + self.overplot = overplot + + self.showGraphs = showGraphs + + self.__driverObj = Driver(driver) + + def __openDriver(self): + + self.__driverObj.openDriver(self.idfigure, self.wintitle, self.xw, self.yw) + + def __openFigure(self): + + nrows, ncolumns = self.getSubplots() + + self.__driverObj.openFigure() + self.__driverObj.setSubPlots(nrows, ncolumns) + + + def __isOutOfXRange(self, x): + pass + + def __changeXRange(self, x): + pass + + def __createFrames(self): + + for frame in range(self.nframes): + frameObj = Frame(idframe = frame, + showGraph1 = self.showGraph1, + showGraph2 = self.showGraph2 + ) + + self.frameObjList.append(frameObj) + + def plot1DArray(self, data1D, x=None, channelList=None, xmin=None, xmax=None, minvalue=None, maxvlaue=None, save=False, gpath='./'): + + nx, ny = data1D.shape + + if channelList == None: + chanellList = range(nx) + + if x == None: + x = numpy.arange(data1D.size) + + + + + if not(self.__isDriverOpen): + self.__openDriver() + self.__isDriverOpen = True + + if not(self.__isConfig): + if self.xmin == None: xmin = numpy.min(x) + if self.xmax == None: xmax = numpy.max(x) + if self.minvalue == None: minvalue = numpy.min(data1D) + if self.maxvalue == None: maxvalue = numpy.max(data1D) + + self.__createFrames() + self.__isConfig = True + + + if not(self.__isOutOfXRange(x)): + self.__changeXRange(x) + + if self.__isFigureOpen: + self.__driverObj.closePage() + self.__isFigureOpen = False + + if not(self.__isFigureOpen): + self.__openFigure() + + for channel in channelList: + frameObj = self.frameObjList[channel] + frameObj.init(xmin=xmin, + xmax=xmax, + minvalue=minvalue, + maxvalue=maxvalue) + + self.__isFigureOpen = True + + + for channel in channelList: + dataCh = data1D[channel] + frameObj = self.frameObjList[channel] + + frameObj.clearData() + frameObj.plot(dataCh) + + frameObj.refresh() + + if not(self.overplot): + self.__driverObj.closeFigure() + self.__isFigureOpen = False + + + def plot2DArray(self, x, y, data2D, xmin=None, xmax=None, ymin=None, ymax=None, minvalue=None, maxvalue=None, save=False, gpath='./'): + + if not(self.__isCOpen): + self.__createFrames() + self.__openFigure() + self.__isOpen = True + + if not(self.__isConfig): + self.setRange(xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, minvalue=minvalue, maxvalue=maxvalue) + + self.__isConfig = True + + for channel in channelList: + dataCh = dataArray[channel] + frameObj = frameObjList[channel] + frameObj.plot(dataCh) + + def saveFigure(self, filename): + pass + + + def getSubplots(self): + + raise ValueError, '' + +class RTIFrame(schainPlot.Frame): + + def __init__(self): + pass + + def setup(self): + pass + +class RTIPlot(schainPlot.Plot): + + def __init__(self): + pass + + def setup(self): + pass \ No newline at end of file diff --git a/schainpy/Graphics/schainPlot.py b/schainpy/Graphics/schainPlot.py index f5d2659..de013db 100644 --- a/schainpy/Graphics/schainPlot.py +++ b/schainpy/Graphics/schainPlot.py @@ -8,8 +8,13 @@ class Figure: __isDriverOpen = False __isFigureOpen = False __isConfig = False - __width = None - __height = None + __xw = None + __yw = None + + xmin = None + xmax = None + minvalue = None + maxvalue = None idfigure = None nframes = None @@ -20,10 +25,9 @@ class Figure: frameObjList = [] - def __init__(self, idfigure, nframes, wintitle, width=600, height=800, overplot=0, driver='xwin', colormap='br_green', *showGraphs): + def __init__(self, idfigure, wintitle, xw=600, yw=800, overplot=0, driver='xwin', colormap='br_green', *showGraphs): self.idfigure = idfigure - self.nframes = nframes self.wintitle = wintitle self.colormap = colormap self.driver = driver @@ -32,74 +36,93 @@ class Figure: self.showGraphs = showGraphs self.__driverObj = Driver(driver) - - def __createFrames(self): - - for frame in range(self.nframes): - frameObj = Frame(idFrame = frame, - showGraph1 = self.showGraph1, - showGraph2 = self.showGraph2 - ) - - self.frameObjList.append(frameObj) def __openDriver(self): - self.__driverObj.openDriver(self.idfigure, self.wintitle, self.width, self.height) + self.__driverObj.openDriver(self.idfigure, self.wintitle, self.xw, self.yw) def __openFigure(self): - self.__createFrames() nrows, ncolumns = self.getSubplots() self.__driverObj.openFigure() self.__driverObj.setSubPlots(nrows, ncolumns) - def __verifyXRange(self, x): + def __isOutOfXRange(self, x): pass - def __updateXRange(self, x): + def __changeXRange(self, x): pass - - def plot1DArray(self, data1D, x=None, xmin=None, xmax=None, minvalue=None, maxvlaue=None, save=False, gpath='./'): + + def __createFrames(self): + for frame in range(self.nframes): + frameObj = Frame(idframe = frame, + showGraph1 = self.showGraph1, + showGraph2 = self.showGraph2 + ) + + self.frameObjList.append(frameObj) + + def plot1DArray(self, data1D, x=None, channelList=None, xmin=None, xmax=None, minvalue=None, maxvlaue=None, save=False, gpath='./'): + + nx, ny = data1D.shape + + if channelList == None: + chanellList = range(nx) + + if x == None: + x = numpy.arange(data1D.size) + + + + if not(self.__isDriverOpen): self.__openDriver() self.__isDriverOpen = True if not(self.__isConfig): - if x == None: x = numpy.arange(data1D.size) - if xmin == None: xmin = numpy.min(x) - if xmax == None: xmax = numpy.max(x) - if minvalue == None: minvalue = numpy.min(data1D) - if maxvalue == None: maxvalue = numpy.max(data1D) + if self.xmin == None: xmin = numpy.min(x) + if self.xmax == None: xmax = numpy.max(x) + if self.minvalue == None: minvalue = numpy.min(data1D) + if self.maxvalue == None: maxvalue = numpy.max(data1D) - self.setRange(xmin=xmin, xmax=xmax, minvalue=minvalue, maxvalue=maxvalue) + self.__createFrames() self.__isConfig = True - if not(self.__verifyXRange(x)): - self.__updateXRange(x) + + if not(self.__isOutOfXRange(x)): + self.__changeXRange(x) + if self.__isFigureOpen: - close_figure() + self.__driverObj.closePage() self.__isFigureOpen = False if not(self.__isFigureOpen): self.__openFigure() + + for channel in channelList: + frameObj = self.frameObjList[channel] + frameObj.init(xmin=xmin, + xmax=xmax, + minvalue=minvalue, + maxvalue=maxvalue) + self.__isFigureOpen = True - for frame in channelList: - dataCh = data1D[channel] - frameObj = frameObjList[channel] - frameObj.plotBox() for channel in channelList: - dataCh = dataArray[channel] - frameObj = frameObjList[channel] + dataCh = data1D[channel] + frameObj = self.frameObjList[channel] + + frameObj.clearData() frameObj.plot(dataCh) + + frameObj.refresh() if not(self.overplot): - close_figure() + self.__driverObj.closeFigure() self.__isFigureOpen = False @@ -130,84 +153,111 @@ class Figure: class Frame: + """ + subplots + """ + plotObjList = [] - def __init__(self, idFrame, showGraph1=False, showGraph2=False): + def __init__(self, idframe, showGraph1=False, showGraph2=False): - self.idFrame = idFrame + self.idframe = idframe self.showGraph1 = showGraph1 self.showGraph2 = showGraph2 - self.nPlots = 2 - self.createPlots() + self.nplots = 1 + showGraph1 + showGraph2 + self.__createPlots() - def __getScreenPosMain(self): - left = 1.2 - bottom = 2.3 - width = 2.0 - height = 1.4 + def __createPlots(self): - return left, bottom, width, height + for nplot in range(self.nplots): + xi, yi, xw, yw = self.__getScreenPos(nplot) + plotObj = Plot(xi, yi, xw, yw) + + self.plotObjList.append(plotObj) + + def __getScreenPosMainPlot(self): + + """ + Calcula las coordenadas asociadas al plot principal. + """ + + xi = 1.2 + yi = 2.3 + xw = 2.0 + yw = 1.4 + + return xi, yi, xw, yw def __getScreenPosGraph1(self): - left = 1.2 - bottom = 2.3 - width = 2.0 - height = 1.4 + xi = 1.2 + yi = 2.3 + xw = 2.0 + yw = 1.4 - return left, bottom, width, height + return xi, yi, xw, yw def __getScreenPosGraph2(self): - left = 1.2 - bottom = 2.3 - width = 2.0 - height = 1.4 + xi = 1.2 + yi = 2.3 + xw = 2.0 + yw = 1.4 - return left, bottom, width, height + return xi, yi, xw, yw def __getScreenPos(self, nplot): if nplot == 0: - left, bottom, width, height = self.__getScreenPosMain() + xi, yi, xw, yw = self.__getScreenPosMain() if nplot == 1: - left, bottom, width, height = self.__getScreenPosMain() + xi, yi, xw, yw = self.__getScreenPosMain() if nplot == 2: - left, bottom, width, height = self.__getScreenPosMain() + xi, yi, xw, yw = self.__getScreenPosMain() - return left, bottom, width, height - - def createPlots(self): + return xi, yi, xw, yw + + + def init(self, xmin, xmax, ymin, yamx, minvalue, maxvalue): - for nplot in range(self.nPlots): - left, bottom, width, height = self.__getScreenPos(nplot) - plotObj = Plot(left, bottom, width, height) - - self.plotObjList.append(plotObj) + """ + """ + + for plotObj in self.plotObjList: + plotObj.plotBox(xmin, xmax, ymin, yamx, minvalue, maxvalue) - def setup(self): + def clearData(self): pass - + def plot(self, data): - pass + + for plotObj in self.plotObjList: + plotObj.plotData(data) + + def refresh(self): + pass + + class Plot: - def __init__(self, left, bottom, width, height): + def __init__(self, xi, yi, xw, yw): - self.left = left - self.bottom = bottom - self.width = width - self.height = height + self.xi = xi + self.yi = yi + self.xw = xw + self.yw = yw - def setRange(self, xrange, yrange, zrange): + def __setRange(self, xrange, yrange, zrange): pass - def setLabels(self, xlabel, ylabel, zlabel): + def __setLabels(self, xlabel, ylabel, zlabel): pass + - def plotBox(self): + def plotBox(self,xmin, xmax, ymin, yamx, minvalue, maxvalue): pass def plotData(self): - pass + + raise ValueError, "" diff --git a/schainpy/Graphics/schainPlotTypes.py b/schainpy/Graphics/schainPlotTypes.py index f48f78e..dabfb92 100644 --- a/schainpy/Graphics/schainPlotTypes.py +++ b/schainpy/Graphics/schainPlotTypes.py @@ -39,8 +39,8 @@ class RTIFrame(Frame): self.showGraph1 = showColorbar self.showGraph2 = showPowerProfile - def setXYPos - + def setXYPos(self): + pass class SelfSpcFigure(Figure): def __init__(self):