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")
def main():

    usage = "usage: %prog [options] <site URL>"
    parser = optparse.OptionParser(usage=usage)
    parser.add_option("-u", "--user", 
            default=os.environ.get('PORTAL_USER', ''),
            help="Plone user")
    parser.add_option("-p", "--password",
            default=os.environ.get('PORTAL_PASSWORD', ''),
            help="Plone user's password")

    (opts, args) = parser.parse_args()

    if len(args) != 1:
        parser.error("the URL to the Plone site is required")

    url = args[0]
    site = LEAMsite(url, user=opts.user, passwd=opts.password)
    if site.error:
        parser.error("the URL is not a valid site")

    top = site.createFolder("luc", url)
    site.editFolder(top, 
        title="Land Use Model",
        description="LEAM Land Use Change Model allows future land use "
            "scenarios to be created and evaluated.",
    )

    scenarios = site.createFolder("scenarios", top)
    site.editFolder(scenarios,
        title="Scenarios",
        description="Define and review scenarios in this folder.  New "
            "scenarios will automatically be run and results returned by "
            "the modeling system."
    )

    projections = site.createFolder("projections", top)
    site.editFolder(projections, 
        title="Projections",
        description="Enter population and employment projection associated "
            "with specific areas in this folder.  The projection consist of "
            "the projection rate by year, a region or zone, and population "
            "and employment density maps."
    )

    subregional = site.createFolder("subregional", projections)
    site.editFolder(subregional,
        title="Subregional Maps",
        description="Subregional maps identify different zones used within "
            "the model.  These maps can be used as part of a projection or "
            "within impact models."
    )

    density = site.createFolder("density", projections)
    site.editFolder(density,
        title="Density Maps",
        description="Density maps associated with projections.  Maps "
            "should include POPDENS field, EMPDENS field, or both."
    )

    drivers = site.createFolder("drivers", top)
    site.editFolder(drivers,
        title="Regional Drivers",
        description="Enter a set of drivers that will be associated with "
            "a specific probability map in this folder.  The actual "
            "probabilty map will be created during the model run."
    )

    transportation = site.createFolder("transportation", drivers)
    site.editFolder(transportation,
        title="Transportation Networks",
        description="Transportation networks require two fields, FCLASS "
            "and MINSPEED.  FCLASS is the function class of the road.  "
            "MINSPEED represents the calculated speed at peak traffic times."
    )

    specials = site.createFolder("specials", drivers)
    site.editFolder(specials,
        title = "Special Drivers",
        description="Special drivers provides a mechanism for directly "
            "modifying the probability maps. "
    )
    
    nogrowth = site.createFolder("nogrowth", drivers)
    site.editFolder(nogrowth,
        title = "No Growth Maps",
        description = "No growth layers are used to remove areas from "
            "development. No special fields are required for this layer. "
            "Any areas identified in 'no growth' layers will be ignored "
            "by the model."
    )

    attractors = site.createFolder("attractors", drivers)
    site.editFolder(attractors,
        title="Regional Attractors",
        description="Enter regional attractors such as cities and employment "
            "centers in this folder. The cities layer is a point layer and "
            "must have provide the population in field POP.  The employment "
            "layer should have the number of employees associated with each "
            "employment center in the EMP field."
    )

    grids = site.createFolder("grids", drivers)
    site.editFolder(grids,
        title="Raster Data Layers",
        description="""Land use maps, DEMs, and other raster data types."""
    )

    post = site.createFolder("post-processing", top)
    site.editFolder(post,
        title="Post-Processing",
        description="Items placed in this folder will be executed "
            "automatically when a new LUC scenario has be created. "
    )

    resources = site.createFolder("resources", top)
    site.editFolder(resources,
        title="Resources",
        description="Resources useful during the modeling process."
    )
Exemple #4
0
def main():

    usage = "usage: %prog [options] <site URL>"
    parser = optparse.OptionParser(usage=usage)
    parser.add_option("-u", "--user", default="", help="Plone user")
    parser.add_option("-p",
                      "--password",
                      default="",
                      help="Plone user's password")

    (opts, args) = parser.parse_args()

    if len(args) != 1:
        parser.error("the URL to the Plone site is required")

    user = opts.user or os.environ.get('PORTAL_USER', '')
    password = opts.password or os.environ.get('PORTAL_PASSWORD', '')

    url = args[0]
    site = LEAMsite(url, user=opts.user, passwd=opts.password)
    if site.error:
        parser.error("the URL is not a valid site")

    top = site.createFolder("luc", url)
    site.editFolder(
        top,
        title="Land Use Model",
        description="LEAM Land Use Change Model allows future land use "
        "scenarios to be created and evaluated.",
    )

    scenarios = site.createFolder("scenarios", top)
    site.editFolder(
        scenarios,
        title="Scenarios",
        description="Define and review scenarios in this folder.  New "
        "scenarios will automatically be run and results returned by "
        "the modeling system.")

    projections = site.createFolder("projections", top)
    site.editFolder(
        projections,
        title="Subregional Projections",
        description="Enter population and employment projection associated "
        "with specific areas in this folder.  The projection may "
        "contains zones, population and employment densities.")

    subregional = site.createFolder("subregional", projections)
    site.editFolder(
        subregional,
        title="Subregional Maps",
        description="Subregional maps identify different zones used within "
        "the model.  These maps can be used as part of a projection or "
        "within impact models.")

    density = site.createFolder("density", projections)
    site.editFolder(
        density,
        title="Density Maps",
        description="Density maps associated with projections.  Maps "
        "should include POPDENS field, EMPDENS field, or both.")

    drivers = site.createFolder("drivers", top)
    site.editFolder(
        drivers,
        title="Regional Drivers",
        description="Enter a set of drivers that will be associated with "
        "a specific probability map in this folder.  The actual "
        "probabilty map will be created during the model run.")

    transportation = site.createFolder("transportation", drivers)
    site.editFolder(
        transportation,
        title="Transportation Networks",
        description="Transportation networks require two fields, FCLASS "
        "and MINSPEED.  FCLASS is the function class of the road.  "
        "MINSPEED represents the calculated speed at peak traffic times.")

    specials = site.createFolder("specials", drivers)
    site.editFolder(
        specials,
        title="Special Drivers",
        description="Special drivers provides a mechanism for directly "
        "modifying the probability maps. ")

    nogrowth = site.createFolder("nogrowth", drivers)
    site.editFolder(
        nogrowth,
        title="No Growth Maps",
        description="No growth layers are used to remove areas from "
        "development. No special fields are required for this layer. "
        "Any areas identified in 'no growth' layers will be ignored "
        "by the model.")

    attractors = site.createFolder("attractors", drivers)
    site.editFolder(
        attractors,
        title="Regional Attractors",
        description="Enter regional attractors such as cities and employment "
        "centers in this folder. The cities layer is a point layer and "
        "must have provide the population in field POP.  The employment "
        "layer should have the number of employees associated with each "
        "employment center in the EMP field.")

    grids = site.createFolder("grids", drivers)
    site.editFolder(
        grids,
        title="Raster Data Layers",
        description="""Land use maps, DEMs, and other raster data types.""")

    post = site.createFolder("post-processing", top)
    site.editFolder(post,
                    title="Post-Processing",
                    description="Items placed in this folder will be executed "
                    "automatically when a new LUC scenario has be created. ")

    resources = site.createFolder("resources", top)
    site.editFolder(
        resources,
        title="Resources",
        description="Resources useful during the modeling process.")