From 52714d4d854d262e8ff0732952011dce6fc8956c 2022-05-06 15:24:26 From: Roberto Flores Date: 2022-05-06 15:24:26 Subject: [PATCH] HDFWriter writes standard Weather parameters/Now we can run a type OTHER Operation even if flagNoData is True --- diff --git a/schainpy/model/io/jroIO_digitalRF.py b/schainpy/model/io/jroIO_digitalRF.py index 985324b..d260d37 100644 --- a/schainpy/model/io/jroIO_digitalRF.py +++ b/schainpy/model/io/jroIO_digitalRF.py @@ -408,6 +408,7 @@ class DigitalRFReader(ProcessingUnit): self.__samples_to_read = int(nSamples) # FIJO: AHORA 40 + #self.__samples_to_read = int(1000000) # FIJO: AHORA 40 self.__nChannels = len(self.__channelList) #print("------------------------------------------") #print("self.__samples_to_read",self.__samples_to_read) @@ -522,6 +523,8 @@ class DigitalRFReader(ProcessingUnit): for indexSubchannel in range(self.__num_subchannels): try: t0 = time() + #print("Unitindex",self.__thisUnixSample) + #print("__samples_to_read",self.__samples_to_read) result = self.digitalReadObj.read_vector_c81d(self.__thisUnixSample, self.__samples_to_read, thisChannelName, sub_channel=indexSubchannel) @@ -634,6 +637,7 @@ class DigitalRFReader(ProcessingUnit): # ojo debo anadir el readNextBLock y el __isBufferEmpty( self.dataOut.flagNoData = False buffer = self.__data_buffer[:,self.__bufferIndex:self.__bufferIndex + self.__samples_to_read] + #print("test",self.__bufferIndex) buffer = buffer.reshape((self.__nChannels, self.nProfileBlocks, int(self.__samples_to_read/self.nProfileBlocks))) self.dataOut.nProfileBlocks = self.nProfileBlocks self.dataOut.data = buffer diff --git a/schainpy/model/io/jroIO_param.py b/schainpy/model/io/jroIO_param.py index b5cc156..d0b6db7 100644 --- a/schainpy/model/io/jroIO_param.py +++ b/schainpy/model/io/jroIO_param.py @@ -482,6 +482,8 @@ class HDFWriter(Operation): self.dataOut = dataOut self.mode = mode + self.var = dataList[0] + if not(self.isConfig): self.setup(path=path, blocksPerFile=blocksPerFile, metadataList=metadataList, dataList=dataList, @@ -532,33 +534,47 @@ class HDFWriter(Operation): setFile, ext ) elif self.setType == "weather": - print("HOLA AMIGOS") - wr_exp = self.dataOut.wr_exp - if wr_exp== "PPI": - wr_type = 'E' - ang_ = numpy.mean(self.dataOut.elevation) - else: - wr_type = 'A' - ang_ = numpy.mean(self.dataOut.azimuth) - - wr_writer = '%s%s%2.1f%s'%('-', - wr_type, - ang_, - '-') - ###print("wr_writer********************",wr_writer) - file = '%s%4.4d%2.2d%2.2d%s%2.2d%2.2d%2.2d%s%s%s' % (self.optchar, - timeTuple.tm_year, - timeTuple.tm_mon, - timeTuple.tm_mday, - '-', - timeTuple.tm_hour, - timeTuple.tm_min, - timeTuple.tm_sec, - wr_writer, - type_data, - ext ) - ###print("FILENAME", file) + if self.var.lower() == 'Zdb'.lower(): + wr_type = 'Z' + elif self.var.lower() == 'Zdb_D'.lower(): + wr_type = 'D' + elif self.var.lower() == 'PhiD_P'.lower(): + wr_type = 'P' + elif self.var.lower() == 'RhoHV_R'.lower(): + wr_type = 'R' + elif self.var.lower() == 'velRadial_V'.lower(): + wr_type = 'V' + elif self.var.lower() == 'Sigmav_W'.lower(): + wr_type = 'S' + elif self.var.lower() == 'dataPP_POWER'.lower(): + wr_type = 'Pow' + elif self.var.lower() == 'dataPP_DOP'.lower(): + wr_type = 'Dop' + + + #Z_SOPHy_El10.0_20200505_14:02:15.h5 + #Z_SOPHy_Az40.0_20200505_14:02:15.h5 + if self.dataOut.flagMode == 1: #'AZI' #PPI + ang_type = 'El' + ang_ = round(numpy.mean(self.dataOut.data_ele),1) + elif self.dataOut.flagMode == 0: #'ELE' #RHI + ang_type = 'Az' + ang_ = round(numpy.mean(self.dataOut.data_azi),1) + + file = '%s%s%s%2.1f%s%2.2d%2.2d%2.2d%s%2.2d%2.2d%2.2d%s' % (wr_type, + '_SOPHy_', + ang_type, + ang_, + '_', + timeTuple.tm_year, + timeTuple.tm_mon, + timeTuple.tm_mday, + '_', + timeTuple.tm_hour, + timeTuple.tm_min, + timeTuple.tm_sec, + ext ) else: setFile = timeTuple.tm_hour*60+timeTuple.tm_min @@ -571,7 +587,7 @@ class HDFWriter(Operation): self.filename = os.path.join( path, subfolder, file ) #Setting HDF5 File - + print("filename",self.filename) self.fp = h5py.File(self.filename, 'w') #write metadata self.writeMetadata(self.fp) @@ -682,6 +698,7 @@ class HDFWriter(Operation): return def putData(self): + if (self.blockIndex == self.blocksPerFile) or self.timeFlag():# or self.generalFlag_vRF(): self.closeFile() self.setNextFile() diff --git a/schainpy/model/proc/jroproc_base.py b/schainpy/model/proc/jroproc_base.py index 3661ec6..c6e75a1 100644 --- a/schainpy/model/proc/jroproc_base.py +++ b/schainpy/model/proc/jroproc_base.py @@ -86,7 +86,17 @@ class ProcessingUnit(object): ##### correcion de la declaracion Out for op, optype, opkwargs in self.operations: aux = self.dataOut.copy() - if optype == 'other' and not self.dataOut.flagNoData: + ''' + print("op",op) + try: + print("runNextOp",self.dataOut.runNextOp) + except: + pass + ''' + if not hasattr(self.dataOut, 'runNextOp'): + self.dataOut.runNextOp = False + if optype == 'other' and (not self.dataOut.flagNoData or self.dataOut.runNextOp): + #if optype == 'other' and not self.dataOut.flagNoData: self.dataOut = op.run(self.dataOut, **opkwargs) elif optype == 'external' and not self.dataOut.flagNoData: #op.queue.put(self.dataOut) diff --git a/schainpy/model/proc/jroproc_parameters.py b/schainpy/model/proc/jroproc_parameters.py index 1867c52..ad65b28 100755 --- a/schainpy/model/proc/jroproc_parameters.py +++ b/schainpy/model/proc/jroproc_parameters.py @@ -4882,7 +4882,7 @@ class Block360_vRF4(Operation): Add a profile to he __buffer and increase in one the __profiel Index ''' tmp= getattr(data, attr) - if tmp.shape[0] is not 2: + if tmp.shape[0] != 2: size_tmp= tmp.shape[0] tmp=tmp.reshape(1,size_tmp) @@ -4993,9 +4993,10 @@ class Block360_vRF4(Operation): if diff_angle > 0: #Subida return 0 - def run(self, dataOut, attr_data='dataPP_POWER', axis=None,**kwargs): + def run(self, dataOut, attr_data='dataPP_POWER', axis=None, runNextOp = False,**kwargs): dataOut.attr_data = attr_data + dataOut.runNextOp = runNextOp dataOut.flagMode = axis[0] #Provisional, debería venir del header @@ -5013,7 +5014,7 @@ class Block360_vRF4(Operation): dataOut.data_ele = data_e dataOut.utctime = avgdatatime dataOut.flagNoData = False - print("********************attr_data********************",attr_data) + #print("********************attr_data********************",attr_data) #print(data_360.shape) #print(dataOut.heightList) diff --git a/schainpy/model/proc/jroproc_voltage.py b/schainpy/model/proc/jroproc_voltage.py index d439ad6..d7adca0 100644 --- a/schainpy/model/proc/jroproc_voltage.py +++ b/schainpy/model/proc/jroproc_voltage.py @@ -669,7 +669,7 @@ class CohInt(Operation): if not dataOut.flagCohInt: dataOut.nCohInt *= self.n dataOut.flagCohInt = True - dataOut.utctime = avgdatatime + ####################################dataOut.utctime = avgdatatime # print avgdata, avgdatatime # raise # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt @@ -1696,7 +1696,8 @@ class PulsePair_vRF(Operation): def run(self, dataOut,n = None,removeDC= False, overlapping= False,**kwargs): if dataOut.flagDataAsBlock: - n = dataOut.nProfiles + n = int(dataOut.nProfiles) + #print("n",n) if not self.isConfig: self.setup(dataOut = dataOut, n = n , removeDC=removeDC , **kwargs)