diff --git a/schainpy2/Data/JROData.py b/schainpy2/Data/JROData.py index 9e84a66..e0e00bb 100644 --- a/schainpy2/Data/JROData.py +++ b/schainpy2/Data/JROData.py @@ -62,6 +62,7 @@ class JROData: ippSeconds = None + timeInterval = None def __init__(self): diff --git a/schainpy2/Graphics/schainPlot.py b/schainpy2/Graphics/schainPlot.py index b2bf429..7be80e0 100644 --- a/schainpy2/Graphics/schainPlot.py +++ b/schainpy2/Graphics/schainPlot.py @@ -58,9 +58,6 @@ class Figure: self.frameObjList = [] -# self.showGraph1 = args[0] -# self.showGraph2 = args[1] - self.drvObj.driver.setFigure() self.drvObj.driver.setColormap(colormap) @@ -143,16 +140,12 @@ class Figure: self.createFrames() self.__isConfig = True - if not(self.__isOutOfXRange(x)): - self.changeXRange(x) - - if self.__isFigureOpen: - self.drvObj.driver.closePage() - self.__isFigureOpen = False + self.selectFigure() self.__newPage() + for channel in channelList: frameObj = self.frameObjList[channel] frameObj.init(xmin=self.xmin, @@ -165,15 +158,12 @@ class Figure: for channel in channelList: dataCh = data1D[channel,:] frameObj = self.frameObjList[channel] -# frameObj.clearData() frameObj.plot(x, dataCh) - -# frameObj.refresh() + self.__refresh() + if save: -# self.colorplotObj.setFigure(indexPlot) - path = gpath now = datetime.datetime.now() file = "scope_img%02d_%d_%d.png"%(self.idfigure, time.mktime(now.timetuple()), now.microsecond) @@ -198,7 +188,7 @@ class Figure: deltax=None, save=False, gpath='./', - clearData=False, + cleardata=False, *args): @@ -223,8 +213,9 @@ class Figure: if not(self.changeXRange(x)): return 0 - + self.__closePage() + self.__isFigureOpen = False self.selectFigure() @@ -256,7 +247,7 @@ class Figure: self.__refresh() - if clearData == True: + if cleardata == True: self.__closePage() self.__isFigureOpen = False diff --git a/schainpy2/Graphics/schainPlotTypes.py b/schainpy2/Graphics/schainPlotTypes.py index f68e031..e6b6cf8 100644 --- a/schainpy2/Graphics/schainPlotTypes.py +++ b/schainpy2/Graphics/schainPlotTypes.py @@ -3,9 +3,143 @@ import datetime import time from schainPlot import * +class CrossSpc(Figure): + overplot = 0 + xw = 900 + yw = 650 + showprofile = False + signalA = None + signalB = None + coherence = None + phase = None + + def __init__(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): + Figure.__init__(self,idfigure, nframes, wintitle, self.xw, self.yw, self.overplot, driver, colormap, colorbar) + + self.showprofile = showprofile + self.signalA = None + self.signalB = None + self.coherence = None + self.phase = None + + def getSubplots(self): + nrows = self.nframes + ncolumns = 1 + return nrows, ncolumns + + def setParms(self, data, x, y, xmin, xmax, ymin, ymax, minvalue, maxvalue, *args): + + if xmin == None: xmin = numpy.min(x) + if xmax == None: xmax = numpy.max(x) + if ymin == None: ymin = numpy.min(y) + if ymax == None: ymax = numpy.max(y) + if minvalue == None: minvalue = 20. + if maxvalue == None: maxvalue = 90. + + self.signalA = self.data[0] + self.signalB = self.data[1] + self.coherence = self.data[2] + self.phase = self.data[3] + + self.xmin = xmin + self.xmax = xmax + self.minrange = ymin + self.maxrange = ymax + self.ymin = ymin + self.ymax = ymax + self.minvalue = minvalue + self.maxvalue = maxvalue + + def changeXRange(self, *args): + pass + + def createFrames(self): + self.frameObjList = [] + + for frame in range(self.nframes): + frameObj = CrossSpcFrame(self.drvObj,frame + 1, self.colorbar, self.showprofile) + self.frameObjList.append(frameObj) + + +class CrossSpcFrame(Frame): + def __init__(self): + self.drvObj = drvObj + self.idframe = idframe + self.nplots = 4 + + if showprofile: + self.nplots += 4 + + self.colorbar = colorbar + self.showprofile = showprofile + self.createPlots() + + def createPlots(self): + plotObjList = [] + idplot = 0 + counter_plot = 0 + for i in range(self.nplots): + xi, yi, xw, yw = self.getScreenPos(idplot) + plotObj = SpcPlot(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, self.colorbar) + plotObjList.append(plotObj) + + if self.showprofile: + xi, yi, xw, yw = self.getScreenPos(idplot) + type = "pwbox" + title = "" + xlabel = "dB" + ylabel = "" + idplot += 1 + plotObj = Plot1D(self.drvObj, self.idframe, idplot, xi, yi, xw, yw, type, title, xlabel, ylabel) + plotObjList.append(plotObj) + idplot += 1 + + self.plotObjList = plotObjList + + def getScreenPos(self,idplot): + pass + + def getScreenPosMainPlot(self): + xi = 0.15 + + if self.showprofile: + xw = 0.55 + + else: + xw = 0.65 + + if self.colorbar: + xw = xw - 0.06 + + yi = 0.20; yw = 0.75 + + return xi, yi, xw, yw + + def getScreenPosGraph1(self): + if self.colorbar: + xi = 0.65 + 0.08 + else: + xi = 0.75 + 0.05 + + xw = xi + 0.2 + + yi = 0.2; yw = 0.75 + + return xi, yi, xw, yw + + def plot(self,x, y, data): + plotObj = self.plotObjList[0] + plotObj.plot(x,y,data) + + if self.showprofile: + plotObj = self.plotObjList[1] + avg_data = numpy.average(data, axis=0) + plotObj.plot(avg_data,y) + + class SpcFigure(Figure): overplot = 0 - xw = 800 + xw = 900 yw = 650 showprofile = False @@ -86,10 +220,10 @@ class SpcFrame(Frame): xi = 0.15 if self.showprofile: - xw = 0.65 + xw = 0.55 else: - xw = 0.75 + xw = 0.65 if self.colorbar: xw = xw - 0.06 @@ -116,7 +250,8 @@ class SpcFrame(Frame): if self.showprofile: plotObj = self.plotObjList[1] - plotObj.plot(data,y) + avg_data = numpy.average(data, axis=0) + plotObj.plot(avg_data,y) class SpcPlot(Plot): @@ -147,7 +282,7 @@ class SpcPlot(Plot): self.xopt = "bcnst" self.yopt = "bcnstv" - self.szchar = 0.8 + self.szchar = 0.7 self.strforchannel = "Channel %d"%self.idframe self.xlabel = "m/s" self.ylabel = "Range (Km)" @@ -376,7 +511,7 @@ class RTIPlot(Plot): self.xpos = [self.xi,self.xw] self.ypos = [self.yi,self.yw] self.xaxisastime = True - self.timefmt = "%H:%M" + self.timefmt = "%H:%M:%S" self.xopt = "bcnstd" self.yopt = "bcnstv" @@ -492,7 +627,7 @@ class Plot1D(Plot): self.timefmt = None self.xopt = "bcnst" self.yopt = "bcnstv" - self.szchar = 1.0 + self.szchar = 0.7 self.type = type self.title = title self.xlabel = xlabel diff --git a/schainpy2/IO/VoltageIO.py b/schainpy2/IO/VoltageIO.py index 32690f4..f687e8e 100644 --- a/schainpy2/IO/VoltageIO.py +++ b/schainpy2/IO/VoltageIO.py @@ -295,6 +295,10 @@ class VoltageReader(JRODataReader): self.dataOutObj.utctime = self.basicHeaderObj.utc + self.basicHeaderObj.miliSecond/1000. + self.profileIndex * self.ippSeconds + self.dataOutObj.ippSeconds = self.ippSeconds + + self.dataOutObj.timeInterval = self.ippSeconds + self.dataOutObj.nCohInt = self.processingHeaderObj.nCohInt self.dataOutObj.flagShiftFFT = False @@ -313,6 +317,10 @@ class VoltageReader(JRODataReader): self.dataOutObj.radarControllerHeaderObj = self.radarControllerHeaderObj.copy() self.dataOutObj.flagNoData = False + +# print self.profileIndex, self.dataOutObj.utctime +# if self.profileIndex == 800: +# a=1 return self.dataOutObj.data diff --git a/schainpy2/Processing/SpectraProcessor.py b/schainpy2/Processing/SpectraProcessor.py index 5cbc80e..2514898 100644 --- a/schainpy2/Processing/SpectraProcessor.py +++ b/schainpy2/Processing/SpectraProcessor.py @@ -53,7 +53,7 @@ class SpectraProcessor: self.buffer = None self.profIndex = 0 - def setup(self, dataInObj=None, dataOutObj=None, nFFTPoints=None, pairList=None): + def setup(self, dataInObj=None, dataOutObj=None, nFFTPoints=None, pairsList=None): if dataInObj == None: raise ValueError, "This SpectraProcessor.setup() function needs dataInObj input variable" @@ -70,13 +70,13 @@ class SpectraProcessor: nFFTPoints = dataInObj.nFFTPoints - if pairList == None: - pairList = self.dataInObj.pairList + if pairsList == None: + pairsList = dataInObj.pairsList - if pairList == None: + if pairsList == None: nPairs = 0 else: - nPairs = len(pairList) + nPairs = len(pairsList) self.dataInObj = dataInObj @@ -85,7 +85,7 @@ class SpectraProcessor: self.dataOutObj = dataOutObj self.dataOutObj.nFFTPoints = nFFTPoints - self.dataOutObj.pairList = pairList + self.dataOutObj.pairsList = pairsList self.dataOutObj.nPairs = nPairs return self.dataOutObj @@ -176,10 +176,10 @@ class SpectraProcessor: cspc = None pairIndex = 0 - if self.dataOutObj.pairList != None: + if self.dataOutObj.pairsList != None: #calculo de cross-spectra cspc = numpy.zeros((self.dataOutObj.nPairs, self.dataOutObj.nFFTPoints, self.dataOutObj.nHeights), dtype='complex') - for pair in self.pairList: + for pair in self.dataOutObj.pairsList: cspc[pairIndex,:,:] = numpy.abs(fft_volt[pair[0],:,:] * numpy.conjugate(fft_volt[pair[1],:,:])) pairIndex += 1 blocksize += cspc.size @@ -222,6 +222,47 @@ class SpectraProcessor: objIncohInt = IncoherentIntegration(N,timeInterval) self.integratorObjList.append(objIncohInt) + + def addCrossSpc(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): + crossSpcObj = CrossSpcFigure(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) + self.plotObjList.append(crossSpcObj) + + def plotCrossSpc(self, idfigure=None, + xmin=None, + xmax=None, + ymin=None, + ymax=None, + minvalue=None, + maxvalue=None, + wintitle='', + driver='plplot', + colormap='br_green', + colorbar=True, + showprofile=False, + save=False, + gpath=None, + pairsList = None): + + if self.dataOutObj.flagNoData: + return 0 + + if pairsList == None: + pairsList = self.dataOutObj.pairsList + + nframes = len(pairsList) + + x = numpy.arange(self.dataOutObj.nFFTPoints) + + y = self.dataOutObj.heightList + + + + + if len(self.plotObjList) <= self.plotObjIndex: + self.addSpc(idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile) + + + def addSpc(self, idfigure, nframes, wintitle, driver, colormap, colorbar, showprofile): @@ -276,7 +317,7 @@ class SpectraProcessor: plotObj = self.plotObjList[self.plotObjIndex] - plotObj.plotPcolor(data, + plotObj.plotPcolor(data=data, x=x, y=y, channelList=channelList, @@ -289,9 +330,9 @@ class SpectraProcessor: figuretitle=figuretitle, xrangestep=None, deltax=None, - save=False, - gpath='./', - clearData=True + save=save, + gpath=gpath, + cleardata=cleardata ) self.plotObjIndex += 1 diff --git a/schainpy2/Processing/VoltageProcessor.py b/schainpy2/Processing/VoltageProcessor.py index 77af530..69951b7 100644 --- a/schainpy2/Processing/VoltageProcessor.py +++ b/schainpy2/Processing/VoltageProcessor.py @@ -67,7 +67,7 @@ class VoltageProcessor: maxvalue=None, wintitle='', driver='plplot', - colormap='br_green', + colormap='br_greeen', colorbar=True, showprofile=False, xrangestep=None, @@ -103,21 +103,25 @@ class VoltageProcessor: cleardata = False - plotObj.plotPcolor(data, - currenttime, - range, - channelList, - starttime, - endtime, - rangemin, - rangemax, - minvalue, - maxvalue, - figuretitle, - xrangestep, - save, - gpath, - cleardata) + deltax = self.dataOutObj.timeInterval + + plotObj.plotPcolor(data=data, + x=currenttime, + y=range, + channelList=channelList, + xmin=starttime, + xmax=endtime, + ymin=rangemin, + ymax=rangemax, + minvalue=minvalue, + maxvalue=maxvalue, + figuretitle=figuretitle, + xrangestep=xrangestep, + deltax=deltax, + save=save, + gpath=gpath, + cleardata=cleardata) + self.plotObjIndex += 1 @@ -168,16 +172,17 @@ class VoltageProcessor: plotObj = self.plotObjList[self.plotObjIndex] - plotObj.plot1DArray(data1D, - self.dataOutObj.heightList, - self.dataOutObj.channelList, - xmin, - xmax, - minvalue, - maxvalue, - figureTitle, - save, - gpath) + plotObj.plot1DArray(data1D=data1D, + x=self.dataOutObj.heightList, + channelList=self.dataOutObj.channelList, + xmin=xmin, + xmax=xmax, + minvalue=minvalue, + maxvalue=maxvalue, + figureTitle=figureTitle, + save=save, + gpath=gpath) + self.plotObjIndex += 1