diff --git a/schainpy/model/graphics/jroplot_data.py b/schainpy/model/graphics/jroplot_data.py index 4bd04bb..ccaad41 100644 --- a/schainpy/model/graphics/jroplot_data.py +++ b/schainpy/model/graphics/jroplot_data.py @@ -517,7 +517,7 @@ class PlotData(Operation, Process): self.__plot() except zmq.Again as e: - log.log('.', tag='', nl=False) + # log.log('.', tag='', nl=False) if self.data: figpause(self.data.throttle) else: diff --git a/schainpy/model/io/pxIO_param.py b/schainpy/model/io/pxIO_param.py index ce5fee5..b95f44e 100644 --- a/schainpy/model/io/pxIO_param.py +++ b/schainpy/model/io/pxIO_param.py @@ -77,6 +77,7 @@ class NCDFReader(JRODataReader, ProcessingUnit): self.nTries = kwargs.get('nTries', 3) self.online = kwargs.get('online', False) self.delay = kwargs.get('delay', 30) + self.ele = kwargs.get('ext', '') if self.path is None: raise ValueError, 'The path is not valid' @@ -107,9 +108,11 @@ class NCDFReader(JRODataReader, ProcessingUnit): fileList0 = [] for subpath in paths: - fileList0 += [os.path.join(subpath, s) for s in glob.glob1(subpath, '*') if os.path.splitext(s)[-1] in self.ext] + fileList0 += [os.path.join(subpath, s) for s in glob.glob1(subpath, '*') if os.path.splitext(s)[-1] in self.ext and 'E{}'.format(self.ele) in s] fileList0.sort() + if self.online: + fileList0 = fileList0[-1:] self.files = {} @@ -156,63 +159,59 @@ class NCDFReader(JRODataReader, ProcessingUnit): path - Path to find files ''' - old_files = self.files[self.dt] self.files = {} for n in range(self.nTries): if self.walk: paths = [os.path.join(self.path, p) for p in os.listdir(self.path) if os.path.isdir(os.path.join(self.path, p))] - paths = paths[-2:] + path = paths[-1] else: - paths = [self.path] + paths = self.path - new_files = [] - - for path in paths: - new_files += [os.path.join(path, s) for s in glob.glob1(path, '*') if os.path.splitext(s)[-1] in self.ext and os.path.join(path, s not in old_files)] + new_files = [os.path.join(path, s) for s in glob.glob1(path, '*') if os.path.splitext(s)[-1] in self.ext and 'E{}'.format(self.ele) in s] new_files.sort() - - if new_files: + + for fullname in new_files: + thisFile = fullname.split('/')[-1] + year = thisFile[3:7] + if not year.isdigit(): + continue + + month = thisFile[7:9] + if not month.isdigit(): + continue + + day = thisFile[9:11] + if not day.isdigit(): + continue + + year, month, day = int(year), int(month), int(day) + dateFile = datetime.date(year, month, day) + timeFile = datetime.time(int(thisFile[12:14]), int(thisFile[14:16]), int(thisFile[16:18])) + + dt = datetime.datetime.combine(dateFile, timeFile) + + if self.dt >= dt: + continue + + if dt not in self.files: + self.dt = dt + self.files[dt] = [] + + self.files[dt].append(fullname) + break + + if self.files: break else: log.warning('Waiting {} seconds for the next file, try {} ...'.format(self.delay, n + 1), 'NCDFReader') time.sleep(self.delay) - if not new_files: - log.error('No more files found', 'NCDFReader') + if not self.files: return 0 - startDate = self.dt - datetime.timedelta(seconds=1) - - for fullname in new_files: - thisFile = fullname.split('/')[-1] - year = thisFile[3:7] - if not year.isdigit(): - continue - - month = thisFile[7:9] - if not month.isdigit(): - continue - - day = thisFile[9:11] - if not day.isdigit(): - continue - - year, month, day = int(year), int(month), int(day) - dateFile = datetime.date(year, month, day) - timeFile = datetime.time(int(thisFile[12:14]), int(thisFile[14:16]), int(thisFile[16:18])) - - if (startDate > dateFile): - continue - - dt = datetime.datetime.combine(dateFile, timeFile) - if dt not in self.files: - self.files[dt] = [] - - self.files[dt].append(fullname) - self.dates = self.files.keys() self.dates.sort() self.cursor = 0 @@ -240,12 +239,15 @@ class NCDFReader(JRODataReader, ProcessingUnit): ''' cursor = self.cursor - if not self.online_mode: - self.dt = self.dates[cursor] if cursor == len(self.dates): if self.online: + cursor = 0 + self.dt = self.dates[cursor] self.online_mode = True + if not self.search_files_online(): + log.success('No more files', 'NCDFReader') + return 0 else: log.success('No more files', 'NCDFReader') self.flagNoMoreFiles = 1 @@ -253,6 +255,7 @@ class NCDFReader(JRODataReader, ProcessingUnit): else: if not self.search_files_online(): return 0 + cursor = self.cursor log.log( 'Opening: {}\'s files'.format(self.dates[cursor]), diff --git a/schainpy/model/utils/jroutils_publish.py b/schainpy/model/utils/jroutils_publish.py index f215738..c07bb3f 100644 --- a/schainpy/model/utils/jroutils_publish.py +++ b/schainpy/model/utils/jroutils_publish.py @@ -41,8 +41,8 @@ PLOT_CODES = { 'wind' : 22, 'skymap' : 23, # 'MPHASE_CODE' : 24, - 'moments' : 25, - 'param' : 26, + 'V' : 25, + 'Z' : 26, 'spc_fit' : 27, 'ew_drifts' : 28, 'reflectivity': 30 @@ -749,7 +749,7 @@ class SendToFTP(Operation, Process): DOY_STR = '%3.3d'%thisDatetime.timetuple().tm_yday exp_code = '%3.3d'%exp_code sub_exp_code = '%2.2d'%sub_exp_code - plot_code = '%2.2d'% PLOT_CODES[filename.split('_')[0].split('-')[0]] + plot_code = '%2.2d'% PLOT_CODES[filename.split('_')[0].split('-')[1]] name = YEAR_STR + DOY_STR + '00' + exp_code + sub_exp_code + plot_code + '00.png' return name