diff --git a/schainpy/model/graphics/jroplot_parameters.py b/schainpy/model/graphics/jroplot_parameters.py index c479390..60c25fd 100644 --- a/schainpy/model/graphics/jroplot_parameters.py +++ b/schainpy/model/graphics/jroplot_parameters.py @@ -111,8 +111,8 @@ class MomentsPlot(Figure): channelIndexList.append(dataOut.channelList.index(channel)) factor = dataOut.normFactor - x = dataOut.abscissaRange - y = dataOut.heightRange + x = dataOut.abscissaList + y = dataOut.heightList z = dataOut.data_pre[channelIndexList,:,:]/factor z = numpy.where(numpy.isfinite(z), z, numpy.NAN) @@ -452,8 +452,8 @@ class WindProfilerPlot(Figure): tmax = None x = dataOut.getTimeRange1() -# y = dataOut.heightRange - y = dataOut.heightRange +# y = dataOut.heightList + y = dataOut.heightList z = dataOut.data_output.copy() nplots = z.shape[0] #Number of wind dimensions estimated @@ -649,8 +649,8 @@ class ParametersPlot(Figure): 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, onlyPositive = False, - zlabel = "", parameterName = "", + parameterIndex = None, onlyPositive = False, + zlabel = "", parameterName = "", parameterObject = "data_param", 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): @@ -671,27 +671,25 @@ class ParametersPlot(Figure): zmax : None """ + data_param = getattr(dataOut, parameterObject) + if channelList == None: - channelIndexList = dataOut.channelIndexList + channelIndexList = numpy.arange(data_param.shape[0]) 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)) - + channelIndexList = numpy.array(channelIndexList) + if timerange != None: self.timerange = timerange #tmin = None #tmax = None - if paramIndex == None: - paramIndex = 1 + if parameterIndex == None: + parameterIndex = 1 x = dataOut.getTimeRange1() - y = dataOut.heightRange - z = dataOut.data_param[channelIndexList,paramIndex,:].copy() + y = dataOut.heightList + z = data_param[channelIndexList,parameterIndex,:].copy() - zRange = dataOut.abscissaRange + zRange = dataOut.abscissaList nplots = z.shape[0] #Number of wind dimensions estimated # thisDatetime = dataOut.datatime thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) @@ -718,10 +716,6 @@ class ParametersPlot(Figure): if ymax == None: ymax = numpy.nanmax(y) if zmin == None: zmin = numpy.nanmin(zRange) if zmax == None: zmax = numpy.nanmax(zRange) - - if dataOut.data_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 @@ -862,7 +856,7 @@ class SpectralFittingPlot(Figure): cutHeight = dataOut.heightList[heightindex] factor = dataOut.normFactor - x = dataOut.abscissaRange[:-1] + x = dataOut.abscissaList[:-1] #y = dataOut.getHeiRange() z = dataOut.data_pre[:,:,heightindex]/factor @@ -1037,15 +1031,6 @@ class EWDriftsPlot(Figure): 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 @@ -1053,7 +1038,7 @@ class EWDriftsPlot(Figure): tmax = None x = dataOut.getTimeRange1() -# y = dataOut.heightRange +# y = dataOut.heightList y = dataOut.heightList z = dataOut.data_output @@ -1081,7 +1066,7 @@ class EWDriftsPlot(Figure): showprofile = False # thisDatetime = dataOut.datatime - thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) + thisDatetime = datetime.datetime.utcfromtimestamp(x[1]) title = wintitle + " EW Drifts" xlabel = "" ylabel = "Height (Km)" diff --git a/schainpy/model/io/jroIO_HDF5.py b/schainpy/model/io/jroIO_HDF5.py index b86bc96..78e280b 100644 --- a/schainpy/model/io/jroIO_HDF5.py +++ b/schainpy/model/io/jroIO_HDF5.py @@ -17,38 +17,59 @@ class HDF5Reader(ProcessingUnit): timezone = None + secStart = None + + secEnd = None + fileIndex = None blockIndex = None + blocksPerFile = None + path = None + #List of Files + + filenameList = None + + datetimeList = None + #Hdf5 File fpMetadata = None + pathMeta = None + listMetaname = None - listMetadata = None + listMeta = None - fp = None + listDataname = None - #dataOut reconstruction + listData = None + listShapes = None - dataOut = None + fp = None - nChannels = None #Dimension 0 + #dataOut reconstruction - nPoints = None #Dimension 1, number of Points or Parameters + dataOut = None - nSamples = None #Dimension 2, number of samples or ranges + nRecords = None def __init__(self): - + self.dataOut = self.__createObjByDefault() return + + def __createObjByDefault(self): + dataObj = Parameters() + + return dataObj + def setup(self,path=None, startDate=None, endDate=None, @@ -66,11 +87,18 @@ class HDF5Reader(ProcessingUnit): # self.all = all # self.online = online self.path = path - + + startDateTime = datetime.datetime.combine(startDate,startTime) + endDateTime = datetime.datetime.combine(endDate,endTime) + secStart = (startDateTime-datetime.datetime(1970,1,1)).total_seconds() + secEnd = (endDateTime-datetime.datetime(1970,1,1)).total_seconds() + + self.secStart = secStart + self.secEnd = secEnd if not(online): #Busqueda de archivos offline - self.__searchFilesOffline(path, startDate, endDate, ext, startTime, endTime, walk) + self.__searchFilesOffline(path, startDate, endDate, ext, startTime, endTime, secStart, secEnd, walk) else: self.__searchFilesOnline(path, walk) @@ -97,6 +125,8 @@ class HDF5Reader(ProcessingUnit): ext, startTime=datetime.time(0,0,0), endTime=datetime.time(23,59,59), + secStart = 0, + secEnd = numpy.inf, walk=True): # self.__setParameters(path, startDate, endDate, startTime, endTime, walk) @@ -181,7 +211,7 @@ class HDF5Reader(ProcessingUnit): for file in fileList: filename = os.path.join(thisPath,file) - thisDatetime = self.__isFileinThisTime(filename, startTime, endTime) + thisDatetime = self.__isFileinThisTime(filename, secStart, secEnd) if not(thisDatetime): continue @@ -204,7 +234,7 @@ class HDF5Reader(ProcessingUnit): return pathList, filenameList - def __isFileinThisTime(self, filename, startTime, endTime): + def __isFileinThisTime(self, filename, startSeconds, endSeconds): """ Retorna 1 si el archivo de datos se encuentra dentro del rango de horas especificado. @@ -224,8 +254,7 @@ class HDF5Reader(ProcessingUnit): Si la cabecera no puede ser leida. """ - - + try: fp = fp = h5py.File(filename,'r') except IOError: @@ -233,21 +262,20 @@ class HDF5Reader(ProcessingUnit): raise IOError, "The file %s can't be opened" %(filename) grp = fp['Data'] - time = grp['time'] - time0 = time[:][0] + timeAux = grp['time'] + time0 = timeAux[:][0].astype(numpy.float) #Time Vector fp.close() - thisDatetime = datetime.datetime.utcfromtimestamp(time0) - if self.timezone == 'lt': - thisDatetime = thisDatetime - datetime.timedelta(minutes = 300) - - thisTime = thisDatetime.time() - - if not ((startTime <= thisTime) and (endTime > thisTime)): + time0 -= 5*3600 + + boolTimer = numpy.logical_and(time0 >= startSeconds,time0 < endSeconds) + + if not (numpy.any(boolTimer)): return None + thisDatetime = datetime.datetime.utcfromtimestamp(time0[0]) return thisDatetime def __checkPath(self): @@ -264,7 +292,6 @@ class HDF5Reader(ProcessingUnit): idFile += 1 if not(idFile < len(self.filenameList)): - self.flagNoMoreFiles = 1 print "No more Files" return 0 @@ -281,12 +308,57 @@ class HDF5Reader(ProcessingUnit): print "Setting the file: %s"%self.filename self.__readMetadata() - + self.__setBlockList() +# self.nRecords = self.fp['Data'].attrs['blocksPerFile'] + self.nRecords = self.fp['Data'].attrs['nRecords'] + self.blockIndex = 0 return 1 + def __setBlockList(self): + ''' + self.fp + self.startDateTime + self.endDateTime + + self.blockList + self.blocksPerFile + + ''' + filePointer = self.fp + secStart = self.secStart + secEnd = self.secEnd + + grp = filePointer['Data'] + timeVector = grp['time'].value.astype(numpy.float)[0] + + if self.timezone == 'lt': + timeVector -= 5*3600 + + ind = numpy.where(numpy.logical_and(timeVector >= secStart , timeVector < secEnd))[0] + + self.blockList = ind + self.blocksPerFile = len(ind) + + return + def __readMetadata(self): + ''' + self.pathMeta + + self.listShapes + self.listMetaname + self.listMeta + + ''' + grp = self.fp['Data'] - self.pathMeta = os.path.join(self.path, grp.attrs['metadata']) + pathMeta = os.path.join(self.path, grp.attrs['metadata']) + + if pathMeta == self.pathMeta: + return + else: + self.pathMeta = pathMeta + filePointer = h5py.File(self.pathMeta,'r') groupPointer = filePointer['Metadata'] @@ -295,81 +367,172 @@ class HDF5Reader(ProcessingUnit): for item in groupPointer.items(): name = item[0] - if name=='data shape': - self.nSamples = 1 - self.nPoints = 1 - self.nChannels = 1 + if name=='array dimensions': + table = groupPointer[name][:] + listShapes = {} + for shapes in table: + listShapes[shapes[0]] = numpy.array([shapes[1],shapes[2],shapes[3],shapes[4]]) else: - data = groupPointer[name][:] + data = groupPointer[name].value listMetaname.append(name) listMetadata.append(data) if name=='type': - self.__initDataOut(name) + self.__initDataOut(data) filePointer.close() - self.listMetadata = listMetaname - self.listMetadata = listMetadata + self.listShapes = listShapes + self.listMetaname = listMetaname + self.listMeta = listMetadata return + def __readData(self): + grp = self.fp['Data'] + listdataname = [] + listdata = [] + + for item in grp.items(): + name = item[0] + + if name == 'time': + listdataname.append('utctime') + timeAux = grp[name].value.astype(numpy.float)[0] + listdata.append(timeAux) + continue + + listdataname.append(name) + array = self.__setDataArray(self.nRecords, grp[name],self.listShapes[name]) + listdata.append(array) + + self.listDataname = listdataname + self.listData = listdata + return + + def __setDataArray(self, nRecords, dataset, shapes): + + nChannels = shapes[0] #Dimension 0 + + nPoints = shapes[1] #Dimension 1, number of Points or Parameters + + nSamples = shapes[2] #Dimension 2, number of samples or ranges + + mode = shapes[3] + +# if nPoints>1: +# arrayData = numpy.zeros((nRecords,nChannels,nPoints,nSamples)) +# else: +# arrayData = numpy.zeros((nRecords,nChannels,nSamples)) +# +# chn = 'channel' +# +# for i in range(nChannels): +# +# data = dataset[chn + str(i)].value +# +# if nPoints>1: +# data = numpy.rollaxis(data,2) +# +# arrayData[:,i,:] = data + + arrayData = numpy.zeros((nRecords,nChannels,nPoints,nSamples)) + doSqueeze = False + if mode == 0: + strds = 'channel' + nDatas = nChannels + newShapes = (nRecords,nPoints,nSamples) + if nPoints == 1: + doSqueeze = True + axisSqueeze = 2 + else: + strds = 'param' + nDatas = nPoints + newShapes = (nRecords,nChannels,nSamples) + if nChannels == 1: + doSqueeze = True + axisSqueeze = 1 + + for i in range(nDatas): + + data = dataset[strds + str(i)].value + data = data.reshape(newShapes) + + if mode == 0: + arrayData[:,i,:,:] = data + else: + arrayData[:,:,i,:] = data + + if doSqueeze: + arrayData = numpy.squeeze(arrayData, axis=axisSqueeze) + + return arrayData + def __initDataOut(self, type): - if 'type'=='Parameters': - self.dataOut = Parameters() - elif 'type'=='Spectra': - self.dataOut = Spectra() - elif 'type'=='Voltage': - self.dataOut = Voltage() - elif 'type'=='Correlation': - self.dataOut = Correlation() +# if type =='Parameters': +# self.dataOut = Parameters() +# elif type =='Spectra': +# self.dataOut = Spectra() +# elif type =='Voltage': +# self.dataOut = Voltage() +# elif type =='Correlation': +# self.dataOut = Correlation() return def __setDataOut(self): - listMetadata = self.listMetadata + listMeta = self.listMeta listMetaname = self.listMetaname listDataname = self.listDataname listData = self.listData blockIndex = self.blockIndex + blockList = self.blockList - for i in range(len(listMetadata)): - setattr(self.dataOut,listMetaname[i],listMetadata[i]) + for i in range(len(listMeta)): + setattr(self.dataOut,listMetaname[i],listMeta[i]) for j in range(len(listData)): - setattr(self.dataOut,listDataname[j][blockIndex,:],listData[j][blockIndex,:]) + if listDataname[j]=='utctime': +# setattr(self.dataOut,listDataname[j],listData[j][blockList[blockIndex]]) + setattr(self.dataOut,'utctimeInit',listData[j][blockList[blockIndex]]) + continue + + setattr(self.dataOut,listDataname[j],listData[j][blockList[blockIndex],:]) - return + return self.dataOut.data_param def getData(self): - if self.flagNoMoreFiles: - self.dataOut.flagNoData = True - print 'Process finished' - return 0 - - if self.__hasNotDataInBuffer(): - self.__setNextFile() - - - if self.datablock == None: # setear esta condicion cuando no hayan datos por leers - self.dataOut.flagNoData = True - return 0 +# if self.flagNoMoreFiles: +# self.dataOut.flagNoData = True +# print 'Process finished' +# return 0 +# + if self.blockIndex==self.blocksPerFile: + if not( self.__setNextFileOffline() ): + self.dataOut.flagNoData = True + return 0 + +# +# if self.datablock == None: # setear esta condicion cuando no hayan datos por leers +# self.dataOut.flagNoData = True +# return 0 + self.__readData() self.__setDataOut() self.dataOut.flagNoData = False self.blockIndex += 1 - return self.dataOut.data + return def run(self, **kwargs): if not(self.isConfig): self.setup(**kwargs) - self.setObjProperties() +# self.setObjProperties() self.isConfig = True self.getData() @@ -412,11 +575,19 @@ class HDF5Writer(Operation): metadataList = None - dataDim = None + arrayDim = None tableDim = None - dtype = [('arrayName', 'S10'),('nChannels', 'i'), ('nPoints', 'i'), ('nSamples', 'i')] +# dtype = [('arrayName', 'S20'),('nChannels', 'i'), ('nPoints', 'i'), ('nSamples', 'i'),('mode', 'b')] + + dtype = [('arrayName', 'S20'),('nDimensions', 'i'), ('dim2', 'i'), ('dim1', 'i'),('dim0', 'i'),('mode', 'b')] + + mode = None + + nDatas = None #Number of datasets to be stored per array + + nDims = None #Number Dimensions in each dataset def __init__(self): @@ -431,23 +602,31 @@ class HDF5Writer(Operation): if kwargs.has_key('ext'): self.ext = kwargs['ext'] - else: - self.blocksPerFile = 10 - + if kwargs.has_key('blocksPerFile'): self.blocksPerFile = kwargs['blocksPerFile'] else: self.blocksPerFile = 10 + self.metadataList = kwargs['metadataList'] + + self.dataList = kwargs['dataList'] + self.dataOut = dataOut - self.metadataList = ['type','inputUnit','abscissaRange','heightRange'] - - self.dataList = ['data_param', 'data_error', 'data_SNR'] + if kwargs.has_key('mode'): + mode = kwargs['mode'] + + if type(mode) == int: + mode = numpy.zeros(len(self.dataList)) + mode + else: + mode = numpy.zeros(len(self.dataList)) + + self.mode = mode - self.dataDim = numpy.zeros((len(self.dataList),3)) + arrayDim = numpy.zeros((len(self.dataList),5)) - #Data types + #Table dimensions dtype0 = self.dtype @@ -455,18 +634,29 @@ class HDF5Writer(Operation): for i in range(len(self.dataList)): - dataDim = getattr(self.dataOut, self.dataList[i]).shape + dataAux = getattr(self.dataOut, self.dataList[i]) - if len(dataDim) == 3: - self.dataDim[i,:] = numpy.array(dataDim) + if type(dataAux)==float or type(dataAux)==int: + arrayDim[i,0] = 1 else: - self.dataDim[i,0] = numpy.array(dataDim)[0] - self.dataDim[i,2] = numpy.array(dataDim)[1] - self.dataDim[i,1] = 1 + arrayDim0 = dataAux.shape + arrayDim[i,0] = len(arrayDim0) + arrayDim[i,4] = mode[i] - table = numpy.array((self.dataList[i],) + tuple(self.dataDim[i,:]),dtype = dtype0) + if len(arrayDim0) == 3: + arrayDim[i,1:-1] = numpy.array(arrayDim0) + elif len(arrayDim0) == 2: + arrayDim[i,2:-1] = numpy.array(arrayDim0) #nHeights + elif len(arrayDim0) == 1: + arrayDim[i,3] = arrayDim0 + elif len(arrayDim0) == 0: + arrayDim[i,0] = 1 + arrayDim[i,3] = 1 + + table = numpy.array((self.dataList[i],) + tuple(arrayDim[i,:]),dtype = dtype0) tableList.append(table) - + + self.arrayDim = arrayDim self.tableDim = numpy.array(tableList, dtype = dtype0) self.blockIndex = 0 @@ -535,6 +725,7 @@ class HDF5Writer(Operation): ext = self.ext path = self.path setFile = self.setFile + mode = self.mode if self.fp != None: self.fp.close() @@ -576,29 +767,48 @@ class HDF5Writer(Operation): grp = fp.create_group("Data") grp.attrs['metadata'] = self.metaFile - grp['blocksPerFile'] = 0 +# grp.attrs['blocksPerFile'] = 0 ds = [] data = [] - for i in range(len(self.dataList)): + nDatas = numpy.zeros(len(self.dataList)) + nDims = self.arrayDim[:,0] + + for i in range(len(self.dataList)): - grp0 = grp.create_group(self.dataList[i]) - - for j in range(int(self.dataDim[i,0])): - tableName = "channel" + str(j) - - if not(self.dataDim[i,1] == 1): - ds0 = grp0.create_dataset(tableName, (1,1,1) , chunks = True) - else: - ds0 = grp0.create_dataset(tableName, (1,1) , chunks = True) - + if nDims[i]==1: + ds0 = grp.create_dataset(self.dataList[i], (1,1), maxshape=(1,None) , chunks = True, dtype='S20') ds.append(ds0) data.append([]) - - ds0 = grp.create_dataset("time", (1,) , chunks = True) - ds.append(ds0) - data.append([]) + + else: + + if mode[i]==0: + strMode = "channel" + nDatas[i] = self.arrayDim[i,1] + else: + strMode = "param" + nDatas[i] = self.arrayDim[i,2] + + if nDims[i]==2: + nDatas[i] = self.arrayDim[i,2] + + grp0 = grp.create_group(self.dataList[i]) + + for j in range(int(nDatas[i])): + tableName = strMode + str(j) + + if nDims[i] == 3: + ds0 = grp0.create_dataset(tableName, (1,1,1) , maxshape=(None,None,None), chunks=True) + else: + ds0 = grp0.create_dataset(tableName, (1,1) , maxshape=(None,None), chunks=True) + + ds.append(ds0) + data.append([]) + + self.nDatas = nDatas + self.nDims = nDims #Saving variables print 'Writing the file: %s'%filename @@ -624,31 +834,46 @@ class HDF5Writer(Operation): ''' data Array configured + + self.data ''' #Creating Arrays data = self.data + nDatas = self.nDatas + nDims = self.nDims + mode = self.mode ind = 0 + for i in range(len(self.dataList)): dataAux = getattr(self.dataOut,self.dataList[i]) - for j in range(int(self.dataDim[i,0])): - data[ind] = dataAux[j,:] - - if not(self.dataDim[i,1] == 1): - data[ind] = data[ind].reshape((data[ind].shape[0],data[ind].shape[1],1)) - if not self.firsttime: - data[ind] = numpy.dstack((self.ds[ind][:], data[ind])) - else: - data[ind] = data[ind].reshape((1,data[ind].shape[0])) - if not self.firsttime: - data[ind] = numpy.vstack((self.ds[ind][:], data[ind])) + if nDims[i] == 1: + data[ind] = numpy.array([str(dataAux)]).reshape((1,1)) + if not self.firsttime: + data[ind] = numpy.hstack((self.ds[ind][:], self.data[ind])) ind += 1 - data[ind] = numpy.array([self.dataOut.utctime]) - if not self.firsttime: - self.data[ind] = numpy.hstack((self.ds[ind][:], self.data[ind])) + else: + for j in range(int(nDatas[i])): + if (mode[i] == 0) or (nDims[i] == 2): #In case division per channel or Dimensions is only 1 + data[ind] = dataAux[j,:] + else: + data[ind] = dataAux[:,j,:] + + if nDims[i] == 3: + data[ind] = data[ind].reshape((data[ind].shape[0],data[ind].shape[1],1)) + + if not self.firsttime: + data[ind] = numpy.dstack((self.ds[ind][:], data[ind])) + + else: + data[ind] = data[ind].reshape((1,data[ind].shape[0])) + + if not self.firsttime: + data[ind] = numpy.vstack((self.ds[ind][:], data[ind])) + ind += 1 + self.data = data - return def writeBlock(self): @@ -656,12 +881,12 @@ class HDF5Writer(Operation): Saves the block in the HDF5 file ''' for i in range(len(self.ds)): - self.ds[i].shape = self.data[i].shape + self.ds[i].resize(self.data[i].shape) self.ds[i][:] = self.data[i] self.blockIndex += 1 - self.grp.attrs.modify('blocksPerFile', self.blockIndex) + self.grp.attrs.modify('nRecords', self.blockIndex) self.firsttime = False return diff --git a/schainpy/model/proc/jroproc_parameters.py b/schainpy/model/proc/jroproc_parameters.py index ad54b2d..278c9f6 100644 --- a/schainpy/model/proc/jroproc_parameters.py +++ b/schainpy/model/proc/jroproc_parameters.py @@ -22,7 +22,7 @@ class ParametersProc(ProcessingUnit): def __init__(self): ProcessingUnit.__init__(self) - self.objectDict = {} +# self.objectDict = {} self.buffer = None self.firstdatatime = None self.profIndex = 0 @@ -57,7 +57,7 @@ class ParametersProc(ProcessingUnit): self.dataOut.ippSeconds = self.dataIn.ippSeconds # self.dataOut.windowOfFilter = self.dataIn.windowOfFilter self.dataOut.timeInterval = self.dataIn.timeInterval - self.dataOut.heightRange = self.dataIn.getHeiRange() + self.dataOut.heightList = self.dataIn.getHeiRange() self.dataOut.frequency = self.dataIn.frequency def run(self, nSeconds = None, nProfiles = None): @@ -100,7 +100,7 @@ class ParametersProc(ProcessingUnit): if self.dataIn.type == "Spectra": self.dataOut.data_pre = self.dataIn.data_spc.copy() - self.dataOut.abscissaRange = self.dataIn.getVelRange(1) + self.dataOut.abscissaList = self.dataIn.getVelRange(1) self.dataOut.noise = self.dataIn.getNoise() self.dataOut.normFactor = self.dataIn.normFactor self.dataOut.flagNoData = False @@ -112,17 +112,24 @@ class ParametersProc(ProcessingUnit): indR = numpy.where(lagRRange == 0)[0][0] self.dataOut.data_pre = self.dataIn.data_corr.copy()[:,:,indR,:] - self.dataOut.abscissaRange = self.dataIn.getLagTRange(1) + self.dataOut.abscissaList = self.dataIn.getLagTRange(1) self.dataOut.noise = self.dataIn.noise self.dataOut.normFactor = self.dataIn.normFactor self.dataOut.data_SNR = self.dataIn.SNR self.dataOut.groupList = self.dataIn.pairsList self.dataOut.flagNoData = False + + #---------------------- Correlation Data --------------------------- + + if self.dataIn.type == "Parameters": + self.dataOut.copy(self.dataIn) + self.dataOut.flagNoData = False + return True self.__updateObjFromInput() self.firstdatatime = None - self.dataOut.initUtcTime = self.dataIn.ltctime + self.dataOut.utctimeInit = self.dataIn.utctime self.dataOut.outputInterval = self.dataIn.timeInterval #------------------- Get Moments ---------------------------------- @@ -133,7 +140,7 @@ class ParametersProc(ProcessingUnit): Input: channelList : simple channel list to select e.g. [2,3,7] self.dataOut.data_pre - self.dataOut.abscissaRange + self.dataOut.abscissaList self.dataOut.noise Affected: @@ -142,7 +149,7 @@ class ParametersProc(ProcessingUnit): ''' data = self.dataOut.data_pre - absc = self.dataOut.abscissaRange[:-1] + absc = self.dataOut.abscissaList[:-1] noise = self.dataOut.noise data_param = numpy.zeros((data.shape[0], 4, data.shape[2])) @@ -238,7 +245,7 @@ class ParametersProc(ProcessingUnit): Input: self.dataOut.data_pre - self.dataOut.abscissaRange + self.dataOut.abscissaList self.dataOut.noise self.dataOut.normFactor self.dataOut.data_SNR @@ -252,7 +259,7 @@ class ParametersProc(ProcessingUnit): data = self.dataOut.data_pre normFactor = self.dataOut.normFactor nHeights = self.dataOut.nHeights - absc = self.dataOut.abscissaRange[:-1] + absc = self.dataOut.abscissaList[:-1] noise = self.dataOut.noise SNR = self.dataOut.data_SNR pairsList = self.dataOut.groupList @@ -1201,7 +1208,11 @@ class ParametersProc(ProcessingUnit): #Initial values data_spc = self.dataIn.data_spc[coord,:,h] - p0 = numpy.array(self.dataOut.library.initialValuesFunction(data_spc, constants)) + + if (h>0)and(error1[3]<5): + p0 = self.dataOut.data_param[i,:,h-1] + else: + p0 = numpy.array(self.dataOut.library.initialValuesFunction(data_spc, constants, i)) try: #Least Squares @@ -1570,10 +1581,10 @@ class WindProfiler(Operation): def run(self, dataOut, technique, **kwargs): param = dataOut.data_param - if dataOut.abscissaRange != None: - absc = dataOut.abscissaRange[:-1] + if dataOut.abscissaList != None: + absc = dataOut.abscissaList[:-1] noise = dataOut.noise - heightRange = dataOut.getHeiRange() + heightList = dataOut.getHeiRange() SNR = dataOut.data_SNR if technique == 'DBS': @@ -1602,7 +1613,9 @@ class WindProfiler(Operation): theta_y = theta_y[arrayChannel] velRadial0 = param[:,1,:] #Radial velocity - dataOut.data_output, dataOut.heightRange, dataOut.data_SNR = self.techniqueDBS(velRadial0, theta_x, theta_y, azimuth, correctFactor, horizontalOnly, heightRange, SNR) #DBS Function + dataOut.data_output, dataOut.heightList, dataOut.data_SNR = self.techniqueDBS(velRadial0, theta_x, theta_y, azimuth, correctFactor, horizontalOnly, heightList, SNR) #DBS Function + dataOut.utctimeInit = dataOut.utctime + dataOut.outputInterval = dataOut.timeInterval elif technique == 'SA': @@ -1627,7 +1640,7 @@ class WindProfiler(Operation): nChannels = dataOut.nChannels dataOut.data_output = self.techniqueSA(pairs, pairsList, nChannels, tau, azimuth, _lambda, position_x, position_y, absc, correctFactor) - dataOut.initUtcTime = dataOut.ltctime + dataOut.utctimeInit = dataOut.utctime dataOut.outputInterval = dataOut.timeInterval elif technique == 'Meteors': @@ -1656,7 +1669,9 @@ class WindProfiler(Operation): if self.__isConfig == False: # self.__initime = dataOut.datatime.replace(minute = 0, second = 0, microsecond = 03) #Get Initial LTC time - self.__initime = (dataOut.datatime.replace(minute = 0, second = 0, microsecond = 0) - datetime.datetime(1970, 1, 1)).total_seconds() + self.__initime = datetime.datetime.utcfromtimestamp(self.dataOut.utctime) + self.__initime = (self.__initime.replace(minute = 0, second = 0, microsecond = 0) - datetime.datetime(1970, 1, 1)).total_seconds() + self.__isConfig = True if self.__buffer == None: @@ -1666,13 +1681,14 @@ class WindProfiler(Operation): else: self.__buffer = numpy.vstack((self.__buffer, dataOut.data_param)) - self.__checkTime(dataOut.ltctime, dataOut.paramInterval, dataOut.outputInterval) #Check if the buffer is ready + self.__checkTime(dataOut.utctime, dataOut.paramInterval, dataOut.outputInterval) #Check if the buffer is ready if self.__dataReady: - dataOut.initUtcTime = self.__initime - self.__initime = self.__initime + dataOut.outputInterval #to erase time offset + dataOut.utctimeInit = self.__initime + + self.__initime += dataOut.outputInterval #to erase time offset - dataOut.data_output, dataOut.heightRange = self.techniqueMeteors(self.__buffer, meteorThresh, hmin, hmax) + dataOut.data_output, dataOut.heightList = self.techniqueMeteors(self.__buffer, meteorThresh, hmin, hmax) dataOut.flagNoData = False self.__buffer = None @@ -1743,7 +1759,7 @@ class EWDriftsEstimation(Operation): dataOut.data_output = winds dataOut.data_SNR = SNR1 - dataOut.initUtcTime = dataOut.ltctime + dataOut.utctimeInit = dataOut.utctime dataOut.outputInterval = dataOut.timeInterval return