Skip to content

Commit 6c45a7e

Browse files
committed
Feasibility daylighting and segmenting of growth metrics
1 parent 711537e commit 6c45a7e

File tree

3 files changed

+73
-2
lines changed

3 files changed

+73
-2
lines changed

baus/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,9 @@ def residential_developer(feasibility, households, buildings, parcels, year,
646646
limits_settings, final_year, run_setup):
647647

648648
orca.eval_step("alt_feasibility")
649+
650+
feas_path = os.path.join(orca.get_injectable("outputs_dir"),f'feasibility_residential_developer_start_{year}.csv')
651+
feasibility.to_frame().to_csv(feas_path)
649652

650653
kwargs = developer_settings['residential_developer']
651654

baus/summaries/core_summaries.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,19 @@ def parcel_growth_summary(year, run_name, initial_summary_year, final_year):
5858
df2 = pd.read_csv(coresum_output_dir / f"{run_name}_parcel_summary_{final_year}.csv",
5959
index_col="parcel_id")
6060

61+
# Store initial and final values before calculating growth
62+
df1[f'residential_units_{initial_summary_year}'] = df1['residential_units'].fillna(0)
63+
df1[f'residential_units_{final_year}'] = df2['residential_units'].fillna(0)
64+
df1[f'built_dua_{initial_summary_year}'] = df1['built_dua'].fillna(0)
65+
df1[f'built_dua_{final_year}'] = df2['built_dua'].fillna(0)
66+
df1[f'built_far_{initial_summary_year}'] = df1['built_far'].fillna(0)
67+
df1[f'built_far_{final_year}'] = df2['built_far'].fillna(0)
68+
6169
for col in df1.columns:
62-
if col in ["geom_id", "x", "y"]:
70+
if col in ["geom_id", "x", "y",
71+
f'residential_units_{initial_summary_year}', f'residential_units_{final_year}',
72+
f'built_dua_{initial_summary_year}', f'built_dua_{final_year}',
73+
f'built_far_{initial_summary_year}', f'built_far_{final_year}']:
6374
continue
6475

6576
# fill na with 0 otherwise it drops the parcel data during subtraction

scripts/metrics/metrics_growth.py

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ def growth_patterns_geography(rtp: str,
159159
for area, filter_condition in metrics_utils.PARCEL_AREA_FILTERS[rtp].items():
160160
if callable(filter_condition): # Check if the filter is a function
161161
df_area = modelrun_data[year]['parcel'].loc[filter_condition(modelrun_data[year]['parcel'])]
162+
if area == "TOC":
163+
logging.debug(f"TOC parcel assignment counts:\n{df_area['toc_id'].value_counts(dropna=False)}")
164+
162165
elif filter_condition == None:
163166
df_area = modelrun_data[year]['parcel']
164167
logging.debug("area={} df_area len={:,}".format(area, len(df_area)))
@@ -171,6 +174,10 @@ def growth_patterns_geography(rtp: str,
171174
'modelrun_alias': f"{year} {modelrun_alias}",
172175
'area': area,
173176
'county': county,
177+
'q1_households': group['hhq1'].sum(),
178+
'q2_households': group['hhq2'].sum(),
179+
'q3_households': group['hhq3'].sum(),
180+
'q4_households': group['hhq4'].sum(),
174181
'total_households': group['tothh'].sum(),
175182
'total_jobs': group['totemp'].sum()
176183
})
@@ -179,13 +186,21 @@ def growth_patterns_geography(rtp: str,
179186
summary_list.append({
180187
'modelrun_alias' : f"{year} {modelrun_alias}",
181188
'area' : area,
189+
'q1_households': df_area['hhq1'].sum(),
190+
'q2_households': df_area['hhq2'].sum(),
191+
'q3_households': df_area['hhq3'].sum(),
192+
'q4_households': df_area['hhq4'].sum(),
182193
'total_households': df_area['tothh'].sum(),
183194
'total_jobs' : df_area['totemp'].sum()
184195
})
185196

186197
# save regional numbers for return_dict
187198
if area == 'Region':
188199
return_dict[year] = {
200+
'q1_households': df_area['hhq1'].sum(),
201+
'q2_households': df_area['hhq2'].sum(),
202+
'q3_households': df_area['hhq3'].sum(),
203+
'q4_households': df_area['hhq4'].sum(),
189204
'total_households': df_area['tothh'].sum(),
190205
'total_jobs' : df_area['totemp'].sum()
191206
}
@@ -202,31 +217,61 @@ def growth_patterns_geography(rtp: str,
202217
logging.debug("summary_final:\n{}".format(summary_final))
203218

204219
# Caclculate household and job growth totals
220+
summary_final['hhq1_growth'] = summary_final['q1_households'] - summary_final['q1_households_initial']
221+
summary_final['hhq2_growth'] = summary_final['q2_households'] - summary_final['q2_households_initial']
222+
summary_final['hhq3_growth'] = summary_final['q3_households'] - summary_final['q3_households_initial']
223+
summary_final['hhq4_growth'] = summary_final['q4_households'] - summary_final['q4_households_initial']
205224
summary_final['hh_growth'] = summary_final['total_households'] - summary_final['total_households_initial']
206225
summary_final['jobs_growth'] = summary_final['total_jobs' ] - summary_final['total_jobs_initial']
207226

208227
# Handle county-level growth shares for each area
209228
if county_level_output:
210229
# Get total growth per county for denominator
230+
total_hhq1_growth_per_county = summary_final.loc[summary_final.area == 'Region'].set_index('county')['hhq1_growth']
231+
total_hhq2_growth_per_county = summary_final.loc[summary_final.area == 'Region'].set_index('county')['hhq2_growth']
232+
total_hhq3_growth_per_county = summary_final.loc[summary_final.area == 'Region'].set_index('county')['hhq3_growth']
233+
total_hhq4_growth_per_county = summary_final.loc[summary_final.area == 'Region'].set_index('county')['hhq4_growth']
211234
total_hh_growth_per_county = summary_final.loc[summary_final.area == 'Region'].set_index('county')['hh_growth']
212235
total_jobs_growth_per_county = summary_final.loc[summary_final.area == 'Region'].set_index('county')['jobs_growth']
213236
# Map the total growth per county
237+
summary_final['total_hhq1_growth'] = summary_final['county'].map(total_hhq1_growth_per_county)
238+
summary_final['total_hhq2_growth'] = summary_final['county'].map(total_hhq2_growth_per_county)
239+
summary_final['total_hhq3_growth'] = summary_final['county'].map(total_hhq3_growth_per_county)
240+
summary_final['total_hhq4_growth'] = summary_final['county'].map(total_hhq4_growth_per_county)
214241
summary_final['total_hh_growth'] = summary_final['county'].map(total_hh_growth_per_county)
215242
summary_final['total_jobs_growth'] = summary_final['county'].map(total_jobs_growth_per_county)
216243
# Calculate share area growth for each county
244+
summary_final['hhq1_share_of_growth'] = summary_final['hhq1_growth'] / summary_final['total_hhq1_growth']
245+
summary_final['hhq2_share_of_growth'] = summary_final['hhq2_growth'] / summary_final['total_hhq2_growth']
246+
summary_final['hhq3_share_of_growth'] = summary_final['hhq3_growth'] / summary_final['total_hhq3_growth']
247+
summary_final['hhq4_share_of_growth'] = summary_final['hhq4_growth'] / summary_final['total_hhq4_growth']
217248
summary_final['hh_share_of_growth'] = summary_final['hh_growth'] / summary_final['total_hh_growth']
218249
summary_final['jobs_share_of_growth'] = summary_final['jobs_growth'] / summary_final['total_jobs_growth']
219250
summary_final.drop(columns=['total_hh_growth', 'total_jobs_growth'], inplace=True)
220251

221252
# Handle region-level growth share for each area
222253
else:
254+
total_hhq1_growth = summary_final.loc[summary_final.area=='Region', 'hhq1_growth'].sum()
255+
total_hhq2_growth = summary_final.loc[summary_final.area=='Region', 'hhq2_growth'].sum()
256+
total_hhq3_growth = summary_final.loc[summary_final.area=='Region', 'hhq3_growth'].sum()
257+
total_hhq4_growth = summary_final.loc[summary_final.area=='Region', 'hhq4_growth'].sum()
223258
total_hh_growth = summary_final.loc[summary_final.area=='Region', 'hh_growth'].sum()
224259
total_jobs_growth = summary_final.loc[summary_final.area=='Region', 'jobs_growth'].sum()
260+
261+
summary_final['hhq1_share_of_growth'] = summary_final['hhq1_growth'] / total_hhq1_growth
262+
summary_final['hhq2_share_of_growth'] = summary_final['hhq2_growth'] / total_hhq2_growth
263+
summary_final['hhq3_share_of_growth'] = summary_final['hhq3_growth'] / total_hhq3_growth
264+
summary_final['hhq4_share_of_growth'] = summary_final['hhq4_growth'] / total_hhq4_growth
225265
summary_final['hh_share_of_growth'] = summary_final['hh_growth'] / total_hh_growth
226266
summary_final['jobs_share_of_growth'] = summary_final['jobs_growth'] / total_jobs_growth
227267

228268
# Remove the growth columns if not needed in the final output
229-
summary_final.drop(columns=['total_households_initial', 'total_jobs_initial'], inplace=True)
269+
summary_final.drop(columns=['q1_households_initial',
270+
'q2_households_initial',
271+
'q3_households_initial',
272+
'q4_households_initial',
273+
'total_households_initial',
274+
'total_jobs_initial'], inplace=True)
230275
logging.debug("summary_final:\n{}".format(summary_final))
231276

232277
# Concatenate the initial and final totals.
@@ -235,13 +280,25 @@ def growth_patterns_geography(rtp: str,
235280

236281
if county_level_output:
237282
combined_df = combined_df[['modelrun_id', 'modelrun_alias', 'county', 'area',
283+
'q1_households', 'q2_households',
284+
'q3_households', 'q4_households',
238285
'total_households', 'total_jobs',
286+
'hhq1_growth', 'hhq2_growth',
287+
'hhq3_growth', 'hhq4_growth',
239288
'hh_growth', 'jobs_growth',
289+
'hhq1_share_of_growth', 'hhq2_share_of_growth',
290+
'hhq3_share_of_growth', 'hhq4_share_of_growth',
240291
'hh_share_of_growth', 'jobs_share_of_growth']]
241292
else:
242293
combined_df = combined_df[['modelrun_id', 'modelrun_alias', 'area',
294+
'q1_households', 'q2_households',
295+
'q3_households', 'q4_households',
243296
'total_households', 'total_jobs',
297+
'hhq1_growth', 'hhq2_growth',
298+
'hhq3_growth', 'hhq4_growth',
244299
'hh_growth', 'jobs_growth',
300+
'hhq1_share_of_growth', 'hhq2_share_of_growth',
301+
'hhq3_share_of_growth', 'hhq4_share_of_growth',
245302
'hh_share_of_growth', 'jobs_share_of_growth']]
246303

247304
filename = f"metrics_growthPattern_geographies_{horizon_year}.csv"

0 commit comments

Comments
 (0)