@@ -122,7 +122,25 def isFileInTimeRange(filename, startTime, endTime): | |||||
122 | print "Skipping the file %s because it has not a valid header" %(filename) |
|
122 | print "Skipping the file %s because it has not a valid header" %(filename) | |
123 | return None |
|
123 | return None | |
124 |
|
124 | |||
125 | if not ((startTime <= thisTime) and (endTime > thisTime)): |
|
125 | #General case | |
|
126 | # o>>>>>>>>>>>>>><<<<<<<<<<<<<<o | |||
|
127 | #-----------o----------------------------o----------- | |||
|
128 | # startTime endTime | |||
|
129 | ||||
|
130 | if endTime >= startTime: | |||
|
131 | if (thisTime < startTime) or (thisTime > endTime): | |||
|
132 | return None | |||
|
133 | ||||
|
134 | return thisDatetime | |||
|
135 | ||||
|
136 | #If endTime < startTime then endTime belongs to the next day | |||
|
137 | ||||
|
138 | ||||
|
139 | #<<<<<<<<<<<o o>>>>>>>>>>> | |||
|
140 | #-----------o----------------------------o----------- | |||
|
141 | # endTime startTime | |||
|
142 | ||||
|
143 | if (thisTime < startTime) and (thisTime > endTime): | |||
126 | return None |
|
144 | return None | |
127 |
|
145 | |||
128 | return thisDatetime |
|
146 | return thisDatetime | |
@@ -526,84 +544,22 class JRODataReader(JRODataIO): | |||||
526 |
|
544 | |||
527 | pathList = [] |
|
545 | pathList = [] | |
528 |
|
546 | |||
529 | # if not walk: |
|
|||
530 | # #pathList.append(path) |
|
|||
531 | # multi_path = path.split(',') |
|
|||
532 | # for single_path in multi_path: |
|
|||
533 | # |
|
|||
534 | # if not os.path.isdir(single_path): |
|
|||
535 | # continue |
|
|||
536 | # |
|
|||
537 | # pathList.append(single_path) |
|
|||
538 | # |
|
|||
539 | # else: |
|
|||
540 | # #dirList = [] |
|
|||
541 | # multi_path = path.split(',') |
|
|||
542 | # for single_path in multi_path: |
|
|||
543 | # |
|
|||
544 | # if not os.path.isdir(single_path): |
|
|||
545 | # continue |
|
|||
546 | # |
|
|||
547 | # dirList = [] |
|
|||
548 | # for thisPath in os.listdir(single_path): |
|
|||
549 | # if not os.path.isdir(os.path.join(single_path,thisPath)): |
|
|||
550 | # continue |
|
|||
551 | # if not isRadarFolder(thisPath): |
|
|||
552 | # continue |
|
|||
553 | # |
|
|||
554 | # dirList.append(thisPath) |
|
|||
555 | # |
|
|||
556 | # if not(dirList): |
|
|||
557 | # return None, None |
|
|||
558 | # |
|
|||
559 | # if startDate and endDate: |
|
|||
560 | # thisDate = startDate |
|
|||
561 | # |
|
|||
562 | # while(thisDate <= endDate): |
|
|||
563 | # year = thisDate.timetuple().tm_year |
|
|||
564 | # doy = thisDate.timetuple().tm_yday |
|
|||
565 | # |
|
|||
566 | # matchlist = fnmatch.filter(dirList, '?' + '%4.4d%3.3d' % (year,doy) + '*') |
|
|||
567 | # if len(matchlist) == 0: |
|
|||
568 | # thisDate += datetime.timedelta(1) |
|
|||
569 | # continue |
|
|||
570 | # for match in matchlist: |
|
|||
571 | # pathList.append(os.path.join(single_path,match,expLabel)) |
|
|||
572 | # |
|
|||
573 | # thisDate += datetime.timedelta(1) |
|
|||
574 | # else: |
|
|||
575 | # for thiDir in dirList: |
|
|||
576 | # pathList.append(os.path.join(single_path,thiDir,expLabel)) |
|
|||
577 |
|
||||
578 | dateList, pathList = self.findDatafiles(path, startDate, endDate, expLabel, ext, walk, include_path=True) |
|
547 | dateList, pathList = self.findDatafiles(path, startDate, endDate, expLabel, ext, walk, include_path=True) | |
579 |
|
548 | |||
580 | if dateList == []: |
|
549 | if dateList == []: | |
581 | print "Any folder was found for the date range: %s-%s" %(startDate, endDate) |
|
550 | print "[Reading] No *%s files in %s from %s to %s)"%(ext, path, | |
|
551 | datetime.datetime.combine(startDate,startTime).ctime(), | |||
|
552 | datetime.datetime.combine(endDate,endTime).ctime()) | |||
|
553 | ||||
582 | return None, None |
|
554 | return None, None | |
583 |
|
555 | |||
584 | if len(dateList) > 1: |
|
556 | if len(dateList) > 1: | |
585 | print "%d dates with data were found for the date range: %s - %s" %(len(dateList), startDate, endDate) |
|
557 | print "[Reading] %d dates with data were found for the date range: %s - %s" %(len(dateList), startDate, endDate) | |
586 | else: |
|
558 | else: | |
587 | print "data was found for the date %s" %(dateList[0]) |
|
559 | print "[Reading] data was found for the date %s" %(dateList[0]) | |
588 |
|
560 | |||
589 | filenameList = [] |
|
561 | filenameList = [] | |
590 | datetimeList = [] |
|
562 | datetimeList = [] | |
591 | # pathDict = {} |
|
|||
592 | # filenameList_to_sort = [] |
|
|||
593 | # |
|
|||
594 | # for i in range(len(pathList)): |
|
|||
595 | # |
|
|||
596 | # thisPath = pathList[i] |
|
|||
597 | # |
|
|||
598 | # fileList = glob.glob1(thisPath, "*%s" %ext) |
|
|||
599 | # if len(fileList) < 1: |
|
|||
600 | # continue |
|
|||
601 | # fileList.sort() |
|
|||
602 | # pathDict.setdefault(fileList[0]) |
|
|||
603 | # pathDict[fileList[0]] = i |
|
|||
604 | # filenameList_to_sort.append(fileList[0]) |
|
|||
605 | # |
|
|||
606 | # filenameList_to_sort.sort() |
|
|||
607 |
|
563 | |||
608 | for thisPath in pathList: |
|
564 | for thisPath in pathList: | |
609 | # thisPath = pathList[pathDict[file]] |
|
565 | # thisPath = pathList[pathDict[file]] | |
@@ -627,14 +583,14 class JRODataReader(JRODataIO): | |||||
627 | datetimeList.append(thisDatetime) |
|
583 | datetimeList.append(thisDatetime) | |
628 |
|
584 | |||
629 | if not(filenameList): |
|
585 | if not(filenameList): | |
630 |
print "Any file was found |
|
586 | print "[Reading] Any file was found int time range %s - %s" %(startTime.ctime(), endTime.ctime()) | |
631 | return None, None |
|
587 | return None, None | |
632 |
|
588 | |||
633 |
print "%d file(s) was(were) found |
|
589 | print "[Reading] %d file(s) was(were) found in time range: %s - %s" %(len(filenameList), startTime, endTime) | |
634 |
|
590 | |||
635 |
|
591 | |||
636 | for i in range(len(filenameList)): |
|
592 | for i in range(len(filenameList)): | |
637 | print "%s -> [%s]" %(filenameList[i], datetimeList[i].ctime()) |
|
593 | print "[Reading] %s -> [%s]" %(filenameList[i], datetimeList[i].ctime()) | |
638 |
|
594 | |||
639 | self.filenameList = filenameList |
|
595 | self.filenameList = filenameList | |
640 | self.datetimeList = datetimeList |
|
596 | self.datetimeList = datetimeList | |
@@ -690,7 +646,7 class JRODataReader(JRODataIO): | |||||
690 | fullpath = os.path.join(path, doypath, expLabel) |
|
646 | fullpath = os.path.join(path, doypath, expLabel) | |
691 |
|
647 | |||
692 |
|
648 | |||
693 | print "%s folder was found: " %(fullpath ) |
|
649 | print "[Reading] %s folder was found: " %(fullpath ) | |
694 |
|
650 | |||
695 | if set == None: |
|
651 | if set == None: | |
696 | filename = getlastFileFromPath(fullpath, ext) |
|
652 | filename = getlastFileFromPath(fullpath, ext) | |
@@ -700,7 +656,7 class JRODataReader(JRODataIO): | |||||
700 | if not(filename): |
|
656 | if not(filename): | |
701 | return None, None, None, None, None, None |
|
657 | return None, None, None, None, None, None | |
702 |
|
658 | |||
703 | print "%s file was found" %(filename) |
|
659 | print "[Reading] %s file was found" %(filename) | |
704 |
|
660 | |||
705 | if not(self.__verifyFile(os.path.join(fullpath, filename))): |
|
661 | if not(self.__verifyFile(os.path.join(fullpath, filename))): | |
706 | return None, None, None, None, None, None |
|
662 | return None, None, None, None, None, None | |
@@ -1206,10 +1162,10 class JRODataReader(JRODataIO): | |||||
1206 | walk=walk) |
|
1162 | walk=walk) | |
1207 |
|
1163 | |||
1208 | if not(pathList): |
|
1164 | if not(pathList): | |
1209 |
print "[Reading] No *%s files in |
|
1165 | # print "[Reading] No *%s files in %s (%s - %s)"%(ext, path, | |
1210 | datetime.datetime.combine(startDate,startTime).ctime(), |
|
1166 | # datetime.datetime.combine(startDate,startTime).ctime(), | |
1211 | datetime.datetime.combine(endDate,endTime).ctime()) |
|
1167 | # datetime.datetime.combine(endDate,endTime).ctime()) | |
1212 |
|
1168 | # | ||
1213 | sys.exit(-1) |
|
1169 | sys.exit(-1) | |
1214 |
|
1170 | |||
1215 |
|
1171 |
General Comments 0
You need to be logged in to leave comments.
Login now