From 42e9a23049f54f69a9a556301d31a10b370a38df 2021-08-19 17:44:36 From: avaldez Date: 2021-08-19 17:44:36 Subject: [PATCH] 19 DE AGOSTO 2021 RM --- diff --git a/schainpy/model/data/jrodata.py b/schainpy/model/data/jrodata.py index fb65348..7d7bec8 100644 --- a/schainpy/model/data/jrodata.py +++ b/schainpy/model/data/jrodata.py @@ -273,13 +273,13 @@ class JROData(GenericData): ''' ''' return self.radarControllerHeaderObj.ippSeconds - + @ippSeconds.setter def ippSeconds(self, ippSeconds): ''' ''' self.radarControllerHeaderObj.ippSeconds = ippSeconds - + @property def code(self): ''' @@ -370,7 +370,7 @@ class Voltage(JROData): self.flagShiftFFT = False self.flagDataAsBlock = False # Asumo que la data es leida perfil a perfil self.profileIndex = 0 - self.metadata_list = ['type', 'heightList', 'timeZone', 'nProfiles', 'channelList', 'nCohInt', + self.metadata_list = ['type', 'heightList', 'timeZone', 'nProfiles', 'channelList', 'nCohInt', 'code', 'nCode', 'nBaud', 'ippSeconds', 'ipp'] def getNoisebyHildebrand(self, channel=None): @@ -461,7 +461,7 @@ class Spectra(JROData): self.ippFactor = 1 self.beacon_heiIndexList = [] self.noise_estimation = None - self.metadata_list = ['type', 'heightList', 'timeZone', 'pairsList', 'channelList', 'nCohInt', + self.metadata_list = ['type', 'heightList', 'timeZone', 'pairsList', 'channelList', 'nCohInt', 'code', 'nCode', 'nBaud', 'ippSeconds', 'ipp','nIncohInt', 'nFFTPoints', 'nProfiles'] def getNoisebyHildebrand(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): @@ -611,7 +611,7 @@ class Spectra(JROData): print("This property should not be initialized") return - + noise = property(getNoise, setValue, "I'm the 'nHeights' property.") @@ -708,7 +708,7 @@ class Fits(JROData): return self.ipp_sec noise = property(getNoise, "I'm the 'nHeights' property.") - + class Correlation(JROData): @@ -966,7 +966,7 @@ class PlotterData(object): ''' self.data[tm] = data - + for key, value in meta.items(): setattr(self, key, value) @@ -1012,7 +1012,7 @@ class PlotterData(object): meta['xrange'] = self.roundFloats(self.xrange[2][::dx].tolist()) else: data = self.roundFloats(self.data[tm][self.key].tolist()) - + ret = { 'plot': plot_name, 'code': self.exp_code, diff --git a/schainpy/model/graphics/jroplot_base.py b/schainpy/model/graphics/jroplot_base.py index 8604ab9..5eb5643 100644 --- a/schainpy/model/graphics/jroplot_base.py +++ b/schainpy/model/graphics/jroplot_base.py @@ -252,7 +252,7 @@ class Plot(Operation): self.__throttle_plot = apply_throttle(self.throttle) code = self.attr_data if self.attr_data else self.CODE self.data = PlotterData(self.CODE, self.exp_code, self.localtime) - + if self.server: if not self.server.startswith('tcp://'): self.server = 'tcp://{}'.format(self.server) @@ -271,7 +271,7 @@ class Plot(Operation): self.setup() - self.time_label = 'LT' if self.localtime else 'UTC' + self.time_label = 'LT' if self.localtime else 'UTC' if self.width is None: self.width = 8 @@ -376,7 +376,7 @@ class Plot(Operation): ''' Set min and max values, labels, ticks and titles ''' - + for n, ax in enumerate(self.axes): if ax.firsttime: if self.xaxis != 'time': @@ -459,14 +459,14 @@ class Plot(Operation): self.plot() self.format() - + for n, fig in enumerate(self.figures): if self.nrows == 0 or self.nplots == 0: log.warning('No data', self.name) fig.text(0.5, 0.5, 'No Data', fontsize='large', ha='center') fig.canvas.manager.set_window_title(self.CODE) continue - + fig.canvas.manager.set_window_title('{} - {}'.format(self.title, self.getDateTime(self.data.max_time).strftime('%Y/%m/%d'))) fig.canvas.draw() @@ -476,7 +476,7 @@ class Plot(Operation): if self.save: self.save_figure(n) - + if self.server: self.send_to_server() @@ -489,33 +489,44 @@ class Plot(Operation): 'interval': dataOut.timeInterval, 'channels': dataOut.channelList } - + data, meta = self.update(dataOut) metadata.update(meta) self.data.update(data, timestamp, metadata) - + def save_figure(self, n): ''' ''' - - if (self.data.max_time - self.save_time) <= self.save_period: - return + if self.oneFigure: + if (self.data.max_time - self.save_time) <= self.save_period: + return self.save_time = self.data.max_time fig = self.figures[n] - if self.throttle == 0: - figname = os.path.join( - self.save, - self.save_code, - '{}_{}.png'.format( + if self.oneFigure: + figname = os.path.join( + self.save, self.save_code, - self.getDateTime(self.data.max_time).strftime( - '%Y%m%d_%H%M%S' - ), + '{}_{}.png'.format( + self.save_code, + self.getDateTime(self.data.max_time).strftime( + '%Y%m%d_%H%M%S' + ), + ) + ) + else: + figname = os.path.join( + self.save, + self.save_code, + '{}_ch{}_{}.png'.format( + self.save_code,n, + self.getDateTime(self.data.max_time).strftime( + '%Y%m%d_%H%M%S' + ), + ) ) - ) log.log('Saving figure: {}'.format(figname), self.name) if not os.path.isdir(os.path.dirname(figname)): os.makedirs(os.path.dirname(figname)) @@ -530,6 +541,7 @@ class Plot(Operation): ), ) ) + log.log('Saving figure: {}'.format(figname), self.name) if not os.path.isdir(os.path.dirname(figname)): os.makedirs(os.path.dirname(figname)) @@ -541,14 +553,14 @@ class Plot(Operation): if self.exp_code == None: log.warning('Missing `exp_code` skipping sending to server...') - + last_time = self.data.max_time interval = last_time - self.sender_time if interval < self.sender_period: return self.sender_time = last_time - + attrs = ['titles', 'zmin', 'zmax', 'tag', 'ymin', 'ymax'] for attr in attrs: value = getattr(self, attr) @@ -565,7 +577,7 @@ class Plot(Operation): self.data.meta['interval'] = int(interval) self.sender_queue.append(last_time) - + while True: try: tm = self.sender_queue.popleft() @@ -604,7 +616,7 @@ class Plot(Operation): self.ncols: number of cols self.nplots: number of plots (channels or pairs) self.ylabel: label for Y axes - self.titles: list of axes title + self.titles: list of axes title ''' raise NotImplementedError @@ -619,14 +631,14 @@ class Plot(Operation): ''' Must be defined in the child class, update self.data with new data ''' - + data = { self.CODE: getattr(dataOut, 'data_{}'.format(self.CODE)) } meta = {} return data, meta - + def run(self, dataOut, **kwargs): ''' Main plotting routine @@ -650,7 +662,7 @@ class Plot(Operation): self.poll.register(self.socket, zmq.POLLIN) tm = getattr(dataOut, self.attr_time) - + if self.data and 'time' in self.xaxis and (tm - self.tmin) >= self.xrange*60*60: self.save_time = tm self.__plot() @@ -667,7 +679,7 @@ class Plot(Operation): dt = self.getDateTime(tm) if self.xmin is None: self.tmin = tm - self.xmin = dt.hour + self.xmin = dt.hour minutes = (self.xmin-int(self.xmin)) * 60 seconds = (minutes - int(minutes)) * 60 self.tmin = (dt.replace(hour=int(self.xmin), minute=int(minutes), second=int(seconds)) - @@ -690,4 +702,3 @@ class Plot(Operation): self.__plot() if self.data and not self.data.flagNoData and self.pause: figpause(10) - diff --git a/schainpy/model/graphics/jroplot_heispectra.py b/schainpy/model/graphics/jroplot_heispectra.py index a98a5cd..de5d1cf 100644 --- a/schainpy/model/graphics/jroplot_heispectra.py +++ b/schainpy/model/graphics/jroplot_heispectra.py @@ -33,14 +33,16 @@ class SpectraHeisPlot(Plot): meta = {} spc = 10*numpy.log10(dataOut.data_spc / dataOut.normFactor) data['spc_heis'] = spc - - return data, meta + + return data, meta def plot(self): c = 3E8 deltaHeight = self.data.yrange[1] - self.data.yrange[0] x = numpy.arange(-1*len(self.data.yrange)/2., len(self.data.yrange)/2.)*(c/(2*deltaHeight*len(self.data.yrange)*1000)) + #x = (1/1000.0)*numpy.arange(-1*len(self.data.yrange)/2., len(self.data.yrange)/2.)*(c/(2*deltaHeight*len(self.data.yrange)*1000)) + self.y = self.data[-1]['spc_heis'] self.titles = [] @@ -80,8 +82,8 @@ class RTIHeisPlot(Plot): spc = dataOut.data_spc / dataOut.normFactor spc = 10*numpy.log10(numpy.average(spc, axis=1)) data['rti_heis'] = spc - - return data, meta + + return data, meta def plot(self): diff --git a/schainpy/model/graphics/jroplot_parameters.py b/schainpy/model/graphics/jroplot_parameters.py index 8909167..a8b95be 100644 --- a/schainpy/model/graphics/jroplot_parameters.py +++ b/schainpy/model/graphics/jroplot_parameters.py @@ -5,6 +5,8 @@ import numpy 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 EARTH_RADIUS = 6.3710e3 @@ -63,7 +65,7 @@ class SnrPlot(RTIPlot): def update(self, dataOut): data = { - 'snr': 10*numpy.log10(dataOut.data_snr) + 'snr': 10*numpy.log10(dataOut.data_snr) } return data, {} @@ -79,7 +81,7 @@ class DopplerPlot(RTIPlot): def update(self, dataOut): data = { - 'dop': 10*numpy.log10(dataOut.data_dop) + 'dop': 10*numpy.log10(dataOut.data_dop) } return data, {} @@ -95,7 +97,7 @@ class PowerPlot(RTIPlot): def update(self, dataOut): data = { - 'pow': 10*numpy.log10(dataOut.data_pow/dataOut.normFactor) + 'pow': 10*numpy.log10(dataOut.data_pow/dataOut.normFactor) } return data, {} @@ -179,7 +181,7 @@ class GenericRTIPlot(Plot): self.nrows = self.data.shape('param')[0] self.nplots = self.nrows self.plots_adjust.update({'hspace':0.8, 'left': 0.1, 'bottom': 0.08, 'right':0.95, 'top': 0.95}) - + if not self.xlabel: self.xlabel = 'Time' @@ -196,7 +198,7 @@ class GenericRTIPlot(Plot): meta = {} return data, meta - + def plot(self): # self.data.normalize_heights() self.x = self.data.times @@ -368,3 +370,216 @@ class PolarMapPlot(Plot): self.titles = ['{} {}'.format( self.data.parameters[x], title) for x in self.channels] +class WeatherPlot(Plot): + CODE = 'weather' + plot_name = 'weather' + plot_type = 'ppistyle' + buffering = False + + def setup(self): + self.ncols = 1 + self.nrows = 1 + self.nplots= 1 + self.ylabel= 'Range [Km]' + self.titles= ['Weather'] + self.colorbar=False + self.width =8 + self.height =8 + self.ini =0 + self.len_azi =0 + self.buffer_ini = None + self.buffer_azi = 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 + + def update(self, dataOut): + + data = {} + meta = {} + data['weather'] = 10*numpy.log10(dataOut.data_360[0]/(650**2)) + data['azi'] = dataOut.data_azi + + return data, meta + + def plot(self): + thisDatetime = datetime.datetime.utcfromtimestamp(self.data.times[-1]) + + data = self.data[-1] + tmp_h = (data['weather'].shape[1])/10.0 + stoprange = float(tmp_h*1.5)#stoprange = float(33*1.5) por ahora 400 + rangestep = float(0.15) + r = numpy.arange(0, stoprange, rangestep) + self.y = 2*r + + tmp_v = data['weather'] + print("tmp_v",tmp_v.shape) + tmp_z = data['azi'] + #print("tmp_z",tmp_z.shape) + res = 1 + step = (360/(res*tmp_v.shape[0])) + print("step",step) + mode = 1 + if mode==0: + #print("self.ini",self.ini) + val = numpy.mean(tmp_v[:,0]) + self.len_azi = len(tmp_z) + ones = numpy.ones([(360-tmp_v.shape[0]),tmp_v.shape[1]])*val + self.buffer_ini = numpy.vstack((tmp_v,ones)) + + n = ((360/res)-len(tmp_z)) + start = tmp_z[-1]+res + end = tmp_z[0]-res + if start>end: + end = end+360 + azi_zeros = numpy.linspace(start,end,int(n)) + azi_zeros = numpy.where(azi_zeros>360,azi_zeros-360,azi_zeros) + self.buffer_ini_azi = numpy.hstack((tmp_z,azi_zeros)) + self.ini = self.ini+1 + + if mode==1: + #print("self.ini",self.ini) + if self.ini==0: + res = 1 + step = (360/(res*tmp_v.shape[0])) + val = numpy.mean(tmp_v[:,0]) + self.len_azi = len(tmp_z) + self.buf_tmp = tmp_v + ones = numpy.ones([(360-tmp_v.shape[0]),tmp_v.shape[1]])*val + self.buffer_ini = numpy.vstack((tmp_v,ones)) + + n = ((360/res)-len(tmp_z)) + start = tmp_z[-1]+res + end = tmp_z[0]-res + if start>end: + end =end+360 + azi_zeros = numpy.linspace(start,end,int(n)) + azi_zeros = numpy.where(azi_zeros>360,azi_zeros-360,azi_zeros) + self.buf_azi = tmp_z + self.buffer_ini_azi = numpy.hstack((tmp_z,azi_zeros)) + self.ini = self.ini+1 + elif 031: + start= tmp_z[0] + end =tmp_z[-1] + print("start","end",start,end) + if self.ini==32: + tmp_v=tmp_v+20 + if self.ini==33: + tmp_v=tmp_v+10 + if self.ini==34: + tmp_v=tmp_v+20 + if self.ini==35: + tmp_v=tmp_v+20 + ''' + self.buf_tmp= numpy.vstack((self.buf_tmp,tmp_v)) + print("ERROR_INMINENTE",self.buf_tmp.shape) + if self.buf_tmp.shape[0]==360: + self.buffer_ini=self.buf_tmp + else: + val=30.0 + ones = numpy.ones([(360-self.buf_tmp.shape[0]),self.buf_tmp.shape[1]])*val + self.buffer_ini = numpy.vstack((self.buf_tmp,ones)) + + self.buf_azi = numpy.hstack((self.buf_azi,tmp_z)) + n = ((360/res)-len(self.buf_azi)) + if n==0: + self.buffer_ini_azi = self.buf_azi + else: + start = self.buf_azi[-1]+res + end = self.buf_azi[0]-res + if start>end: + end =end+360 + azi_zeros = numpy.linspace(start,end,int(n)) + azi_zeros = numpy.where(azi_zeros>360,azi_zeros-360,azi_zeros) + if tmp_z[0]=2: + if self.flag=tmp_z[-1])[0][0]) + print("tmp_r",tmp_r) + index_f=(self.flag+1)*len(tmp_z)+tmp_r + + if len(tmp_z[index_i:])>len(self.buf_azi[len(tmp_z)*(self.flag+1):index_f]): + final = len(self.buf_azi[len(tmp_z)*(self.flag+1):index_f]) + else: + final= len(tmp_z[index_i:]) + self.buf_azi[len(tmp_z)*(self.flag+1):index_f]=tmp_z[index_i:index_i+final] + self.buf_tmp[len(tmp_z)*(self.flag+1):index_f,:]=tmp_v[index_i:index_i+final,:] + if limit_i=tmp_z[-1])[0][0]) + n_p =index_f-len(tmp_z)*(self.flag+1) + if n_p>0: + self.buf_azi[len(tmp_z)*(self.flag+1):index_f]=tmp_z[-1]*numpy.ones(n_p) + self.buf_tmp[len(tmp_z)*(self.flag+1):index_f,:]=tmp_v[-1,:]*numpy.ones([n_p,tmp_v.shape[1]]) + + ''' + if self.buf_azi[len(tmp_z)]=tmp_z[-1])[0][0]) + #print("index",index_i,index_f) + if len(tmp_z[index_i:])>len(self.buf_azi[len(tmp_z):index_f]): + final = len(self.buf_azi[len(tmp_z):index_f]) + else: + final = len(tmp_z[index_i:]) + self.buf_azi[len(tmp_z):index_f]=tmp_z[index_i:index_i+final] + self.buf_tmp[len(tmp_z):index_f,:]=tmp_v[index_i:index_i+final,:] + ''' + self.buf_tmp[len(tmp_z)*(self.flag):len(tmp_z)*(self.flag+1),:]=tmp_v + self.buf_azi[len(tmp_z)*(self.flag):len(tmp_z)*(self.flag+1)] = tmp_z + self.buffer_ini=self.buf_tmp + self.buffer_ini_azi = self.buf_azi + ##print("--------salida------------") + start= tmp_z[0] + end = tmp_z[-1] + ##print("start","end",start,end) + ##print(self.buffer_ini_azi[:120]) + self.ini= self.ini+1 + self.flag = self.flag +1 + if self.flag==step: + self.flag=0 + + for i,ax in enumerate(self.axes): + if ax.firsttime: + plt.clf() + cgax, pm = wrl.vis.plot_ppi(self.buffer_ini,r=r,az=self.buffer_ini_azi,fig=self.figures[0], proj='cg', vmin=30, vmax=70) + else: + plt.clf() + cgax, pm = wrl.vis.plot_ppi(self.buffer_ini,r=r,az=self.buffer_ini_azi,fig=self.figures[0], proj='cg', vmin=30, vmax=70) + caax = cgax.parasites[0] + paax = cgax.parasites[1] + cbar = plt.gcf().colorbar(pm, pad=0.075) + caax.set_xlabel('x_range [km]') + caax.set_ylabel('y_range [km]') + plt.text(1.0, 1.05, 'azimuth '+str(thisDatetime), transform=caax.transAxes, va='bottom',ha='right') diff --git a/schainpy/model/graphics/jroplot_spectra.py b/schainpy/model/graphics/jroplot_spectra.py index 1cc386a..92542ce 100644 --- a/schainpy/model/graphics/jroplot_spectra.py +++ b/schainpy/model/graphics/jroplot_spectra.py @@ -44,7 +44,7 @@ class SpectraPlot(Plot): 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)) - + if self.CODE == 'spc_moments': data['moments'] = dataOut.moments # data['spc'] = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor) @@ -53,8 +53,8 @@ class SpectraPlot(Plot): data['gaussfit'] = dataOut.DGauFitParams # data['spc'] = 10*numpy.log10(dataOut.data_pre[0]/dataOut.normFactor) - return data, meta - + return data, meta + def plot(self): if self.xaxis == "frequency": x = self.data.xrange[0] @@ -82,7 +82,7 @@ class SpectraPlot(Plot): noise = data['noise'][n] if self.CODE == 'spc_moments': mean = data['moments'][n, 1] - if self.CODE == 'gaussian_fit': + if self.CODE == 'gaussian_fit': # mean = data['moments'][n, 1] gau0 = data['gaussfit'][n][2,:,0] gau1 = data['gaussfit'][n][2,:,1] @@ -164,8 +164,8 @@ class CrossSpectraPlot(Plot): data['cspc'] = numpy.array(tmp) - return data, meta - + return data, meta + def plot(self): if self.xaxis == "frequency": @@ -177,7 +177,7 @@ class CrossSpectraPlot(Plot): else: x = self.data.xrange[2] self.xlabel = "Velocity (m/s)" - + self.titles = [] y = self.data.yrange @@ -201,13 +201,13 @@ class CrossSpectraPlot(Plot): ax.plt.set_array(coh.T.ravel()) self.titles.append( 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1])) - + ax = self.axes[2 * n + 1] if ax.firsttime: ax.plt = ax.pcolormesh(x, y, phase.T, vmin=-180, vmax=180, - cmap=plt.get_cmap(self.colormap_phase) + cmap=plt.get_cmap(self.colormap_phase) ) else: ax.plt.set_array(phase.T.ravel()) @@ -226,6 +226,7 @@ class RTIPlot(Plot): def setup(self): self.xaxis = 'time' self.ncols = 1 + print("ch",self.data.channels) self.nrows = len(self.data.channels) self.nplots = len(self.data.channels) self.ylabel = 'Range [km]' @@ -266,6 +267,7 @@ class RTIPlot(Plot): cmap=plt.get_cmap(self.colormap) ) if self.showprofile: + print("test-------------------------------------1") ax.plot_profile = self.pf_axes[n].plot( data['rti'][n], self.y)[0] ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(data['noise'][n], len(self.y)), self.y, @@ -335,7 +337,7 @@ class PhasePlot(CoherencePlot): class NoisePlot(Plot): ''' - Plot for noise + Plot for noise ''' CODE = 'noise' @@ -380,7 +382,7 @@ class NoisePlot(Plot): y = Y[ch] self.axes[0].lines[ch].set_data(x, y) - + class PowerProfilePlot(Plot): CODE = 'pow_profile' @@ -412,10 +414,10 @@ class PowerProfilePlot(Plot): self.y = y x = self.data[-1][self.CODE] - + if self.xmin is None: self.xmin = numpy.nanmin(x)*0.9 if self.xmax is None: self.xmax = numpy.nanmax(x)*1.1 - + if self.axes[0].firsttime: for ch in self.data.channels: self.axes[0].plot(x[ch], y, lw=1, label='Ch{}'.format(ch)) @@ -464,7 +466,7 @@ class SpectraCutPlot(Plot): else: x = self.data.xrange[2][:-1] self.xlabel = "Velocity (m/s)" - + if self.CODE == 'cut_gaussian_fit': x = self.data.xrange[2][:-1] self.xlabel = "Velocity (m/s)" @@ -481,7 +483,7 @@ class SpectraCutPlot(Plot): index = numpy.arange(0, len(y), int((len(y))/9)) for n, ax in enumerate(self.axes): - if self.CODE == 'cut_gaussian_fit': + if self.CODE == 'cut_gaussian_fit': gau0 = data['gauss_fit0'] gau1 = data['gauss_fit1'] if ax.firsttime: @@ -493,10 +495,10 @@ class SpectraCutPlot(Plot): if self.CODE == 'cut_gaussian_fit': ax.plt_gau0 = ax.plot(x, gau0[n, :, index].T, lw=1, linestyle='-.') for i, line in enumerate(ax.plt_gau0): - line.set_color(ax.plt[i].get_color()) + line.set_color(ax.plt[i].get_color()) ax.plt_gau1 = ax.plot(x, gau1[n, :, index].T, lw=1, linestyle='--') for i, line in enumerate(ax.plt_gau1): - line.set_color(ax.plt[i].get_color()) + line.set_color(ax.plt[i].get_color()) labels = ['Range = {:2.1f}km'.format(y[i]) for i in index] self.figures[0].legend(ax.plt, labels, loc='center right') else: @@ -600,7 +602,7 @@ class BeaconPhase(Plot): server=None, folder=None, username=None, password=None, ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): - if dataOut.flagNoData: + if dataOut.flagNoData: return dataOut if not isTimeInHourRange(dataOut.datatime, xmin, xmax): @@ -740,4 +742,4 @@ class BeaconPhase(Plot): thisDatetime=thisDatetime, update_figfile=update_figfile) - return dataOut \ No newline at end of file + return dataOut diff --git a/schainpy/model/io/jroIO_base.py b/schainpy/model/io/jroIO_base.py index 7d17366..a658151 100644 --- a/schainpy/model/io/jroIO_base.py +++ b/schainpy/model/io/jroIO_base.py @@ -384,7 +384,7 @@ def isRadarFolder(folder): def isRadarFile(file): - try: + try: year = int(file[1:5]) doy = int(file[5:8]) set = int(file[8:11]) @@ -395,10 +395,10 @@ def isRadarFile(file): def getDateFromRadarFile(file): - try: + try: year = int(file[1:5]) doy = int(file[5:8]) - set = int(file[8:11]) + set = int(file[8:11]) except: return None @@ -417,7 +417,7 @@ def getDateFromRadarFolder(folder): return thisDate def parse_format(s, fmt): - + for i in range(fmt.count('%')): x = fmt.index('%') d = DT_DIRECTIVES[fmt[x:x+2]] @@ -484,7 +484,7 @@ class Reader(object): def run(self): - raise NotImplementedError + raise NotImplementedError def getAllowedArgs(self): if hasattr(self, '__attrs__'): @@ -496,19 +496,19 @@ class Reader(object): for key, value in kwargs.items(): setattr(self, key, value) - + def find_folders(self, path, startDate, endDate, folderfmt, last=False): - folders = [x for f in path.split(',') + folders = [x for f in path.split(',') for x in os.listdir(f) if os.path.isdir(os.path.join(f, x))] folders.sort() if last: folders = [folders[-1]] - for folder in folders: - try: - dt = datetime.datetime.strptime(parse_format(folder, folderfmt), folderfmt).date() + for folder in folders: + try: + dt = datetime.datetime.strptime(parse_format(folder, folderfmt), folderfmt).date() if dt >= startDate and dt <= endDate: yield os.path.join(path, folder) else: @@ -517,38 +517,38 @@ class Reader(object): log.log('Skiping folder {}'.format(folder), self.name) continue return - - def find_files(self, folders, ext, filefmt, startDate=None, endDate=None, + + def find_files(self, folders, ext, filefmt, startDate=None, endDate=None, expLabel='', last=False): - - for path in folders: + + for path in folders: files = glob.glob1(path, '*{}'.format(ext)) files.sort() if last: - if files: + if files: fo = files[-1] - try: + try: dt = datetime.datetime.strptime(parse_format(fo, filefmt), filefmt).date() - yield os.path.join(path, expLabel, fo) - except Exception as e: + yield os.path.join(path, expLabel, fo) + except Exception as e: pass return else: return for fo in files: - try: - dt = datetime.datetime.strptime(parse_format(fo, filefmt), filefmt).date() + try: + dt = datetime.datetime.strptime(parse_format(fo, filefmt), filefmt).date() if dt >= startDate and dt <= endDate: yield os.path.join(path, expLabel, fo) else: log.log('Skiping file {}'.format(fo), self.name) except Exception as e: log.log('Skiping file {}'.format(fo), self.name) - continue + continue def searchFilesOffLine(self, path, startDate, endDate, - expLabel, ext, walk, + expLabel, ext, walk, filefmt, folderfmt): """Search files in offline mode for the given arguments @@ -561,12 +561,12 @@ class Reader(object): path, startDate, endDate, folderfmt) else: folders = path.split(',') - + return self.find_files( - folders, ext, filefmt, startDate, endDate, expLabel) + folders, ext, filefmt, startDate, endDate, expLabel) def searchFilesOnLine(self, path, startDate, endDate, - expLabel, ext, walk, + expLabel, ext, walk, filefmt, folderfmt): """Search for the last file of the last folder @@ -579,13 +579,13 @@ class Reader(object): Return: generator with the full path of last filename """ - + if walk: folders = self.find_folders( path, startDate, endDate, folderfmt, last=True) else: folders = path.split(',') - + return self.find_files( folders, ext, filefmt, startDate, endDate, expLabel, last=True) @@ -594,13 +594,13 @@ class Reader(object): while True: if self.fp != None: - self.fp.close() + self.fp.close() if self.online: newFile = self.setNextFileOnline() else: newFile = self.setNextFileOffline() - + if not(newFile): if self.online: raise schainpy.admin.SchainError('Time to wait for new files reach') @@ -609,10 +609,10 @@ class Reader(object): raise schainpy.admin.SchainWarning('No files found in the given path') else: raise schainpy.admin.SchainWarning('No more files to read') - + if self.verifyFile(self.filename): break - + log.log('Opening file: %s' % self.filename, self.name) self.readFirstHeader() @@ -625,7 +625,7 @@ class Reader(object): self.filename self.fp self.filesize - + Return: boolean @@ -633,7 +633,7 @@ class Reader(object): nextFile = True nextDay = False - for nFiles in range(self.nFiles+1): + for nFiles in range(self.nFiles+1): for nTries in range(self.nTries): fullfilename, filename = self.checkForRealPath(nextFile, nextDay) if fullfilename is not None: @@ -643,18 +643,18 @@ class Reader(object): self.name) time.sleep(self.delay) nextFile = False - continue - + continue + if fullfilename is not None: break - + self.nTries = 1 - nextFile = True + nextFile = True if nFiles == (self.nFiles - 1): log.log('Trying with next day...', self.name) nextDay = True - self.nTries = 3 + self.nTries = 3 if fullfilename: self.fileSize = os.path.getsize(fullfilename) @@ -666,18 +666,18 @@ class Reader(object): self.flagNoMoreFiles = 0 self.fileIndex += 1 return 1 - else: + else: return 0 - + def setNextFileOffline(self): """Open the next file to be readed in offline mode""" - + try: filename = next(self.filenameList) self.fileIndex +=1 except StopIteration: self.flagNoMoreFiles = 1 - return 0 + return 0 self.filename = filename self.fileSize = os.path.getsize(filename) @@ -685,22 +685,22 @@ class Reader(object): self.flagIsNewFile = 1 return 1 - + @staticmethod def isDateTimeInRange(dt, startDate, endDate, startTime, endTime): """Check if the given datetime is in range""" - + if startDate <= dt.date() <= endDate: if startTime <= dt.time() <= endTime: return True return False - + def verifyFile(self, filename): """Check for a valid file - + Arguments: filename -- full path filename - + Return: boolean """ @@ -709,9 +709,43 @@ class Reader(object): def checkForRealPath(self, nextFile, nextDay): """Check if the next file to be readed exists""" + if nextFile: + self.set += 1 + if nextDay: + self.set = 0 + self.doy += 1 + foldercounter = 0 + prefixDirList = [None, 'd', 'D'] + if self.ext.lower() == ".r": # voltage + prefixFileList = ['d', 'D'] + elif self.ext.lower() == ".pdata": # spectra + prefixFileList = ['p', 'P'] + elif self.ext.lower() == ".hdf5": # HDF5 + prefixFileList = ['D', 'P'] # HDF5 + + # barrido por las combinaciones posibles + for prefixDir in prefixDirList: + thispath = self.path + if prefixDir != None: + # formo el nombre del directorio xYYYYDDD (x=d o x=D) + if foldercounter == 0: + thispath = os.path.join(self.path, "%s%04d%03d" % + (prefixDir, self.year, self.doy)) + else: + thispath = os.path.join(self.path, "%s%04d%03d_%02d" % ( + prefixDir, self.year, self.doy, foldercounter)) + for prefixFile in prefixFileList: # barrido por las dos combinaciones posibles de "D" + # formo el nombre del file xYYYYDDDSSS.ext + filename = "%s%04d%03d%03d%s" % (prefixFile, self.year, self.doy, self.set, self.ext) + fullfilename = os.path.join( + thispath, filename) + + if os.path.exists(fullfilename): + return fullfilename, filename + + return None, filename + #raise NotImplementedError - raise NotImplementedError - def readFirstHeader(self): """Parse the file header""" @@ -783,8 +817,8 @@ class JRODataReader(Reader): Return: str -- fullpath of the file """ - - + + if nextFile: self.set += 1 if nextDay: @@ -796,7 +830,7 @@ class JRODataReader(Reader): prefixFileList = ['d', 'D'] elif self.ext.lower() == ".pdata": # spectra prefixFileList = ['p', 'P'] - + # barrido por las combinaciones posibles for prefixDir in prefixDirList: thispath = self.path @@ -816,9 +850,9 @@ class JRODataReader(Reader): if os.path.exists(fullfilename): return fullfilename, filename - - return None, filename - + + return None, filename + def __waitNewBlock(self): """ Return 1 si se encontro un nuevo bloque de datos, 0 de otra forma. @@ -860,9 +894,9 @@ class JRODataReader(Reader): def __setNewBlock(self): if self.fp == None: - return 0 - - if self.flagIsNewFile: + return 0 + + if self.flagIsNewFile: self.lastUTTime = self.basicHeaderObj.utc return 1 @@ -875,12 +909,12 @@ class JRODataReader(Reader): currentSize = self.fileSize - self.fp.tell() neededSize = self.processingHeaderObj.blockSize + self.basicHeaderSize - + if (currentSize >= neededSize): self.basicHeaderObj.read(self.fp) self.lastUTTime = self.basicHeaderObj.utc return 1 - + if self.__waitNewBlock(): self.lastUTTime = self.basicHeaderObj.utc return 1 @@ -966,10 +1000,10 @@ class JRODataReader(Reader): except IOError: log.error("File {} can't be opened".format(filename), self.name) return False - + if self.online and self.waitDataBlock(0): pass - + basicHeaderObj = BasicHeader(LOCALTIME) systemHeaderObj = SystemHeader() radarControllerHeaderObj = RadarControllerHeader() @@ -996,7 +1030,7 @@ class JRODataReader(Reader): dt2 = basicHeaderObj.datatime if not self.isDateTimeInRange(dt1, self.startDate, self.endDate, self.startTime, self.endTime) and not \ self.isDateTimeInRange(dt2, self.startDate, self.endDate, self.startTime, self.endTime): - flag = False + flag = False fp.close() return flag @@ -1105,11 +1139,11 @@ class JRODataReader(Reader): return dateList def setup(self, **kwargs): - + self.set_kwargs(**kwargs) if not self.ext.startswith('.'): self.ext = '.{}'.format(self.ext) - + if self.server is not None: if 'tcp://' in self.server: address = server @@ -1131,36 +1165,36 @@ class JRODataReader(Reader): for nTries in range(self.nTries): fullpath = self.searchFilesOnLine(self.path, self.startDate, - self.endDate, self.expLabel, self.ext, self.walk, + self.endDate, self.expLabel, self.ext, self.walk, self.filefmt, self.folderfmt) try: fullpath = next(fullpath) except: fullpath = None - + if fullpath: break log.warning( 'Waiting {} sec for a valid file in {}: try {} ...'.format( - self.delay, self.path, nTries + 1), + self.delay, self.path, nTries + 1), self.name) time.sleep(self.delay) if not(fullpath): raise schainpy.admin.SchainError( - 'There isn\'t any valid file in {}'.format(self.path)) + 'There isn\'t any valid file in {}'.format(self.path)) pathname, filename = os.path.split(fullpath) self.year = int(filename[1:5]) self.doy = int(filename[5:8]) - self.set = int(filename[8:11]) - 1 + self.set = int(filename[8:11]) - 1 else: log.log("Searching files in {}".format(self.path), self.name) - self.filenameList = self.searchFilesOffLine(self.path, self.startDate, + self.filenameList = self.searchFilesOffLine(self.path, self.startDate, self.endDate, self.expLabel, self.ext, self.walk, self.filefmt, self.folderfmt) - + self.setNextFile() return @@ -1181,7 +1215,7 @@ class JRODataReader(Reader): self.dataOut.useLocalTime = self.basicHeaderObj.useLocalTime self.dataOut.ippSeconds = self.radarControllerHeaderObj.ippSeconds / self.nTxs - + def getFirstHeader(self): raise NotImplementedError @@ -1214,8 +1248,8 @@ class JRODataReader(Reader): """ Arguments: - path : - startDate : + path : + startDate : endDate : startTime : endTime : @@ -1284,7 +1318,7 @@ class JRODataWriter(Reader): dtype_width = get_dtype_width(dtype_index) return dtype_width - + def getProcessFlags(self): processFlags = 0 @@ -1322,9 +1356,9 @@ class JRODataWriter(Reader): self.basicHeaderObj.size = self.basicHeaderSize # bytes self.basicHeaderObj.version = self.versionFile - self.basicHeaderObj.dataBlock = self.nTotalBlocks + self.basicHeaderObj.dataBlock = self.nTotalBlocks utc = numpy.floor(self.dataOut.utctime) - milisecond = (self.dataOut.utctime - utc) * 1000.0 + milisecond = (self.dataOut.utctime - utc) * 1000.0 self.basicHeaderObj.utc = utc self.basicHeaderObj.miliSecond = milisecond self.basicHeaderObj.timeZone = self.dataOut.timeZone @@ -1465,9 +1499,9 @@ class JRODataWriter(Reader): if self.dataOut.datatime.date() > self.fileDate: setFile = 0 self.nTotalBlocks = 0 - + filen = '{}{:04d}{:03d}{:03d}{}'.format( - self.optchar, timeTuple.tm_year, timeTuple.tm_yday, setFile, ext) + self.optchar, timeTuple.tm_year, timeTuple.tm_yday, setFile, ext) filename = os.path.join(path, subfolder, filen) @@ -1515,11 +1549,11 @@ class JRODataWriter(Reader): self.ext = ext.lower() self.path = path - + if set is None: self.setFile = -1 else: - self.setFile = set - 1 + self.setFile = set - 1 self.blocksPerFile = blocksPerFile self.profilesPerBlock = profilesPerBlock diff --git a/schainpy/model/io/jroIO_digitalRF.py b/schainpy/model/io/jroIO_digitalRF.py index 9d1ca09..913e167 100644 --- a/schainpy/model/io/jroIO_digitalRF.py +++ b/schainpy/model/io/jroIO_digitalRF.py @@ -113,8 +113,8 @@ class DigitalRFReader(ProcessingUnit): numpy.arange(self.__nSamples, dtype=numpy.float) * \ self.__deltaHeigth - self.dataOut.channelList = list(range(self.__num_subchannels)) - + #self.dataOut.channelList = list(range(self.__num_subchannels)) + self.dataOut.channelList = list(range(len(self.__channelList))) self.dataOut.blocksize = self.dataOut.nChannels * self.dataOut.nHeights # self.dataOut.channelIndexList = None @@ -344,9 +344,12 @@ class DigitalRFReader(ProcessingUnit): 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) if not startUTCSecond: startUTCSecond = start_index / self.__sample_rate @@ -403,8 +406,10 @@ class DigitalRFReader(ProcessingUnit): # por que en el otro metodo lo primero q se hace es sumar samplestoread self.__thisUnixSample = int(startUTCSecond * self.__sample_rate) - self.__samples_to_read - self.__data_buffer = numpy.zeros( - (self.__num_subchannels, self.__samples_to_read), dtype=numpy.complex) + #self.__data_buffer = numpy.zeros( + # (self.__num_subchannels, self.__samples_to_read), dtype=numpy.complex) + self.__data_buffer = numpy.zeros((int(len(channelList)), self.__samples_to_read), dtype=numpy.complex) + self.__setFileHeader() self.isConfig = True @@ -436,7 +441,7 @@ class DigitalRFReader(ProcessingUnit): try: self.digitalReadObj.reload(complete_update=True) except: - self.digitalReadObj = digital_rf.DigitalRFReader(self.path) + self.digitalReadObj = digital_rf.DigitalRFReader(self.path) start_index, end_index = self.digitalReadObj.get_bounds( self.__channelNameList[self.__channelList[0]]) @@ -476,7 +481,7 @@ class DigitalRFReader(ProcessingUnit): # Set the next data self.__flagDiscontinuousBlock = False self.__thisUnixSample += self.__samples_to_read - + if self.__thisUnixSample + 2 * self.__samples_to_read > self.__endUTCSecond * self.__sample_rate: print ("[Reading] There are no more data into selected time-range") if self.__online: @@ -492,7 +497,7 @@ class DigitalRFReader(ProcessingUnit): indexChannel = 0 dataOk = False - + for thisChannelName in self.__channelNameList: # TODO VARIOS CHANNELS? for indexSubchannel in range(self.__num_subchannels): try: @@ -519,8 +524,8 @@ class DigitalRFReader(ProcessingUnit): result.shape[0], self.__samples_to_read)) break - - self.__data_buffer[indexSubchannel, :] = result * volt_scale + + self.__data_buffer[indexChannel, :] = result * volt_scale indexChannel+=1 dataOk = True @@ -587,7 +592,7 @@ class DigitalRFReader(ProcessingUnit): return print('[Reading] waiting %d seconds to read a new block' % seconds) - time.sleep(seconds) + sleep(seconds) self.dataOut.data = self.__data_buffer[:, self.__bufferIndex:self.__bufferIndex + self.__nSamples] self.dataOut.utctime = ( self.__thisUnixSample + self.__bufferIndex) / self.__sample_rate @@ -624,12 +629,12 @@ class DigitalRFReader(ProcessingUnit): ''' This method will be called many times so here you should put all your code ''' - + if not self.isConfig: self.setup(**kwargs) #self.i = self.i+1 self.getData(seconds=self.__delay) - + return @MPDecorator diff --git a/schainpy/model/proc/jroproc_heispectra.py b/schainpy/model/proc/jroproc_heispectra.py index be414c1..898b176 100644 --- a/schainpy/model/proc/jroproc_heispectra.py +++ b/schainpy/model/proc/jroproc_heispectra.py @@ -89,7 +89,7 @@ class SpectraHeisProc(ProcessingUnit): if self.dataIn.type == "Fits": self.__updateObjFromFits() self.dataOut.flagNoData = False - return + return if self.dataIn.type == "SpectraHeis": self.dataOut.copy(self.dataIn) @@ -302,6 +302,9 @@ class IncohInt4SpectraHeis(Operation): if self.__initime == None: self.__initime = datatime + #if self.__profIndex == 0: + # self.__initime = datatime + if self.__byTime: avgdata = self.byTime(data, datatime) else: @@ -330,6 +333,7 @@ class IncohInt4SpectraHeis(Operation): self.setup(n=n, timeInterval=timeInterval, overlapping=overlapping) self.isConfig = True + #print("utc_time",dataOut.utctime) avgdata, avgdatatime = self.integrate(dataOut.data_spc, dataOut.utctime) # dataOut.timeInterval *= n @@ -343,5 +347,5 @@ class IncohInt4SpectraHeis(Operation): # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nIncohInt # dataOut.timeInterval = self.__timeInterval*self.n dataOut.flagNoData = False - - return dataOut \ No newline at end of file + + return dataOut diff --git a/schainpy/model/proc/jroproc_parameters.py b/schainpy/model/proc/jroproc_parameters.py index 62904ec..0aa4798 100755 --- a/schainpy/model/proc/jroproc_parameters.py +++ b/schainpy/model/proc/jroproc_parameters.py @@ -1,4 +1,4 @@ -import numpy +import numpy,os,h5py import math from scipy import optimize, interpolate, signal, stats, ndimage import scipy @@ -45,6 +45,12 @@ def _unpickle_method(func_name, obj, cls): break return func.__get__(obj, cls) +def isNumber(str): + try: + float(str) + return True + except: + return False class ParametersProc(ProcessingUnit): @@ -108,6 +114,13 @@ class ParametersProc(ProcessingUnit): self.dataOut.flagNoData = False self.dataOut.utctimeInit = self.dataIn.utctime self.dataOut.paramInterval = self.dataIn.nProfiles*self.dataIn.nCohInt*self.dataIn.ippSeconds + + if hasattr(self.dataIn, 'flagDataAsBlock'): + self.dataOut.flagDataAsBlock = self.dataIn.flagDataAsBlock + + if hasattr(self.dataIn, 'profileIndex'): + self.dataOut.profileIndex = self.dataIn.profileIndex + if hasattr(self.dataIn, 'dataPP_POW'): self.dataOut.dataPP_POW = self.dataIn.dataPP_POW @@ -143,6 +156,9 @@ class ParametersProc(ProcessingUnit): self.dataOut.groupList = self.dataIn.pairsList self.dataOut.flagNoData = False + if hasattr(self.dataIn, 'flagDataAsBlock'): + self.dataOut.flagDataAsBlock = self.dataIn.flagDataAsBlock + if hasattr(self.dataIn, 'ChanDist'): #Distances of receiver channels self.dataOut.ChanDist = self.dataIn.ChanDist else: self.dataOut.ChanDist = None @@ -220,7 +236,7 @@ class RemoveWideGC(Operation): self.i = 0 self.ich = 0 self.ir = 0 - + def run(self, dataOut, ClutterWidth=2.5): # print ('Entering RemoveWideGC ... ') @@ -247,11 +263,11 @@ class RemoveWideGC(Operation): junk = numpy.append(numpy.insert(numpy.squeeze(self.spc[ich,gc_values,ir]),0,HSn),HSn) j1index = numpy.squeeze(numpy.where(numpy.diff(junk)>0)) j2index = numpy.squeeze(numpy.where(numpy.diff(junk)<0)) - if ((numpy.size(j1index)<=1) | (numpy.size(j2index)<=1)) : + if ((numpy.size(j1index)<=1) | (numpy.size(j2index)<=1)) : continue junk3 = numpy.squeeze(numpy.diff(j1index)) junk4 = numpy.squeeze(numpy.diff(j2index)) - + valleyindex = j2index[numpy.where(junk4>1)] peakindex = j1index[numpy.where(junk3>1)] @@ -261,7 +277,7 @@ class RemoveWideGC(Operation): if numpy.size(isvalid) >1 : vindex = numpy.argmax(self.spc[ich,gc_values[peakindex[isvalid]],ir]) isvalid = isvalid[vindex] - + # clutter peak gcpeak = peakindex[isvalid] vl = numpy.where(valleyindex < gcpeak) @@ -283,7 +299,7 @@ class RemoveWideGC(Operation): return dataOut class SpectralFilters(Operation): - ''' This class allows to replace the novalid values with noise for each channel + ''' This class allows to replace the novalid values with noise for each channel This applies to CLAIRE RADAR PositiveLimit : RightLimit of novalid data @@ -303,7 +319,7 @@ class SpectralFilters(Operation): def __init__(self): Operation.__init__(self) self.i = 0 - + def run(self, dataOut, ): self.spc = dataOut.data_pre[0].copy() @@ -311,7 +327,7 @@ class SpectralFilters(Operation): VelRange = dataOut.spc_range[2] # novalid corresponds to data within the Negative and PositiveLimit - + # Removing novalid data from the spectra for i in range(self.Num_Chn): @@ -383,7 +399,7 @@ class GaussianFit(Operation): p1 = numpy.transpose(numpy.transpose([dataOut.DGauFitParams[iCh][4,:,1]] * self.Num_Bin)) elif method == 'squared': p0 = 2. - p1 = 2. + p1 = 2. gau0[iCh] = A0*numpy.exp(-0.5*numpy.abs((x_mtr-v0)/s0)**p0)+N0 gau1[iCh] = A1*numpy.exp(-0.5*numpy.abs((x_mtr-v1)/s1)**p1)+N1 dataOut.GaussFit0 = gau0 @@ -445,7 +461,7 @@ class GaussianFit(Operation): # print ('stop 2.1') fatspectra=1.0 # noise per channel.... we might want to use the noise at each range - + # wnoise = noise_ #/ spc_norm_max #commented by D. Scipión 19.03.2021 #wnoise,stdv,i_max,index =enoise(spc,num_intg) #noise estimate using Hildebrand Sekhon, only wnoise is used #if wnoise>1.1*pnoise: # to be tested later @@ -493,7 +509,7 @@ class GaussianFit(Operation): if powerwidth <= 1: # print('powerwidth <= 1') continue - + # print ('stop 6') firstpeak = powerlo + powerwidth/10.# first gaussian energy location secondpeak = powerhi - powerwidth/10. #second gaussian energy location @@ -531,7 +547,7 @@ class GaussianFit(Operation): noise=lsq1[0][4] #return (numpy.array([shift0,width0,Amplitude0,p0]), # numpy.array([shift1,width1,Amplitude1,p1]),noise,snrdB,chiSq1,6.,sigmas1,[None,]*9,choice) - + # print ('stop 9') ''' two Gaussians ''' #shift0=numpy.mod(firstpeak+minx,64); shift1=numpy.mod(secondpeak+minx,64) @@ -628,7 +644,7 @@ class GaussianFit(Operation): if Amplitude1<0.05: shift1,width1,Amplitude1,p1 = 4*[numpy.NaN] - # print ('stop 16 ') + # print ('stop 16 ') # SPC_ch1[:,ht] = noise + Amplitude0*numpy.exp(-0.5*(abs(x-shift0)/width0)**p0) # SPC_ch2[:,ht] = noise + Amplitude1*numpy.exp(-0.5*(abs(x-shift1)/width1)**p1) # SPCparam = (SPC_ch1,SPC_ch2) @@ -662,7 +678,7 @@ class GaussianFit(Operation): model0 = amplitude0*numpy.exp(-0.5*abs((x-shift0)/width0)**power0) model0u = amplitude0*numpy.exp(-0.5*abs((x - shift0 - self.Num_Bin)/width0)**power0) model0d = amplitude0*numpy.exp(-0.5*abs((x - shift0 + self.Num_Bin)/width0)**power0) - + model1 = amplitude1*numpy.exp(-0.5*abs((x - shift1)/width1)**power1) model1u = amplitude1*numpy.exp(-0.5*abs((x - shift1 - self.Num_Bin)/width1)**power1) model1d = amplitude1*numpy.exp(-0.5*abs((x - shift1 + self.Num_Bin)/width1)**power1) @@ -731,7 +747,7 @@ class PrecipitationProc(Operation): self.Lambda = Lambda self.aL = aL self.tauW = tauW - self.ThetaT = ThetaT + self.ThetaT = ThetaT self.ThetaR = ThetaR self.GSys = 10**(36.63/10) # Ganancia de los LNA 36.63 dB self.lt = 10**(1.67/10) # Perdida en cables Tx 1.67 dB @@ -771,7 +787,7 @@ class PrecipitationProc(Operation): ETAn = (RadarConstant *ExpConstant) * Pr * rMtrx**2 #Reflectivity (ETA) ETAd = ETAn * 6.18 * exp( -0.6 * D_Vz ) * delv_z # Radar Cross Section - sigmaD = Km2 * (D_Vz * 1e-3 )**6 * numpy.pi**5 / Lambda**4 + sigmaD = Km2 * (D_Vz * 1e-3 )**6 * numpy.pi**5 / Lambda**4 # Drop Size Distribution DSD = ETAn / sigmaD # Equivalente Reflectivy @@ -792,7 +808,7 @@ class PrecipitationProc(Operation): dataOut.data_output = RR[8] dataOut.data_param = numpy.ones([3,self.Num_Hei]) dataOut.channelList = [0,1,2] - + dataOut.data_param[0]=10*numpy.log10(Ze_org) dataOut.data_param[1]=-W dataOut.data_param[2]=RR @@ -868,7 +884,7 @@ class FullSpectralAnalysis(Operation): Parameters affected: Winds, height range, SNR """ - def run(self, dataOut, Xi01=None, Xi02=None, Xi12=None, Eta01=None, Eta02=None, Eta12=None, SNRdBlimit=-30, + def run(self, dataOut, Xi01=None, Xi02=None, Xi12=None, Eta01=None, Eta02=None, Eta12=None, SNRdBlimit=-30, minheight=None, maxheight=None, NegativeLimit=None, PositiveLimit=None): spc = dataOut.data_pre[0].copy() @@ -912,14 +928,14 @@ class FullSpectralAnalysis(Operation): if Height >= range_min and Height < range_max: # error_code will be useful in future analysis - [Vzon,Vmer,Vver, error_code] = self.WindEstimation(spc[:,:,Height], cspc[:,:,Height], pairsList, + [Vzon,Vmer,Vver, error_code] = self.WindEstimation(spc[:,:,Height], cspc[:,:,Height], pairsList, ChanDist, Height, dataOut.noise, dataOut.spc_range, dbSNR[Height], SNRdBlimit, NegativeLimit, PositiveLimit,dataOut.frequency) if abs(Vzon) < 100. and abs(Vmer) < 100.: velocityX[Height] = Vzon velocityY[Height] = -Vmer velocityZ[Height] = Vver - + # Censoring data with SNR threshold dbSNR [dbSNR < SNRdBlimit] = numpy.NaN @@ -1019,7 +1035,7 @@ class FullSpectralAnalysis(Operation): xSamples = xFrec # the frequency range is taken delta_x = xSamples[1] - xSamples[0] # delta_f or delta_x - # only consider velocities with in NegativeLimit and PositiveLimit + # only consider velocities with in NegativeLimit and PositiveLimit if (NegativeLimit is None): NegativeLimit = numpy.min(xVel) if (PositiveLimit is None): @@ -1034,7 +1050,7 @@ class FullSpectralAnalysis(Operation): # spwd limit - updated by D. Scipión 30.03.2021 widthlimit = 10 '''************************* SPC is normalized ********************************''' - spc_norm = spc.copy() + spc_norm = spc.copy() # For each channel for i in range(nChan): spc_sub = spc_norm[i,:] - noise[i] # only the signal power @@ -1053,9 +1069,9 @@ class FullSpectralAnalysis(Operation): >= 0, as it is the modulus squared of the signals (complex * it's conjugate) """ # initial conditions - popt = [1e-10,0,1e-10] + popt = [1e-10,0,1e-10] # Spectra average - SPCMean = numpy.average(SPC_Samples,0) + SPCMean = numpy.average(SPC_Samples,0) # Moments in frequency SPCMoments = self.Moments(SPCMean[xvalid], xSamples_zoom) @@ -1310,7 +1326,7 @@ class SpectralMoments(Operation): signal_power = ((spec2[valid] - n0) * fwindow[valid]).mean() # D. Scipión added with correct definition total_power = (spec2[valid] * fwindow[valid]).mean() # D. Scipión added with correct definition - power = ((spec2[valid] - n0) * fwindow[valid]).sum() + power = ((spec2[valid] - n0) * fwindow[valid]).sum() fd = ((spec2[valid]- n0)*freq[valid] * fwindow[valid]).sum() / power w = numpy.sqrt(((spec2[valid] - n0)*fwindow[valid]*(freq[valid]- fd)**2).sum() / power) snr = (spec2.mean()-n0)/n0 @@ -3884,3 +3900,567 @@ class SMOperations(): # error[indInvalid1] = 13 # # return heights, error + + +class WeatherRadar(Operation): + ''' + Function tat implements Weather Radar operations- + Input: + Output: + Parameters affected: + ''' + isConfig = False + + def __init__(self): + Operation.__init__(self) + + def setup(self,dataOut,Pt=0,Gt=0,Gr=0,lambda_=0, aL=0, + tauW= 0,thetaT=0,thetaR=0,Km =0): + self.nCh = dataOut.nChannels + self.nHeis = dataOut.nHeights + deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] + self.Range = numpy.arange(dataOut.nHeights)*deltaHeight + dataOut.heightList[0] + self.Range = self.Range.reshape(1,self.nHeis) + self.Range = numpy.tile(self.Range,[self.nCh,1]) + '''-----------1 Constante del Radar----------''' + self.Pt = Pt + self.Gt = Gt + self.Gr = Gr + self.lambda_ = lambda_ + self.aL = aL + self.tauW = tauW + self.thetaT = thetaT + self.thetaR = thetaR + self.Km = Km + Numerator = ((4*numpy.pi)**3 * aL**2 * 16 *numpy.log(2)) + Denominator = (Pt * Gt * Gr * lambda_**2 * SPEED_OF_LIGHT * tauW * numpy.pi*thetaT*thetaR) + self.RadarConstant = Numerator/Denominator + '''-----------2 Reflectividad del Radar y Factor de Reflectividad------''' + self.n_radar = numpy.zeros((self.nCh,self.nHeis)) + self.Z_radar = numpy.zeros((self.nCh,self.nHeis)) + + def setMoments(self,dataOut,i): + + type = dataOut.inputUnit + nCh = dataOut.nChannels + nHeis= dataOut.nHeights + data_param = numpy.zeros((nCh,4,nHeis)) + if type == "Voltage": + data_param[:,0,:] = dataOut.dataPP_POW/(dataOut.nCohInt**2) + data_param[:,1,:] = dataOut.dataPP_DOP + data_param[:,2,:] = dataOut.dataPP_WIDTH + data_param[:,3,:] = dataOut.dataPP_SNR + if type == "Spectra": + data_param[:,0,:] = dataOut.data_POW + data_param[:,1,:] = dataOut.data_DOP + data_param[:,2,:] = dataOut.data_WIDTH + def setMoments(self,dataOut,i): + data_param[:,3,:] = dataOut.data_SNR + + return data_param[:,i,:] + + + def run(self,dataOut,Pt=25,Gt=200.0,Gr=50.0,lambda_=0.32, aL=2.5118, + tauW= 4.0e-6,thetaT=0.165,thetaR=0.367,Km =0.93): + + if not self.isConfig: + self.setup(dataOut= dataOut,Pt=25,Gt=200.0,Gr=50.0,lambda_=0.32, aL=2.5118, + tauW= 4.0e-6,thetaT=0.165,thetaR=0.367,Km =0.93) + self.isConfig = True + '''-----------------------------Potencia de Radar -Signal S-----------------------------''' + Pr = self.setMoments(dataOut,0) + + for R in range(self.nHeis): + self.n_radar[:,R] = self.RadarConstant*Pr[:,R]* (self.Range[:,R])**2 + + self.Z_radar[:,R] = self.n_radar[:,R]* self.lambda_**4/( numpy.pi**5 * self.Km**2) + + '''----------- Factor de Reflectividad Equivalente lamda_ < 10 cm , lamda_= 3.2cm-------''' + Zeh = self.Z_radar + dBZeh = 10*numpy.log10(Zeh) + dataOut.factor_Zeh= dBZeh + self.n_radar = numpy.zeros((self.nCh,self.nHeis)) + self.Z_radar = numpy.zeros((self.nCh,self.nHeis)) + + return dataOut + +class PedestalInformation(Operation): + path_ped = None + path_adq = None + t_Interval_p = None + n_Muestras_p = None + isConfig = False + blocksPerfile= None + f_a_p = None + online = None + angulo_adq = None + nro_file = None + nro_key_p = None + + + def __init__(self): + Operation.__init__(self) + + def getfirstFilefromPath(self,path,meta,ext): + validFilelist = [] + #print("SEARH",path) + try: + fileList = os.listdir(path) + except: + print("check path - fileList") + if len(fileList)<1: + return None + # meta 1234 567 8-18 BCDE + # H,D,PE YYYY DDD EPOC .ext + + for thisFile in fileList: + #print("HI",thisFile) + if meta =="PE": + try: + number= int(thisFile[len(meta)+7:len(meta)+17]) + except: + print("There is a file or folder with different format") + if meta == "D": + try: + number= int(thisFile[8:11]) + except: + print("There is a file or folder with different format") + + if not isNumber(str=number): + continue + if (os.path.splitext(thisFile)[-1].lower() != ext.lower()): + continue + validFilelist.sort() + validFilelist.append(thisFile) + if len(validFilelist)>0: + validFilelist = sorted(validFilelist,key=str.lower) + return validFilelist + return None + + def gettimeutcfromDirFilename(self,path,file): + dir_file= path+"/"+file + fp = h5py.File(dir_file,'r') + #epoc = fp['Metadata'].get('utctimeInit')[()] + epoc = fp['Data'].get('utc')[()] + fp.close() + return epoc + + def getDatavaluefromDirFilename(self,path,file,value): + dir_file= path+"/"+file + fp = h5py.File(dir_file,'r') + array = fp['Data'].get(value)[()] + fp.close() + return array + + def getFile_KeyP(self,list_pedestal,list_adq): + print(list_pedestal) + print(list_adq) + + def getNROFile(self,utc_adq,utc_ped_list): + c=0 + for i in range(len(utc_ped_list)): + if utc_adq>utc_ped_list[i]: + c +=1 + + return c-1,utc_ped_list[c-1],utc_ped_list[c] + + + def setup_offline(self,list_pedestal,list_adq): + print("SETUP OFFLINE") + print(self.path_ped) + print(self.path_adq) + print(len(self.list_pedestal)) + print(len(self.list_adq)) + utc_ped_list=[] + for i in range(len(self.list_pedestal)): + utc_ped_list.append(self.gettimeutcfromDirFilename(path=self.path_ped,file=self.list_pedestal[i])) + + #utc_ped_list= utc_ped_list + utc_adq = self.gettimeutcfromDirFilename(path=self.path_adq,file=self.list_adq[0]) + #print("utc_ped_list",utc_ped_list) + print("utc_adq",utc_adq) + nro_file,utc_ped = self.getNROFile(utc_adq=utc_adq, utc_ped_list= utc_ped_list) + + print("nro_file",nro_file,"utc_ped",utc_ped) + print("nro_file",i) + nro_key_p = int((utc_adq-utc_ped)/self.t_Interval_p) + print("nro_key_p",nro_key_p) + + ff_pedestal = self.list_pedestal[nro_file] + #angulo = self.getDatavaluefromDirFilename(path=self.path_ped,file=ff_pedestal,value="azimuth") + angulo = self.getDatavaluefromDirFilename(path=self.path_ped,file=ff_pedestal,value="azi_pos") + + print("utc_pedestal_init :",utc_ped+nro_key_p*self.t_Interval_p) + print("angulo_array :",angulo[nro_key_p]) + self.nro_file = nro_file + self.nro_key_p = nro_key_p + + def setup_online(self,dataOut): + utc_adq =dataOut.utctime + print("Online-utc_adq",utc_adq) + print(len(self.list_pedestal)) + utc_ped_list=[] + for i in range(len(self.list_pedestal)): + utc_ped_list.append(self.gettimeutcfromDirFilename(path=self.path_ped,file=self.list_pedestal[i])) + print(utc_ped_list[:20]) + #print(utc_ped_list[488:498]) + print("ultimo UTC-PEDESTAL",utc_ped_list[-1]) + nro_file,utc_ped,utc_ped_1 = self.getNROFile(utc_adq=utc_adq, utc_ped_list= utc_ped_list) + print("nro_file",nro_file,"utc_ped",utc_ped,"utc_ped_1",utc_ped_1) + print("name_PEDESTAL",self.list_pedestal[nro_file]) + nro_key_p = int((utc_adq-utc_ped)/self.t_Interval_p) + print("nro_key_p",nro_key_p) + ff_pedestal = self.list_pedestal[nro_file] + #angulo = self.getDatavaluefromDirFilename(path=self.path_ped,file=ff_pedestal,value="azimuth") + angulo = self.getDatavaluefromDirFilename(path=self.path_ped,file=ff_pedestal,value="azi_pos") + + print("utc_pedestal_init :",utc_ped+nro_key_p*self.t_Interval_p) + print("angulo_array :",angulo[nro_key_p]) + self.nro_file = nro_file + self.nro_key_p = nro_key_p + + + ''' + print("############################") + utc_adq = dataOut.utctime + print("ONLINE",dataOut.utctime) + print("utc_adq" , utc_adq) + utc_pedestal= self.gettimeutcfromDirFilename(path=self.path_ped,file=self.list_pedestal[0]) + print("utc_pedestal", utc_pedestal) + flag_i = 0 + flag = 0 + ready = 0 + if len(self.list_pedestal)!=0: + enable_p=1 + if (enable_p!=0): + while(flag_i==0): + if utc_adq>utc_pedestal: + nro_file = int((utc_adq - utc_pedestal)/(self.t_Interval_p*self.n_Muestras_p)) + print("nro_file--------------------",nro_file) + print(len(self.list_pedestal)) + if nro_file> len(self.list_pedestal): + nro_file = len(self.list_pedestal)-1 + ff_pedestal = self.list_pedestal[nro_file] + print(ff_pedestal) + utc_pedestal = self.gettimeutcfromDirFilename(path=self.path_ped,file=ff_pedestal) + while(flag==0): + print("adq",utc_adq) + print("ped",utc_pedestal) + print("nro_file",nro_file) + if utc_adq >utc_pedestal: + print("DENTRO DEL IF-SETUP") + ff_pedestal = self.list_pedestal[nro_file] + if 0<(utc_adq - utc_pedestal)<(self.t_Interval_p*self.n_Muestras_p): + nro_file= nro_file + ff_pedestal = self.list_pedestal[nro_file] + ready = 1 + if (utc_adq-utc_pedestal)>(self.t_Interval_p*self.n_Muestras_p): + nro_tmp= int((utc_adq-utc_pedestal)/(self.n_Muestras_p)) + nro_file= nro_file+1*nro_tmp#chsssssssssssssssssssasssddasdas/ equear esta condicion + if nro_tmp==0: + nro_file= nro_file +1 + ff_pedestal = self.list_pedestal[nro_file] + print("",ff_pedestal) + utc_pedestal = self.gettimeutcfromDirFilename(path=self.path_ped,file=ff_pedestal) + else: + print("DENTRO DEL ELSE-SETUP") + nro_tmp= int((utc_pedestal-utc_adq)/(self.n_Muestras_p)) + if utc_pedestal>utc_adq and nro_tmp==0: + nro_tmp= int((utc_pedestal-utc_adq)) + print("nro_tmp",nro_tmp) + if nro_file>nro_tmp: + nro_file = nro_file-1*nro_tmp + else: + nro_file =nro_file -1 + + ff_pedestal = self.list_pedestal[nro_file] + utc_pedestal = self.gettimeutcfromDirFilename(path=self.path_ped,file=ff_pedestal) + + if ready: + angulo = self.getDatavaluefromDirFilename(path=self.path_ped,file=ff_pedestal,value="azimuth") + nro_key_p = int((utc_adq-utc_pedestal)/self.t_Interval_p) + print("nro_file :",nro_file) + print("name_file :",ff_pedestal) + print("utc_pedestal_file :",utc_pedestal) + print("nro_key_p :",nro_key_p) + print("utc_pedestal_init :",utc_pedestal+nro_key_p*self.t_Interval_p) + print("angulo_array :",angulo[nro_key_p]) + flag=1 + flag_i=1 + else: + print("La lista de archivos de pedestal o adq esta vacia") + nro_file=None + nro_key_p=None + self.nro_file = nro_file + self.nro_key_p = nro_key_p + ''' + + def setup(self,dataOut,path_ped,path_adq,t_Interval_p,n_Muestras_p,blocksPerfile,f_a_p,online): + self.__dataReady = False + self.path_ped = path_ped + self.path_adq = path_adq + self.t_Interval_p = t_Interval_p + self.n_Muestras_p = n_Muestras_p + self.blocksPerfile= blocksPerfile + self.f_a_p = f_a_p + self.online = online + self.angulo_adq = numpy.zeros(self.blocksPerfile) + self.__profIndex = 0 + print(self.path_ped) + print(self.path_adq) + self.list_pedestal = self.getfirstFilefromPath(path=self.path_ped,meta="PE",ext=".hdf5") + print("LIST NEW", self.list_pedestal[:20]) + self.list_adq = self.getfirstFilefromPath(path=self.path_adq,meta="D",ext=".hdf5") + print("*************Longitud list pedestal****************",len(self.list_pedestal)) + + if self.online: + print("Enable Online") + self.setup_online(dataOut) + else: + self.setup_offline(list_pedestal=self.list_pedestal,list_adq=self.list_adq) + + def setNextFileP(self,dataOut): + if self.online: + data_pedestal = self.setNextFileonline() + else: + data_pedestal = self.setNextFileoffline() + + return data_pedestal + + + def setNextFileoffline(self): + tmp =0 + for j in range(self.blocksPerfile): + #print("NUMERO DEL BLOQUE:",j) + iterador = self.nro_key_p +self.f_a_p*(j-tmp) + #print("iterador",iterador) + if iterador < self.n_Muestras_p: + self.nro_file = self.nro_file + else: + self.nro_file = self.nro_file+1 + dif = self.blocksPerfile-(self.nro_key_p+self.f_a_p*(j-tmp-1)) + tmp = j + self.nro_key_p= self.f_a_p-dif + iterador = self.nro_key_p + #print("nro_file",self.nro_file) + try: + ff_pedestal = self.list_pedestal[self.nro_file] + except: + return numpy.ones(self.blocksPerfile)*numpy.nan + + angulo = self.getDatavaluefromDirFilename(path=self.path_ped,file=ff_pedestal,value="azimuth") + self.angulo_adq[j]= angulo[iterador] + + return self.angulo_adq + + def setNextFileonline(self): + tmp = 0 + self.nTries_p = 3 + self.delay = 3 + ready = 1 + for j in range(self.blocksPerfile): + iterador = self.nro_key_p +self.f_a_p*(j-tmp) + if iterador < self.n_Muestras_p: + self.nro_file = self.nro_file + else: + self.nro_file = self.nro_file+1 + dif = self.blocksPerfile-(self.nro_key_p+self.f_a_p*(j-tmp-1)) + tmp = j + self.nro_key_p= self.f_a_p-dif + iterador = self.nro_key_p + print("nro_file---------------- :",self.nro_file) + try: + # update list_pedestal + self.list_pedestal = self.getfirstFilefromPath(path=self.path_ped,meta="PE",ext=".hdf5") + ff_pedestal = self.list_pedestal[self.nro_file] + except: + ff_pedestal = None + ready = 0 + for nTries_p in range(self.nTries_p): + try: + # update list_pedestal + self.list_pedestal = self.getfirstFilefromPath(path=self.path_ped,meta="PE",ext=".hdf5") + ff_pedestal = self.list_pedestal[self.nro_file] + except: + ff_pedestal = None + if ff_pedestal is not None: + ready=1 + break + log.warning("Waiting %0.2f sec for the next file: \"%s\" , try %02d ..." % (self.delay, self.nro_file, nTries_p + 1)) + time.sleep(self.delay) + continue + #return numpy.ones(self.blocksPerfile)*numpy.nan + + if ready == 1: + #angulo = self.getDatavaluefromDirFilename(path=self.path_ped,file=ff_pedestal,value="azimuth") + angulo = self.getDatavaluefromDirFilename(path=self.path_ped,file=ff_pedestal,value="azi_pos") + + else: + print("there is no pedestal file") + angulo = numpy.ones(self.n_Muestras_p)*numpy.nan + self.angulo_adq[j]= angulo[iterador] + print("Angulo",self.angulo_adq) + print("Angulo",len(self.angulo_adq)) + #self.nro_key_p=iterador + self.f_a_p + #if self.nro_key_p< self.n_Muestras_p: + # self.nro_file = self.nro_file + #else: + # self.nro_file = self.nro_file+1 + # self.nro_key_p= self.nro_key_p + return self.angulo_adq + + + def run(self, dataOut,path_ped,path_adq,t_Interval_p,n_Muestras_p,blocksPerfile,f_a_p,online): + if not self.isConfig: + self.setup( dataOut, path_ped,path_adq,t_Interval_p,n_Muestras_p,blocksPerfile,f_a_p,online) + self.isConfig = True + + dataOut.flagNoData = True + #print("profIndex",self.__profIndex) + + if self.__profIndex==0: + angulo_adq = self.setNextFileP(dataOut) + dataOut.azimuth = angulo_adq + self.__dataReady = True + self.__profIndex += 1 + if self.__profIndex== blocksPerfile: + self.__profIndex = 0 + if self.__dataReady: + #print(self.__profIndex,dataOut.azimuth[:10]) + dataOut.flagNoData = False + return dataOut + + +class Block360(Operation): + ''' + ''' + isConfig = False + __profIndex = 0 + __initime = None + __lastdatatime = None + __buffer = None + __dataReady = False + n = None + __nch = 0 + __nHeis = 0 + index = 0 + + def __init__(self,**kwargs): + Operation.__init__(self,**kwargs) + + def setup(self, dataOut, n = None): + ''' + n= Numero de PRF's de entrada + ''' + self.__initime = None + self.__lastdatatime = 0 + self.__dataReady = False + self.__buffer = 0 + self.__buffer_1D = 0 + self.__profIndex = 0 + self.index = 0 + self.__nch = dataOut.nChannels + self.__nHeis = dataOut.nHeights + ##print("ELVALOR DE n es:", n) + if n == None: + raise ValueError("n should be specified.") + + if n != None: + if n<1: + print("n should be greater than 2") + raise ValueError("n should be greater than 2") + + self.n = n + #print("nHeights") + self.__buffer = numpy.zeros(( dataOut.nChannels,n, dataOut.nHeights)) + self.__buffer2= numpy.zeros(n) + + def putData(self,data): + ''' + Add a profile to he __buffer and increase in one the __profiel Index + ''' + #print("line 4049",data.dataPP_POW.shape,data.dataPP_POW[:10]) + #print("line 4049",data.azimuth.shape,data.azimuth) + self.__buffer[:,self.__profIndex,:]= data.dataPP_POW + #print("me casi",self.index,data.azimuth[self.index]) + #print(self.__profIndex, self.index , data.azimuth[self.index] ) + #print("magic",data.profileIndex) + #print(data.azimuth[self.index]) + #print("index",self.index) + + self.__buffer2[self.__profIndex] = data.azimuth[self.index] + #print("q pasa") + self.index+=1 + #print("index",self.index,data.azimuth[:10]) + self.__profIndex += 1 + return #················· Remove DC··································· + + def pushData(self,data): + ''' + Return the PULSEPAIR and the profiles used in the operation + Affected : self.__profileIndex + ''' + #print("pushData") + + data_360 = self.__buffer + data_p = self.__buffer2 + n = self.__profIndex + + self.__buffer = numpy.zeros((self.__nch, self.n,self.__nHeis)) + self.__buffer2 = numpy.zeros(self.n) + self.__profIndex = 0 + #print("pushData") + return data_360,n,data_p + + + def byProfiles(self,dataOut): + + self.__dataReady = False + data_360 = None + data_p = None + #print("dataOu",dataOut.dataPP_POW) + self.putData(data=dataOut) + #print("profIndex",self.__profIndex) + if self.__profIndex == self.n: + data_360,n,data_p = self.pushData(data=dataOut) + self.__dataReady = True + + return data_360,data_p + + + def blockOp(self, dataOut, datatime= None): + if self.__initime == None: + self.__initime = datatime + data_360,data_p = self.byProfiles(dataOut) + self.__lastdatatime = datatime + + if data_360 is None: + return None, None,None + + avgdatatime = self.__initime + deltatime = datatime - self.__lastdatatime + self.__initime = datatime + #print(data_360.shape,avgdatatime,data_p.shape) + return data_360,avgdatatime,data_p + + def run(self, dataOut,n = None,**kwargs): + + if not self.isConfig: + self.setup(dataOut = dataOut, n = n , **kwargs) + self.index = 0 + #print("comova",self.isConfig) + self.isConfig = True + if self.index==dataOut.azimuth.shape[0]: + self.index=0 + data_360, avgdatatime,data_p = self.blockOp(dataOut, dataOut.utctime) + dataOut.flagNoData = True + + if self.__dataReady: + dataOut.data_360 = data_360 # S + #print("DATAREADY---------------------------------------------") + print("data_360",dataOut.data_360.shape) + dataOut.data_azi = data_p + #print("jroproc_parameters",data_p[0],data_p[-1])#,data_360.shape,avgdatatime) + dataOut.utctime = avgdatatime + dataOut.flagNoData = False + return dataOut diff --git a/schainpy/model/proc/jroproc_voltage.py b/schainpy/model/proc/jroproc_voltage.py index 9c71e4d..5fb2314 100644 --- a/schainpy/model/proc/jroproc_voltage.py +++ b/schainpy/model/proc/jroproc_voltage.py @@ -1287,7 +1287,7 @@ class CombineProfiles(Operation): return dataOut -class PulsePairVoltage(Operation): +class PulsePair(Operation): ''' Function PulsePair(Signal Power, Velocity) The real component of Lag[0] provides Intensity Information @@ -1324,6 +1324,7 @@ class PulsePairVoltage(Operation): ''' n= Numero de PRF's de entrada ''' + print("[INICIO]-setup del METODO PULSE PAIR") self.__initime = None self.__lastdatatime = 0 self.__dataReady = False @@ -1482,6 +1483,7 @@ class PulsePairVoltage(Operation): dataOut.dataPP_SNR = data_snrPP dataOut.dataPP_WIDTH = data_specwidth dataOut.PRFbyAngle = self.n #numero de PRF*cada angulo rotado que equivale a un tiempo. + dataOut.nProfiles = int(dataOut.nProfiles/n) dataOut.utctime = avgdatatime dataOut.flagNoData = False return dataOut diff --git a/schainpy/scripts/HDF5_WR_DATA.py b/schainpy/scripts/HDF5_WR_DATA.py new file mode 100644 index 0000000..48e2502 --- /dev/null +++ b/schainpy/scripts/HDF5_WR_DATA.py @@ -0,0 +1,31 @@ +import os,sys +import datetime +import time +from schainpy.controller import Project +path='/DATA_RM/TEST_HDF5' +path_adq=path +path_ped='/DATA_RM/TEST_PEDESTAL/P2021200' +figpath = '/home/soporte/Pictures' +desc = "Simulator Test" + +controllerObj = Project() +controllerObj.setup(id='10',name='Test Simulator',description=desc) +readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader', + path=path, + startDate="2021/01/01", #"2020/01/01",#today, + endDate= "2021/12/01", #"2020/12/30",#today, + startTime='00:00:00', + endTime='23:59:59', + t_Interval_p=0.01, + n_Muestras_p=100, + delay=5, + #set=0, + online=0, + walk=1)#1 + +procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId()) + + +controllerObj.start() +#online 1 utc_adq 1617490240.48 +#online 0 utc_adq 1617489815.4804 diff --git a/schainpy/scripts/PEDESTAL_CLIENT_F.py b/schainpy/scripts/PEDESTAL_CLIENT_F.py new file mode 100644 index 0000000..efc3877 --- /dev/null +++ b/schainpy/scripts/PEDESTAL_CLIENT_F.py @@ -0,0 +1,92 @@ +import numpy +import sys +import zmq +import time +import h5py +import os + +timetuple=time.localtime() +meta='P' +dir="%s%4.4d%3.3d"%(meta,timetuple.tm_year,timetuple.tm_yday) + +path="/home/soporte/Downloads/PEDESTAL/"+dir + +ext=".hdf5" + +port ="5556" +if len(sys.argv)>1: + port = sys.argv[1] + int(port) + +if len(sys.argv)>2: + port1 = sys.argv[2] + int(port1) + +#Socket to talk to server +context = zmq.Context() +socket = context.socket(zmq.SUB) + +print("Collecting updates from weather server...") +socket.connect("tcp://localhost:%s"%port) + +if len(sys.argv)>2: + socket.connect("tcp://localhost:%s"%port1) + +#Subscribe to zipcode, default is NYC,10001 +topicfilter = "10001" +socket.setsockopt_string(zmq.SUBSCRIBE,topicfilter) +#Process 5 updates +total_value=0 +count= -1 +azi= [] +elev=[] +time0=[] +#for update_nbr in range(250): +while(True): + string= socket.recv() + topic,ang_elev,ang_elev_dec,ang_azi,ang_azi_dec,seconds,seconds_dec= string.split() + ang_azi =float(ang_azi)+1e-3*float(ang_azi_dec) + ang_elev =float(ang_elev)+1e-3*float(ang_elev_dec) + seconds =float(seconds) +1e-6*float(seconds_dec) + azi.append(ang_azi) + elev.append(ang_elev) + time0.append(seconds) + count +=1 + if count == 100: + timetuple=time.localtime() + epoc = time.mktime(timetuple) + #print(epoc) + fullpath = path + ("/" if path[-1]!="/" else "") + + if not os.path.exists(fullpath): + os.mkdir(fullpath) + + azi_array = numpy.array(azi) + elev_array = numpy.array(elev) + time0_array= numpy.array(time0) + pedestal_array=numpy.array([azi,elev,time0]) + count=0 + azi= [] + elev=[] + time0=[] + #print(pedestal_array[0]) + #print(pedestal_array[1]) + + meta='PE' + filex="%s%4.4d%3.3d%10.4d%s"%(meta,timetuple.tm_year,timetuple.tm_yday,epoc,ext) + filename = os.path.join(fullpath,filex) + fp = h5py.File(filename,'w') + #print("Escribiendo HDF5...",epoc) + #·················· Data·....······································ + grp = fp.create_group("Data") + dset = grp.create_dataset("azimuth" , data=pedestal_array[0]) + dset = grp.create_dataset("elevacion", data=pedestal_array[1]) + dset = grp.create_dataset("utc" , data=pedestal_array[2]) + #·················· Metadata······································· + grp = fp.create_group("Metadata") + dset = grp.create_dataset("utctimeInit", data=pedestal_array[2][0]) + timeInterval = pedestal_array[2][1]-pedestal_array[2][0] + dset = grp.create_dataset("timeInterval", data=timeInterval) + fp.close() + +#print ("Average messagedata value for topic '%s' was %dF" % ( topicfilter,total_value / update_nbr)) diff --git a/schainpy/scripts/PEDESTAL_SERVER_F.py b/schainpy/scripts/PEDESTAL_SERVER_F.py new file mode 100644 index 0000000..446a76a --- /dev/null +++ b/schainpy/scripts/PEDESTAL_SERVER_F.py @@ -0,0 +1,48 @@ +########################################################################### +############################### SERVIDOR################################### +######################### SIMULADOR DE PEDESTAL############################ +########################################################################### +import time +import math +import numpy +import struct +from time import sleep +import zmq +import pickle +port="5556" +context = zmq.Context() +socket = context.socket(zmq.PUB) +socket.bind("tcp://*:%s"%port) +###### PARAMETROS DE ENTRADA################################ +print("PEDESTAL RESOLUCION 0.01") +print("MAXIMA VELOCIDAD DEL PEDESTAL") +ang_elev = 4.12 +ang_azi = 30 +velocidad= input ("Ingresa velocidad:") +velocidad= float(velocidad) +print (velocidad) +############################################################ +sleep(3) +print("Start program") +t1 = time.time() +count=0 +while(True): + tmp_vuelta = int(360/velocidad) + t1=t1+tmp_vuelta*count + count= count+1 + muestras_seg = 100 + t2 = time.time() + for i in range(tmp_vuelta): + for j in range(muestras_seg): + tmp_variable = (i+j/100.0) + ang_azi = (tmp_variable)*float(velocidad) + seconds = t1+ tmp_variable + topic=10001 + print ("Azim°: ","%.4f"%ang_azi,"Time:" ,"%.5f"%seconds) + seconds_dec=(seconds-int(seconds))*1e6 + ang_azi_dec= (ang_azi-int(ang_azi))*1e3 + ang_elev_dec=(ang_elev-int(ang_elev))*1e3 + sleep(0.0088) + socket.send_string("%d %d %d %d %d %d %d"%(topic,ang_elev,ang_elev_dec,ang_azi,ang_azi_dec,seconds,seconds_dec)) + t3 = time.time() + print ("Total time for 1 vuelta in Seconds",t3-t2) diff --git a/schainpy/scripts/TEST_USRP_OPERACIONES.py b/schainpy/scripts/TEST_USRP_OPERACIONES.py new file mode 100644 index 0000000..0272eee --- /dev/null +++ b/schainpy/scripts/TEST_USRP_OPERACIONES.py @@ -0,0 +1,275 @@ +#!python +''' +''' + +import os, sys +import datetime +import time + +#path = os.path.dirname(os.getcwd()) +#path = os.path.dirname(path) +#sys.path.insert(0, path) + +from schainpy.controller import Project + +desc = "USRP_test" +filename = "USRP_processing.xml" +controllerObj = Project() +controllerObj.setup(id = '191', name='Test_USRP', description=desc) + +############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA ############# + +####################################################################### +######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB################# +####################################################################### +#path = '/media/data/data/vientos/57.2063km/echoes/NCO_Woodman' +#path = '/DATA_RM/TEST_INTEGRACION' +#path = '/DATA_RM/PRUEBA_USRP_RP' +path = '/DATA_RM/PRUEBA_USRP_RP' + +figpath = '/home/soporte/Pictures/TEST_RP_0001' +figpath = '/home/soporte/Pictures/TEST_RP_6000' +figpath = '/home/soporte/Pictures/USRP' +#remotefolder = "/home/wmaster/graficos" +####################################################################### +################# RANGO DE PLOTEO###################################### +####################################################################### +dBmin = '-5' +dBmax = '20' +xmin = '0' +xmax ='24' +ymin = '0' +ymax = '600' +####################################################################### +########################FECHA########################################## +####################################################################### +str = datetime.date.today() +today = str.strftime("%Y/%m/%d") +str2 = str - datetime.timedelta(days=1) +yesterday = str2.strftime("%Y/%m/%d") +####################################################################### +######################## UNIDAD DE LECTURA############################# +####################################################################### +readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader', + path=path, + startDate="2021/07/02",#today, + endDate="2021/07/02",#today, + startTime='14:50:00',# inicio libre + #startTime='00:00:00', + endTime='14:55:59', + delay=0, + #set=0, + online=0, + walk=1, + ippKm = 6000) + +opObj11 = readUnitConfObj.addOperation(name='printInfo') +#opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') +####################################################################### +################ OPERACIONES DOMINIO DEL TIEMPO######################## +####################################################################### + +procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) + +opObj11 = procUnitConfObjA.addOperation(name='selectHeights') +opObj11.addParameter(name='minIndex', value='1', format='int') +# opObj11.addParameter(name='maxIndex', value='10000', format='int') +opObj11.addParameter(name='maxIndex', value='39980', format='int') + +# +# codigo64='1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,0,0,0,1,0,0,1,0,1,1,1,0,0,0,1,0,'+\ +# '1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1' + +#opObj11 = procUnitConfObjA.addOperation(name='setRadarFrequency') +#opObj11.addParameter(name='frequency', value='49920000') + +''' +opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other') +opObj11.addParameter(name='n', value='625', format='int')#10 +opObj11.addParameter(name='removeDC', value=1, format='int') +''' + +# Ploteo TEST +''' +opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other') +opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other') +opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other') +#opObj11.addParameter(name='xmax', value=8) +opObj11 = procUnitConfObjA.addOperation(name='PulsepairSpecwidthPlot', optype='other') +''' +# OJO SCOPE +#opObj10 = procUnitConfObjA.addOperation(name='ScopePlot', optype='external') +#opObj10.addParameter(name='id', value='10', format='int') +##opObj10.addParameter(name='xmin', value='0', format='int') +##opObj10.addParameter(name='xmax', value='50', format='int') +#opObj10.addParameter(name='type', value='iq') +##opObj10.addParameter(name='ymin', value='-5000', format='int') +##opObj10.addParameter(name='ymax', value='8500', format='int') +#opObj11.addParameter(name='save', value=figpath, format='str') +#opObj11.addParameter(name='save_period', value=10, format='int') + +#opObj10 = procUnitConfObjA.addOperation(name='setH0') +#opObj10.addParameter(name='h0', value='-5000', format='float') + +#opObj11 = procUnitConfObjA.addOperation(name='filterByHeights') +#opObj11.addParameter(name='window', value='1', format='int') + +#codigo='1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1' +#opObj11 = procUnitConfObjSousy.addOperation(name='Decoder', optype='other') +#opObj11.addParameter(name='code', value=codigo, format='floatlist') +#opObj11.addParameter(name='nCode', value='1', format='int') +#opObj11.addParameter(name='nBaud', value='28', format='int') + +#opObj11 = procUnitConfObjA.addOperation(name='CohInt', optype='other') +#opObj11.addParameter(name='n', value='100', format='int') + +####################################################################### +########## OPERACIONES ParametersProc######################## +####################################################################### +###procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId()) +''' + +opObj11 = procUnitConfObjA.addOperation(name='PedestalInformation') +opObj11.addParameter(name='path_ped', value=path_ped) +opObj11.addParameter(name='path_adq', value=path_adq) +opObj11.addParameter(name='t_Interval_p', value='0.01', format='float') +opObj11.addParameter(name='n_Muestras_p', value='100', format='float') +opObj11.addParameter(name='blocksPerfile', value='100', format='int') +opObj11.addParameter(name='f_a_p', value='25', format='int') +opObj11.addParameter(name='online', value='0', format='int') + +opObj11 = procUnitConfObjA.addOperation(name='Block360') +opObj11.addParameter(name='n', value='40', format='int') + +opObj11= procUnitConfObjA.addOperation(name='WeatherPlot',optype='other') +opObj11.addParameter(name='save', value=figpath) +opObj11.addParameter(name='save_period', value=1) + +8 +''' + +####################################################################### +########## OPERACIONES DOMINIO DE LA FRECUENCIA######################## +####################################################################### + +#procUnitConfObjB = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjA.getId()) +#procUnitConfObjB.addParameter(name='nFFTPoints', value='32', format='int') +#procUnitConfObjB.addParameter(name='nProfiles', value='32', format='int') + +procUnitConfObjC = controllerObj.addProcUnit(datatype='SpectraHeisProc', inputId=procUnitConfObjA.getId()) +#procUnitConfObjB.addParameter(name='nFFTPoints', value='64', format='int') +#procUnitConfObjB.addParameter(name='nProfiles', value='64', format='int') +opObj11 = procUnitConfObjC.addOperation(name='IncohInt4SpectraHeis', optype='other') +#opObj11.addParameter(name='timeInterval', value='4', format='int') +opObj11.addParameter(name='n', value='100', format='int') + +#procUnitConfObjB.addParameter(name='pairsList', value='(0,0),(1,1),(0,1)', format='pairsList') + +#opObj13 = procUnitConfObjB.addOperation(name='removeDC') +#opObj13.addParameter(name='mode', value='2', format='int') + +#opObj11 = procUnitConfObjB.addOperation(name='IncohInt', optype='other') +#opObj11.addParameter(name='n', value='8', format='float') +####################################################################### +########## PLOTEO DOMINIO DE LA FRECUENCIA############################# +####################################################################### +#---- + +opObj11 = procUnitConfObjC.addOperation(name='SpectraHeisPlot') +opObj11.addParameter(name='id', value='10', format='int') +opObj11.addParameter(name='wintitle', value='Spectra_Alturas', format='str') +#opObj11.addParameter(name='xmin', value=-100000, format='float') +#opObj11.addParameter(name='xmax', value=100000, format='float') +opObj11.addParameter(name='oneFigure', value=False,format='bool') +#opObj11.addParameter(name='zmin', value=-10, format='int') +#opObj11.addParameter(name='zmax', value=40, format='int') +opObj11.addParameter(name='ymin', value=10, format='int') +opObj11.addParameter(name='ymax', value=55, format='int') +opObj11.addParameter(name='grid', value=True, format='bool') +#opObj11.addParameter(name='showprofile', value='1', format='int') +opObj11.addParameter(name='save', value=figpath, format='str') +#opObj11.addParameter(name='save_period', value=10, format='int') + +''' +opObj11 = procUnitConfObjC.addOperation(name='RTIHeisPlot') +opObj11.addParameter(name='id', value='10', format='int') +opObj11.addParameter(name='wintitle', value='RTI_Alturas', format='str') +opObj11.addParameter(name='xmin', value=11.0, format='float') +opObj11.addParameter(name='xmax', value=18.0, format='float') +opObj11.addParameter(name='zmin', value=10, format='int') +opObj11.addParameter(name='zmax', value=30, format='int') +opObj11.addParameter(name='ymin', value=5, format='int') +opObj11.addParameter(name='ymax', value=28, format='int') +opObj11.addParameter(name='showprofile', value='1', format='int') +opObj11.addParameter(name='save', value=figpath, format='str') +opObj11.addParameter(name='save_period', value=10, format='int') +''' +''' +#SpectraPlot + +opObj11 = procUnitConfObjB.addOperation(name='SpectraPlot', optype='external') +opObj11.addParameter(name='id', value='1', format='int') +opObj11.addParameter(name='wintitle', value='Spectra', format='str') +#opObj11.addParameter(name='xmin', value=-0.01, format='float') +#opObj11.addParameter(name='xmax', value=0.01, format='float') +opObj11.addParameter(name='zmin', value=dBmin, format='int') +opObj11.addParameter(name='zmax', value=dBmax, format='int') +#opObj11.addParameter(name='ymin', value=ymin, format='int') +#opObj11.addParameter(name='ymax', value=ymax, format='int') +opObj11.addParameter(name='showprofile', value='1', format='int') +opObj11.addParameter(name='save', value=figpath, format='str') +opObj11.addParameter(name='save_period', value=10, format='int') + +#RTIPLOT + +opObj11 = procUnitConfObjB.addOperation(name='RTIPlot', optype='external') +opObj11.addParameter(name='id', value='2', format='int') +opObj11.addParameter(name='wintitle', value='RTIPlot', format='str') +opObj11.addParameter(name='zmin', value=dBmin, format='int') +opObj11.addParameter(name='zmax', value=dBmax, format='int') +#opObj11.addParameter(name='ymin', value=ymin, format='int') +#opObj11.addParameter(name='ymax', value=ymax, format='int') +#opObj11.addParameter(name='xmin', value=15, format='int') +#opObj11.addParameter(name='xmax', value=16, format='int') + +opObj11.addParameter(name='showprofile', value='1', format='int') +opObj11.addParameter(name='save', value=figpath, format='str') +opObj11.addParameter(name='save_period', value=10, format='int') + +''' +# opObj11 = procUnitConfObjB.addOperation(name='CrossSpectraPlot', optype='other') +# opObj11.addParameter(name='id', value='3', format='int') +# opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str') +# opObj11.addParameter(name='ymin', value=ymin, format='int') +# opObj11.addParameter(name='ymax', value=ymax, format='int') +# opObj11.addParameter(name='phase_cmap', value='jet', format='str') +# opObj11.addParameter(name='zmin', value=dBmin, format='int') +# opObj11.addParameter(name='zmax', value=dBmax, format='int') +# opObj11.addParameter(name='figpath', value=figures_path, format='str') +# opObj11.addParameter(name='save', value=0, format='bool') +# opObj11.addParameter(name='pairsList', value='(0,1)', format='pairsList') +# # +# opObj11 = procUnitConfObjB.addOperation(name='CoherenceMap', optype='other') +# opObj11.addParameter(name='id', value='4', format='int') +# opObj11.addParameter(name='wintitle', value='Coherence', format='str') +# opObj11.addParameter(name='phase_cmap', value='jet', format='str') +# opObj11.addParameter(name='xmin', value=xmin, format='float') +# opObj11.addParameter(name='xmax', value=xmax, format='float') +# opObj11.addParameter(name='figpath', value=figures_path, format='str') +# opObj11.addParameter(name='save', value=0, format='bool') +# opObj11.addParameter(name='pairsList', value='(0,1)', format='pairsList') +# + +''' +####################################################################### +############### UNIDAD DE ESCRITURA ################################### +####################################################################### +#opObj11 = procUnitConfObjB.addOperation(name='SpectraWriter', optype='other') +#opObj11.addParameter(name='path', value=wr_path) +#opObj11.addParameter(name='blocksPerFile', value='50', format='int') +print ("Escribiendo el archivo XML") +print ("Leyendo el archivo XML") +''' + + +controllerObj.start() diff --git a/schainpy/scripts/USRP_ADQ_PP.py b/schainpy/scripts/USRP_ADQ_PP.py new file mode 100644 index 0000000..3008fdb --- /dev/null +++ b/schainpy/scripts/USRP_ADQ_PP.py @@ -0,0 +1,126 @@ +#!python +''' +''' + +import os, sys +import datetime +import time + +#path = os.path.dirname(os.getcwd()) +#path = os.path.dirname(path) +#sys.path.insert(0, path) + +from schainpy.controller import Project + +desc = "USRP_test" +filename = "USRP_processing.xml" +controllerObj = Project() +controllerObj.setup(id = '191', name='Test_USRP', description=desc) + +############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA ############# + +####################################################################### +######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB################# +####################################################################### +#path = '/media/data/data/vientos/57.2063km/echoes/NCO_Woodman' +#path = '/DATA_RM/TEST_INTEGRACION' +path = '/DATA_RM/TEST_ONLINE' +path_pp = '/DATA_RM/TEST_HDF5' + +figpath = '/home/soporte/Pictures/TEST_INTEGRACION_IMG' +#remotefolder = "/home/wmaster/graficos" +####################################################################### +################# RANGO DE PLOTEO###################################### +####################################################################### +dBmin = '-5' +dBmax = '20' +xmin = '0' +xmax ='24' +ymin = '0' +ymax = '600' +####################################################################### +########################FECHA########################################## +####################################################################### +str = datetime.date.today() +today = str.strftime("%Y/%m/%d") +str2 = str - datetime.timedelta(days=1) +yesterday = str2.strftime("%Y/%m/%d") +####################################################################### +######################## UNIDAD DE LECTURA############################# +####################################################################### +readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader', + path=path, + startDate="2021/01/01",#today, + endDate="2021/12/30",#today, + startTime='00:00:00', + endTime='23:59:59', + delay=0, + #set=0, + online=1, + walk=1, + ippKm = 60) + +opObj11 = readUnitConfObj.addOperation(name='printInfo') +#opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') +####################################################################### +################ OPERACIONES DOMINIO DEL TIEMPO######################## +####################################################################### + +procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) + +# +# codigo64='1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,0,0,0,1,0,0,1,0,1,1,1,0,0,0,1,0,'+\ +# '1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1' + +#opObj11 = procUnitConfObjA.addOperation(name='setRadarFrequency') +#opObj11.addParameter(name='frequency', value='70312500') +opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other') +opObj11.addParameter(name='n', value='625', format='int')#10 +opObj11.addParameter(name='removeDC', value=1, format='int') +# Ploteo TEST +''' +opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other') +opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other') +opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other') +#opObj11.addParameter(name='xmax', value=8) +opObj11 = procUnitConfObjA.addOperation(name='PulsepairSpecwidthPlot', optype='other') +''' +# OJO SCOPE +#opObj10 = procUnitConfObjA.addOperation(name='ScopePlot', optype='external') +#opObj10.addParameter(name='id', value='10', format='int') +##opObj10.addParameter(name='xmin', value='0', format='int') +##opObj10.addParameter(name='xmax', value='50', format='int') +#opObj10.addParameter(name='type', value='iq') +##opObj10.addParameter(name='ymin', value='-5000', format='int') +##opObj10.addParameter(name='ymax', value='8500', format='int') +#opObj11.addParameter(name='save', value=figpath, format='str') +#opObj11.addParameter(name='save_period', value=10, format='int') + +#opObj10 = procUnitConfObjA.addOperation(name='setH0') +#opObj10.addParameter(name='h0', value='-5000', format='float') + +#opObj11 = procUnitConfObjA.addOperation(name='filterByHeights') +#opObj11.addParameter(name='window', value='1', format='int') + +#codigo='1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1' +#opObj11 = procUnitConfObjSousy.addOperation(name='Decoder', optype='other') +#opObj11.addParameter(name='code', value=codigo, formatyesterday='floatlist') +#opObj11.addParameter(name='nCode', value='1', format='int') +#opObj11.addParameter(name='nBaud', value='28', format='int') + +#opObj11 = procUnitConfObjA.addOperation(name='CohInt', optype='other') +#opObj11.addParameter(name='n', value='100', format='int') + +####################################################################### +########## OPERACIONES ParametersProc######################## +####################################################################### + +procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId()) +opObj10 = procUnitConfObjB.addOperation(name='HDFWriter') +opObj10.addParameter(name='path',value=path_pp) +#opObj10.addParameter(name='mode',value=0) +opObj10.addParameter(name='blocksPerFile',value='100',format='int') +opObj10.addParameter(name='metadataList',value='utctimeInit,timeZone,paramInterval,profileIndex,channelList,heightList,flagDataAsBlock',format='list') +opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,utctime',format='list')#,format='list' + +controllerObj.start() diff --git a/schainpy/scripts/USRP_ADQ_SPECM.py b/schainpy/scripts/USRP_ADQ_SPECM.py new file mode 100644 index 0000000..62b8f5f --- /dev/null +++ b/schainpy/scripts/USRP_ADQ_SPECM.py @@ -0,0 +1,126 @@ +#!python +''' +''' + +import os, sys +import datetime +import time + +#path = os.path.dirname(os.getcwd()) +#path = os.path.dirname(path) +#sys.path.insert(0, path) + +from schainpy.controller import Project + +desc = "USRP_test" +filename = "USRP_processing.xml" +controllerObj = Project() +controllerObj.setup(id = '191', name='Test_USRP', description=desc) + +############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA ############# + +####################################################################### +######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB################# +####################################################################### +#path = '/media/data/data/vientos/57.2063km/echoes/NCO_Woodman' +#path = '/DATA_RM/TEST_INTEGRACION' +path = '/DATA_RM/TEST_ONLINE' +path_pp = '/DATA_RM/TEST_HDF5' + +figpath = '/home/soporte/Pictures/TEST_INTEGRACION_IMG' +#remotefolder = "/home/wmaster/graficos" +####################################################################### +################# RANGO DE PLOTEO###################################### +####################################################################### +dBmin = '-5' +dBmax = '20' +xmin = '0' +xmax ='24' +ymin = '0' +ymax = '600' +####################################################################### +########################FECHA########################################## +####################################################################### +str = datetime.date.today() +today = str.strftime("%Y/%m/%d") +str2 = str - datetime.timedelta(days=1) +yesterday = str2.strftime("%Y/%m/%d") +####################################################################### +######################## UNIDAD DE LECTURA############################# +####################################################################### +readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader', + path=path, + startDate="2021/01/01",#today, + endDate="2021/12/30",#today, + startTime='00:00:00', + endTime='23:59:59', + delay=0, + #set=0, + online=1, + walk=1, + ippKm = 60) + +opObj11 = readUnitConfObj.addOperation(name='printInfo') +#opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') +####################################################################### +################ OPERACIONES DOMINIO DEL TIEMPO######################## +####################################################################### + +procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) + +# +# codigo64='1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,0,0,0,1,0,0,1,0,1,1,1,0,0,0,1,0,'+\ +# '1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1' + +#opObj11 = procUnitConfObjA.addOperation(name='setRadarFrequency') +#opObj11.addParameter(name='frequency', value='70312500') +opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other') +opObj11.addParameter(name='n', value='625', format='int')#10 +opObj11.addParameter(name='removeDC', value=1, format='int') +# Ploteo TEST +''' +opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other') +opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other') +opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other') +#opObj11.addParameter(name='xmax', value=8) +opObj11 = procUnitConfObjA.addOperation(name='PulsepairSpecwidthPlot', optype='other') +''' +# OJO SCOPE +#opObj10 = procUnitConfObjA.addOperation(name='ScopePlot', optype='external') +#opObj10.addParameter(name='buffer_sizeid', value='10', format='int') +##opObj10.addParameter(name='xmin', value='0', format='int') +##opObj10.addParameter(name='xmax', value='50', format='int') +#opObj10.addParameter(name='type', value='iq') +##opObj10.addParameter(name='ymin', value='-5000', format='int') +##opObj10.addParameter(name='ymax', value='8500', format='int') +#opObj11.addParameter(name='save', value=figpath, format='str') +#opObj11.addParameter(name='save_period', value=10, format='int') + +#opObj10 = procUnitConfObjA.addOperation(name='setH0') +#opObj10.addParameter(name='h0', value='-5000', format='float') + +#opObj11 = procUnitConfObjA.addOperation(name='filterByHeights') +#opObj11.addParameter(name='window', value='1', format='int') + +#codigo='1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1' +#opObj11 = procUnitConfObjSousy.addOperation(name='Decoder', optype='other') +#opObj11.addParameter(name='code', value=codigo, formatyesterday='floatlist') +#opObj11.addParameter(name='nCode', value='1', format='int') +#opObj11.addParameter(name='nBaud', value='28', format='int') + +#opObj11 = procUnitConfObjA.addOperation(name='CohInt', optype='other') +#opObj11.addParameter(name='n', value='100', format='int') + +####################################################################### +########## OPERACIONES ParametersProc######################## +####################################################################### + +procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId()) +opObj10 = procUnitConfObjB.addOperation(name='HDFWriter') +opObj10.addParameter(name='path',value=path_pp) +#opObj10.addParameter(name='mode',value=0) +opObj10.addParameter(name='blocksPerFile',value='100',format='int') +opObj10.addParameter(name='metadataList',value='utctimeInit,timeZone,paramInterval,profileIndex,channelList,heightList,flagDataAsBlock',format='list') +opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,utctime',format='list')#,format='list' + +controllerObj.start() diff --git a/schainpy/scripts/USRP_PLOT_THOR.py b/schainpy/scripts/USRP_PLOT_THOR.py index d2e2eb0..8252b7c 100644 --- a/schainpy/scripts/USRP_PLOT_THOR.py +++ b/schainpy/scripts/USRP_PLOT_THOR.py @@ -23,17 +23,15 @@ controllerObj.setup(id = '191', name='Test_USRP', description=desc) ######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB################# ####################################################################### #path = '/media/data/data/vientos/57.2063km/echoes/NCO_Woodman' - - -path = '/home/soporte/data_hdf5' #### with clock 35.16 db noise - -figpath = '/home/soporte/data_hdf5_imag' +#path = '/DATA_RM/TEST_INTEGRACION' +path = '/DATA_RM/TEST_ONLINE' +figpath = '/home/soporte/Pictures/TEST_INTEGRACION_IMG' #remotefolder = "/home/wmaster/graficos" ####################################################################### ################# RANGO DE PLOTEO###################################### ####################################################################### -dBmin = '30' -dBmax = '60' +dBmin = '-5' +dBmax = '20' xmin = '0' xmax ='24' ymin = '0' @@ -50,18 +48,18 @@ yesterday = str2.strftime("%Y/%m/%d") ####################################################################### readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRFReader', path=path, - startDate="2019/01/01",#today, - endDate="2109/12/30",#today, + startDate="2021/01/01",#today, + endDate="2021/12/30",#today, startTime='00:00:00', endTime='23:59:59', delay=0, #set=0, online=0, walk=1, - ippKm = 1000) + ippKm = 60) opObj11 = readUnitConfObj.addOperation(name='printInfo') -opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') +#opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') ####################################################################### ################ OPERACIONES DOMINIO DEL TIEMPO######################## ####################################################################### @@ -72,15 +70,32 @@ procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=rea # '1,1,1,0,1,1,0,1,1,1,1,0,0,0,1,0,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1,0,0,0,1,0,0,1,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,0,1,0,0,0,1,1,1,0,1' #opObj11 = procUnitConfObjA.addOperation(name='setRadarFrequency') -#opObj11.addParameter(name='frequency', value='30e6', format='float') +#opObj11.addParameter(name='frequency', value='70312500') + +''' +opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other') +opObj11.addParameter(name='n', value='625', format='int')#10 +opObj11.addParameter(name='removeDC', value=1, format='int') +''' -#opObj10 = procUnitConfObjA.addOperation(name='Scope', optype='external') +# Ploteo TEST +''' +opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other') +opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other') +opObj11 = procUnitConfObjA.addOperation(name='PulsepairVelocityPlot', optype='other') +#opObj11.addParameter(name='xmax', value=8) +opObj11 = procUnitConfObjA.addOperation(name='PulsepairSpecwidthPlot', optype='other') +''' +# OJO SCOPE +#opObj10 = procUnitConfObjA.addOperation(name='ScopePlot', optype='external') #opObj10.addParameter(name='id', value='10', format='int') ##opObj10.addParameter(name='xmin', value='0', format='int') ##opObj10.addParameter(name='xmax', value='50', format='int') #opObj10.addParameter(name='type', value='iq') -#opObj10.addParameter(name='ymin', value='-5000', format='int') +##opObj10.addParameter(name='ymin', value='-5000', format='int') ##opObj10.addParameter(name='ymax', value='8500', format='int') +#opObj11.addParameter(name='save', value=figpath, format='str') +#opObj11.addParameter(name='save_period', value=10, format='int') #opObj10 = procUnitConfObjA.addOperation(name='setH0') #opObj10.addParameter(name='h0', value='-5000', format='float') @@ -98,55 +113,104 @@ procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=rea #opObj11.addParameter(name='n', value='100', format='int') ####################################################################### +########## OPERACIONES ParametersProc######################## +####################################################################### +###procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId()) +''' + +opObj11 = procUnitConfObjA.addOperation(name='PedestalInformation') +opObj11.addParameter(name='path_ped', value=path_ped) +opObj11.addParameter(name='path_adq', value=path_adq) +opObj11.addParameter(name='t_Interval_p', value='0.01', format='float') +opObj11.addParameter(name='n_Muestras_p', value='100', format='float') +opObj11.addParameter(name='blocksPerfile', value='100', format='int') +opObj11.addParameter(name='f_a_p', value='25', format='int') +opObj11.addParameter(name='online', value='0', format='int') + +opObj11 = procUnitConfObjA.addOperation(name='Block360') +opObj11.addParameter(name='n', value='40', format='int') + +opObj11= procUnitConfObjA.addOperation(name='WeatherPlot',optype='other') +opObj11.addParameter(name='save', value=figpath) +opObj11.addParameter(name='save_period', value=1) + + +''' + +####################################################################### ########## OPERACIONES DOMINIO DE LA FRECUENCIA######################## ####################################################################### -procUnitConfObjSousySpectra = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjA.getId()) -procUnitConfObjSousySpectra.addParameter(name='nFFTPoints', value='100', format='int') -procUnitConfObjSousySpectra.addParameter(name='nProfiles', value='100', format='int') -#procUnitConfObjSousySpectra.addParameter(name='pairsList', value='(0,0),(1,1),(0,1)', format='pairsList') -#opObj13 = procUnitConfObjSousySpectra.addOperation(name='removeDC') +procUnitConfObjB = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjA.getId()) +procUnitConfObjB.addParameter(name='nFFTPoints', value='32', format='int') +procUnitConfObjB.addParameter(name='nProfiles', value='32', format='int') + +procUnitConfObjC = controllerObj.addProcUnit(datatype='SpectraHeisProc', inputId=procUnitConfObjA.getId()) +#procUnitConfObjB.addParameter(name='nFFTPoints', value='64', format='int') +#procUnitConfObjB.addParameter(name='nProfiles', value='64', format='int') +opObj11 = procUnitConfObjC.addOperation(name='IncohInt4SpectraHeis', optype='other') +opObj11.addParameter(name='timeInterval', value='8', format='int') + + +#procUnitConfObjB.addParameter(name='pairsList', value='(0,0),(1,1),(0,1)', format='pairsList') + +#opObj13 = procUnitConfObjB.addOperation(name='removeDC') #opObj13.addParameter(name='mode', value='2', format='int') -#opObj11 = procUnitConfObjSousySpectra.addOperation(name='IncohInt', optype='other') -#opObj11.addParameter(name='n', value='60', format='float') +opObj11 = procUnitConfObjB.addOperation(name='IncohInt', optype='other') +opObj11.addParameter(name='n', value='8', format='float') ####################################################################### ########## PLOTEO DOMINIO DE LA FRECUENCIA############################# ####################################################################### +#---- + +opObj11 = procUnitConfObjC.addOperation(name='SpectraHeisPlot') +opObj11.addParameter(name='id', value='10', format='int') +opObj11.addParameter(name='wintitle', value='Spectra_Alturas', format='str') +#opObj11.addParameter(name='xmin', value=-100000, format='float') +#opObj11.addParameter(name='xmax', value=100000, format='float') +#opObj11.addParameter(name='zmin', value=dBmin, format='int') +#opObj11.addParameter(name='zmax', value=dBmax, format='int') +opObj11.addParameter(name='ymin', value=-20, format='int') +opObj11.addParameter(name='ymax', value=50, format='int') +opObj11.addParameter(name='showprofile', value='1', format='int') +opObj11.addParameter(name='save', value=figpath, format='str') +opObj11.addParameter(name='save_period', value=10, format='int') + + #SpectraPlot -opObj11 = procUnitConfObjSousySpectra.addOperation(name='SpectraPlot', optype='external') +opObj11 = procUnitConfObjB.addOperation(name='SpectraPlot', optype='external') opObj11.addParameter(name='id', value='1', format='int') opObj11.addParameter(name='wintitle', value='Spectra', format='str') #opObj11.addParameter(name='xmin', value=-0.01, format='float') #opObj11.addParameter(name='xmax', value=0.01, format='float') -#opObj11.addParameter(name='zmin', value=dBmin, format='int') -#opObj11.addParameter(name='zmax', value=dBmax, format='int') +opObj11.addParameter(name='zmin', value=dBmin, format='int') +opObj11.addParameter(name='zmax', value=dBmax, format='int') #opObj11.addParameter(name='ymin', value=ymin, format='int') #opObj11.addParameter(name='ymax', value=ymax, format='int') opObj11.addParameter(name='showprofile', value='1', format='int') opObj11.addParameter(name='save', value=figpath, format='str') opObj11.addParameter(name='save_period', value=10, format='int') - #RTIPLOT -opObj11 = procUnitConfObjSousySpectra.addOperation(name='RTIPlot', optype='external') +opObj11 = procUnitConfObjB.addOperation(name='RTIPlot', optype='external') opObj11.addParameter(name='id', value='2', format='int') opObj11.addParameter(name='wintitle', value='RTIPlot', format='str') -#opObj11.addParameter(name='zmin', value=dBmin, format='int') -#opObj11.addParameter(name='zmax', value=dBmax, format='int') +opObj11.addParameter(name='zmin', value=dBmin, format='int') +opObj11.addParameter(name='zmax', value=dBmax, format='int') #opObj11.addParameter(name='ymin', value=ymin, format='int') #opObj11.addParameter(name='ymax', value=ymax, format='int') -opObj11.addParameter(name='xmin', value=0, format='int') -opObj11.addParameter(name='xmax', value=23, format='int') +#opObj11.addParameter(name='xmin', value=15, format='int') +#opObj11.addParameter(name='xmax', value=16, format='int') opObj11.addParameter(name='showprofile', value='1', format='int') opObj11.addParameter(name='save', value=figpath, format='str') opObj11.addParameter(name='save_period', value=10, format='int') -# opObj11 = procUnitConfObjSousySpectra.addOperation(name='CrossSpectraPlot', optype='other') +# opObj11 = procUnitConfObjB.addOperation(name='CrossSpectraPlot', optype='other') # opObj11.addParameter(name='id', value='3', format='int') # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str') # opObj11.addParameter(name='ymin', value=ymin, format='int') @@ -158,7 +222,7 @@ opObj11.addParameter(name='save_period', value=10, format='int') # opObj11.addParameter(name='save', value=0, format='bool') # opObj11.addParameter(name='pairsList', value='(0,1)', format='pairsList') # # -# opObj11 = procUnitConfObjSousySpectra.addOperation(name='CoherenceMap', optype='other') +# opObj11 = procUnitConfObjB.addOperation(name='CoherenceMap', optype='other') # opObj11.addParameter(name='id', value='4', format='int') # opObj11.addParameter(name='wintitle', value='Coherence', format='str') # opObj11.addParameter(name='phase_cmap', value='jet', format='str') @@ -168,16 +232,17 @@ opObj11.addParameter(name='save_period', value=10, format='int') # opObj11.addParameter(name='save', value=0, format='bool') # opObj11.addParameter(name='pairsList', value='(0,1)', format='pairsList') # + +''' ####################################################################### ############### UNIDAD DE ESCRITURA ################################### ####################################################################### -#opObj11 = procUnitConfObjSousySpectra.addOperation(name='SpectraWriter', optype='other') +#opObj11 = procUnitConfObjB.addOperation(name='SpectraWriter', optype='other') #opObj11.addParameter(name='path', value=wr_path) #opObj11.addParameter(name='blocksPerFile', value='50', format='int') print ("Escribiendo el archivo XML") print ("Leyendo el archivo XML") - +''' controllerObj.start() - diff --git a/schainpy/scripts/WR_PROC_PP_PLOT.py b/schainpy/scripts/WR_PROC_PP_PLOT.py new file mode 100644 index 0000000..9f35589 --- /dev/null +++ b/schainpy/scripts/WR_PROC_PP_PLOT.py @@ -0,0 +1,52 @@ +import os,sys +import datetime +import time +from schainpy.controller import Project +#path='/DATA_RM/TEST_HDF5/d2021200' +#path='/DATA_RM/TEST_HDF5/d2021200' +path='/DATA_RM/TEST_HDF5/d2021203' + +path_adq=path +#path_ped='/DATA_RM/TEST_PEDESTAL/P2021200' +path_ped='/DATA_RM/TEST_PEDESTAL/P2021203' + +figpath = '/home/soporte/Pictures' +desc = "Simulator Test" + +controllerObj = Project() +controllerObj.setup(id='10',name='Test Simulator',description=desc) +readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader', + path=path, + startDate="2021/01/01", #"2020/01/01",#today, + endDate= "2021/12/01", #"2020/12/30",#today, + startTime='00:00:00', + endTime='23:59:59', + t_Interval_p=0.01, + n_Muestras_p=100, + delay=5, + #set=0, + online=0, + walk=0)#1 + +procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId()) + +opObj11 = procUnitConfObjA.addOperation(name='PedestalInformation') +opObj11.addParameter(name='path_ped', value=path_ped) +opObj11.addParameter(name='path_adq', value=path_adq) +opObj11.addParameter(name='t_Interval_p', value='0.01', format='float') +opObj11.addParameter(name='n_Muestras_p', value='100', format='float') +opObj11.addParameter(name='blocksPerfile', value='100', format='int') +opObj11.addParameter(name='f_a_p', value='25', format='int') +opObj11.addParameter(name='online', value='0', format='int') + + +opObj11 = procUnitConfObjA.addOperation(name='Block360') +opObj11.addParameter(name='n', value='40', format='int') + +opObj11= procUnitConfObjA.addOperation(name='WeatherPlot',optype='other') +opObj11.addParameter(name='save', value=figpath) +opObj11.addParameter(name='save_period', value=1) + +controllerObj.start() +#online 1 utc_adq 1617490240.48 +#online 0 utc_adq 1617489815.4804 diff --git a/schainpy/scripts/WR_PROC_PP_PLOT_ONLINE.py b/schainpy/scripts/WR_PROC_PP_PLOT_ONLINE.py new file mode 100644 index 0000000..88c7301 --- /dev/null +++ b/schainpy/scripts/WR_PROC_PP_PLOT_ONLINE.py @@ -0,0 +1,59 @@ +import os,sys +import datetime +import time +from schainpy.controller import Project +#path='/DATA_RM/TEST_HDF5/d2021200' +#path='/DATA_RM/TEST_HDF5/d2021200' +#path='/DATA_RM/TEST_HDF5/d2021214' +#path='/DATA_RM/TEST_HDF5/d2021229' + +path='/DATA_RM/TEST_HDF5/d2021231' + + +path_adq=path +#path_ped='/DATA_RM/TEST_PEDESTAL/P2021200' +#path_ped='/DATA_RM/TEST_PEDESTAL/P2021214' +#path_ped='/DATA_RM/TEST_PEDESTAL/P2021230' +path_ped='/DATA_RM/TEST_PEDESTAL/P20210819' +figpath = '/home/soporte/Pictures' +desc = "Simulator Test" + +controllerObj = Project() +controllerObj.setup(id='10',name='Test Simulator',description=desc) +readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader', + path=path, + startDate="2021/01/01", #"2020/01/01",#today, + endDate= "2021/12/01", #"2020/12/30",#today, + startTime='00:00:00', + endTime='23:59:59', + t_Interval_p=0.01, + n_Muestras_p=100, + delay=30, + #set=0, + online=1, + walk=0, + nTries=6)#1 + +procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId()) + +opObj11 = procUnitConfObjA.addOperation(name='PedestalInformation') +opObj11.addParameter(name='path_ped', value=path_ped) +opObj11.addParameter(name='path_adq', value=path_adq) +opObj11.addParameter(name='t_Interval_p', value='0.01', format='float') +opObj11.addParameter(name='n_Muestras_p', value='100', format='float') +opObj11.addParameter(name='blocksPerfile', value='100', format='int') +opObj11.addParameter(name='f_a_p', value='25', format='int') +opObj11.addParameter(name='online', value='1', format='int')# habilitar el enable aqui tambien + + +opObj11 = procUnitConfObjA.addOperation(name='Block360') +opObj11.addParameter(name='n', value='40', format='int') +# este bloque funciona bien con divisores de 360 no olvidar 0 10 20 30 40 60 90 120 180 + +opObj11= procUnitConfObjA.addOperation(name='WeatherPlot',optype='other') +opObj11.addParameter(name='save', value=figpath) +opObj11.addParameter(name='save_period', value=1) + +controllerObj.start() +#online 1 utc_adq 1617490240.48 +#online 0 utc_adq 1617489815.4804 diff --git a/schainpy/scripts/config_WR.txt b/schainpy/scripts/config_WR.txt new file mode 100644 index 0000000..ee4c939 --- /dev/null +++ b/schainpy/scripts/config_WR.txt @@ -0,0 +1,35 @@ +#******************************************************************************* +#*************ARCHIVO DE CONFIGURACION - RADAR METEOROLOGICO******************** +#******************************************************************************* +# 1-Resolucion_angular(Grados º)-F +1.0 +# 2-Velocidad_Pedestal Azimuth(º/s)-F +4.0 +# 3-Posicion_Pedestal Azimuth(º/s)-F +0.0 +# 4-Posicion_Pedestal Elevacion(º/s)-F +30.0 +# 5-IPP(useg)-F +400 +# n-PulsePair-nFFTPoints-R +625 +# 6-Cantidad_Muestras_archivo_pedestal-F +100 +# 7-Tiempo_por_muestra_pedestal-F +0.01 +# Tiempo_archivo_por_pedestal-R +1.0 +# 8-Bloques_por_arhivo_adquisicion-F +100.0 +# tiempo_por_archivo_adquisicion-R +25.0 +# mode Time Domain(T , 1) or Frequency Domain(F , 0) +1 +# path_p +/home/developer/Downloads/Pedestal/P2021093 +# path_a +/home/developer/Downloads/HDF5_TESTPP2V3/d2021093 +# online +0 +# Directorio final +/home/developer/Downloads/HDF5_WR/ diff --git a/schainpy/scripts/readFileconfig.py b/schainpy/scripts/readFileconfig.py new file mode 100644 index 0000000..9df862a --- /dev/null +++ b/schainpy/scripts/readFileconfig.py @@ -0,0 +1,70 @@ +print("LECTURA DE ARCHIVOS DE CONFIGURACION") +class ReadfileWR(): + def __init__(self,filename): + f = open(filename, "r") + i=0 + self.dict={'paht_ped':None,'path_adq':None,'path_res':None,'resolution':None,'vel_ped_azi':None,'pos_ped_azi':None,'pos_ped_ele':None,'ipp':None,'n':None,'len_ped':None,\ + 't_s_ped':None,'t_f_ped':None,'b_f_adq':None,'t_f_adq':None,'mode':None,'online':None} + while(True): + ##print(i) + linea = f.readline() + if i==4: + resolution=float(linea) + self.dict['resolution']=resolution + if i==6: + vel_pedestal_a=float(linea) + self.dict['vel_ped_azi']=vel_pedestal_a + if i==8: + pos_pedestal_a=float(linea) + self.dict['pos_ped_azi']=pos_pedestal_a + if i==10: + pos_pedestal_e=float(linea) + self.dict['pos_ped_ele']=pos_pedestal_e + if i==12: + ipp = float(linea) + self.dict['ipp']= round(ipp,5) + if i==14: + n = float(linea) + self.dict['n']= n + if i==16: + len_pedestal= float(linea) + self.dict['len_ped']= len_pedestal + if i==18: + time_x_sample_ped=float(linea) + self.dict['t_s_ped']= time_x_sample_ped + if i==20: + time_x_file_ped = float(linea) + self.dict['t_f_ped']= time_x_file_ped + if i==22: + bloques_x_file_adq= float(linea) + self.dict['b_f_adq']=bloques_x_file_adq + if i==24: + time_x_file_adq = float(linea) + self.dict['t_f_adq'] = time_x_file_adq + if i==26: + mode= int(linea) + self.dict['mode'] = mode + if i==28: + path_p= str(linea) + self.dict['path_ped'] = path_p + if i==30: + path_a= str(linea) + self.dict['path_adq'] = path_a + if i==32: + online= int(linea) + self.dict['online'] = online + if i==34: + path_r= str(linea) + self.dict['path_res'] = path_r + #print(linea) + if not linea: + break + i+=1 + f.close() + def getDict(self): + return self.dict + + +#filename= "/home/developer/Downloads/config_WR.txt" +#dict= ReadfileWR(filename).getDict() +#print(dict) diff --git a/schainpy/scripts/sun_high_ivan.py b/schainpy/scripts/sun_high_ivan.py new file mode 100644 index 0000000..8d46fc1 --- /dev/null +++ b/schainpy/scripts/sun_high_ivan.py @@ -0,0 +1,118 @@ +#!python +''' +''' + +import os, sys +import datetime +import time + + +from schainpy.controller import Project + +desc = "USRP_test" +filename = "USRP_processing.xml" +controllerObj = Project() +controllerObj.setup(id = '191', name='Test_USRP', description=desc) + +############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA ############# + +####################################################################### +######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB################# +####################################################################### +# path IVAN +path = '/home/soporte/jarsjuliahigh/high' + +figpath = '/home/soporte/Pictures/IVAN' +#remotefolder = "/home/wmaster/graficos" +####################################################################### +################# RANGO DE PLOTEO###################################### +####################################################################### +dBmin = '10' +dBmax = '55' +xmin = '0' +xmax ='24' +ymin = '0' +ymax = '600' +####################################################################### +########################FECHA########################################## +####################################################################### +str = datetime.date.today() +today = str.strftime("%Y/%m/%d") +str2 = str - datetime.timedelta(days=1) +yesterday = str2.strftime("%Y/%m/%d") +####################################################################### +######################## UNIDAD DE LECTURA############################# +####################################################################### +readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader', + path=path, + startDate="2021/07/02",#today, + endDate="2021/07/02",#today, + startTime='14:50:01',# inicio libre + endTime='14:55:59', + delay=0, + #set=0, + online=0, + walk=0) + +opObj11 = readUnitConfObj.addOperation(name='printInfo') +#opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') +####################################################################### +################ OPERACIONES DOMINIO DEL TIEMPO######################## +####################################################################### + +procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) + +#opObj10 = procUnitConfObjA.addOperation(name='selectChannels') +#opObj10.addParameter(name='channelList', value=[0]) + +''' +opObj10 = procUnitConfObjA.addOperation(name='ScopePlot', optype='external') +opObj10.addParameter(name='id', value='10', format='int') +#opObj10.addParameter(name='xmin', value='0', format='int') +##opObj10.addParameter(name='xmax', value='50', format='int') +opObj10.addParameter(name='type', value='iq') +##opObj10.addParameter(name='ymin', value='-5000', format='int') +##opObj10.addParameter(name='ymax', value='8500', format='int') +#opObj11.addParameter(name='save', value=figpath, format='str') +#opObj11.addParameter(name='save_period', value=10, format='int') +''' +###opObj11 = procUnitConfObjA.addOperation(name='selectHeights') +###opObj11.addParameter(name='minIndex', value='1', format='int') +#### opObj11.addParameter(name='maxIndex', value='10000', format='int') +####opObj11.addParameter(name='maxIndex', value='39980', format='int') + +####################################################################### +########## OPERACIONES DOMINIO DE LA FRECUENCIA######################## +####################################################################### + +#procUnitConfObjB = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjA.getId()) +#procUnitConfObjB.addParameter(name='nFFTPoints', value='32', format='int') +#procUnitConfObjB.addParameter(name='nProfiles', value='32', format='int') + +procUnitConfObjC = controllerObj.addProcUnit(datatype='SpectraHeisProc', inputId=procUnitConfObjA.getId()) + +opObj11 = procUnitConfObjC.addOperation(name='IncohInt4SpectraHeis', optype='other') +#opObj11.addParameter(name='timeInterval', value='4', format='int') +opObj11.addParameter(name='n', value='100', format='int') + +#opObj11.addParameter(name='overlapping', value=True, format='bool') + +opObj11 = procUnitConfObjC.addOperation(name='SpectraHeisPlot') +opObj11.addParameter(name='id', value='10', format='int') +opObj11.addParameter(name='wintitle', value='Spectra_Alturas', format='str') + +#opObj11.addParameter(name='xmin', value=-100000, format='float') +#opObj11.addParameter(name='xmax', value=100000, format='float') +opObj11.addParameter(name='oneFigure', value=False,format='bool') +#opObj11.addParameter(name='zmin', value=-10, format='int') +#opObj11.addParameter(name='zmax', value=40, format='int') +opObj11.addParameter(name='ymin', value=dBmin, format='int') +opObj11.addParameter(name='ymax', value=dBmax, format='int') +opObj11.addParameter(name='grid', value=True, format='bool') +#opObj11.addParameter(name='showprofile', value='1', format='int') +opObj11.addParameter(name='save', value=figpath, format='str') +#opObj11.addParameter(name='save_period', value=10, format='int') + + + +controllerObj.start() diff --git a/schainpy/scripts/sun_high_jhon.py b/schainpy/scripts/sun_high_jhon.py new file mode 100644 index 0000000..a87a5f9 --- /dev/null +++ b/schainpy/scripts/sun_high_jhon.py @@ -0,0 +1,103 @@ +#!python +''' +''' + +import os, sys +import datetime +import time + + +from schainpy.controller import Project + +desc = "USRP_test" +filename = "USRP_processing.xml" +controllerObj = Project() +controllerObj.setup(id = '191', name='Test_USRP', description=desc) + +############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA ############# + +####################################################################### +######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB################# +####################################################################### +# path JHON +path = '/home/soporte/jars2' + +figpath = '/home/soporte/Pictures/JHON' +#remotefolder = "/home/wmaster/graficos" +####################################################################### +################# RANGO DE PLOTEO###################################### +####################################################################### +dBmin = '0' +dBmax = '50' +xmin = '0' +xmax ='24' +ymin = '0' +ymax = '600' +####################################################################### +########################FECHA########################################## +####################################################################### +str = datetime.date.today() +today = str.strftime("%Y/%m/%d") +str2 = str - datetime.timedelta(days=1) +yesterday = str2.strftime("%Y/%m/%d") +####################################################################### +######################## UNIDAD DE LECTURA############################# +####################################################################### +readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader', + path=path, + startDate="2021/07/02",#today, + endDate="2021/07/02",#today, + startTime='19:45:00',# inicio libre + endTime='19:50:59', + delay=0, + #set=0, + online=0, + walk=0) + +opObj11 = readUnitConfObj.addOperation(name='printInfo') +#opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') +####################################################################### +################ OPERACIONES DOMINIO DEL TIEMPO######################## +####################################################################### + +procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) + +opObj11 = procUnitConfObjA.addOperation(name='selectHeights') +opObj11.addParameter(name='minIndex', value='1', format='int') +# opObj11.addParameter(name='maxIndex', value='10000', format='int') +opObj11.addParameter(name='maxIndex', value='39980', format='int') + + +####################################################################### +########## OPERACIONES DOMINIO DE LA FRECUENCIA######################## +####################################################################### + +#procUnitConfObjB = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjA.getId()) +#procUnitConfObjB.addParameter(name='nFFTPoints', value='32', format='int') +#procUnitConfObjB.addParameter(name='nProfiles', value='32', format='int') + +procUnitConfObjC = controllerObj.addProcUnit(datatype='SpectraHeisProc', inputId=procUnitConfObjA.getId()) + +#opObj11 = procUnitConfObjC.addOperation(name='IncohInt4SpectraHeis', optype='other') +#opObj11.addParameter(name='timeInterval', value='4', format='int') +opObj11 = procUnitConfObjC.addOperation(name='IncohInt4SpectraHeis', optype='other') +#opObj11.addParameter(name='timeInterval', value='4', format='int') +opObj11.addParameter(name='n', value='100', format='int') + + +opObj11 = procUnitConfObjC.addOperation(name='SpectraHeisPlot') +opObj11.addParameter(name='id', value='10', format='int') +opObj11.addParameter(name='wintitle', value='Spectra_Alturas', format='str') +#opObj11.addParameter(name='xmin', value=-100000, format='float') +#opObj11.addParameter(name='xmax', value=100000, format='float') +opObj11.addParameter(name='oneFigure', value=False,format='bool') +#opObj11.addParameter(name='zmin', value=-10, format='int') +#opObj11.addParameter(name='zmax', value=40, format='int') +opObj11.addParameter(name='ymin', value=dBmin, format='int') +opObj11.addParameter(name='ymax', value=dBmax, format='int') +opObj11.addParameter(name='grid', value=True, format='bool') +#opObj11.addParameter(name='showprofile', value='1', format='int') +opObj11.addParameter(name='save', value=figpath, format='str') +#opObj11.addParameter(name='save_period', value=10, format='int') + +controllerObj.start() diff --git a/schainpy/scripts/test_sim00010.py b/schainpy/scripts/test_sim00010.py index 8710965..5a799d2 100644 --- a/schainpy/scripts/test_sim00010.py +++ b/schainpy/scripts/test_sim00010.py @@ -2,6 +2,18 @@ import os, sys import datetime import time from schainpy.controller import Project +''' +NOTA: +Este script de prueba. +- Unidad del lectura 'SimulatorReader'. +- Unidad de procesamiento VoltageProc +- Unidad de procesamiento SpectraProc (profileIndex no esta en metadata porque se queda en voltage.) +- Operacion removeDC. +- Unidad de procesamiento ParametersProc +- Operacion SpectralMoments +- Operacion SpectralMomentsPlot +- Unidad de escrituda 'HDFWriter'. +''' desc = "USRP_test" filename = "USRP_processing.xml" @@ -10,8 +22,8 @@ controllerObj.setup(id = '191', name='Test_USRP', description=desc) ############## USED TO PLOT IQ VOLTAGE, POWER AND SPECTRA ############# ######PATH DE LECTURA, ESCRITURA, GRAFICOS Y ENVIO WEB################# -path = '/home/alex/Downloads/test_rawdata' -figpath = '/home/alex/Downloads/hdf5_test' +path = '/home/soporte/Downloads/RAWDATA' +figpath = '/home/soporte/Downloads/IMAGE' ######################## UNIDAD DE LECTURA############################# ''' readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader', @@ -63,20 +75,19 @@ procUnitConfObjC= controllerObj.addProcUnit(datatype='ParametersProc',inputId=pr procUnitConfObjC.addOperation(name='SpectralMoments') #opObj11 = procUnitConfObjC.addOperation(name='PowerPlot') -''' + opObj11 = procUnitConfObjC.addOperation(name='SpectralMomentsPlot') #opObj11.addParameter(name='xmin', value=14) #opObj11.addParameter(name='xmax', value=15) -#opObj11.addParameter(name='save', value=figpath) +opObj11.addParameter(name='save', value=figpath) opObj11.addParameter(name='showprofile', value=1) -#opObj11.addParameter(name='save_period', value=10) -''' +opObj11.addParameter(name='save_period', value=10) -opObj10 = procUnitConfObjC.addOperation(name='ParameterWriter') -opObj10.addParameter(name='path',value=figpath) +opObj10 = procUnitConfObjC.addOperation(name='HDFWriter') +opObj10.addParameter(name='path',value=path) #opObj10.addParameter(name='mode',value=0) opObj10.addParameter(name='blocksPerFile',value='100',format='int') -opObj10.addParameter(name='metadataList',value='utctimeInit,timeInterval',format='list') -opObj10.addParameter(name='dataList',value='data_POW,data_DOP,data_WIDTH,data_SNR')#,format='list' +opObj10.addParameter(name='metadataList',value='utctimeInit,heightList,nIncohInt,nCohInt,nProfiles,channelList',format='list')#profileIndex +opObj10.addParameter(name='dataList',value='data_pow,data_dop,utctime',format='list')#,format='list' controllerObj.start() diff --git a/schainpy/scripts/test_sim00011.py b/schainpy/scripts/test_sim00011.py new file mode 100644 index 0000000..e02fc05 --- /dev/null +++ b/schainpy/scripts/test_sim00011.py @@ -0,0 +1,47 @@ +import os,sys +import datetime +import time +from schainpy.controller import Project +''' +NOTA: +Este script de prueba. +- Unidad del lectura 'HDFReader'. +- Unidad de procesamiento VoltageProc +- Unidad de procesamiento SpectraProc +- Operacion removeDC. +- Unidad de procesamiento ParametersProc +- Operacion SpectralMoments +- Operacion SpectralMomentsPlot +- Unidad de escrituda 'HDFWriter'. +''' +path='/home/developer/Downloads/HDF5_WR' +figpath = path +desc = "Simulator Test" + +controllerObj = Project() + +controllerObj.setup(id='10',name='Test Simulator',description=desc) + +readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader', + path=path, + startDate="2021/01/01", #"2020/01/01",#today, + endDate= "2021/12/01", #"2020/12/30",#today, + startTime='00:00:00', + endTime='23:59:59', + delay=0, + #set=0, + online=0, + walk=0)#1 + +procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId()) + +opObj11 = procUnitConfObjA.addOperation(name='Block360') +opObj11.addParameter(name='n', value='40', format='int') + +opObj11= procUnitConfObjA.addOperation(name='WeatherPlot',optype='other') +opObj11.addParameter(name='save', value=figpath) +opObj11.addParameter(name='save_period', value=1) +#opObj11 = procUnitConfObjA.addOperation(name='PowerPlot', optype='other')#PulsepairPowerPlot +#opObj11 = procUnitConfObjA.addOperation(name='PPSignalPlot', optype='other') + +controllerObj.start() diff --git a/schainpy/scripts/test_sim00011a.py b/schainpy/scripts/test_sim00011a.py new file mode 100644 index 0000000..56999e7 --- /dev/null +++ b/schainpy/scripts/test_sim00011a.py @@ -0,0 +1,51 @@ +import os,sys,json +import datetime +import time +from schainpy.controller import Project +''' +NOTA: +Este script de prueba. +- Unidad del lectura 'HDFReader'. +- Unidad de procesamiento ParametersProc +- Operacion SpectralMomentsPlot + +''' +path = '/home/soporte/Downloads/RAWDATA_PP' +path='/DATA_RM/TEST_HDF5/d2021203' +figpath = '/home/soporte/Downloads/IMAGE' +desc = "Simulator Test" +desc_data = { + 'Data': { + 'dataPP_POW': 'Data/dataPP_POW/channel00', + 'utctime':'Data/utctime' + }, + 'Metadata': { + 'heightList' :'Metadata/heightList', + 'flagDataAsBlock':'Metadata/flagDataAsBlock', + 'profileIndex':'Metadata/profileIndex' + } + } + +controllerObj = Project() + +controllerObj.setup(id='10',name='Test Simulator',description=desc) + +readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader', + path=path, + startDate="2021/01/01", #"2020/01/01",#today, + endDate= "2021/12/01", #"2020/12/30",#today, + startTime='00:00:00', + endTime='23:59:59', + delay=0, + #set=0, + online=0, + walk=0, + description= json.dumps(desc_data))#1 + +procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId()) + +#opObj11 = procUnitConfObjA.addOperation(name='PulsepairPowerPlot', optype='other')#PulsepairPowerPlot +opObj11 = procUnitConfObjA.addOperation(name='PulsepairSignalPlot', optype='other') + + +controllerObj.start() diff --git a/schainpy/scripts/test_sim00011b.py b/schainpy/scripts/test_sim00011b.py new file mode 100644 index 0000000..f0064ea --- /dev/null +++ b/schainpy/scripts/test_sim00011b.py @@ -0,0 +1,56 @@ +import os,sys,json +import datetime +import time +from schainpy.controller import Project +''' +NOTA: +Este script de prueba. +- Unidad del lectura 'HDFReader'. +- Unidad de procesamiento ParametersProc +- Operacion SpectralMomentsPlot + +''' +path = '/home/soporte/Downloads/RAWDATA' +figpath = '/home/soporte/Downloads/IMAGE' +desc = "Simulator Test" +desc_data = { + 'Data': { + 'data_pow': 'Data/data_pow/channel00', + 'data_dop': 'Data/data_dop/channel00', + 'utctime':'Data/utctime' + }, + 'Metadata': { + 'heightList':'Metadata/heightList', + 'nIncohInt' :'Metadata/nIncohInt', + 'nCohInt' :'Metadata/nCohInt', + 'nProfiles' :'Metadata/nProfiles', + 'channelList' :'Metadata/channelList' + } + } + +controllerObj = Project() + +controllerObj.setup(id='10',name='Test Simulator',description=desc) + +readUnitConfObj = controllerObj.addReadUnit(datatype='HDFReader', + path=path, + startDate="2021/01/01", #"2020/01/01",#today, + endDate= "2021/12/01", #"2020/12/30",#today, + startTime='00:00:00', + endTime='23:59:59', + delay=0, + #set=0, + online=0, + walk=1, + description= json.dumps(desc_data))#1 + +procUnitConfObjA = controllerObj.addProcUnit(datatype='ParametersProc',inputId=readUnitConfObj.getId()) +''' +opObj11 = procUnitConfObjA.addOperation(name='DopplerPlot',optype='external') +#opObj11.addParameter(name='xmin', value=0) +#opObj11.addParameter(name='xmax', value=23) +opObj11.addParameter(name='save', value=figpath) +opObj11.addParameter(name='showprofile', value=0) +opObj11.addParameter(name='save_period', value=10) +''' +controllerObj.start() diff --git a/schainpy/scripts/test_sim00012.py b/schainpy/scripts/test_sim00012.py new file mode 100644 index 0000000..2e5012d --- /dev/null +++ b/schainpy/scripts/test_sim00012.py @@ -0,0 +1,55 @@ +import os,sys +import datetime +import time +from schainpy.controller import Project + +#************************************************************************* +#**************************LECTURA config_WR.txt************************** +#************************************************************************* +from readFileconfig import ReadfileWR +filename= "/home/soporte/schainv3/schain/schainpy/scripts/config_WR.txt" +dict= ReadfileWR(filename).getDict() + +FixRCP_IPP = dict['ipp']*0.15 #equivalencia +dataBlocksPerFile= dict['b_f_adq'] +profilesPerBlock= int(dict['n']) +pulsepair = int(dict['n']) +#************************************************************************* +path = '/home/soporte/Downloads/RAWDATA_PP_C' +figpath = path +desc = "Simulator Test" +controllerObj = Project() +controllerObj.setup(id='10',name='Test Simulator',description=desc) +readUnitConfObj = controllerObj.addReadUnit(datatype='SimulatorReader', + frequency=9.345e9, + FixRCP_IPP= FixRCP_IPP, + Tau_0 = 30, + AcqH0_0=0, + samples=330, + AcqDH_0=0.15, + FixRCP_TXA=0.15, + FixRCP_TXB=0.15, + Fdoppler=600.0, + Hdoppler=36, + Adoppler=300,#300 + delay=0, + online=0, + walk=0, + profilesPerBlock=profilesPerBlock, + dataBlocksPerFile=dataBlocksPerFile)#,#nTotalReadFiles=2) +#opObj11 = readUnitConfObj.addOperation(name='printInfo') +procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) + +opObj11 = procUnitConfObjA.addOperation(name='PulsePair') +opObj11.addParameter(name='n', value=pulsepair, format='int')#10 + +procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId()) + +opObj10 = procUnitConfObjB.addOperation(name='HDFWriter') +opObj10.addParameter(name='path',value=figpath) +#opObj10.addParameter(name='mode',value=2) +opObj10.addParameter(name='blocksPerFile',value='100',format='int') +opObj10.addParameter(name='metadataList',value='utctimeInit,paramInterval,heightList,profileIndex,flagDataAsBlock',format='list') +opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,utctime',format='list')#,format='list' + +controllerObj.start() diff --git a/schainpy/scripts/test_sim00013.py b/schainpy/scripts/test_sim00013.py new file mode 100644 index 0000000..869fa43 --- /dev/null +++ b/schainpy/scripts/test_sim00013.py @@ -0,0 +1,50 @@ +import os,sys +import datetime +import time +from schainpy.controller import Project +path = '/home/soporte/Downloads/RAWDATA_PP_Z' +figpath = path +desc = "Simulator Test" + +controllerObj = Project() + +controllerObj.setup(id='10',name='Test Simulator',description=desc) + +readUnitConfObj = controllerObj.addReadUnit(datatype='SimulatorReader', + frequency=9.345e9, + FixRCP_IPP= 60, + Tau_0 = 30, + AcqH0_0=0, + samples=330, + AcqDH_0=0.15, + FixRCP_TXA=0.15, + FixRCP_TXB=0.15, + Fdoppler=600.0, + Hdoppler=36, + Adoppler=300,#300 + delay=0, + online=0, + walk=0, + profilesPerBlock=625, + dataBlocksPerFile=360)#,#nTotalReadFiles=2) + +### opObj11 = readUnitConfObj.addOperation(name='printInfo') + +procUnitConfObjA = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) + +opObj11 = procUnitConfObjA.addOperation(name='PulsePair', optype='other') +opObj11.addParameter(name='n', value='625', format='int')#10 +opObj11.addParameter(name='removeDC', value=1, format='int') + +procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId()) + +opObj10 = procUnitConfObjB.addOperation(name="WeatherRadar") + +opObj10 = procUnitConfObjB.addOperation(name='HDFWriter') +opObj10.addParameter(name='path',value=figpath) +#opObj10.addParameter(name='mode',value=0) +opObj10.addParameter(name='blocksPerFile',value='100',format='int') +opObj10.addParameter(name='metadataList',value='utctimeInit,timeInterval',format='list') +opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,dataPP_SNR,dataPP_WIDTH,factor_Zeh,utctime')#,format='list' + +controllerObj.start() diff --git a/schainpy/scripts/test_sim0009.py b/schainpy/scripts/test_sim0009.py index 43d6640..190bd4f 100644 --- a/schainpy/scripts/test_sim0009.py +++ b/schainpy/scripts/test_sim0009.py @@ -2,7 +2,7 @@ import os,sys import datetime import time from schainpy.controller import Project -path = '/home/alex/Downloads/NEW_WR2/spc16removeDC' +path = '/home/soporte/Downloads/RAWDATA_PP' figpath = path desc = "Simulator Test" @@ -63,11 +63,11 @@ opObj11.addParameter(name='removeDC', value=1, format='int') procUnitConfObjB= controllerObj.addProcUnit(datatype='ParametersProc',inputId=procUnitConfObjA.getId()) -opObj10 = procUnitConfObjB.addOperation(name='ParameterWriter') +opObj10 = procUnitConfObjB.addOperation(name='HDFWriter') opObj10.addParameter(name='path',value=figpath) #opObj10.addParameter(name='mode',value=0) opObj10.addParameter(name='blocksPerFile',value='100',format='int') -opObj10.addParameter(name='metadataList',value='utctimeInit,timeInterval',format='list') -opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,dataPP_SNR,dataPP_WIDTH')#,format='list' +opObj10.addParameter(name='metadataList',value='utctimeInit,paramInterval,profileIndex,heightList,flagDataAsBlock',format='list') +opObj10.addParameter(name='dataList',value='dataPP_POW,dataPP_DOP,dataPP_SNR,dataPP_WIDTH,utctime',format='list')#,format='list' controllerObj.start()