##// END OF EJS Templates
Fix px1000 reading online
jespinoza -
r1138:c6cf5a83f48e
parent child
Show More
@@ -517,7 +517,7 class PlotData(Operation, Process):
517 517 self.__plot()
518 518
519 519 except zmq.Again as e:
520 log.log('.', tag='', nl=False)
520 # log.log('.', tag='', nl=False)
521 521 if self.data:
522 522 figpause(self.data.throttle)
523 523 else:
@@ -77,6 +77,7 class NCDFReader(JRODataReader, ProcessingUnit):
77 77 self.nTries = kwargs.get('nTries', 3)
78 78 self.online = kwargs.get('online', False)
79 79 self.delay = kwargs.get('delay', 30)
80 self.ele = kwargs.get('ext', '')
80 81
81 82 if self.path is None:
82 83 raise ValueError, 'The path is not valid'
@@ -107,9 +108,11 class NCDFReader(JRODataReader, ProcessingUnit):
107 108 fileList0 = []
108 109
109 110 for subpath in paths:
110 fileList0 += [os.path.join(subpath, s) for s in glob.glob1(subpath, '*') if os.path.splitext(s)[-1] in self.ext]
111 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]
111 112
112 113 fileList0.sort()
114 if self.online:
115 fileList0 = fileList0[-1:]
113 116
114 117 self.files = {}
115 118
@@ -156,63 +159,59 class NCDFReader(JRODataReader, ProcessingUnit):
156 159 path - Path to find files
157 160 '''
158 161
159 old_files = self.files[self.dt]
160 162 self.files = {}
161 163
162 164 for n in range(self.nTries):
163 165
164 166 if self.walk:
165 167 paths = [os.path.join(self.path, p) for p in os.listdir(self.path) if os.path.isdir(os.path.join(self.path, p))]
166 paths = paths[-2:]
168 path = paths[-1]
167 169 else:
168 paths = [self.path]
170 paths = self.path
169 171
170 new_files = []
171
172 for path in paths:
173 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)]
172 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]
174 173
175 174 new_files.sort()
176
177 if new_files:
175
176 for fullname in new_files:
177 thisFile = fullname.split('/')[-1]
178 year = thisFile[3:7]
179 if not year.isdigit():
180 continue
181
182 month = thisFile[7:9]
183 if not month.isdigit():
184 continue
185
186 day = thisFile[9:11]
187 if not day.isdigit():
188 continue
189
190 year, month, day = int(year), int(month), int(day)
191 dateFile = datetime.date(year, month, day)
192 timeFile = datetime.time(int(thisFile[12:14]), int(thisFile[14:16]), int(thisFile[16:18]))
193
194 dt = datetime.datetime.combine(dateFile, timeFile)
195
196 if self.dt >= dt:
197 continue
198
199 if dt not in self.files:
200 self.dt = dt
201 self.files[dt] = []
202
203 self.files[dt].append(fullname)
204 break
205
206 if self.files:
178 207 break
179 208 else:
180 209 log.warning('Waiting {} seconds for the next file, try {} ...'.format(self.delay, n + 1), 'NCDFReader')
181 210 time.sleep(self.delay)
182 211
183 if not new_files:
184 log.error('No more files found', 'NCDFReader')
212 if not self.files:
185 213 return 0
186 214
187 startDate = self.dt - datetime.timedelta(seconds=1)
188
189 for fullname in new_files:
190 thisFile = fullname.split('/')[-1]
191 year = thisFile[3:7]
192 if not year.isdigit():
193 continue
194
195 month = thisFile[7:9]
196 if not month.isdigit():
197 continue
198
199 day = thisFile[9:11]
200 if not day.isdigit():
201 continue
202
203 year, month, day = int(year), int(month), int(day)
204 dateFile = datetime.date(year, month, day)
205 timeFile = datetime.time(int(thisFile[12:14]), int(thisFile[14:16]), int(thisFile[16:18]))
206
207 if (startDate > dateFile):
208 continue
209
210 dt = datetime.datetime.combine(dateFile, timeFile)
211 if dt not in self.files:
212 self.files[dt] = []
213
214 self.files[dt].append(fullname)
215
216 215 self.dates = self.files.keys()
217 216 self.dates.sort()
218 217 self.cursor = 0
@@ -240,12 +239,15 class NCDFReader(JRODataReader, ProcessingUnit):
240 239 '''
241 240
242 241 cursor = self.cursor
243
244 242 if not self.online_mode:
245 self.dt = self.dates[cursor]
246 243 if cursor == len(self.dates):
247 244 if self.online:
245 cursor = 0
246 self.dt = self.dates[cursor]
248 247 self.online_mode = True
248 if not self.search_files_online():
249 log.success('No more files', 'NCDFReader')
250 return 0
249 251 else:
250 252 log.success('No more files', 'NCDFReader')
251 253 self.flagNoMoreFiles = 1
@@ -253,6 +255,7 class NCDFReader(JRODataReader, ProcessingUnit):
253 255 else:
254 256 if not self.search_files_online():
255 257 return 0
258 cursor = self.cursor
256 259
257 260 log.log(
258 261 'Opening: {}\'s files'.format(self.dates[cursor]),
@@ -41,8 +41,8 PLOT_CODES = {
41 41 'wind' : 22,
42 42 'skymap' : 23,
43 43 # 'MPHASE_CODE' : 24,
44 'moments' : 25,
45 'param' : 26,
44 'V' : 25,
45 'Z' : 26,
46 46 'spc_fit' : 27,
47 47 'ew_drifts' : 28,
48 48 'reflectivity': 30
@@ -749,7 +749,7 class SendToFTP(Operation, Process):
749 749 DOY_STR = '%3.3d'%thisDatetime.timetuple().tm_yday
750 750 exp_code = '%3.3d'%exp_code
751 751 sub_exp_code = '%2.2d'%sub_exp_code
752 plot_code = '%2.2d'% PLOT_CODES[filename.split('_')[0].split('-')[0]]
752 plot_code = '%2.2d'% PLOT_CODES[filename.split('_')[0].split('-')[1]]
753 753 name = YEAR_STR + DOY_STR + '00' + exp_code + sub_exp_code + plot_code + '00.png'
754 754 return name
755 755
General Comments 0
You need to be logged in to leave comments. Login now