def main(): global srcsite, dstsite usage = "usage: %prog [options] <fss> <src URL> <dst URL>" parser = optparse.OptionParser(usage=usage) parser.add_option parser.add_option("-u", "--user", default="admin", help="Plone user") parser.add_option("-p", "--password", default="leam4z", help="Plone user's password") (opts, args) = parser.parse_args() if len(args) != 3: parser.error("the URL and the fss path are required") else: fss, src, dst = args srcsite = LEAMsite(src, user=opts.user, passwd=opts.password) if srcsite.error: parser.error("the URL '%s' is not a valid site" % src) dstsite = LEAMsite(dst, user=opts.user, passwd=opts.password) if dstsite.error: parser.error("the URL '%s' is not a valid site" % dst) walk(fss, processFSS, (fss, src, dst))
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(): # conection to the portal global site site = LEAMsite(resultsdir, user=sys.argv[1], passwd=sys.argv[2]) print "--upload pop_attr map..." popattr_simmap = 'Data/pop_att.gtif' popattr_mapfile = 'Outputs/pop_att.map' popattrurl = site.putSimMap("popattr.tif", "popattr.map", url, simmap_file=open(popattr_simmap, 'rb'), mapfile_file=open(popattr_mapfile, 'rb')) site.updateSimMap(popattrurl, title='popattr-autoColor', description='interpolated attractionmap for population centers.\n \ Automatic Color works only for integer quantile values.')
def main(): # Sample variable values # scenariotitle = 'test2_projection' # resultsdir = 'http://portal.leam.illinois.edu/chicago/luc/scenarios/test4_scenario' # demandgraphurl="http://portal.leam.illinois.edu/chicago/luc/projections/test2_projection/getGraph" resultsdir = sys.argv[1] scenariotitle = os.path.basename(resultsdir) global site global runlog site = LEAMsite(resultsdir, user=sys.argv[2], passwd=sys.argv[3]) runlog = RunLog(resultsdir, site, initmsg='Scenario ' + scenariotitle) demandgraphurl = sys.argv[4] demandstr = site.getURL(demandgraphurl).getvalue() executeGLUCModel(demandstr, scenariotitle, runlog)
def main(): # conection to the portal global site site = LEAMsite(resultsdir, user=sys.argv[1], passwd=sys.argv[2]) print "--upload pop_attr map..." popattr_simmap = 'Data/pop_att.gtif' popattr_mapfile = 'Outputs/pop_att.map' popattrurl = site.putSimMap("popattr.tif", "popattr.map", url, simmap_file=open(popattr_simmap, 'rb'), mapfile_file=open(popattr_mapfile, 'rb')) site.updateSimMap( popattrurl, title='popattr-autoColor', description='interpolated attractionmap for population centers.\n \ Automatic Color works only for integer quantile values.')
def main(): f = open(sys.argv[1]) luc = LUC(f.read()) f.close() site = LEAMsite('http://ewg.leamgroup.com') base = luc.growth[0]['id'] print luc.growth[0]['layer'] site.getURL(luc.growth[0]['layer'], filename=base+'.layer.zip') site.getURL(luc.growth[0]['graph'], filename=base+'.graph') print "SCENARIO:", luc.scenario.keys() print "GROWTH[0]:", luc.growth[0].keys() print "GROWTH[0] GRAPH:", luc.growth[0]['graph'] print "GROWTHMAPS: len =", len(luc.growthmap) print "GROWTHMAPS:", luc.growthmap[0].keys() print "GROWTHMAPS nogrowth:", luc.growthmap[0]['nogrowth'] print "GROWTHMAPS: download=", luc.growthmap[0]['download'] print "DECLINE: len=", len(luc.decline), print "DECLINE: len=", len(luc.declinemap),
def main(): f = open(sys.argv[1]) luc = LUC(f.read()) f.close() site = LEAMsite('http://ewg.leamgroup.com') base = luc.growth[0]['id'] print luc.growth[0]['layer'] #site.getURL(luc.growth[0]['layer'], filename=base+'.layer.zip') site.getURL(luc.growth[0]['graph'], filename=base + '.graph') print "SCENARIO:", luc.scenario.keys() print "GROWTH[0]:", luc.growth[0].keys() print "GROWTH[0] GRAPH:", luc.growth[0]['graph'] print "GROWTHMAPS: len =", len(luc.growthmap) print "GROWTHMAPS:", luc.growthmap[0].keys() print "GROWTHMAPS nogrowth:", luc.growthmap[0]['nogrowth'] print "GROWTHMAPS: download=", luc.growthmap[0]['download'] print "DECLINE: len=", len(luc.decline), print "DECLINE: len=", len(luc.declinemap),
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(): sys.stdout = open('./Log/multicostModel.stdout.log', 'w') sys.stderr = open('./Log/multicostModel.stderr.log', 'w') # exportRaster('emp_centers4_47_98') # importVector('Data/FID4_47_98', EMPCENTERS) # print "list available raster maps in database..." # grass.run_command('g.mlist', type='rast') resultsdir = sys.argv[1] user = sys.argv[2] passwd = sys.argv[3] site = LEAMsite(resultsdir, user, passwd) global runlog runlog = RunLog(resultsdir, site, initmsg='Scenario ' + scenariotitle) runMulticostModel(user, passwd, runlog)
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." )
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.")