fixed bug regarding ability to access a subset of files in a folder
Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/0d1f3d0f Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/0d1f3d0f Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/0d1f3d0f Branch: refs/heads/master Commit: 0d1f3d0f891ece9492e3c355c19464c4ff24faaf Parents: a5b7677 Author: georgette <[email protected]> Authored: Tue Jun 3 09:37:52 2014 -0400 Committer: georgette <[email protected]> Committed: Tue Jun 3 09:37:52 2014 -0400 ---------------------------------------------------------------------- mccsearch/.DS_Store | Bin 0 -> 6148 bytes mccsearch/GrADsScripts/.DS_Store | Bin 0 -> 6148 bytes mccsearch/code/.DS_Store | Bin 0 -> 6148 bytes mccsearch/code/mccSearch.py | 17 ++++++++++++----- mccsearch/code/mccSearchUI.py | 10 +++++----- 5 files changed, 17 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/0d1f3d0f/mccsearch/.DS_Store ---------------------------------------------------------------------- diff --git a/mccsearch/.DS_Store b/mccsearch/.DS_Store new file mode 100644 index 0000000..9cc3ce1 Binary files /dev/null and b/mccsearch/.DS_Store differ http://git-wip-us.apache.org/repos/asf/climate/blob/0d1f3d0f/mccsearch/GrADsScripts/.DS_Store ---------------------------------------------------------------------- diff --git a/mccsearch/GrADsScripts/.DS_Store b/mccsearch/GrADsScripts/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/mccsearch/GrADsScripts/.DS_Store differ http://git-wip-us.apache.org/repos/asf/climate/blob/0d1f3d0f/mccsearch/code/.DS_Store ---------------------------------------------------------------------- diff --git a/mccsearch/code/.DS_Store b/mccsearch/code/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/mccsearch/code/.DS_Store differ http://git-wip-us.apache.org/repos/asf/climate/blob/0d1f3d0f/mccsearch/code/mccSearch.py ---------------------------------------------------------------------- diff --git a/mccsearch/code/mccSearch.py b/mccsearch/code/mccSearch.py index 8c2c801..b7dc4eb 100644 --- a/mccsearch/code/mccSearch.py +++ b/mccsearch/code/mccSearch.py @@ -77,13 +77,14 @@ PRUNED_GRAPH = nx.DiGraph() #------------------------ End GLOBAL VARS ------------------------- #************************ Begin Functions ************************* #****************************************************************** -def readMergData(dirname): +def readMergData(dirname, filelist = None): ''' Purpose:: Read MERG data into RCMES format Input:: - Directory to the MERG files in NETCDF format + dirname: a string representing the directory to the MERG files in NETCDF format + filelist (optional): a list of strings representing the filenames betweent the start and end dates provided Output:: A 3D masked array (t,lat,lon) with only the variables which meet the minimum temperature @@ -107,7 +108,8 @@ def readMergData(dirname): mergLonVarName = 'longitude' filelistInstructions = dirname + '/*' - filelist = glob.glob(filelistInstructions) + if filelist == None: + filelist = glob.glob(filelistInstructions) #sat_img is the array that will contain all the masked frames @@ -1893,6 +1895,7 @@ def checkForFiles(startTime, endTime, thisDir, fileType): status: a boolean representing whether all files exists ''' + filelist =[] startFilename = '' endFilename ='' currFilename = '' @@ -1951,10 +1954,14 @@ def checkForFiles(startTime, endTime, thisDir, fileType): currFilename = thisDir+"/"+startFilename while currFilename is not endFilename: + if not os.path.isfile(currFilename): print "file is missing! Filename: ", currFilename status = False - return status + return status, filelist + else: + #create filelist + filelist.append(currFilename) status = True if currFilename == endFilename: @@ -1973,7 +1980,7 @@ def checkForFiles(startTime, endTime, thisDir, fileType): if fileType == 2: currFilename = thisDir+"/"+"3B42."+str(curryr)+currmmStr+currddStr+"."+currhrStr+".7A.nc" - return status + return status,filelist #****************************************************************** def findTime(curryr, currmm, currdd, currhr): ''' http://git-wip-us.apache.org/repos/asf/climate/blob/0d1f3d0f/mccsearch/code/mccSearchUI.py ---------------------------------------------------------------------- diff --git a/mccsearch/code/mccSearchUI.py b/mccsearch/code/mccSearchUI.py index 9dbb727..45dc73a 100644 --- a/mccsearch/code/mccSearchUI.py +++ b/mccsearch/code/mccSearchUI.py @@ -85,13 +85,13 @@ def main(): endDateTime = raw_input("> Please enter the end date and time yyyymmddhr: \n") #check if all the files exisits in the MERG and TRMM directories entered - test = mccSearch.checkForFiles(startDateTime, endDateTime, DIRS['TRMMdirName'], 2) + test, _ = mccSearch.checkForFiles(startDateTime, endDateTime, DIRS['TRMMdirName'], 2) if test == False: - print "Error with files in the original MERG directory entered. Please check your files before restarting. " + print "Error with files in the original TRMM directory entered. Please check your files before restarting. " return - test = mccSearch.checkForFiles(startDateTime, endDateTime, DIRS['CEoriDirName'],1) + test, filelist = mccSearch.checkForFiles(startDateTime, endDateTime, DIRS['CEoriDirName'],1) if test == False: - print "Error with files in the original TRMM directory entered. Please check your files before restarting. " + print "Error with files in the original MERG directory entered. Please check your files before restarting. " return #create main directory and file structure for storing intel @@ -116,7 +116,7 @@ def main(): print "\t\t Starting the MCCSearch Analysis " print ("-"*80) print "\n -------------- Reading MERG and TRMM Data ----------" - mergImgs, timeList = mccSearch.readMergData(DIRS['CEoriDirName']) + mergImgs, timeList = mccSearch.readMergData(DIRS['CEoriDirName'], filelist) print "\n -------------- findCloudElements ----------" CEGraph = mccSearch.findCloudElements(mergImgs,timeList,DIRS['TRMMdirName']) #if the TRMMdirName wasnt entered for whatever reason, you can still get the TRMM data this way
