Exemplo n.º 1
0
def main():    
         
    # The system stdout and stderr will be in /leam/scratch/<scenarioname>/<scenarioname>.log
    jobstart = time.asctime()
    os.environ['PATH'] = ':'.join(['./bin', os.environ.get('BIN', '.'),'/bin', '/usr/bin'])
    configurl, user, password = parseFlags()
    
    print "Parsing configuration file.............\n"
    configfile = get_config(configurl, user, password)
    luc = LUC(configfile)
    print luc.growthmap[0]
    # luc has sorted luc.growthmap(drivers) in year and luc.growth(projections)

    print "Setting up GRASS environment.............\n"
    get_grassfolder(luc.scenario['grass_loc'], user, password)
    grasssetup.grassConfig()
    global grass
    grass = grasssetup.grass
    
    print "Connect to the LEAM storage server............."
    resultsdir = luc.scenario['results']
    print resultsdir, '\n'

    title = luc.scenario['title']
    global site, runlog # run.log will be stored in Log repository
    site = LEAMsite(resultsdir, user=user, passwd=password)
 
    #create runlog file 
    site.createFolder("RunLog", resultsdir)    



    runlog = RunLog(resultsdir+"/runlog", site, initmsg='Scenario ' + title)
    runlog.p('started at '+jobstart)
    
    # creat two folders
    site.createFolder("Details", resultsdir)
    site.createFolder("Results", resultsdir)


    global projectiontable
    projectiontable = ProjTable()
    
    growth = dict(deltapop=[0.0], deltaemp=[0.0])
    if luc.growth: # note growthmap[0]...should change luc, using luc_new
        runlog.h('Processing Growth driver set.............')
        startyear, isprobmapcached = processDriverSets(luc.growthmap[0])
        if not isprobmapcached:
            runlog.h('Building Probability Maps..............')
            runMulticostModel(resultsdir, site, runlog)
            cacheProbmaps(luc.growthmap[0]['url'])            

    if luc.growthmap:
        runlog.h('Processing Growth Projection set........')
        demandstr = processProjectionSet(luc.growth[0])
        genYearChangemap.executeGLUCModel(demandstr, title, runlog)
        runlog.h('Publishing all results..............')
        #wrap the simmap file to Results
        publishResults(title, site, resultsdir+"/results")
def main():

    # The system stdout and stderr will be in /leam/scratch/<scenarioname>/<scenarioname>.log
    jobstart = time.asctime()
    os.environ['PATH'] = ':'.join(
        ['./bin', os.environ.get('BIN', '.'), '/bin', '/usr/bin'])
    configurl, user, password = parseFlags()

    print "Parsing configuration file.............\n"
    configfile = get_config(configurl, user, password)
    luc = LUC(configfile)
    print luc.growthmap[0]
    # luc has sorted luc.growthmap(drivers) in year and luc.growth(projections)

    print "Setting up GRASS environment.............\n"
    get_grassfolder(luc.scenario['grass_loc'], user, password)
    grasssetup.grassConfig()
    global grass
    grass = grasssetup.grass

    print "Connect to the LEAM storage server............."
    resultsdir = luc.scenario['results']
    print resultsdir, '\n'

    title = luc.scenario['title']
    global site, runlog  # run.log will be stored in Log repository
    site = LEAMsite(resultsdir, user=user, passwd=password)

    #create runlog file
    site.createFolder("RunLog", resultsdir)

    runlog = RunLog(resultsdir + "/runlog", site, initmsg='Scenario ' + title)
    runlog.p('started at ' + jobstart)

    # creat two folders
    site.createFolder("Details", resultsdir)
    site.createFolder("Results", resultsdir)

    global projectiontable
    projectiontable = ProjTable()

    growth = dict(deltapop=[0.0], deltaemp=[0.0])
    if luc.growth:  # note growthmap[0]...should change luc, using luc_new
        runlog.h('Processing Growth driver set.............')
        startyear, isprobmapcached = processDriverSets(luc.growthmap[0])
        if not isprobmapcached:
            runlog.h('Building Probability Maps..............')
            runMulticostModel(resultsdir, site, runlog)
            #open cache function temporarily
            cacheProbmaps(luc.growthmap[0]['url'])

    if luc.growthmap:
        runlog.h('Processing Growth Projection set........')
        demandstr = processProjectionSet(luc.growth[0])
        genYearChangemap.executeGLUCModel(demandstr, title, runlog)
        runlog.h('Publishing all results..............')
        #wrap the simmap file to Results
        publishResults(title, site, resultsdir + "/results")