diff --git a/schainpy/model/graphics/jroplot_parameters.py b/schainpy/model/graphics/jroplot_parameters.py index 2aff0dc..d090095 100644 --- a/schainpy/model/graphics/jroplot_parameters.py +++ b/schainpy/model/graphics/jroplot_parameters.py @@ -455,7 +455,7 @@ class WindProfilerPlot(Figure): # y = dataOut.heightRange y = dataOut.heightRange - z = dataOut.winds + z = dataOut.winds.copy() nplots = z.shape[0] #Number of wind dimensions estimated nplotsw = nplots @@ -573,4 +573,221 @@ class WindProfilerPlot(Figure): if x[1] >= self.axesList[0].xmax: self.counter_imagwr = wr_period self.__isConfig = False + self.figfile = None + + +class RadialVelocityPlot(Figure): + + __isConfig = None + __nsubplots = None + + WIDTHPROF = None + HEIGHTPROF = None + PREFIX = 'rti' + + def __init__(self): + + self.timerange = 2*60*60 + self.__isConfig = False + self.__nsubplots = 1 + + self.WIDTH = 800 + self.HEIGHT = 150 + self.WIDTHPROF = 120 + self.HEIGHTPROF = 0 + self.counter_imagwr = 0 + + self.PLOT_CODE = 0 + self.FTP_WEI = None + self.EXP_CODE = None + self.SUB_EXP_CODE = None + self.PLOT_POS = None + self.tmin = None + self.tmax = None + + self.xmin = None + self.xmax = None + + self.figfile = None + + def getSubplots(self): + + ncol = 1 + nrow = self.nplots + + return nrow, ncol + + def setup(self, id, nplots, wintitle, showprofile=True, show=True): + + self.__showprofile = showprofile + self.nplots = nplots + + ncolspan = 1 + colspan = 1 + + self.createFigure(id = id, + wintitle = wintitle, + widthplot = self.WIDTH + self.WIDTHPROF, + heightplot = self.HEIGHT + self.HEIGHTPROF, + show=show) + + nrow, ncol = self.getSubplots() + + counter = 0 + for y in range(nrow): + for x in range(ncol): + + if counter >= self.nplots: + break + + self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) + + if showprofile: + self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) + + counter += 1 + + def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, + xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None, + SNRmin = None, SNRmax = None, SNRthresh = None, paramIndex = None, + save=False, figpath='', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, + server=None, folder=None, username=None, password=None, + ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): + + """ + + Input: + dataOut : + id : + wintitle : + channelList : + showProfile : + xmin : None, + xmax : None, + ymin : None, + ymax : None, + zmin : None, + zmax : None + """ + + if channelList == None: + channelIndexList = dataOut.channelIndexList + else: + channelIndexList = [] + for channel in channelList: + if channel not in dataOut.channelList: + raise ValueError, "Channel %d is not in dataOut.channelList" + channelIndexList.append(dataOut.channelList.index(channel)) + + if timerange != None: + self.timerange = timerange + + #tmin = None + #tmax = None + if paramIndex == None: + paramIndex = 1 + x = dataOut.getTimeRange1() + y = dataOut.heightRange + z = dataOut.data_param[channelIndexList,paramIndex,:].copy() + + zRange = dataOut.abscissaRange + nplots = z.shape[0] #Number of wind dimensions estimated + nplotsw = nplots + + if dataOut.SNR != None: + nplots += 1 + SNR = dataOut.SNR + SNRavg = numpy.average(SNR, axis=0) + + SNRdB = 10*numpy.log10(SNR) + SNRavgdB = 10*numpy.log10(SNRavg) + + if SNRthresh == None: SNRthresh = -5.0 + ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0] + + for i in range(nplotsw): + z[i,ind] = numpy.nan +# thisDatetime = dataOut.datatime + thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) + title = wintitle + " Radial Velocity" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) + xlabel = "" + ylabel = "Height (Km)" + + if not self.__isConfig: + + self.setup(id=id, + nplots=nplots, + wintitle=wintitle, + showprofile=showprofile, + show=show) + + self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) + + if ymin == None: ymin = numpy.nanmin(y) + if ymax == None: ymax = numpy.nanmax(y) + if zmin == None: zmin = numpy.nanmin(zRange) + if zmax == None: zmax = numpy.nanmax(zRange) + if dataOut.SNR != None: + if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) + if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) + + self.FTP_WEI = ftp_wei + self.EXP_CODE = exp_code + self.SUB_EXP_CODE = sub_exp_code + self.PLOT_POS = plot_pos + + self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") + self.__isConfig = True + self.figfile = figfile + + self.setWinTitle(title) + + if ((self.xmax - x[1]) < (x[1]-x[0])): + x[1] = self.xmax + + for i in range(nplotsw): + title = "Channel %d: %s" %(dataOut.channelList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) + if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): + title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) + axes = self.axesList[i*self.__nsubplots] + z1 = z[i,:].reshape((1,-1)) + axes.pcolorbuffer(x, y, z1, + xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, + xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="RdBu_r", + ticksize=9, cblabel='', cbsize="1%") + + if dataOut.SNR != None: + i += 1 + title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) + axes = self.axesList[i*self.__nsubplots] + + SNRavgdB = SNRavgdB.reshape((1,-1)) + + axes.pcolorbuffer(x, y, SNRavgdB, + xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, + xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, + ticksize=9, cblabel='', cbsize="1%", colormap="jet") + + self.draw() + + if self.figfile == None: + str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") + self.figfile = self.getFilename(name = str_datetime) + + if figpath != '': + + self.counter_imagwr += 1 + if (self.counter_imagwr>=wr_period): + # store png plot to local folder + self.saveFigure(figpath, self.figfile) + # store png plot to FTP server according to RT-Web format + name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) + ftp_filename = os.path.join(figpath, name) + self.saveFigure(figpath, ftp_filename) + + self.counter_imagwr = 0 + + if x[1] >= self.axesList[0].xmax: + self.counter_imagwr = wr_period + self.__isConfig = False self.figfile = None \ No newline at end of file diff --git a/schainpy/model/proc/jroproc_parameters.py b/schainpy/model/proc/jroproc_parameters.py index 481c893..3538b29 100644 --- a/schainpy/model/proc/jroproc_parameters.py +++ b/schainpy/model/proc/jroproc_parameters.py @@ -91,6 +91,7 @@ class ParametersProc(ProcessingUnit): self.buffer = None self.firstdatatime = None self.profIndex = 0 + return #---------------------- Spectra Data --------------------------- @@ -99,11 +100,7 @@ class ParametersProc(ProcessingUnit): self.dataOut.abscissaRange = self.dataIn.getVelRange(1) self.dataOut.noise = self.dataIn.getNoise() self.dataOut.normFactor = self.dataIn.normFactor - - self.__updateObjFromInput() - self.dataOut.flagNoData = False - self.firstdatatime = None - + #---------------------- Correlation Data --------------------------- if self.dataIn.type == "Correlation": @@ -117,9 +114,12 @@ class ParametersProc(ProcessingUnit): self.dataOut.SNR = self.dataIn.SNR self.dataOut.pairsList = self.dataIn.pairsList - self.__updateObjFromInput() - self.dataOut.flagNoData = False - self.firstdatatime = None + + self.__updateObjFromInput() + self.dataOut.flagNoData = False + self.firstdatatime = None + self.dataOut.initUtcTime = self.dataIn.ltctime + self.dataOut.windsInterval = self.dataIn.timeInterval #------------------- Get Moments ---------------------------------- def GetMoments(self, channelList = None): @@ -143,12 +143,14 @@ class ParametersProc(ProcessingUnit): data_param = numpy.zeros((data.shape[0], 4, data.shape[2])) - if channelList== None: channelList = self.dataOut.channelList + if channelList== None: + channelList = self.dataIn.channelList + self.dataOut.channelList = channelList for ind in channelList: data_param[ind,:,:] = self.__calculateMoments(data[ind,:,:], absc, noise[ind]) - - self.dataOut.data_param = data_param[:,1:] + + self.dataOut.data_param = data_param[:,1:,:] self.dataOut.SNR = data_param[:,0] return @@ -1461,8 +1463,6 @@ class WindProfiler(Operation): velRadial0 = param[:,1,:] #Radial velocity dataOut.winds, dataOut.heightRange, dataOut.SNR = self.techniqueDBS(velRadial0, theta_x, theta_y, azimuth, correctFactor, horizontalOnly, heightRange, SNR) #DBS Function - dataOut.initUtcTime = dataOut.ltctime - dataOut.windsInterval = dataOut.timeInterval elif technique == 'SA': diff --git a/schainpy/test/WindProfiler_DBS01.py b/schainpy/test/WindProfiler_DBS01.py index d00db07..21843e9 100644 --- a/schainpy/test/WindProfiler_DBS01.py +++ b/schainpy/test/WindProfiler_DBS01.py @@ -28,8 +28,8 @@ controllerObj.setup(id = '191', name='test01', description=desc) #2014051 20 Feb 2014 path = '/home/soporte/Data/MST/DBS/d2014051' pathFigure = '/home/soporte/workspace/Graficos/DBS/prueba1/' -xmin = '0.0' -xmax = '8.0' +xmin = '0' +xmax = '7.5' startTime = '00:00:00' filehdf5 = "DBS_2014051.hdf5" @@ -108,6 +108,17 @@ opObj21.addParameter(name='save', value='1', format='bool') opObj21.addParameter(name='figpath', value=pathFigure, format='str') opObj21.addParameter(name='zmin', value='5', format='int') opObj21.addParameter(name='zmax', value='90', format='int') + +opObj21 = procUnitConfObj2.addOperation(name='RadialVelocityPlot', optype='other') +opObj21.addParameter(name='id', value='5', format='int') +opObj21.addParameter(name='wintitle', value='Radial Velocity Plot', format='str') +opObj21.addParameter(name='save', value='1', format='bool') +opObj21.addParameter(name='figpath', value=pathFigure, format='str') +opObj21.addParameter(name='SNRmin', value='-10', format='int') +opObj21.addParameter(name='SNRmax', value='60', format='int') +opObj21.addParameter(name='SNRthresh', value='0', format='float') +opObj21.addParameter(name='xmin', value=xmin, format='float') +opObj21.addParameter(name='xmax', value=xmax, format='float') opObj22 = procUnitConfObj2.addOperation(name='WindProfiler', optype='other') opObj22.addParameter(name='technique', value='DBS', format='str') diff --git a/schainpy/test/WindProfiler_SA01.py b/schainpy/test/WindProfiler_SA01.py index 15babd8..493ecc0 100644 --- a/schainpy/test/WindProfiler_SA01.py +++ b/schainpy/test/WindProfiler_SA01.py @@ -19,20 +19,20 @@ controllerObj.setup(id = '191', name='test01', description=desc) #Experimentos #2014050 19 Feb 2014 -# path = '/home/soporte/Documents/MST_Data/SA/d2014050' -# pathFigure = '/home/soporte/workspace/Graficos/SA/d2014050_prueba/' -# xmin = '15.5' -# xmax = '23.99999999' -# startTime = '15:30:00' -# filehdf5 = "SA_2014050.hdf5" +path = '/home/soporte/Data/MST/SA/d2014050' +pathFigure = '/home/soporte/workspace/Graficos/SA/new1/' +xmin = '15.5' +xmax = '24' +startTime = '15:30:00' +filehdf5 = "SA_2014050.hdf5" #2014051 20 Feb 2014 -path = '/home/soporte/Data/MST/SA/d2014051' -pathFigure = '/home/soporte/workspace/Graficos/SA/prueba1/' -xmin = '0.0' -xmax = '8.0' -startTime = '06:00:00' -filehdf5 = "SA_2014051.hdf5" +# path = '/home/soporte/Data/MST/SA/d2014051' +# pathFigure = '/home/soporte/workspace/Graficos/SA/new/' +# xmin = '0.0' +# xmax = '8.0' +# startTime = '00:00:00' +# filehdf5 = "SA_2014051.hdf5" readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader', path=path, @@ -63,7 +63,7 @@ opObj11.addParameter(name='maxIndex', value='60', format='float') #--------------------------------------------------------------------------------------------------- procUnitConfObj1 = controllerObj.addProcUnit(datatype='CorrelationProc', inputId=procUnitConfObj0.getId()) # procUnitConfObj1.addParameter(name='pairsList', value='(0,0),(1,1),(2,2),(3,3),(1,0),(2,3)', format='pairsList') -procUnitConfObj1.addParameter(name='pairsList', value='(0,0),(1,1),(2,2),(3,3),(0,3),(0,2),(1,3),(1,2)', format='pairsList') +procUnitConfObj1.addParameter(name='pairsList', value='(0,0),(1,1),(2,2),(3,3),(0,3),(0,2),(1,3),(1,2),(0,1),(2,3)', format='pairsList') procUnitConfObj1.addParameter(name='fullT', value='1', format='bool') procUnitConfObj1.addParameter(name='removeDC', value='1', format='bool') #procUnitConfObj1.addParameter(name='lagT', value='0,1,2,3', format='intlist') @@ -98,7 +98,7 @@ opObj21.addParameter(name='technique', value='SA', format='str') opObj21.addParameter(name='positionX', value='36,0,36,0', format='floatlist') opObj21.addParameter(name='positionY', value='36,0,0,36', format='floatlist') opObj21.addParameter(name='azimuth', value='51.06', format='float') -opObj21.addParameter(name='crosspairsList', value='(0,3),(0,2),(1,3),(1,2)', format='pairsList')#COrregir +opObj21.addParameter(name='crosspairsList', value='(0,3),(0,2),(1,3),(1,2),(0,1),(2,3)', format='pairsList')#COrregir # opObj22 = procUnitConfObj2.addOperation(name='WindProfilerPlot', optype='other') opObj22.addParameter(name='id', value='4', format='int')