Ejemplo n.º 1
0
     'db_input_database':'psrc',
     'db_output_database':None,
     'cache_directory':cache_directory,
     'base_year':2000,
     'tables_to_cache':[
         'gridcells', 
 #        'households',
 #        'jobs', 
     ]})
 
 #CacheScenarioDatabase().run(gridcell_config)
 
 # step 2 cache water demand data by 
 dbcon = ScenarioDatabase(database_name = "water_demand_seattle2") 
 
 print "Create Storage object."
 from opus_core.storage_factory import StorageFactory
 storage = StorageFactory().get_storage(type="mysql_storage", storage_location=dbcon)
 
 from waterdemand.datasets.consumption_dataset import ConsumptionDataset
 consumption_types = ['wrmr', 'wcsr', 'wrsr'] #'wcmr'
 for consumption_type in consumption_types:
     
     consumption = ConsumptionDataset(in_storage = storage, in_table_name=consumption_type+'_grid')
     
     for year in range(1990, 2001):
         print "%s %s" % (consumption_type, year)
         year_index = where(consumption.get_attribute("billyear") == year)
         out_storage = StorageFactory().get_storage(type="flt_storage", storage_location=os.path.join(cache_directory, str(year)))
         consumption_subset = DatasetSubset(consumption, year_index)
         consumption_subset.write_dataset(out_storage=out_storage, out_table_name=consumption_type.lower())
Ejemplo n.º 2
0
from urbansim.store.scenario_database import ScenarioDatabase

dbcon = ScenarioDatabase(hostname="trondheim.cs.washington.edu",
                         username="******",
                         password="******",
                         database_name="water_demand_seattle")

print "Create Storage object."
from urbansim.storage_creator import StorageCreator
storage = StorageCreator().build_storage(type="mysql", location=dbcon)

consumption_type = "WRSR"

print "Create ConsumptionDataset object"
from waterdemand.datasets.consumption_dataset import ConsumptionDataset
consumption = ConsumptionDataset(in_storage=storage,
                                 in_table_name=consumption_type + "_grid")

from urbansim.datasets.gridcell_dataset import GridcellDataset
from numpy import array
from opus_core.misc import unique

consumption_grid_id = consumption.get_attribute("grid_id")
years = consumption.get_attribute("billyear")
distinct_years = unique(years)

import os
from numpy import where, zeros, arange
cache_directory = "D:/urbansim_cache/water_demand"
for year in arange(1991, 2001):
    print year
    flt_storage = StorageCreator().build_storage(type="flt",
from urbansim.store.scenario_database import ScenarioDatabase

dbcon = ScenarioDatabase(hostname = "trondheim.cs.washington.edu",
                         username = "******",
                         password = "******",
                         database_name = "water_demand_seattle")

print "Create Storage object."
from urbansim.storage_creator import StorageCreator
storage = StorageCreator().build_storage(type="mysql", location=dbcon)

consumption_type = "WRSR"

print "Create ConsumptionDataset object"
from waterdemand.datasets.consumption_dataset import ConsumptionDataset
consumption = ConsumptionDataset(in_storage = storage, in_table_name=consumption_type + "_grid")

from urbansim.datasets.gridcell_dataset import GridcellDataset
from numpy import array
from opus_core.misc import unique

consumption_grid_id = consumption.get_attribute("grid_id")
years = consumption.get_attribute("billyear")
distinct_years = unique(years)

import os
from numpy import where, zeros, arange
cache_directory = "D:/urbansim_cache/water_demand"
for year in arange(1991, 2001):
    print year
    flt_storage = StorageCreator().build_storage(type="flt", location=os.path.join(cache_directory, str(year)))
Ejemplo n.º 4
0
        ]
    })

    #CacheScenarioDatabase().run(gridcell_config)

    # step 2 cache water demand data by
    dbcon = ScenarioDatabase(database_name="water_demand_seattle2")

    print "Create Storage object."
    from opus_core.storage_factory import StorageFactory
    storage = StorageFactory().get_storage(type="mysql_storage",
                                           storage_location=dbcon)

    from waterdemand.datasets.consumption_dataset import ConsumptionDataset
    consumption_types = ['wrmr', 'wcsr', 'wrsr']  #'wcmr'
    for consumption_type in consumption_types:

        consumption = ConsumptionDataset(in_storage=storage,
                                         in_table_name=consumption_type +
                                         '_grid')

        for year in range(1990, 2001):
            print "%s %s" % (consumption_type, year)
            year_index = where(consumption.get_attribute("billyear") == year)
            out_storage = StorageFactory().get_storage(
                type="flt_storage",
                storage_location=os.path.join(cache_directory, str(year)))
            consumption_subset = DatasetSubset(consumption, year_index)
            consumption_subset.write_dataset(
                out_storage=out_storage,
                out_table_name=consumption_type.lower())