diff --git a/schainpy2/Graphics/__init__.py b/schainpy2/Graphics/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/schainpy2/Graphics/__init__.py diff --git a/schainpy2/Graphics/schainPlot.py b/schainpy2/Graphics/schainPlot.py index 82fc2d8..699e98d 100644 --- a/schainpy2/Graphics/schainPlot.py +++ b/schainpy2/Graphics/schainPlot.py @@ -1,6 +1,6 @@ import numpy -import schainPlplotLib +from schainPlotLib import Driver class Figure: @@ -18,7 +18,7 @@ class Figure: idfigure = None nframes = None - wintitle = wintitle + wintitle = None colormap = None driver = None overplot = None @@ -77,14 +77,11 @@ class Figure: nx, ny = data1D.shape if channelList == None: - chanellList = range(nx) + channelList = range(nx) if x == None: x = numpy.arange(data1D.size) - - - if not(self.__isDriverOpen): self.__openDriver() self.__isDriverOpen = True @@ -98,7 +95,6 @@ class Figure: self.__createFrames() self.__isConfig = True - if not(self.__isOutOfXRange(x)): self.__changeXRange(x) @@ -117,8 +113,7 @@ class Figure: maxvalue=maxvalue) self.__isFigureOpen = True - - + for channel in channelList: dataCh = data1D[channel] frameObj = self.frameObjList[channel] @@ -142,7 +137,6 @@ class Figure: 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: diff --git a/schainpy2/Graphics/schainPlotLib.py b/schainpy2/Graphics/schainPlotLib.py index 8bc1a15..09650bd 100644 --- a/schainpy2/Graphics/schainPlotLib.py +++ b/schainpy2/Graphics/schainPlotLib.py @@ -17,7 +17,7 @@ class PlplotDriver: __isDriverOpen = False pldriver = None - def __init__(self, idfigure=None, xw, yw, wintitle, overplot, colormap, *showGraphs): + def __init__(self, idfigure, xw, yw, wintitle, overplot, colormap, *showGraphs): if idfigure == None: raise ValueError, 'idfigure input must be defined' @@ -38,22 +38,25 @@ class PlplotDriver: plplot.plsstrm(self.idfigure) plplot.plparseopts([self.wintitle],plplot.PL_PARSE_FULL) plplot.plsetopt("geometry", "%dx%d"%(self.xw, self.yw)) - - plplot.plscolbg(255,255,255) - plplot.plscol0(1,0,0,0) + def openDriver(self, pldriver=None): if pldriver == None: if sys.platform == "linux": pldriver = "xcairo" - + + if sys.platform == "linux2": + pldriver = "xcairo" + elif sys.platform == "darwin": pldriver = "xwin" else: pldriver = "" - plplot.plsdev(pldriver) + plplot.plsdev("xwin") #para pruebas + plplot.plscolbg(255,255,255) + plplot.plscol0(1,0,0,0) plplot.plinit() plplot.plspause(False) diff --git a/schainpy2/Graphics/schainPlotTypes.py b/schainpy2/Graphics/schainPlotTypes.py index b84724d..5258a7b 100644 --- a/schainpy2/Graphics/schainPlotTypes.py +++ b/schainpy2/Graphics/schainPlotTypes.py @@ -4,22 +4,13 @@ from schainPlot import * class ScopeFigure(Figure): overplot = 0 xw = 700 - yw = 150 + yw = 600 - def __init__(self, idfigure, nframes, wintitle, driver): + def __init__(self,idfigure,nframes,wintitle,driver): - showGraphs = (0, 0) - - Figure.__init__(self, - idfigure=idfigure, - nframes = nframes, - wintitle=wintitle, - xw=self.xw, - yw=self.yw, - overplot=self.overplot, - driver=driver, - colormap=None, - *showGraphs) + args = (0, 0) + colormap = None + Figure.__init__(self,idfigure,nframes,wintitle,self.xw,self.yw,self.overplot,driver,colormap,*args) self.nframes = nframes self.showColorbar = 0 @@ -89,7 +80,6 @@ class RTIFigure(Figure): self.frameObjList.append(frameObj) - class RTIFrame(Frame): def __init__(self,idFrame, showColorbar, showPowerProfile): self.idFrame = idFrame @@ -115,11 +105,12 @@ class CrossSpcFrame(Frame): def __init__(self): pass -class ScopeFigure(Figure): - def __init__(self): - pass -class ScopeFrame(Frame): - def __init__(self): - pass +if __name__ == '__main__': + idfigure=0 + nframes=2 + wintitle='' + driver='plplot' + scopeObj = ScopeFigure(idfigure,nframes,wintitle,driver) + diff --git a/schainpy2/Processing/VoltageProcessor.py b/schainpy2/Processing/VoltageProcessor.py index b235f19..58571aa 100644 --- a/schainpy2/Processing/VoltageProcessor.py +++ b/schainpy2/Processing/VoltageProcessor.py @@ -13,7 +13,7 @@ sys.path.append(path) from Data.Voltage import Voltage from IO.VoltageIO import VoltageWriter - +from Graphics.schainPlotTypes import ScopeFigure class VoltageProcessor: dataInObj = None @@ -26,8 +26,10 @@ class VoltageProcessor: def __init__(self): self.integratorObjIndex = None self.writerObjIndex = None + self.plotObjIndex = None self.integratorObjList = [] self.writerObjList = [] + self.plotObjList = [] def setup(self,dataInObj=None,dataOutObj=None): self.dataInObj = dataInObj @@ -42,20 +44,64 @@ class VoltageProcessor: def init(self): self.integratorObjIndex = 0 self.writerObjIndex = 0 + self.plotObjIndex = 0 if not(self.dataInObj.flagNoData): self.dataOutObj.copy(self.dataInObj) # No necesita copiar en cada init() los atributos de dataInObj # la copia deberia hacerse por cada nuevo bloque de datos + + def addScope(self, idfigure, nframes, wintitle, driver): + if idfigure==None: + idfigure = self.plotObjIndex + + scopeObj = ScopeFigure(idfigure, nframes, wintitle, driver) + self.plotObjList.append(scopeObj) + + def plotScope(self, + idfigure=None, + minvalue=None, + maxvalue=None, + xmin=None, + xmax=None, + wintitle='', + driver='plplot', + save=False, + gpath=None, + titleList=None, + xlabelList=None, + ylabelList=None, + type="power"): + + if self.dataOutObj.flagNoData: + return 0 + + nframes = len(self.dataOutObj.channelList) + + if len(self.plotObjList) <= self.plotObjIndex: + self.addScope(idfigure, nframes, wintitle, driver) + + self.plotObjList[self.plotObjIndex].plot1DArray(data1D=self.dataOutObj.data, + x=self.dataOutObj.heightList, + channelList=self.dataOutObj.channelList, + xmin=xmin, + xmax=xmax, + minvalue=minvalue, + maxvlaue=maxvalue, + save=save, + gpath=gpath) + + self.plotObjIndex += 1 + def addIntegrator(self,N,timeInterval): objCohInt = CoherentIntegrator(N,timeInterval) self.integratorObjList.append(objCohInt) def addWriter(self, wrpath, blocksPerFile, profilesPerBlock): - objWriter = VoltageWriter(self.dataOutObj) - objWriter.setup(wrpath,blocksPerFile,profilesPerBlock) - self.writerObjList.append(objWriter) + writerObj = VoltageWriter(self.dataOutObj) + writerObj.setup(wrpath,blocksPerFile,profilesPerBlock) + self.writerObjList.append(writerObj) def writeData(self, wrpath, blocksPerFile, profilesPerBlock): @@ -77,6 +123,7 @@ class VoltageProcessor: myCohIntObj = self.integratorObjList[self.integratorObjIndex] myCohIntObj.exe(data=self.dataOutObj.data,timeOfData=None) + class CoherentIntegrator: diff --git a/schainpy2/testSchainExp.py b/schainpy2/testSchainExp.py index 51667e6..98ba52f 100644 --- a/schainpy2/testSchainExp.py +++ b/schainpy2/testSchainExp.py @@ -15,7 +15,6 @@ from IO.VoltageIO import * from Processing.VoltageProcessor import * - class TestSChain(): def __init__(self): @@ -24,23 +23,23 @@ class TestSChain(): self.testSChain() def setValues(self): - self.path = "/Users/danielangelsuarezmunoz/Data/EW_Drifts" - self.startDate = datetime.date(2011,11,28) - self.endDate = datetime.date(2011,11,30) + self.path = "/home/dsuarez/RadarData/EW_DRIFTS" + self.startDate = datetime.date(2012,6,1) + self.endDate = datetime.date(2012,7,30) # self.path = "/Users/danielangelsuarezmunoz/Data/Imaging_rawdata" # self.startDate = datetime.date(2011,10,4) # self.endDate = datetime.date(2011,10,4) # Probando los escritos por Signal Chain - self.path = "/Users/danielangelsuarezmunoz/Data/testWR" - self.startDate = datetime.date(2011,11,28) - self.endDate = datetime.date(2011,11,30) +# self.path = "/home/dsuarez/RadaData" +# self.startDate = datetime.date(2011,11,28) +# self.endDate = datetime.date(2011,11,30) self.startTime = datetime.time(0,0,0) self.endTime = datetime.time(23,59,59) - self.wrpath = "/Users/danielangelsuarezmunoz/Data/testWR" + self.wrpath = "/home/dsuarez/RadarData" self.profilesPerBlock = 40 self.blocksPerFile = 50 @@ -68,10 +67,18 @@ class TestSChain(): while(True): self.readerObj.getData() -# self.voltObjProc.init() + self.voltObjProc.init() # # self.voltObjProc.writeData(self.wrpath,self.profilesPerBlock,self.blocksPerFile) - + + + self.voltObjProc.plotScope(idfigure=1, + wintitle='test plot library', + driver='plplot', + save=False, + gpath=None, + type="power") + if self.readerObj.flagNoMoreFiles: break