Example #1
0
def main():
    CEGraph = nx.DiGraph()
    prunedGraph = nx.DiGraph()
    MCCList = []
    MCSList = []
    MCSMCCNodesList = []
    allMCSsList = []
    allCETRMMList = []

    # for GrADs
    subprocess.call('export DISPLAY=:0.0', shell=True)

    mainDirStr = "/directory/to/where/to/store/outputs"
    TRMMdirName = "/directory/to/the/TRMM/netCDF/files"
    CEoriDirName = "/directory/to/the/MERG/netCDF/files"

    # for first time working with the raw MERG zipped files
    # mccSearch.preprocessingMERG("/directory/to/where/the/raw/MERG/files/are")
    # ---------------------------------------------------------------------------------

    # create main directory and file structure for storing intel
    mccSearch.createMainDirectory(mainDirStr)
    TRMMCEdirName = mainDirStr + '/TRMMnetcdfCEs'
    CEdirName = mainDirStr + '/MERGnetcdfCEs'

    # for doing some postprocessing with the clipped datasets instead of running the full program, e.g.
    # mccSearch.postProcessingNetCDF(3,CEoriDirName)
    # mccSearch.postProcessingNetCDF(2)
    # -------------------------------------------------------------------------------------------------

    # let's go!
    print "\n -------------- Read MERG Data ----------"
    mergImgs, timeList = mccSearch.readMergData(CEoriDirName)
    print("-" * 80)

    print 'in main', len(mergImgs)
    # print 'timeList', timeList
    print 'TRMMdirName ', TRMMdirName
    print "\n -------------- TESTING findCloudElements ----------"
    CEGraph = mccSearch.findCloudElements(mergImgs, timeList, TRMMdirName)
    # if the TRMMdirName wasnt entered for whatever reason, you can still get the TRMM data this way
    # CEGraph = mccSearch.findCloudElements(mergImgs,timeList)
    # allCETRMMList=mccSearch.findPrecipRate(TRMMdirName,timeList)
    # ----------------------------------------------------------------------------------------------
    print("-" * 80)
    print "number of nodes in CEGraph is: ", CEGraph.number_of_nodes()
    print("-" * 80)
    print "\n -------------- TESTING findCloudClusters ----------"
    prunedGraph = mccSearch.findCloudClusters(CEGraph)
    print("-" * 80)
    print "number of nodes in prunedGraph is: ", prunedGraph.number_of_nodes()
    print("-" * 80)
    print "\n -------------- TESTING findMCCs ----------"
    MCCList, MCSList = mccSearch.findMCC(prunedGraph)
    print("-" * 80)
    print "MCC List has been acquired ", len(MCCList)
    print "MCS List has been acquired ", len(MCSList)
    print("-" * 80)
    # now ready to perform various calculations/metrics
    print "\n -------------- TESTING METRICS ----------"

    # some calculations/metrics that work that work
    # print "creating the MCC userfile ", mccSearch.createTextFile(MCCList,1)
    # print "creating the MCS userfile ", mccSearch.createTextFile(MCSList,2)
    # MCCTimes, tdelta = mccSearch.temporalAndAreaInfoMetric(MCCList)
    # print "number of MCCs is: ", mccSearch.numberOfFeatures(MCCList)
    # print "longest duration is: ", mccSearch.longestDuration(MCCTimes), "hrs"
    # print "shortest duration is: ", mccSearch.shortestDuration(MCCTimes), "hrs"
    # #print "Average duration is: ", mccSearch.convert_timedelta(mccSearch.averageMCCLength(MCCTimes))
    # print "Average duration is: ", mccSearch.averageDuration(MCCTimes), "hrs"
    # print "Average size is: ", mccSearch.averageFeatureSize(MCCList), "km^2"

    # some plots that work
    # mccSearch.plotAccTRMM(MCCList)
    mccSearch.displayPrecip(MCCList)
    # mccSearch.plotAccuInTimeRange('2009-09-01_00:00:00', '2009-09-01_09:00:00')
    # mccSearch.displaySize(MCCList)
    # mccSearch.displayPrecip(MCCList)
    # mccSearch.plotHistogram(MCCList)
    #
    print("-" * 80)
Example #2
0
def main():
    CEGraph = nx.DiGraph()
    prunedGraph = nx.DiGraph()
    MCCList =[]
    MCSList=[]
    MCSMCCNodesList =[]
    allMCSsList =[]
    allCETRMMList =[]
    DIRS={}
    # DIRS={
    #          mainDirStr= "/directory/to/where/to/store/outputs"
    #          TRMMdirName = "/directory/to/the/TRMM/netCDF/files" 
    #          CEoriDirName = "/directory/to/the/MERG/netCDF/files"
    #         }
    preprocessing = ''
    rawMERG = ''

    #for GrADs
    subprocess.call('export DISPLAY=:0.0', shell=True)

   
    print "Running MCCSearch ..... \n"
    DIRS['mainDirStr'] = raw_input("> Please enter working directory: \n" )   # This is where data created will be stored

    preprocessing = raw_input ("> Do you need to preprocess the MERG files? [y/n]: \n")
    while preprocessing.lower() != 'n':
        if preprocessing.lower() == 'y':
            #get location for raw files
            rawMERG = raw_input("> Please enter the directory to the RAW MERG (.Z) files: \n")
            #run preprocessing
            mccSearch.preprocessingMERG(rawMERG)
            continue
        elif preprocessing.lower() == 'n' :
            pass
        else:
            print "Error! Invalid choice "
            preprocessing = raw_input ("> Do you need to preprocess the MERG files? [y/n]: \n")
    

    #get the location of the MERG and TRMM data
    DIRS['CEoriDirName'] = raw_input("> Please enter the directory to the MERG netCDF files: \n")

    try:
        if not os.path.exists(DIRS['CEoriDirName']):
            print "Error! MERG invalid path!"
            DIRS['CEoriDirName'] = raw_input("> Please enter the directory to the MERG netCDF files: \n")
    except:
        print "..."


    DIRS['TRMMdirName'] = raw_input("> Please enter the location to the raw TRMM netCDF files: \n")
    try:
        if not os.path.exists(DIRS['TRMMdirName']):
            print "Error: TRMM invalid path!"
            DIRS['TRMMdirName'] = raw_input("> Please enter the location to the raw TRMM netCDF files: \n")
    except:
        pass

    #get the dates for analysis
    startDateTime = raw_input("> Please enter the start date and time yyyymmddhr: \n")
    #check validity of time
    while validDate(startDateTime) == 0:
        print "Invalid time entered for startDateTime!"
        startDateTime = raw_input("> Please enter the start date and time yyyymmddhr: \n")

    endDateTime = raw_input("> Please enter the end date and time yyyymmddhr: \n")
    while validDate(endDateTime) == 0:
        print "Invalid time entered for endDateTime!"
        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)
    if test == False:
        print "Error with files in the original TRMM directory entered. Please check your files before restarting. "
        return
    test, filelist = mccSearch.checkForFiles(startDateTime, endDateTime, DIRS['CEoriDirName'],1)
    if test == False:
        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
    mccSearch.createMainDirectory(DIRS['mainDirStr'])
    TRMMCEdirName = DIRS['mainDirStr']+'/TRMMnetcdfCEs'
    CEdirName = DIRS['mainDirStr']+'/MERGnetcdfCEs'

    # for doing some postprocessing with the clipped datasets instead of running the full program, e.g.
    postprocessing = raw_input("> Do you wish to postprocess data? [y/n] \n")
    while postprocessing.lower() != 'n':
        if postprocessing.lower() == 'y':
            option = postProcessingplotMenu(DIRS)
            return
        elif postprocessing.lower() == 'n':
            pass
        else:
            print "\n Invalid option."
            postprocessing = raw_input("> Do you wish to postprocess data? [y/n] \n")
    # -------------------------------------------------------------------------------------------------
    # Getting started. Make it so number one!
    print ("-"*80)
    print "\t\t Starting the MCCSearch Analysis "
    print ("-"*80) 
    print "\n -------------- Reading MERG and TRMM Data ----------"
    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
    # CEGraph = mccSearch.findCloudElements(mergImgs,timeList)
    # allCETRMMList=mccSearch.findPrecipRate(DIRS['TRMMdirName'],timeList)
    # ----------------------------------------------------------------------------------------------   
    print "\n -------------- findCloudClusters ----------"
    prunedGraph = mccSearch.findCloudClusters(CEGraph)
    print "\n -------------- findMCCs ----------"
    MCCList,MCSList = mccSearch.findMCC(prunedGraph)
    #now ready to perform various calculations/metrics
    print ("-"*80)
    print "\n -------------- METRICS ----------"
    print ("-"*80)
    #some calculations/metrics that work that work
    print "creating the MCC userfile ", mccSearch.createTextFile(MCCList,1)
    print "creating the MCS userfile ", mccSearch.createTextFile(MCSList,2)
    plotMenu(MCCList, MCSList)
    
    #Let's get outta here! Engage!
    print ("-"*80)
Example #3
0
def main():
    CEGraph = nx.DiGraph()
    prunedGraph = nx.DiGraph()
    MCCList =[]
    MCSList=[]
    MCSMCCNodesList =[]
    allMCSsList =[]
    allCETRMMList =[]

    #for GrADs
    subprocess.call('export DISPLAY=:0.0', shell=True)

    mainDirStr= "/directory/to/where/to/store/outputs"
    TRMMdirName = "/directory/to/the/TRMM/netCDF/files" 
    CEoriDirName = "/directory/to/the/MERG/netCDF/files"
   
    #for first time working with the raw MERG zipped files 
    # mccSearch.preprocessingMERG("/directory/to/where/the/raw/MERG/files/are")
    # ---------------------------------------------------------------------------------


    #create main directory and file structure for storing intel
    mccSearch.createMainDirectory(mainDirStr)
    TRMMCEdirName = mainDirStr+'/TRMMnetcdfCEs'
    CEdirName = mainDirStr+'/MERGnetcdfCEs'

    # for doing some postprocessing with the clipped datasets instead of running the full program, e.g.
    # mccSearch.postProcessingNetCDF(3,CEoriDirName)
    # mccSearch.postProcessingNetCDF(2)
    # -------------------------------------------------------------------------------------------------

    #let's go!
    print "\n -------------- Read MERG Data ----------"
    mergImgs, timeList = mccSearch.readMergData(CEoriDirName)
    print ("-"*80)

    print 'in main', len(mergImgs)
    #print 'timeList', timeList
    print 'TRMMdirName ', TRMMdirName
    print "\n -------------- TESTING findCloudElements ----------"
    CEGraph = mccSearch.findCloudElements(mergImgs,timeList,TRMMdirName)
    #if the TRMMdirName wasnt entered for whatever reason, you can still get the TRMM data this way
    # CEGraph = mccSearch.findCloudElements(mergImgs,timeList)
    # allCETRMMList=mccSearch.findPrecipRate(TRMMdirName,timeList)
    # ----------------------------------------------------------------------------------------------
    print ("-"*80)
    print "number of nodes in CEGraph is: ", CEGraph.number_of_nodes()
    print ("-"*80)    
    print "\n -------------- TESTING findCloudClusters ----------"
    prunedGraph = mccSearch.findCloudClusters(CEGraph)
    print ("-"*80)
    print "number of nodes in prunedGraph is: ", prunedGraph.number_of_nodes()
    print ("-"*80)
    print "\n -------------- TESTING findMCCs ----------"
    MCCList,MCSList = mccSearch.findMCC(prunedGraph)
    print ("-"*80)
    print "MCC List has been acquired ", len(MCCList)
    print "MCS List has been acquired ", len(MCSList)
    print ("-"*80)
    #now ready to perform various calculations/metrics
    print "\n -------------- TESTING METRICS ----------"

    #some calculations/metrics that work that work
    # print "creating the MCC userfile ", mccSearch.createTextFile(MCCList,1)
    # print "creating the MCS userfile ", mccSearch.createTextFile(MCSList,2)
    # MCCTimes, tdelta = mccSearch.temporalAndAreaInfoMetric(MCCList)
    # print "number of MCCs is: ", mccSearch.numberOfFeatures(MCCList)
    # print "longest duration is: ", mccSearch.longestDuration(MCCTimes), "hrs"
    # print "shortest duration is: ", mccSearch.shortestDuration(MCCTimes), "hrs"
    # #print "Average duration is: ", mccSearch.convert_timedelta(mccSearch.averageMCCLength(MCCTimes))
    # print "Average duration is: ", mccSearch.averageDuration(MCCTimes), "hrs"
    # print "Average size is: ", mccSearch.averageFeatureSize(MCCList), "km^2" 
    
    #some plots that work
    # mccSearch.plotAccTRMM(MCCList)
    mccSearch.displayPrecip(MCCList)
    # mccSearch.plotAccuInTimeRange('2009-09-01_00:00:00', '2009-09-01_09:00:00')
    # mccSearch.displaySize(MCCList)
    # mccSearch.displayPrecip(MCCList)
    # mccSearch.plotHistogram(MCCList)
    #
    print ("-"*80)
Example #4
0
def main():
    CEGraph = nx.DiGraph()
    prunedGraph = nx.DiGraph()
    MCCList = []
    MCSList = []
    MCSMCCNodesList = []
    allMCSsList = []
    allCETRMMList = []
    DIRS = {}
    # DIRS={
    #          mainDirStr= "/directory/to/where/to/store/outputs"
    #          TRMMdirName = "/directory/to/the/TRMM/netCDF/files"
    #          CEoriDirName = "/directory/to/the/MERG/netCDF/files"
    #         }
    preprocessing = ''
    rawMERG = ''

    print "Running MCCSearch ..... \n"
    DIRS['mainDirStr'] = raw_input(
        "> Please enter working directory: \n"
    )  # This is where data created will be stored

    # preprocessing = raw_input ("> Do you need to preprocess the MERG files? [y/n]: \n")
    # while preprocessing.lower() != 'n':
    #     if preprocessing.lower() == 'y':
    #         #get location for raw files
    #         rawMERG = raw_input("> Please enter the directory to the RAW MERG (.Z) files: \n")
    #         #run preprocessing
    #         mccSearch.preprocessingMERG(rawMERG)
    #         continue
    #     elif preprocessing.lower() == 'n' :
    #         pass
    #     else:
    #         print "Error! Invalid choice "
    #         preprocessing = raw_input ("> Do you need to preprocess the MERG files? [y/n]: \n")

    #get the location of the MERG and TRMM data
    DIRS['CEoriDirName'] = raw_input(
        "> Please enter the directory to the MERG netCDF files: \n")

    try:
        if not os.path.exists(DIRS['CEoriDirName']):
            print "Error! MERG invalid path!"
            DIRS['CEoriDirName'] = raw_input(
                "> Please enter the directory to the MERG netCDF files: \n")
    except:
        print "..."

    DIRS['TRMMdirName'] = raw_input(
        "> Please enter the location to the raw TRMM netCDF files: \n")
    try:
        if not os.path.exists(DIRS['TRMMdirName']):
            print "Error: TRMM invalid path!"
            DIRS['TRMMdirName'] = raw_input(
                "> Please enter the location to the raw TRMM netCDF files: \n")
    except:
        pass

    #get the dates for analysis
    startDateTime = raw_input(
        "> Please enter the start date and time yyyymmddhr: \n")
    #check validity of time
    while validDate(startDateTime) == 0:
        print "Invalid time entered for startDateTime!"
        startDateTime = raw_input(
            "> Please enter the start date and time yyyymmddhr: \n")

    endDateTime = raw_input(
        "> Please enter the end date and time yyyymmddhr: \n")
    while validDate(endDateTime) == 0:
        print "Invalid time entered for endDateTime!"
        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)
    if test == False:
        print "Error with files in the original TRMM directory entered. Please check your files before restarting. "
        return
    test, filelist = mccSearch.checkForFiles(startDateTime, endDateTime,
                                             DIRS['CEoriDirName'], 1)
    if test == False:
        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
    mccSearch.createMainDirectory(DIRS['mainDirStr'])
    TRMMCEdirName = DIRS['mainDirStr'] + '/TRMMnetcdfCEs'
    CEdirName = DIRS['mainDirStr'] + '/MERGnetcdfCEs'

    # for doing some postprocessing with the clipped datasets instead of running the full program, e.g.
    postprocessing = raw_input("> Do you wish to postprocess data? [y/n] \n")
    while postprocessing.lower() != 'n':
        if postprocessing.lower() == 'y':
            option = postProcessingplotMenu(DIRS)
            return
        elif postprocessing.lower() == 'n':
            pass
        else:
            print "\n Invalid option."
            postprocessing = raw_input(
                "> Do you wish to postprocess data? [y/n] \n")
    # -------------------------------------------------------------------------------------------------
    # Getting started. Make it so number one!
    print("-" * 80)
    print "\t\t Starting the MCCSearch Analysis "
    print("-" * 80)
    print "\n -------------- Reading MERG and TRMM Data ----------"
    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
    # CEGraph = mccSearch.findCloudElements(mergImgs,timeList)
    # allCETRMMList=mccSearch.findPrecipRate(DIRS['TRMMdirName'],timeList)
    # ----------------------------------------------------------------------------------------------
    print "\n -------------- findCloudClusters ----------"
    prunedGraph = mccSearch.findCloudClusters(CEGraph)
    print "\n -------------- findMCCs ----------"
    MCCList, MCSList = mccSearch.findMCC(prunedGraph)
    #now ready to perform various calculations/metrics
    print("-" * 80)
    print "\n -------------- METRICS ----------"
    print("-" * 80)
    #some calculations/metrics that work that work
    print "creating the MCC userfile ", mccSearch.createTextFile(MCCList, 1)
    print "creating the MCS userfile ", mccSearch.createTextFile(MCSList, 2)
    plotMenu(MCCList, MCSList)

    #Let's get outta here! Engage!
    print("-" * 80)