Skip to content

Commit

Permalink
Merge 95e7495 into 0c10dc5
Browse files Browse the repository at this point in the history
  • Loading branch information
fscottfoti committed Sep 25, 2014
2 parents 0c10dc5 + 95e7495 commit 3f5eae4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
7 changes: 6 additions & 1 deletion urbansim/developer/developer.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ def pick(self, form, target_units, parcel_size, ave_unit_size,
DataFrame that is returned from feasibility.
"""

if len(self.feasibility) == 0:
# no feasible buldings, might as well bail
return None

if isinstance(form, list):
df = self.keep_form_with_max_profit(form)
else:
Expand All @@ -163,7 +167,8 @@ def pick(self, form, target_units, parcel_size, ave_unit_size,
df['current_units'] = current_units
df = df[df.parcel_size < max_parcel_size]

df['residential_units'] = np.round(df.residential_sqft / df.ave_unit_size)
df['residential_units'] = np.round(df.residential_sqft /
df.ave_unit_size)
df['job_spaces'] = np.round(df.non_residential_sqft / bldg_sqft_per_job)

if residential:
Expand Down
39 changes: 31 additions & 8 deletions urbansim/developer/sqftproforma.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ def __init__(self):

def _reset_defaults(self):
self.parcel_sizes = [10000.0]
self.fars = [.1, .25, .5, .75, 1.0, 1.5, 1.8, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 9.0, 11.0]
self.fars = [.1, .25, .5, .75, 1.0, 1.5, 1.8, 2.0, 2.25, 2.5, 2.75,
3.0, 3.25, 3.5, 3.75, 4.0, 4.5,
5.0, 5.5, 6.0, 6.5, 7.0, 9.0, 11.0]
self.uses = ['retail', 'industrial', 'office', 'residential']
self.residential_uses = [False, False, False, True]
self.forms = {
Expand Down Expand Up @@ -456,7 +458,7 @@ def get_ave_cost_sqft(self, form):
"""
return self.min_ave_cost_d[form]

def lookup(self, form, df, only_built=True):
def lookup(self, form, df, only_built=True, pass_through=None):
"""
This function does the developer model lookups for all the actual input data.
Expand All @@ -472,6 +474,11 @@ def lookup(self, form, df, only_built=True):
by zoning, or whether to return as much information as possible, even if
unlikely to be built (can be used when development might be subsidized
or when debugging)
pass_through : list of strings
List of field names to take from the input parcel frame and pass
to the output feasibility frame - is usually used for debugging
purposes - these fields will be passed all the way through
developer
Input Dataframe Columns
rent : dataframe
Expand Down Expand Up @@ -541,14 +548,27 @@ def lookup(self, form, df, only_built=True):
df['max_far_from_heights'] = df.max_height / c.height_per_story * \
c.parcel_coverage

# now also minimize with max_dua from zoning - since this pro forma is really geared
# toward per sqft metrics, this is a bit tricky. dua is converted to floorspace and
# everything just works (floor space will get covered back to units in developer.pick()
# but we need to test the profitability of the floorspace allowed by max_dua here.
# now also minimize with max_dua from zoning - since this pro forma is
# really geared toward per sqft metrics, this is a bit tricky. dua
# is converted to floorspace and everything just works (floor space
# will get covered back to units in developer.pick() but we need to
# test the profitability of the floorspace allowed by max_dua here.
if 'max_dua' in df.columns:
# if max_dua is in the data frame, ave_unit_size must also be present
# if max_dua is in the data frame, ave_unit_size must also be there
assert 'ave_unit_size' in df.columns
df['max_far_from_dua'] = df.max_dua * df.ave_unit_size / self.config.building_efficiency
# so this is the max_dua times the parcel size in acres, which gives
# the number of units that are allowable on the parcel, times
# by the average unit size which gives the square footage of
# those units, divided by the building efficiency which is a
# factor that indicates that the actual units are not the whole
# FAR of the building and then divided by the parcel size again
# in order to get FAR - I recognize that parcel_size actually
# cancels here as it should, but the calc was hard to get right
# and it's just so much more transparent to have it in there twice
df['max_far_from_dua'] = df.max_dua * \
(df.parcel_size / 43560) * \
df.ave_unit_size / self.config.building_efficiency / \
df.parcel_size
df['min_max_fars'] = df[['max_far_from_heights', 'max_far',
'max_far_from_dua']].min(axis=1)
else:
Expand Down Expand Up @@ -595,6 +615,9 @@ def twod_get(indexes, arr):
'max_profit': twod_get(maxprofitind, profit)
}, index=df.index)

if pass_through:
outdf[pass_through] = df[pass_through]

if only_built:
outdf = outdf.query('max_profit > 0')

Expand Down
3 changes: 2 additions & 1 deletion urbansim/sim/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,8 @@ def run(models, years=None, data_out=None, out_interval=1):
model_name, time.time()-t2))

print("Total time to execute{}: {:.2f}s".format(
" year %d" % year if year is not None else '', time.time()-t1))
" year {}".format(year) if year is not None else '',
time.time()-t1))

if data_out and year_counter == out_interval:
write_tables(data_out, models, year)
Expand Down

0 comments on commit 3f5eae4

Please sign in to comment.