diff --git a/schainpy/model/graphics/jroplot_base.py b/schainpy/model/graphics/jroplot_base.py index 55ee988..f418f90 100644 --- a/schainpy/model/graphics/jroplot_base.py +++ b/schainpy/model/graphics/jroplot_base.py @@ -257,6 +257,7 @@ class Plot(Operation): self.mode = kwargs.get('mode', None) + if self.server: if not self.server.startswith('tcp://'): self.server = 'tcp://{}'.format(self.server) @@ -514,6 +515,7 @@ class Plot(Operation): self.save_time = self.data.max_time fig = self.figures[n] + print("save_code",self.save_code) if self.throttle == 0: if self.oneFigure: figname = os.path.join( diff --git a/schainpy/model/graphics/jroplot_parameters.py b/schainpy/model/graphics/jroplot_parameters.py index b620bed..57a2844 100644 --- a/schainpy/model/graphics/jroplot_parameters.py +++ b/schainpy/model/graphics/jroplot_parameters.py @@ -7,7 +7,7 @@ from schainpy.model.graphics.jroplot_base import Plot, plt from schainpy.model.graphics.jroplot_spectra import SpectraPlot, RTIPlot, CoherencePlot, SpectraCutPlot from schainpy.utils import log # libreria wradlib -import wradlib as wrl +#import wradlib as wrl EARTH_RADIUS = 6.3710e3 @@ -1176,7 +1176,11 @@ class Weather_vRF_Plot(Plot): r = numpy.arange(len(r_mask))*delta_height self.y = 2*r - z = data['data'][self.channels[0]][:,r_mask] + try: + z = data['data'][self.channels[0]][:,r_mask] + + except: + z = data['data'][0][:,r_mask] self.titles = [] @@ -1791,3 +1795,138 @@ class WeatherRHI_vRF4_Plot(Plot): self.titles = ['RHI {} at AZ: {} Channel {}'.format(self.labels[x], str(round(numpy.mean(data['azi']),1)), x) for x in range(self.nrows)] else: self.titles = ['RHI {} at AZ: {} Channel {}'.format(self.labels[0], str(round(numpy.mean(data['azi']),1)), self.channels[0])] + +class WeatherParamsPlot(Plot): + #CODE = 'RHI' + #plot_name = 'RHI' + #plot_type = 'rhistyle' + buffering = False + + def setup(self): + + self.ncols = 1 + self.nrows = 1 + self.nplots= 1 + self.ylabel= 'Range [Km]' + self.xlabel= 'Range [Km]' + self.polar = True + self.grid = True + if self.channels is not None: + self.nplots = len(self.channels) + self.nrows = len(self.channels) + else: + self.nplots = self.data.shape(self.CODE)[0] + self.nrows = self.nplots + self.channels = list(range(self.nplots)) + + self.colorbar=True + self.width =8 + self.height =8 + self.ini =0 + self.len_azi =0 + self.buffer_ini = None + self.buffer_ele = None + self.plots_adjust.update({'wspace': 0.4, 'hspace':0.4, 'left': 0.1, 'right': 0.9, 'bottom': 0.08}) + self.flag =0 + self.indicador= 0 + self.last_data_ele = None + self.val_mean = None + + def update(self, dataOut): + + data = {} + meta = {} + if hasattr(dataOut, 'dataPP_POWER'): + factor = 1 + if hasattr(dataOut, 'nFFTPoints'): + factor = dataOut.normFactor + + if 'pow' in self.attr_data[0].lower(): + data['data'] = 10*numpy.log10(getattr(dataOut, self.attr_data[0])/(factor)) + else: + data['data'] = getattr(dataOut, self.attr_data[0])/(factor) + + if dataOut.mode_op == 'PPI': + self.CODE = 'PPI' + self.title = self.CODE + elif dataOut.mode_op == 'RHI': + self.CODE = 'RHI' + self.title = self.CODE + + data['azi'] = dataOut.data_azi + data['ele'] = dataOut.data_ele + data['mode_op'] = dataOut.mode_op + + return data, meta + + def plot(self): + data = self.data[-1] + r = self.data.yrange + delta_height = r[1]-r[0] + r_mask = numpy.where(r>=0)[0] + self.r_mask =r_mask + r = numpy.arange(len(r_mask))*delta_height + self.y = 2*r + + try: + z = data['data'][self.channels[0]][:,r_mask] + except: + z = data['data'][0][:,r_mask] + + self.titles = [] + + self.ymax = self.ymax if self.ymax else numpy.nanmax(r) + self.ymin = self.ymin if self.ymin else numpy.nanmin(r) + self.zmax = self.zmax if self.zmax else numpy.nanmax(z) + self.zmin = self.zmin if self.zmin else numpy.nanmin(z) + print("mode inside plot",self.data['mode_op'],data['mode_op']) + if data['mode_op'] == 'RHI': + try: + if self.data['mode_op'][-2] == 'PPI': + self.ang_min = None + self.ang_max = None + except: + pass + self.ang_min = self.ang_min if self.ang_min else 0 + self.ang_max = self.ang_max if self.ang_max else 90 + r, theta = numpy.meshgrid(r, numpy.radians(data['ele']) ) + elif data['mode_op'] == 'PPI': + try: + if self.data['mode_op'][-2] == 'RHI': + self.ang_min = None + self.ang_max = None + except: + pass + self.ang_min = self.ang_min if self.ang_min else 0 + self.ang_max = self.ang_max if self.ang_max else 360 + r, theta = numpy.meshgrid(r, numpy.radians(data['azi']) ) + + self.clear_figures() + + for i,ax in enumerate(self.axes): + + if ax.firsttime: + ax.set_xlim(numpy.radians(self.ang_min),numpy.radians(self.ang_max)) + ax.plt = ax.pcolormesh(theta, r, z, cmap=self.colormap, vmin=self.zmin, vmax=self.zmax) + if data['mode_op'] == 'PPI': + ax.set_theta_direction(-1) + else: + ax.set_xlim(numpy.radians(self.ang_min),numpy.radians(self.ang_max)) + ax.plt = ax.pcolormesh(theta, r, z, cmap=self.colormap, vmin=self.zmin, vmax=self.zmax) + if data['mode_op'] == 'PPI': + ax.set_theta_direction(-1) + ax.grid(True) + if data['mode_op'] == 'RHI': + len_aux = int(data['azi'].shape[0]/4) + mean = numpy.mean(data['azi'][len_aux:-len_aux]) + if len(self.channels) !=1: + self.titles = ['RHI {} at AZ: {} Channel {}'.format(self.labels[x], str(round(mean,1)), x) for x in range(self.nrows)] + else: + self.titles = ['RHI {} at AZ: {} Channel {}'.format(self.labels[0], str(round(mean,1)), self.channels[0])] + elif data['mode_op'] == 'PPI': + len_aux = int(data['ele'].shape[0]/4) + mean = numpy.mean(data['ele'][len_aux:-len_aux]) + if len(self.channels) !=1: + self.titles = ['PPI {} at EL: {} Channel {}'.format(self.self.labels[x], str(round(mean,1)), x) for x in range(self.nrows)] + else: + self.titles = ['PPI {} at EL: {} Channel {}'.format(self.labels[0], str(round(mean,1)), self.channels[0])] diff --git a/schainpy/model/io/jroIO_digitalRF.py b/schainpy/model/io/jroIO_digitalRF.py index d260d37..985324b 100644 --- a/schainpy/model/io/jroIO_digitalRF.py +++ b/schainpy/model/io/jroIO_digitalRF.py @@ -408,7 +408,6 @@ 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) @@ -523,8 +522,6 @@ 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) @@ -637,7 +634,6 @@ 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 d0b6db7..d2666d5 100644 --- a/schainpy/model/io/jroIO_param.py +++ b/schainpy/model/io/jroIO_param.py @@ -557,10 +557,14 @@ class HDFWriter(Operation): #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) + len_aux = int(self.dataOut.data_ele.shape[0]/4) + mean = numpy.mean(self.dataOut.data_ele[len_aux:-len:aux]) + ang_ = round(mean,1) elif self.dataOut.flagMode == 0: #'ELE' #RHI ang_type = 'Az' - ang_ = round(numpy.mean(self.dataOut.data_azi),1) + len_aux = int(self.dataOut.data_azi.shape[0]/4) + mean = numpy.mean(self.dataOut.data_azi[len_aux:-len:aux]) + ang_ = round(mean,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_', @@ -587,7 +591,7 @@ class HDFWriter(Operation): self.filename = os.path.join( path, subfolder, file ) #Setting HDF5 File - print("filename",self.filename) + #print("filename",self.filename) self.fp = h5py.File(self.filename, 'w') #write metadata self.writeMetadata(self.fp) diff --git a/schainpy/model/proc/jroproc_parameters.py b/schainpy/model/proc/jroproc_parameters.py old mode 100755 new mode 100644 index ad65b28..27aec73 --- a/schainpy/model/proc/jroproc_parameters.py +++ b/schainpy/model/proc/jroproc_parameters.py @@ -143,6 +143,8 @@ class ParametersProc(ProcessingUnit): if hasattr(self.dataIn, 'dataPP_CCF'): self.dataOut.dataPP_CCF = self.dataIn.dataPP_CCF + if hasattr(self.dataIn, 'flagAskMode'): + self.dataOut.flagAskMode = self.dataIn.flagAskMode return @@ -3927,7 +3929,7 @@ class WeatherRadar(Operation): def setup(self,dataOut,variableList= None,Pt=0,Gt=0,Gr=0,Glna=0,lambda_=0, aL=0, tauW= 0,thetaT=0,thetaR=0,Km =0): - print("INICIO") + self.nCh = dataOut.nChannels self.nHeis = dataOut.nHeights deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] @@ -3950,7 +3952,7 @@ class WeatherRadar(Operation): self.RadarConstant = Numerator/Denominator if self.variableList== None: self.variableList= ['Reflectividad','ReflectividadDiferencial','CoeficienteCorrelacion','FaseDiferencial','VelocidadRadial','AnchoEspectral'] - print('FIN') + def setMoments(self,dataOut,i): type = dataOut.inputUnit @@ -4013,7 +4015,7 @@ class WeatherRadar(Operation): self.n_radar = numpy.zeros((self.nCh,self.nHeis)) self.Z_radar = numpy.zeros((self.nCh,self.nHeis)) for R in range(self.nHeis): - self.n_radar[:,R] = self.RadarConstant*Pr[:,R]* (self.Range[:,R])**2 + self.n_radar[:,R] = self.RadarConstant*Pr[:,R]* (self.Range[:,R])**2*(10**-10.246) self.Z_radar[:,R] = self.n_radar[:,R]* self.lambda_**4/( numpy.pi**5 * self.Km**2) @@ -4035,8 +4037,8 @@ class WeatherRadar(Operation): return Sigmav_W - def run(self,dataOut,variableList=variableList,Pt=0.158,Gt=38.5,Gr=38.5,Glna=70.0,lambda_=0.032, aL=1, - tauW= 0.2*1e-6,thetaT=0.0314,thetaR=0.0314,Km =0.93): + def run(self,dataOut,variableList=variableList,Pt=1.58,Gt=38.5,Gr=38.5,Glna=70.0,lambda_=0.032, aL=1, + tauW= 0.2,thetaT=0.0314,thetaR=0.0314,Km =0.93): if not self.isConfig: self.setup(dataOut= dataOut,variableList=variableList,Pt=Pt,Gt=Gt,Gr=Gr,Glna=Glna,lambda_=lambda_, aL=aL, @@ -4045,7 +4047,6 @@ class WeatherRadar(Operation): for i in range(len(self.variableList)): if self.variableList[i]=='Reflectividad': dataOut.Zdb =self.getReflectividad_D(dataOut=dataOut,type='N') - print(dataOut.Zdb) if self.variableList[i]=='ReflectividadDiferencial': dataOut.Zdb_D =self.getReflectividad_D(dataOut=dataOut,type='D') if self.variableList[i]=='FaseDiferencial': @@ -4116,14 +4117,76 @@ class PedestalInformation(Operation): log.error('No new position files found in {}'.format(path)) raise IOError('No new position files found in {}'.format(path)) + def find_mode(self,index): + sample_max = 20 + start = index + flag_mode = None + azi = self.fp['Data']['azi_pos'][:] + ele = self.fp['Data']['ele_pos'][:] + #print("az: ",az) + #exit(1) + while True: + if start+sample_max > numpy.shape(ele)[0]: + print("CANNOT KNOW IF MODE IS PPI OR RHI, ANALIZE NEXT FILE") + print("ele",ele[start-sample_max:start+sample_max]) + print("azi",ele[start-sample_max:start+sample_max]) + if sample_max == 10: + break + else: + sample_max = 10 + continue + sigma_ele = numpy.nanstd(ele[start:start+sample_max]) + sigma_azi = numpy.nanstd(azi[start:start+sample_max]) + print("Start",start) + print("ele",ele[start:start+sample_max]) + print("s_ele",sigma_ele) + print("azi",azi[start:start+sample_max]) + print("s_azi",sigma_azi) + #print(start) + if sigma_ele<.5 and sigma_azi<.5: + if sigma_ele 1: case_flag = self.checkcase(angles,flagMode) @@ -4993,12 +5066,17 @@ class Block360_vRF4(Operation): if diff_angle > 0: #Subida return 0 - def run(self, dataOut, attr_data='dataPP_POWER', axis=None, runNextOp = False,**kwargs): + def run(self, dataOut, attr_data='dataPP_POWER', runNextOp = False,**kwargs): dataOut.attr_data = attr_data dataOut.runNextOp = runNextOp - - dataOut.flagMode = axis[0] #Provisional, debería venir del header + dataOut.flagAskMode = False + #print("Block 360") + #dataOut.flagMode = axis[0] #Provisional, debería venir del header + if dataOut.mode_op == 'PPI': + dataOut.flagMode = 1 + elif dataOut.mode_op == 'RHI': + dataOut.flagMode = 0 if not self.isConfig: self.setup(dataOut = dataOut, attr = attr_data ,**kwargs) @@ -5014,6 +5092,9 @@ class Block360_vRF4(Operation): dataOut.data_ele = data_e dataOut.utctime = avgdatatime dataOut.flagNoData = False + dataOut.flagAskMode = True + print("AZI: ",dataOut.data_azi) + print("ELE: ",dataOut.data_ele) #print("********************attr_data********************",attr_data) #print(data_360.shape) #print(dataOut.heightList) diff --git a/schainpy/scripts/sophy_proc_tmp.py b/schainpy/scripts/sophy_proc_tmp.py index 8d6e960..4022acf 100644 --- a/schainpy/scripts/sophy_proc_tmp.py +++ b/schainpy/scripts/sophy_proc_tmp.py @@ -7,12 +7,12 @@ PATH = '/DATA_RM/DATA' # PATH = '/Users/jespinoza/workspace/data/' PARAM = { - 'P': {'name': 'dataPP_POWER', 'zmin': 35, 'zmax': 60, 'colormap': 'viridis', 'label': 'Power', 'cb_label': 'dB'}, + 'P': {'name': 'dataPP_POWER', 'zmin': 35, 'zmax': 60, 'colormap': 'jet', 'label': 'Power', 'cb_label': 'dB'}, 'V': {'name': 'dataPP_DOP', 'zmin': -20, 'zmax': 20, 'colormap': 'seismic', 'label': 'Velocity', 'cb_label': 'm/s'}, 'RH': {'name': 'RhoHV_R', 'zmin': 0, 'zmax': 1, 'colormap': 'jet', 'label': 'CoeficienteCorrelacion', 'cb_label': '*'}, 'FD': {'name': 'PhiD_P', 'zmin': -180, 'zmax': 180, 'colormap': 'RdBu_r', 'label': 'Fase Diferencial', 'cb_label': 'º'}, 'ZD': {'name': 'Zdb_D', 'zmin': -20, 'zmax': 80, 'colormap': 'viridis', 'label': 'ReflectividadDiferencial', 'cb_label': 'dB'}, - 'Z': {'name': 'Zdb', 'zmin': 100, 'zmax': 200, 'colormap': 'viridis', 'label': 'Reflectividad', 'cb_label': 'dB'}, + 'Z': {'name': 'Zdb', 'zmin': -20, 'zmax': 60, 'colormap': 'viridis', 'label': 'Reflectividad', 'cb_label': 'dB'}, 'W': {'name': 'Sigmav_W', 'zmin': -20, 'zmax': 60, 'colormap': 'viridis', 'label': 'AnchoEspectral', 'cb_label': 'hz'} } #Z,ZD 'mm^6/m^3'