diff --git a/schainpy/controller.py b/schainpy/controller.py index 8dfca2f..0e918bb 100644 --- a/schainpy/controller.py +++ b/schainpy/controller.py @@ -74,8 +74,8 @@ class ConfBase(): def addParameter(self, name, value, format=None): ''' ''' - if os.path.isdir(value): - self.parameters[name] = value + if format is not None: + self.parameters[name] = eval(format)(value) elif isinstance(value, str) and re.search(r'(\d+/\d+/\d+)', value): self.parameters[name] = datetime.date(*[int(x) for x in value.split('/')]) elif isinstance(value, str) and re.search(r'(\d+:\d+:\d+)', value): @@ -312,7 +312,7 @@ class ReadUnitConf(ProcUnitConf): self.datatype = datatype self.err_queue = err_queue - self.addParameter(name='path', value=path) + self.addParameter(name='path', value=path, format='str') self.addParameter(name='startDate', value=startDate) self.addParameter(name='endDate', value=endDate) self.addParameter(name='startTime', value=startTime) diff --git a/schainpy/model/graphics/jroplot_parameters.py b/schainpy/model/graphics/jroplot_parameters.py index 0dc1684..97ba13d 100644 --- a/schainpy/model/graphics/jroplot_parameters.py +++ b/schainpy/model/graphics/jroplot_parameters.py @@ -620,18 +620,20 @@ class WeatherPlot(Plot): self.res_ele = numpy.mean(data['ele']) ################# PLOTEO ################### for i,ax in enumerate(self.axes): + self.zmin = self.zmin if self.zmin else 20 + self.zmax = self.zmax if self.zmax else 80 if ax.firsttime: plt.clf() - cgax, pm = wrl.vis.plot_ppi(self.res_weather,r=r,az=self.res_azi,fig=self.figures[0], proj='cg', vmin=20, vmax=80) + cgax, pm = wrl.vis.plot_ppi(self.res_weather,r=r,az=self.res_azi,fig=self.figures[0], proj='cg', vmin=self.zmin, vmax=self.zmax) else: plt.clf() - cgax, pm = wrl.vis.plot_ppi(self.res_weather,r=r,az=self.res_azi,fig=self.figures[0], proj='cg', vmin=20, vmax=80) + cgax, pm = wrl.vis.plot_ppi(self.res_weather,r=r,az=self.res_azi,fig=self.figures[0], proj='cg', vmin=self.zmin, vmax=self.zmax) 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)+" Step "+str(self.ini)+ " Elev: "+str(round(self.res_ele,2)), transform=caax.transAxes, va='bottom',ha='right') + plt.text(1.0, 1.05, 'Azimuth '+str(thisDatetime)+" Step "+str(self.ini)+ " EL: "+str(round(self.res_ele, 1)), transform=caax.transAxes, va='bottom',ha='right') self.ini= self.ini+1 @@ -665,7 +667,7 @@ class WeatherRHIPlot(Plot): self.titles = ['{} Channel {}'.format(self.CODE.upper(), x) for x in range(self.nrows)] print("self.titles",self.titles) self.colorbar=False - self.width =8 + self.width =12 self.height =8 self.ini =0 self.len_azi =0 @@ -1072,6 +1074,7 @@ class WeatherRHIPlot(Plot): ###print("self.res_ele",self.res_ele) plt.clf() subplots = [121, 122] + cg={'angular_spacing': 20.} if self.ini==0: self.data_ele_tmp = numpy.ones([self.nplots,int(var_ang)])*numpy.nan self.res_weather= numpy.ones([self.nplots,int(var_ang),len(r_mask)])*numpy.nan @@ -1082,16 +1085,18 @@ class WeatherRHIPlot(Plot): self.res_azi = numpy.mean(data['azi']) if i==0: print("*****************************************************************************to plot**************************",self.res_weather[i].shape) + self.zmin = self.zmin if self.zmin else 20 + self.zmax = self.zmax if self.zmax else 80 if ax.firsttime: #plt.clf() - cgax, pm = wrl.vis.plot_rhi(self.res_weather[i],r=r,th=self.res_ele,ax=subplots[i], proj='cg',vmin=20, vmax=80) + cgax, pm = wrl.vis.plot_rhi(self.res_weather[i],r=r,th=self.res_ele,ax=subplots[i], proj=cg,vmin=self.zmin, vmax=self.zmax) #fig=self.figures[0] else: #plt.clf() if i==0: print(self.res_weather[i]) print(self.res_ele) - cgax, pm = wrl.vis.plot_rhi(self.res_weather[i],r=r,th=self.res_ele,ax=subplots[i], proj='cg',vmin=20, vmax=80) + cgax, pm = wrl.vis.plot_rhi(self.res_weather[i],r=r,th=self.res_ele,ax=subplots[i], proj=cg,vmin=self.zmin, vmax=self.zmax) caax = cgax.parasites[0] paax = cgax.parasites[1] cbar = plt.gcf().colorbar(pm, pad=0.075) diff --git a/schainpy/model/proc/jroproc_parameters.py b/schainpy/model/proc/jroproc_parameters.py index 7e0fc42..852e9b8 100755 --- a/schainpy/model/proc/jroproc_parameters.py +++ b/schainpy/model/proc/jroproc_parameters.py @@ -4059,23 +4059,28 @@ class PedestalInformation(Operation): return False, False fileList = glob.glob(os.path.join(path, '*.h5')) fileList.sort() - for fullname in fileList: - filename = fullname.split('/')[-1] - number = int(filename[4:14]) - if number <= timestamp: - return number, fullname - return False, False + print(fileList) + return fileList def find_next_file(self): while True: + if self.utctime < self.utcfile: + self.flagNoData = True + break + self.flagNoData = False file_size = len(self.fp['Data']['utc']) if self.utctime < self.utcfile+file_size*self.interval: break - self.utcfile += file_size*self.interval + dt = datetime.datetime.utcfromtimestamp(self.utcfile) + if dt.second > 0: + self.utcfile -= dt.second + self.utcfile += self.samples*self.interval dt = datetime.datetime.utcfromtimestamp(self.utctime) path = os.path.join(self.path, dt.strftime('%Y-%m-%dT%H-00-00')) - self.filename = os.path.join(path, 'pos@{}.000.h5'.format(self.utcfile)) + self.filename = os.path.join(path, 'pos@{}.000.h5'.format(int(self.utcfile))) + print('ACQ time: ', self.utctime, 'POS time: ', self.utcfile) + print('Next file: ', self.filename) if not os.path.exists(self.filename): log.warning('Waiting for position files...', self.name) @@ -4088,8 +4093,11 @@ class PedestalInformation(Operation): def get_values(self): - index = int((self.utctime-self.utcfile)/self.interval) - return self.fp['Data']['azi_pos'][index], self.fp['Data']['ele_pos'][index] + if self.flagNoData: + return numpy.nan, numpy.nan + else: + index = int((self.utctime-self.utcfile)/self.interval) + return self.fp['Data']['azi_pos'][index], self.fp['Data']['ele_pos'][index] def setup(self, dataOut, path, conf, samples, interval, wr_exp): @@ -4097,22 +4105,24 @@ class PedestalInformation(Operation): self.conf = conf self.samples = samples self.interval = interval - self.utcfile, self.filename = self.find_file(dataOut.utctime) + filelist = self.find_file(dataOut.utctime) - if not self.filename: + if not filelist: log.error('No position files found in {}'.format(path), self.name) raise IOError('No position files found in {}'.format(path)) else: + self.filename = filelist[0] + self.utcfile = int(self.filename.split('/')[-1][4:14]) log.log('Opening file: {}'.format(self.filename), self.name) self.fp = h5py.File(self.filename, 'r') - def run(self, dataOut, path, conf=None, samples=1500, interval=0.04, wr_exp=None): + def run(self, dataOut, path, conf=None, samples=1500, interval=0.04, wr_exp=None, offset=0): if not self.isConfig: self.setup(dataOut, path, conf, samples, interval, wr_exp) self.isConfig = True - self.utctime = dataOut.utctime + self.utctime = dataOut.utctime + offset self.find_next_file()