Esempio n. 1
0
@out
def sqft_per_unit(building_sqft='parcels_out.building_sqft',
                  non_residential_sqft='parcels_out.non_residential_sqft',
                  residential_units='parcels_out.residential_units'):
    return utils.get_sqft_per_unit(building_sqft, non_residential_sqft,
                                   residential_units)


@out
def stories(stories='parcels_in.stories'):
    return regroup(stories).median()


@out
def tax_exempt(code='parcels_in.n_tax_code'):
    return regroup(code).first().notnull().astype(int)


## Export back to database.


@sim.model()
def export_cnc(parcels_out):
    df = parcels_out.to_frame()
    assert df.index.is_unique
    assert not df.index.hasnans
    df.res_type[df.res_type.isnull()] = ''
    df_to_db(df, 'attributes_cnc', schema=staging)

sim.run(['export_cnc'])
Esempio n. 2
0
import pandas as pd, numpy as np
import models
import urbansim.sim.simulation as sim

np.random.seed(1)

# Simulation run

##Single-year
# sim.run(["build_networks", "neighborhood_vars", "rsh_simulate", "nrh_simulate", "nrh_simulate2", 
         # "price_vars", "feasibility", "residential_developer", "non_residential_developer"])
         
##Multi-year
sim.run(["build_networks"]) #initialize network accessibility engine
sim.run(["neighborhood_vars", #"scheduled_development_events", #scheduled events and accessibility variables
         "rsh_simulate", "nrh_simulate", "nrh_simulate2",   #price models
         "jobs_transition", "elcm_simulate", "households_transition", "hlcm_luz_simulate", #demand/location models
         "price_vars", "feasibility", "residential_developer", "non_residential_developer", #supply/proforma models
         ], years=[2013, 2014, 2015,])

# Summarize results at MSA level
b = sim.get_table('buildings').to_frame(columns = ['msa_id', 'mgra_id', 'residential_units', 'non_residential_sqft', 'note'])
new_du_by_msa = b[b.note  == 'simulated'].groupby('msa_id').residential_units.sum()
new_nrsf_by_msa = b[b.note  == 'simulated'].groupby('msa_id').non_residential_sqft.sum()
proportion_du_by_msa = new_du_by_msa / new_du_by_msa.sum()
proportion_nrsf_by_msa = new_nrsf_by_msa / new_nrsf_by_msa.sum()

# Write out indicators to calibration directory
proportion_du_by_msa.to_csv('.\\data\\calibration\\msa_du_simulated.csv', header = True)
proportion_nrsf_by_msa.to_csv('.\\data\\calibration\\msa_nrsf_simulated.csv', header = True)
Esempio n. 3
0
                                   residential_units)


@out
def stories(stories='ie673.Stories'):
    # 1 story = 10 Alameda County stories.
    return 0.1 * stories


@out
def tax_exempt(land_use_type_id='parcels_out.land_use_type_id'):
    return utils.get_tax_exempt(land_use_type_id, exempt_codes)


## Export back to database.


@sim.model()
def export_ala(parcels_out):
    df = parcels_out.to_frame()

    # Cast "land_use_type_id" to string for compatibility with other counties.
    df['land_use_type_id'] = df.land_use_type_id.astype(str)

    assert df.index.is_unique
    assert not df.index.hasnans()
    df_to_db(df, 'attributes_ala', schema=staging)


sim.run(['export_ala'])
Esempio n. 4
0
@out
def sqft_per_unit(building_sqft='parcels_out.building_sqft',
                  non_residential_sqft='parcels_out.non_residential_sqft',
                  residential_units='parcels_out.residential_units'):
    return utils.get_sqft_per_unit(building_sqft, non_residential_sqft,
                                   residential_units)


@out
def stories(stories='parcels_in.floor'):
    # Take greatest number of stories when deduplicating.
    return stories.groupby(level=0).max().astype(float)


@out
def tax_exempt(land_use_type_id='parcels_out.land_use_type_id'):
    return utils.get_tax_exempt(land_use_type_id, exempt_codes)


## Export back to database.


@sim.model()
def export_nap(parcels_out):
    df = parcels_out.to_frame()
    assert df.index.is_unique
    assert not df.index.hasnans()
    df_to_db(df, 'attributes_nap', schema=staging)

sim.run(['export_nap'])
Esempio n. 5
0
@out
def sqft_per_unit(building_sqft='parcels_out.building_sqft',
                  non_residential_sqft='parcels_out.non_residential_sqft',
                  residential_units='parcels_out.residential_units'):
    return utils.get_sqft_per_unit(building_sqft, non_residential_sqft,
                                   residential_units)


@out
def stories():
    return np.nan


@out
def tax_exempt(land_use_type_id='parcels_out.land_use_type_id'):
    return utils.get_tax_exempt(land_use_type_id, exempt_codes)


## Export back to database.


@sim.model()
def export_son(parcels_out):
    df = parcels_out.to_frame()
    assert df.index.is_unique
    assert not df.index.hasnans()
    df_to_db(df, 'attributes_son', schema=staging)


sim.run(['export_son'])
import urbansim.sim.simulation as sim
from urbansim_defaults import models
import datasources
import models
import variables

sim.run(["build_networks", "neighborhood_vars"])

sim.run(["rsh_estimate"])
Esempio n. 7
0
def sqft_per_unit(building_sqft='parcels_out.building_sqft',
                  non_residential_sqft='parcels_out.non_residential_sqft',
                  residential_units='parcels_out.residential_units'):
    return utils.get_sqft_per_unit(building_sqft, non_residential_sqft,
                                   residential_units)


@out
def stories():
    return np.nan


@out
def tax_exempt(land_use_type_id='parcels_out.land_use_type_id'):
    return utils.get_tax_exempt(land_use_type_id, exempt_codes)


## Export back to database.


@sim.model()
def export_smt(parcels_out):
    df = parcels_out.to_frame()
    assert df.index.is_unique
    assert not df.index.hasnans()
    df.res_type[df.res_type.isnull()] = ''
    df_to_db(df, 'attributes_smt', schema=staging)


sim.run(['export_smt'])
Esempio n. 8
0
@out
def sqft_per_unit(building_sqft='parcels_out.building_sqft',
                  non_residential_sqft='parcels_out.non_residential_sqft',
                  residential_units='parcels_out.residential_units'):
    return utils.get_sqft_per_unit(building_sqft, non_residential_sqft,
                                   residential_units)


@out
def stories():
    return np.nan


@out
def tax_exempt(land_use_type_id='parcels_out.land_use_type_id'):
    return utils.get_tax_exempt(land_use_type_id, exempt_codes)


## Export back to database.


@sim.model()
def export_sol(parcels_out):
    df = parcels_out.to_frame()
    assert df.index.is_unique
    assert not df.index.hasnans()
    df_to_db(df, 'attributes_sol', schema=staging)

sim.run(['export_sol'])
Esempio n. 9
0
                  non_residential_sqft='parcels_out.non_residential_sqft',
                  residential_units='parcels_out.residential_units'):
    return utils.get_sqft_per_unit(building_sqft, non_residential_sqft,
                                   residential_units)


@out
def stories(stories='scvta.NUMBER_OF1'):
    # Field name confirmed by inspecting the Sobrato Office Tower
    # (APN 26428171), at 488 Almaden Blvd, San Jose, which is a
    # single parcel with a 17-story building.
    return stories


@out
def tax_exempt(land_use_type_id='parcels_out.land_use_type_id'):
    return utils.get_tax_exempt(land_use_type_id, exempt_codes)


## Export back to database.


@sim.model()
def export_scl(parcels_out):
    df = parcels_out.to_frame()
    assert df.index.is_unique
    assert not df.index.hasnans()
    df_to_db(df, 'attributes_scl', schema=staging)

sim.run(['export_scl'])
Esempio n. 10
0
    # Alternate inputs:
    # - "ressqft_ex"
    per_unit = 1. * ressqft / residential_units
    per_unit.replace(np.inf, np.nan, inplace=True)
    return per_unit


@out
def stories(stories='parcels_in.stories'):
    # Alternate inputs:
    # - "lidarstori": always zero
    return stories


@out
def tax_exempt(land_use_type_id='parcels_out.land_use_type_id'):
    return utils.get_tax_exempt(land_use_type_id, exempt_codes)


## Export back to database.


@sim.model()
def export_sfr(parcels_out):
    df = parcels_out.to_frame()
    assert df.index.is_unique
    assert not df.index.hasnans()
    df_to_db(df, 'attributes_sfr', schema=staging)

sim.run(['export_sfr'])
Esempio n. 11
0
import pandas as pd, numpy as np
import models
import urbansim.sim.simulation as sim

np.random.seed(1)

# Simulation run

##Single-year
sim.run([
    "build_networks", "neighborhood_vars", "rsh_simulate", "nrh_simulate",
    "nrh_simulate2", "price_vars", "feasibility", "residential_developer",
    "non_residential_developer"
],
        years=[
            2013,
        ])

##Multi-year
# sim.run(["build_networks"]) #initialize network accessibility engine
# sim.run(["neighborhood_vars", #"scheduled_development_events", #scheduled events and accessibility variables
# "rsh_simulate", "nrh_simulate", "nrh_simulate2",   #price models
# "jobs_transition", "elcm_simulate", "households_transition", "hlcm_luz_simulate", #demand/location models
# "price_vars", "feasibility", "residential_developer", "non_residential_developer", #supply/proforma models
# ], years=[2013, 2014, 2015,])

# Summarize results at target LUZ level
target_luz = [69, 70, 72]
b = sim.get_table('buildings').to_frame(columns=[
    'luz_id', 'msa_id', 'mgra_id', 'residential_units', 'non_residential_sqft',
    'note'
Esempio n. 12
0
def sqft_per_unit(building_sqft='parcels_out.building_sqft',
                  non_residential_sqft='parcels_out.non_residential_sqft',
                  residential_units='parcels_out.residential_units'):
    return utils.get_sqft_per_unit(building_sqft, non_residential_sqft,
                                   residential_units)


@out
def stories(stories='parcels_in.storiesnum'):
    return stories.astype(float)


@out
def tax_exempt(land_use_type_id='parcels_out.land_use_type_id'):
    # "exemption" column is value of exemptions, which includes welfare.
    return utils.get_tax_exempt(land_use_type_id, exempt_codes)


## Export back to database.


@sim.model()
def export_mar(parcels_out):
    df = parcels_out.to_frame()
    assert df.index.is_unique
    assert not df.index.hasnans()
    df.res_type[df.res_type.isnull()] = ''
    df_to_db(df, 'attributes_mar', schema=staging)

sim.run(['export_mar'])
Esempio n. 13
0
import pandas as pd, numpy as np
import models
import urbansim.sim.simulation as sim

np.random.seed(1)

# Simulation run

##Single-year
sim.run(["build_networks", "neighborhood_vars", "rsh_simulate", "nrh_simulate", "nrh_simulate2", 
         "price_vars", "feasibility", "residential_developer", "non_residential_developer"], years = [2013,])
         
##Multi-year
# sim.run(["build_networks"]) #initialize network accessibility engine
# sim.run(["neighborhood_vars", #"scheduled_development_events", #scheduled events and accessibility variables
         # "rsh_simulate", "nrh_simulate", "nrh_simulate2",   #price models
         # "jobs_transition", "elcm_simulate", "households_transition", "hlcm_luz_simulate", #demand/location models
         # "price_vars", "feasibility", "residential_developer", "non_residential_developer", #supply/proforma models
         # ], years=[2013, 2014, 2015,])

# Summarize results at target LUZ level
target_luz = [69, 70, 72]
b = sim.get_table('buildings').to_frame(columns = ['luz_id', 'msa_id', 'mgra_id', 'residential_units', 'non_residential_sqft', 'note'])
b_target = b[b.luz_id.isin(target_luz)]
new_du_region = b[b.note  == 'simulated'].residential_units.sum()
new_du_luz = b_target[b_target.note  == 'simulated'].residential_units.sum()
proportion_in_luz = new_du_luz*1.0/new_du_region

# Write out indicators to calibration directory
pd.DataFrame([proportion_in_luz]).to_csv('.\\data\\calibration\\luz_du_simulated.csv', index = False)
Esempio n. 14
0
@out
def sqft_per_unit(building_sqft='parcels_out.building_sqft',
                  non_residential_sqft='parcels_out.non_residential_sqft',
                  residential_units='parcels_out.residential_units'):
    return utils.get_sqft_per_unit(building_sqft, non_residential_sqft,
                                   residential_units)


@out
def stories(stories='FIXME'):
    return stories


@out
def tax_exempt(land_use_type_id='parcels_out.land_use_type_id'):
    return utils.get_tax_exempt(land_use_type_id, exempt_codes)


## Export back to database.


@sim.model()
def export_FIXME(parcels_out):
    df = parcels_out.to_frame()
    assert df.index.is_unique
    assert not df.index.hasnans()
    df_to_db(df, 'attributes_FIXME', schema=staging)

sim.run(['export_FIXME'])
Esempio n. 15
0
                  residential_units='parcels_out.residential_units'):
    return utils.get_sqft_per_unit(building_sqft, non_residential_sqft,
                                   residential_units)


@out
def stories(stories='scvta.NUMBER_OF1'):
    # Field name confirmed by inspecting the Sobrato Office Tower
    # (APN 26428171), at 488 Almaden Blvd, San Jose, which is a
    # single parcel with a 17-story building.
    return stories


@out
def tax_exempt(land_use_type_id='parcels_out.land_use_type_id'):
    return utils.get_tax_exempt(land_use_type_id, exempt_codes)


## Export back to database.


@sim.model()
def export_scl(parcels_out):
    df = parcels_out.to_frame()
    assert df.index.is_unique
    assert not df.index.hasnans()
    df_to_db(df, 'attributes_scl', schema=staging)


sim.run(['export_scl'])
Esempio n. 16
0
@out
def sqft_per_unit(building_sqft='parcels_out.building_sqft',
                  non_residential_sqft='parcels_out.non_residential_sqft',
                  residential_units='parcels_out.residential_units'):
    return utils.get_sqft_per_unit(building_sqft, non_residential_sqft,
                                   residential_units)


@out
def stories():
    return np.nan


@out
def tax_exempt(land_use_type_id='parcels_out.land_use_type_id'):
    return utils.get_tax_exempt(land_use_type_id, exempt_codes)


## Export back to database.


@sim.model()
def export_smt(parcels_out):
    df = parcels_out.to_frame()
    assert df.index.is_unique
    assert not df.index.hasnans()
    df.res_type[df.res_type.isnull()] = ''
    df_to_db(df, 'attributes_smt', schema=staging)

sim.run(['export_smt'])
Esempio n. 17
0
import pandas as pd, numpy as np
import models
import urbansim.sim.simulation as sim

np.random.seed(1)

# Simulation run

##Single-year
# sim.run(["build_networks", "neighborhood_vars", "rsh_simulate", "nrh_simulate", "nrh_simulate2",
# "price_vars", "feasibility", "residential_developer", "non_residential_developer"])

##Multi-year
sim.run(["build_networks"])  #initialize network accessibility engine
sim.run(
    [
        "neighborhood_vars",  #"scheduled_development_events", #scheduled events and accessibility variables
        "rsh_simulate",
        "nrh_simulate",
        "nrh_simulate2",  #price models
        "jobs_transition",
        "elcm_simulate",
        "households_transition",
        "hlcm_luz_simulate",  #demand/location models
        "price_vars",
        "feasibility",
        "residential_developer",
        "non_residential_developer",  #supply/proforma models
    ],
    years=[
        2013,
Esempio n. 18
0
                  non_residential_sqft='parcels_out.non_residential_sqft',
                  residential_units='parcels_out.residential_units'):
    return utils.get_sqft_per_unit(building_sqft, non_residential_sqft,
                                   residential_units)


@out
def stories(stories='parcels_in.storiesnum'):
    return stories.astype(float)


@out
def tax_exempt(land_use_type_id='parcels_out.land_use_type_id'):
    # "exemption" column is value of exemptions, which includes welfare.
    return utils.get_tax_exempt(land_use_type_id, exempt_codes)


## Export back to database.


@sim.model()
def export_mar(parcels_out):
    df = parcels_out.to_frame()
    assert df.index.is_unique
    assert not df.index.hasnans()
    df.res_type[df.res_type.isnull()] = ''
    df_to_db(df, 'attributes_mar', schema=staging)


sim.run(['export_mar'])
Esempio n. 19
0
    # - "ressqft_ex"
    per_unit = 1. * ressqft / residential_units
    per_unit.replace(np.inf, np.nan, inplace=True)
    return per_unit


@out
def stories(stories='parcels_in.stories'):
    # Alternate inputs:
    # - "lidarstori": always zero
    return stories


@out
def tax_exempt(land_use_type_id='parcels_out.land_use_type_id'):
    return utils.get_tax_exempt(land_use_type_id, exempt_codes)


## Export back to database.


@sim.model()
def export_sfr(parcels_out):
    df = parcels_out.to_frame()
    assert df.index.is_unique
    assert not df.index.hasnans()
    df_to_db(df, 'attributes_sfr', schema=staging)


sim.run(['export_sfr'])
Esempio n. 20
0
@out
def sqft_per_unit(building_sqft='parcels_out.building_sqft',
                  non_residential_sqft='parcels_out.non_residential_sqft',
                  residential_units='parcels_out.residential_units'):
    return utils.get_sqft_per_unit(building_sqft, non_residential_sqft,
                                   residential_units)


@out
def stories():
    return np.nan


@out
def tax_exempt(land_use_type_id='parcels_out.land_use_type_id'):
    return utils.get_tax_exempt(land_use_type_id, exempt_codes)


## Export back to database.


@sim.model()
def export_son(parcels_out):
    df = parcels_out.to_frame()
    assert df.index.is_unique
    assert not df.index.hasnans()
    df_to_db(df, 'attributes_son', schema=staging)

sim.run(['export_son'])
Esempio n. 21
0
sim.run(
    [
        "clear_cache",  # recompute variables every year
        "run_arcpy",
        "neighborhood_vars",  # neighborhood variables
        "households_transition",  # households transition
        #"households_relocation",  # households relocation model
        "jobs_transition",  # jobs transition
        #"jobs_relocation",        # jobs relocation model
        "nrh_ind_simulate",  # industrial price model
        "nrh_ofc_simulate",  # office price model
        "nrh_ret_simulate",  # retail price model
        "nrh_mu_oth_simulate",  # non-residential mixed-use, other model
        "rsh_sf_simulate",  # single-family residential price model
        "rsh_mf_simulate",  # multi-family residential price model
        "hlcm_simulate_slc",  # households location choice Salt Lake County
        "hlcm_simulate_utah",  # households location choice Utah County
        "hlcm_simulate_davis",  # households location choice Davis County
        "hlcm_simulate_weber",  # households location choice Weber County
        "elcm_simulate_slc",  # employment location choice Salt Lake County
        "elcm_simulate_utah",  # employment location choice Utah County
        "elcm_simulate_davis",  # employment location choice Davis County
        "elcm_simulate_weber",  # employment location choice Weber County
        #"clear_cache",
        "indicator_export",  # export county and zone level indicators to csv
        "travel_model_export_no_construction",
        #"trend_calibration",
        #"network_prices",
        "feasibility",  # compute development feasibility
        "garbage_collect",
        "residential_developer_slc",  # build actual buildings Salt Lake County
        "residential_developer_utah",  # build actual buildings Utah County
        "residential_developer_davis",  # build actual buildings Davis County
        "residential_developer_weber",  # build actual buildings Weber County
        "office_developer_slc",
        "office_developer_utah",
        "office_developer_davis",
        "office_developer_weber",
        "retail_developer_slc",
        "retail_developer_utah",
        "retail_developer_davis",
        "retail_developer_weber",
        "industrial_developer_slc",
        "industrial_developer_utah",
        "industrial_developer_davis",
        "industrial_developer_weber",
        "travel_model_export_add_construction",  # export travel model inputs at TAZ level in specified years
        #"travel_time_import",
        "run_cube",  # call Cube and import travel times in specified years
    ],
    years=range(2015,
                2061))  #, data_out=utils.get_run_filename(), out_interval=10)
Esempio n. 22
0
    return utils.get_sqft_per_unit(building_sqft, non_residential_sqft,
                                   residential_units)


@out
def stories(stories='ie673.Stories'):
    # 1 story = 10 Alameda County stories.
    return 0.1 * stories


@out
def tax_exempt(land_use_type_id='parcels_out.land_use_type_id'):
    return utils.get_tax_exempt(land_use_type_id, exempt_codes)


## Export back to database.


@sim.model()
def export_ala(parcels_out):
    df = parcels_out.to_frame()

    # Cast "land_use_type_id" to string for compatibility with other counties.
    df['land_use_type_id'] = df.land_use_type_id.astype(str)

    assert df.index.is_unique
    assert not df.index.hasnans()
    df_to_db(df, 'attributes_ala', schema=staging)

sim.run(['export_ala'])