@@ -107,16 +107,17 def isFileinThisTime(filename, startTime, endTime): | |||||
107 | sts = basicHeaderObj.read(fp) |
|
107 | sts = basicHeaderObj.read(fp) | |
108 | fp.close() |
|
108 | fp.close() | |
109 |
|
109 | |||
|
110 | thisDatetime = basicHeaderObj.datatime | |||
110 | thisTime = basicHeaderObj.datatime.time() |
|
111 | thisTime = basicHeaderObj.datatime.time() | |
111 |
|
112 | |||
112 | if not(sts): |
|
113 | if not(sts): | |
113 | print "Skipping the file %s because it has not a valid header" %(filename) |
|
114 | print "Skipping the file %s because it has not a valid header" %(filename) | |
114 |
return |
|
115 | return None | |
115 |
|
116 | |||
116 | if not ((startTime <= thisTime) and (endTime > thisTime)): |
|
117 | if not ((startTime <= thisTime) and (endTime > thisTime)): | |
117 |
return |
|
118 | return None | |
118 |
|
119 | |||
119 |
return this |
|
120 | return thisDatetime | |
120 |
|
121 | |||
121 | def getlastFileFromPath(path, ext): |
|
122 | def getlastFileFromPath(path, ext): | |
122 | """ |
|
123 | """ | |
@@ -318,6 +319,8 class JRODataReader(JRODataIO, ProcessingUnit): | |||||
318 |
|
319 | |||
319 | __isFirstTimeOnline = 1 |
|
320 | __isFirstTimeOnline = 1 | |
320 |
|
321 | |||
|
322 | __printInfo = True | |||
|
323 | ||||
321 | def __init__(self): |
|
324 | def __init__(self): | |
322 |
|
325 | |||
323 | """ |
|
326 | """ | |
@@ -349,11 +352,10 class JRODataReader(JRODataIO, ProcessingUnit): | |||||
349 | walk=True): |
|
352 | walk=True): | |
350 |
|
353 | |||
351 | pathList = [] |
|
354 | pathList = [] | |
352 | dateList = [] |
|
|||
353 |
|
355 | |||
354 | if not walk: |
|
356 | if not walk: | |
355 | pathList.append(path) |
|
357 | pathList.append(path) | |
356 |
|
|
358 | ||
357 | else: |
|
359 | else: | |
358 | dirList = [] |
|
360 | dirList = [] | |
359 | for thisPath in os.listdir(path): |
|
361 | for thisPath in os.listdir(path): | |
@@ -379,7 +381,6 class JRODataReader(JRODataIO, ProcessingUnit): | |||||
379 | continue |
|
381 | continue | |
380 |
|
382 | |||
381 | pathList.append(os.path.join(path,match[0],expLabel)) |
|
383 | pathList.append(os.path.join(path,match[0],expLabel)) | |
382 | dateList.append(thisDate) |
|
|||
383 |
|
384 | |||
384 | thisDate += datetime.timedelta(1) |
|
385 | thisDate += datetime.timedelta(1) | |
385 |
|
386 | |||
@@ -395,7 +396,6 class JRODataReader(JRODataIO, ProcessingUnit): | |||||
395 | for i in range(len(pathList)): |
|
396 | for i in range(len(pathList)): | |
396 |
|
397 | |||
397 | thisPath = pathList[i] |
|
398 | thisPath = pathList[i] | |
398 | thisDate = dateList[i] |
|
|||
399 |
|
399 | |||
400 | fileList = glob.glob1(thisPath, "*%s" %ext) |
|
400 | fileList = glob.glob1(thisPath, "*%s" %ext) | |
401 | fileList.sort() |
|
401 | fileList.sort() | |
@@ -403,13 +403,13 class JRODataReader(JRODataIO, ProcessingUnit): | |||||
403 | for file in fileList: |
|
403 | for file in fileList: | |
404 |
|
404 | |||
405 | filename = os.path.join(thisPath,file) |
|
405 | filename = os.path.join(thisPath,file) | |
406 |
this |
|
406 | thisDatetime = isFileinThisTime(filename, startTime, endTime) | |
407 |
|
407 | |||
408 |
if |
|
408 | if not(thisDatetime): | |
409 | continue |
|
409 | continue | |
410 |
|
410 | |||
411 | filenameList.append(filename) |
|
411 | filenameList.append(filename) | |
412 |
datetimeList.append( |
|
412 | datetimeList.append(thisDatetime) | |
413 |
|
413 | |||
414 | if not(filenameList): |
|
414 | if not(filenameList): | |
415 | print "Any file was found for the time range %s - %s" %(startTime, endTime) |
|
415 | print "Any file was found for the time range %s - %s" %(startTime, endTime) | |
@@ -452,8 +452,10 class JRODataReader(JRODataIO, ProcessingUnit): | |||||
452 | """ |
|
452 | """ | |
453 | dirList = [] |
|
453 | dirList = [] | |
454 |
|
454 | |||
455 | if walk: |
|
455 | if not walk: | |
456 |
|
456 | fullpath = path | ||
|
457 | ||||
|
458 | else: | |||
457 | #Filtra solo los directorios |
|
459 | #Filtra solo los directorios | |
458 | for thisPath in os.listdir(path): |
|
460 | for thisPath in os.listdir(path): | |
459 | if not os.path.isdir(os.path.join(path,thisPath)): |
|
461 | if not os.path.isdir(os.path.join(path,thisPath)): | |
@@ -470,9 +472,7 class JRODataReader(JRODataIO, ProcessingUnit): | |||||
470 |
|
472 | |||
471 | doypath = dirList[-1] |
|
473 | doypath = dirList[-1] | |
472 | fullpath = os.path.join(path, doypath, expLabel) |
|
474 | fullpath = os.path.join(path, doypath, expLabel) | |
473 |
|
475 | |||
474 | else: |
|
|||
475 | fullpath = path |
|
|||
476 |
|
476 | |||
477 | print "%s folder was found: " %(fullpath ) |
|
477 | print "%s folder was found: " %(fullpath ) | |
478 |
|
478 | |||
@@ -491,8 +491,6 class JRODataReader(JRODataIO, ProcessingUnit): | |||||
491 | set = int( filename[8:11] ) |
|
491 | set = int( filename[8:11] ) | |
492 |
|
492 | |||
493 | return fullpath, filename, year, doy, set |
|
493 | return fullpath, filename, year, doy, set | |
494 |
|
||||
495 |
|
||||
496 |
|
494 | |||
497 | def __setNextFileOffline(self): |
|
495 | def __setNextFileOffline(self): | |
498 |
|
496 | |||
@@ -940,10 +938,15 class JRODataReader(JRODataIO, ProcessingUnit): | |||||
940 |
|
938 | |||
941 | def printInfo(self): |
|
939 | def printInfo(self): | |
942 |
|
940 | |||
943 | print self.basicHeaderObj.printInfo() |
|
941 | if self.__printInfo == False: | |
944 | print self.systemHeaderObj.printInfo() |
|
942 | return | |
945 | print self.radarControllerHeaderObj.printInfo() |
|
943 | ||
946 |
|
|
944 | self.basicHeaderObj.printInfo() | |
|
945 | self.systemHeaderObj.printInfo() | |||
|
946 | self.radarControllerHeaderObj.printInfo() | |||
|
947 | self.processingHeaderObj.printInfo() | |||
|
948 | ||||
|
949 | self.__printInfo = False | |||
947 |
|
950 | |||
948 |
|
951 | |||
949 | def run(self, **kwargs): |
|
952 | def run(self, **kwargs): |
@@ -24,9 +24,12 class Header: | |||||
24 |
|
24 | |||
25 | def printInfo(self): |
|
25 | def printInfo(self): | |
26 |
|
26 | |||
|
27 | print "#"*100 | |||
|
28 | print self.__class__.__name__.upper() | |||
|
29 | print "#"*100 | |||
27 | for key in self.__dict__.keys(): |
|
30 | for key in self.__dict__.keys(): | |
28 | print "%s = %s" %(key, self.__dict__[key]) |
|
31 | print "%s = %s" %(key, self.__dict__[key]) | |
29 |
|
32 | |||
30 | class BasicHeader(Header): |
|
33 | class BasicHeader(Header): | |
31 |
|
34 | |||
32 | size = None |
|
35 | size = None |
General Comments 0
You need to be logged in to leave comments.
Login now