From f661d02a930903d8019f259f5d1eef97230f892b 2023-07-11 17:52:01 From: Edson Date: 2023-07-11 17:52:01 Subject: [PATCH] jroplot_parameters.py jroplot_spectra.py jroIO_digitalRF.py jroproc_parameters.py sophy_proc.py --- diff --git a/schainpy/model/graphics/jroplot_parameters.py b/schainpy/model/graphics/jroplot_parameters.py index 6735771..402e282 100644 --- a/schainpy/model/graphics/jroplot_parameters.py +++ b/schainpy/model/graphics/jroplot_parameters.py @@ -528,7 +528,7 @@ class WeatherParamsPlot(Plot): self.nplots= 1 self.ylabel= 'Height [km]' self.xlabel= 'Distance from radar [km]' - + if self.channels is not None: self.nplots = len(self.channels) self.ncols = len(self.channels) @@ -577,9 +577,12 @@ class WeatherParamsPlot(Plot): if hasattr(dataOut, 'dparam'): tmp = getattr(dataOut, 'data_param') else: - + #print("-------------------self.attr_data[0]",self.attr_data[0]) if 'S' in self.attr_data[0]: - tmp = 10*numpy.log10(10.0*getattr(dataOut, 'data_param')[:,0,:]/(factor)) + if self.attr_data[0]=='S': + tmp = 10*numpy.log10(10.0*getattr(dataOut, 'data_param')[:,0,:]/(factor)) + if self.attr_data[0]=='SNR': + tmp = 10*numpy.log10(getattr(dataOut, 'data_param')[:,3,:]) else: tmp = getattr(dataOut, 'data_param')[:,vars[self.attr_data[0]],:] @@ -610,6 +613,12 @@ class WeatherParamsPlot(Plot): data['azi'] = dataOut.data_azi data['ele'] = dataOut.data_ele + + if isinstance(dataOut.mode_op, bytes): + try: + dataOut.mode_op = dataOut.mode_op.decode() + except: + dataOut.mode_op = str(dataOut.mode_op, 'utf-8') data['mode_op'] = dataOut.mode_op self.mode = dataOut.mode_op @@ -634,7 +643,7 @@ class WeatherParamsPlot(Plot): len_aux = int(data['azi'].shape[0]/4) mean = numpy.mean(data['azi'][len_aux:-len_aux]) x, y = r*numpy.cos(theta), r*numpy.sin(theta) - elif data['mode_op'] == 'PPI': + elif data['mode_op'] == 'PPI': r, theta = numpy.meshgrid(r, -numpy.radians(data['azi'])+numpy.pi/2) len_aux = int(data['ele'].shape[0]/4) mean = numpy.mean(data['ele'][len_aux:-len_aux]) @@ -654,7 +663,7 @@ class WeatherParamsPlot(Plot): norm = cb_tables[self.colormap]['norm'] else: norm = None - + for i, ax in enumerate(axes): if data['mode_op'] == 'PPI': ax.set_extent([-75.745893, -74.845893, -12.490436, -11.590436]) @@ -687,6 +696,8 @@ class WeatherParamsPlot(Plot): gl.ylabel_style = {'size': 8} gl.xlabels_top = False gl.ylabels_right = False + #self.shapes="/home/soporte/workspace/sirm/volumes/schain/shapes/" + #print("self.shapes",self.shapes) shape_p = os.path.join(self.shapes,'PER_ADM2/PER_ADM2.shp') shape_d = os.path.join(self.shapes,'PER_ADM1/PER_ADM1.shp') capitales = os.path.join(self.shapes,'CAPITALES/cap_provincia.shp') @@ -695,7 +706,7 @@ class WeatherParamsPlot(Plot): reader_p = shpreader.BasicReader(shape_d, encoding='latin1') reader_c = shpreader.BasicReader(capitales, encoding='latin1') reader_v = shpreader.BasicReader(vias, encoding='latin1') - caps = [x for x in reader_c.records() if x.attributes["Departa"] in ("JUNIN", "LIMA", "AYACUCHO", "HUANCAVELICA")] + caps = [x for x in reader_c.records() if x.attributes["Departa"] in ("JUNIN", "LIMA", "AYACUCHO", "HUANCAVELICA")] districts = [x for x in reader_d.records() if x.attributes["Name"] in ("JUNÍN", "CHANCHAMAYO", "CHUPACA", "CONCEPCIÓN", "HUANCAYO", "JAUJA", "SATIPO", "TARMA", "YAUYOS", "HUAROCHIRÍ", "CANTA", "HUANTA", "TAYACAJA")] provs = [x for x in reader_p.records() if x.attributes["NAME"] in ("Junín", "Lima")] vias = [x for x in reader_v.records() if x.attributes["DEP"] in ("JUNIN", "LIMA")] @@ -713,13 +724,13 @@ class WeatherParamsPlot(Plot): ax.text(cap.attributes['X'], cap.attributes['Y'], cap.attributes['Nombre'].title(), size=7, color='white') ax.text(-75.052003, -11.915552, 'Huaytapallana', size=7, color='cyan') ax.plot(-75.052003, -11.915552, '*') - + for R in (10, 20, 30 , 40, 50): circle = Circle((-75.295893, -12.040436), km2deg(R), facecolor='none', edgecolor='skyblue', linewidth=1, alpha=0.5) ax.add_patch(circle) - ax.text(km2deg(R)*numpy.cos(numpy.radians(45))-75.295893, - km2deg(R)*numpy.sin(numpy.radians(45))-12.040436, + ax.text(km2deg(R)*numpy.cos(numpy.radians(45))-75.295893, + km2deg(R)*numpy.sin(numpy.radians(45))-12.040436, '{}km'.format(R), color='skyblue', size=7) elif data['mode_op'] == 'RHI': ax.grid(color='grey', alpha=0.5, linestyle='--', linewidth=1) diff --git a/schainpy/model/graphics/jroplot_spectra.py b/schainpy/model/graphics/jroplot_spectra.py index b69bb3e..d6de3bd 100644 --- a/schainpy/model/graphics/jroplot_spectra.py +++ b/schainpy/model/graphics/jroplot_spectra.py @@ -43,7 +43,7 @@ class SpectraPlot(Plot): data['spc'] = spc data['rti'] = dataOut.getPower() data['noise'] = 10*numpy.log10(dataOut.getNoise()/dataOut.normFactor) - meta['xrange'] = (dataOut.getFreqRange(1)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(1)) + meta['xrange'] = (dataOut.getFreqRange(0)/1000., dataOut.getAcfRange(1), dataOut.getVelRange(0)) if self.CODE == 'spc_moments': data['moments'] = dataOut.moments diff --git a/schainpy/model/io/jroIO_digitalRF.py b/schainpy/model/io/jroIO_digitalRF.py index 1c16c2e..eef5c5e 100644 --- a/schainpy/model/io/jroIO_digitalRF.py +++ b/schainpy/model/io/jroIO_digitalRF.py @@ -26,6 +26,7 @@ from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation, MPDecora import pickle try: + os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE" import digital_rf except: pass @@ -267,9 +268,14 @@ class DigitalRFReader(ProcessingUnit): self.getByBlock = getByBlock self.nProfileBlocks = nProfileBlocks + if online: + print('Waiting for RF data..') + sleep(40) + if not os.path.isdir(path): raise ValueError("[Reading] Directory %s does not exist" % path) + #print("path",path) try: self.digitalReadObj = digital_rf.DigitalRFReader( path, load_all_metadata=True) @@ -350,29 +356,27 @@ class DigitalRFReader(ProcessingUnit): if startDate: startDatetime = datetime.datetime.combine(startDate, startTime) startUTCSecond = ( - startDatetime - datetime.datetime(1970, 1, 1)).total_seconds() + self.__timezone + startDatetime - datetime.datetime(1970, 1, 1)).total_seconds()# + self.__timezone if endDate: endDatetime = datetime.datetime.combine(endDate, endTime) endUTCSecond = (endDatetime - datetime.datetime(1970, - 1, 1)).total_seconds() + self.__timezone - - - #print(startUTCSecond,endUTCSecond) - start_index, end_index = self.digitalReadObj.get_bounds( - channelNameList[channelList[0]]) - - #print("*****",start_index,end_index) + 1, 1)).total_seconds()# + self.__timezone + start_index, end_index = self.digitalReadObj.get_bounds(channelNameList[channelList[0]]) + if start_index==None or end_index==None: + print("Check error No data, start_index: ",start_index,",end_index: ",end_index) + #return 0 if not startUTCSecond: startUTCSecond = start_index / self.__sample_rate - if start_index > startUTCSecond * self.__sample_rate: startUTCSecond = start_index / self.__sample_rate if not endUTCSecond: endUTCSecond = end_index / self.__sample_rate + if end_index < endUTCSecond * self.__sample_rate: endUTCSecond = end_index / self.__sample_rate #Check UTC and LT time + if not nSamples: if not ippKm: raise ValueError("[Reading] nSamples or ippKm should be defined") @@ -428,6 +432,7 @@ class DigitalRFReader(ProcessingUnit): #self.__data_buffer = numpy.zeros( # (self.__num_subchannels, self.__samples_to_read), dtype=numpy.complex) + print("samplestoread",self.__samples_to_read) self.__data_buffer = numpy.zeros((int(len(channelList)), self.__samples_to_read), dtype=numpy.complex) @@ -442,9 +447,7 @@ class DigitalRFReader(ProcessingUnit): )) print("[Reading] Starting process from %s to %s" % (datetime.datetime.utcfromtimestamp(startUTCSecond - self.__timezone), - datetime.datetime.utcfromtimestamp( - endUTCSecond - self.__timezone) - )) + datetime.datetime.utcfromtimestamp(endUTCSecond - self.__timezone))) self.oldAverage = None self.count = 0 self.executionTime = 0 @@ -532,9 +535,11 @@ class DigitalRFReader(ProcessingUnit): for indexSubchannel in range(self.__num_subchannels): try: t0 = time() + #print("thisUNixSample",self.__thisUnixSample) result = self.digitalReadObj.read_vector_c81d(self.__thisUnixSample, self.__samples_to_read, thisChannelName, sub_channel=indexSubchannel) + #print("result--------------",result) self.executionTime = time() - t0 if self.oldAverage is None: self.oldAverage = self.executionTime @@ -546,7 +551,21 @@ class DigitalRFReader(ProcessingUnit): # read next profile self.__flagDiscontinuousBlock = True print("[Reading] %s" % datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), e) - break + bot = 0 + while(self.__flagDiscontinuousBlock): + bot +=1 + self.__thisUnixSample += self.__sample_rate + try: + result = result = self.digitalReadObj.read_vector_c81d(self.__thisUnixSample,self.__samples_to_read,thisChannelName, sub_channel=indexSubchannel) + self.__flagDiscontinuousBlock=False + print("Searching.. N°: ",bot,"Success",self.__thisUnixSample) + except: + print("Searching...N°: ",bot,"Fail", self.__thisUnixSample) + if self.__flagDiscontinuousBlock==True: + break + else: + print("New data index found...",self.__thisUnixSample) + #break if result.shape[0] != self.__samples_to_read: self.__flagDiscontinuousBlock = True diff --git a/schainpy/model/proc/jroproc_parameters.py b/schainpy/model/proc/jroproc_parameters.py index 9485503..0368255 100644 --- a/schainpy/model/proc/jroproc_parameters.py +++ b/schainpy/model/proc/jroproc_parameters.py @@ -3950,7 +3950,9 @@ class WeatherRadar(Operation): self.nHeis = dataOut.nHeights self.min_index= min_index deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] - self.Range = numpy.arange(dataOut.nHeights)*deltaHeight + dataOut.heightList[0]+min_index*deltaHeight + #self.Range = numpy.arange(dataOut.nHeights)*deltaHeight + dataOut.heightList[0]+min_index*deltaHeight + self.Range = dataOut.heightList + print(self.Range, flush=True) self.Range = self.Range.reshape(1,self.nHeis) self.Range = numpy.tile(self.Range,[self.nCh,1]) '''-----------1 Constante del Radar----------''' diff --git a/schainpy/scripts/sophy_proc.py b/schainpy/scripts/sophy_proc.py index ba5a952..e9b8442 100644 --- a/schainpy/scripts/sophy_proc.py +++ b/schainpy/scripts/sophy_proc.py @@ -214,7 +214,7 @@ def main(args): opObj10 = proc1.addOperation(name="WeatherRadar") opObj10.addParameter(name='tauW',value=(1e-6/sample_rate)*len(code[0])) - opObj10.addParameter(name='Pt',value=((1e-6/sample_rate)*len(code[0])/ipp)*200) + opObj10.addParameter(name='Pt',value=200) op = proc1.addOperation(name='PedestalInformation') op.addParameter(name='path', value=path_ped, format='str') @@ -266,7 +266,7 @@ def main(args): opObj10 = proc2.addOperation(name="WeatherRadar") opObj10.addParameter(name='tauW',value=(1e-6/sample_rate)*len(code[0])) - opObj10.addParameter(name='Pt',value=((1e-6/sample_rate)*len(code[0])/ipp)*200) + opObj10.addParameter(name='Pt',value=200) op = proc2.addOperation(name='PedestalInformation') op.addParameter(name='path', value=path_ped, format='str')