##// END OF EJS Templates
Límite de bloques, hora, zona horaria
joabAM -
r1401:c018ae3094fa
parent child
Show More
@@ -151,13 +151,15 class HDFReader(Reader, ProcessingUnit):
151 self.__setBlockList()
151 self.__setBlockList()
152
152
153 if 'type' in self.meta:
153 if 'type' in self.meta:
154 ##print("Creting dataOut...")
154 self.dataOut = eval(self.meta['type'])()
155 self.dataOut = eval(self.meta['type'])()
156 ##print(vars(self.dataOut))
155
157
156 for attr in self.meta:
158 for attr in self.meta:
157 #print("attr: ", attr)
159 ##print("attr: ", attr)
160 ##print(type(self.dataOut).__name__)
158 setattr(self.dataOut, attr, self.meta[attr])
161 setattr(self.dataOut, attr, self.meta[attr])
159
162
160
161 self.blockIndex = 0
163 self.blockIndex = 0
162
164
163 return
165 return
@@ -277,12 +279,13 class HDFReader(Reader, ProcessingUnit):
277 #self.dataOut.error = True TERMINA EL PROGRAMA, removido
279 #self.dataOut.error = True TERMINA EL PROGRAMA, removido
278 return
280 return
279 for attr in self.data:
281 for attr in self.data:
282 #print("attr ",attr)
280 if self.data[attr].ndim == 1:
283 if self.data[attr].ndim == 1:
281 setattr(self.dataOut, attr, self.data[attr][self.blockIndex])
284 setattr(self.dataOut, attr, self.data[attr][self.blockIndex])
282 else:
285 else:
283 setattr(self.dataOut, attr, self.data[attr][:, self.blockIndex])
286 setattr(self.dataOut, attr, self.data[attr][:, self.blockIndex])
284
287
285 self.dataOut.flagNoData = False
288
286 self.blockIndex += 1
289 self.blockIndex += 1
287
290
288 if self.blockIndex == 1:
291 if self.blockIndex == 1:
@@ -295,7 +298,8 class HDFReader(Reader, ProcessingUnit):
295 self.blockIndex,
298 self.blockIndex,
296 self.blocksPerFile),self.name)
299 self.blocksPerFile),self.name)
297
300
298
301 self.dataOut.flagNoData = False
302 self.dataOut.error = False
299 return
303 return
300
304
301 def run(self, **kwargs):
305 def run(self, **kwargs):
@@ -385,19 +389,26 class HDFWriter(Operation):
385 metadataList = None
389 metadataList = None
386 currentDay = None
390 currentDay = None
387 lastTime = None
391 lastTime = None
392 typeTime = "ut"
393 hourLimit = 3
394 breakDays = True
388
395
389 def __init__(self):
396 def __init__(self):
390
397
391 Operation.__init__(self)
398 Operation.__init__(self)
392 return
399 return
393
400
394 def setup(self, path=None, blocksPerFile=10, metadataList=None, dataList=None, setType=None, description=None):
401 def setup(self, path=None, blocksPerFile=10, metadataList=None, dataList=None, setType=None,
402 description=None,typeTime = "ut",hourLimit = 3, breakDays=True):
395 self.path = path
403 self.path = path
396 self.blocksPerFile = blocksPerFile
404 self.blocksPerFile = blocksPerFile
397 self.metadataList = metadataList
405 self.metadataList = metadataList
398 self.dataList = [s.strip() for s in dataList]
406 self.dataList = [s.strip() for s in dataList]
399 self.setType = setType
407 self.setType = setType
400 self.description = description
408 self.description = description
409 self.timeZone = typeTime
410 self.hourLimit = hourLimit
411 self.breakDays = breakDays
401
412
402 if self.metadataList is None:
413 if self.metadataList is None:
403 self.metadataList = self.dataOut.metadata_list
414 self.metadataList = self.dataOut.metadata_list
@@ -431,7 +442,11 class HDFWriter(Operation):
431
442
432 def timeFlag(self):
443 def timeFlag(self):
433 currentTime = self.dataOut.utctime
444 currentTime = self.dataOut.utctime
445 if self.timeZone == "lt":
434 timeTuple = time.localtime(currentTime)
446 timeTuple = time.localtime(currentTime)
447 elif self.timeZone == "ut":
448 timeTuple = time.gmtime(currentTime)
449
435 dataDay = timeTuple.tm_yday
450 dataDay = timeTuple.tm_yday
436 #print("time UTC: ",currentTime, self.dataOut.datatime)
451 #print("time UTC: ",currentTime, self.dataOut.datatime)
437 if self.lastTime is None:
452 if self.lastTime is None:
@@ -441,25 +456,22 class HDFWriter(Operation):
441
456
442 timeDiff = currentTime - self.lastTime
457 timeDiff = currentTime - self.lastTime
443
458
444 #Si el dia es diferente o si la diferencia entre un dato y otro supera la hora
459 #Si el dia es diferente o si la diferencia entre un dato y otro supera self.hourLimit
445 if dataDay != self.currentDay:
460 if (dataDay != self.currentDay) and self.breakDays:
446 self.currentDay = dataDay
461 self.currentDay = dataDay
447 return True
462 return True
448 elif timeDiff > 3*60*60:
463 elif timeDiff > self.hourLimit*60*60:
449 self.lastTime = currentTime
464 self.lastTime = currentTime
450 return True
465 return True
451 else:
466 else:
452 self.lastTime = currentTime
467 self.lastTime = currentTime
453 return False
468 return False
454
469
455 def run(self, dataOut, path, blocksPerFile=10, metadataList=None,
470 def run(self, dataOut,**kwargs):
456 dataList=[], setType=None, description={}):
457
471
458 self.dataOut = dataOut
472 self.dataOut = dataOut
459 if not(self.isConfig):
473 if not(self.isConfig):
460 self.setup(path=path, blocksPerFile=blocksPerFile,
474 self.setup(**kwargs)
461 metadataList=metadataList, dataList=dataList,
462 setType=setType, description=description)
463
475
464 self.isConfig = True
476 self.isConfig = True
465 self.setNextFile()
477 self.setNextFile()
@@ -472,7 +484,9 class HDFWriter(Operation):
472 ext = self.ext
484 ext = self.ext
473 path = self.path
485 path = self.path
474 setFile = self.setFile
486 setFile = self.setFile
475
487 if self.timeZone == "lt":
488 timeTuple = time.localtime(self.dataOut.utctime)
489 elif self.timeZone == "ut":
476 timeTuple = time.gmtime(self.dataOut.utctime)
490 timeTuple = time.gmtime(self.dataOut.utctime)
477 #print("path: ",timeTuple)
491 #print("path: ",timeTuple)
478 subfolder = 'd%4.4d%3.3d' % (timeTuple.tm_year,timeTuple.tm_yday)
492 subfolder = 'd%4.4d%3.3d' % (timeTuple.tm_year,timeTuple.tm_yday)
1 NO CONTENT: modified file
NO CONTENT: modified file
General Comments 0
You need to be logged in to leave comments. Login now