-
Notifications
You must be signed in to change notification settings - Fork 27
/
assumptions.py
118 lines (99 loc) · 2.82 KB
/
assumptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import urbansim.sim.simulation as sim
import os
import uuid
import pandas as pd
from urbansim.utils import misc
sim.add_injectable("building_sqft_per_job", {
-1: 400,
1: 400,
2: 400,
3: 400,
4: 355,
5: 1161,
6: 470,
7: 661,
8: 960,
9: 825,
10: 445,
11: 445,
12: 383,
13: 383,
14: 383,
})
# this maps building type ids to general building types
# basically just reduces dimensionality
sim.add_injectable("building_type_map", {
1: "Residential",
2: "Residential",
3: "Residential",
4: "Office",
5: "Hotel",
6: "School",
7: "Industrial",
8: "Industrial",
9: "Industrial",
10: "Retail",
11: "Retail",
12: "Residential",
13: "Retail",
14: "Office"
})
# this maps building "forms" from the developer model
# to building types so that when the developer builds a
# "form" this can be converted for storing as a type
# in the building table - in the long run, the developer
# forms and the building types should be the same and the
# developer model should account for the differences
sim.add_injectable("form_to_btype", {
'residential': [1, 2, 3],
'industrial': [7, 8, 9],
'retail': [10, 11],
'office': [4],
'mixedresidential': [12],
'mixedoffice': [14],
})
sim.add_injectable("store", pd.HDFStore(os.path.join(misc.data_dir(),
"sanfran_public.h5"),
mode="r"))
sim.add_injectable("fillna_config", {
"buildings": {
"residential_sales_price": ("zero", "int"),
"non_residential_rent": ("zero", "int"),
"residential_units": ("zero", "int"),
"non_residential_sqft": ("zero", "int"),
"year_built": ("median", "int"),
"building_type_id": ("mode", "int")
},
"jobs": {
"job_category": ("mode", "str"),
}
})
# this keeps track of all of the inputs that get "switched"
# whenever a scenario is changed
sim.add_injectable("scenario_inputs", {
"baseline": {
"zoning_table_name": "zoning_baseline"
},
"test": {
"zoning_table_name": "zoning_test"
}
})
sim.add_injectable("scenario", "baseline")
# this if the function for mapping a specific building that we build to a
# specific building type
@sim.injectable("form_to_btype_f", autocall=False)
def form_to_btype_f(building):
form = building.form
dua = building.residential_units / (building.parcel_size / 43560.0)
# precise mapping of form to building type for residential
if form == "residential":
if dua < 16:
return 1
elif dua < 32:
return 2
return 3
return sim.get_injectable("form_to_btype")[form][0]
sim.add_injectable("run_number", misc.get_run_number())
@sim.injectable("uuid")
def get_run_uuid():
return uuid.uuid4().hex