-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create configurable base year - so we can start from 2010 or 2020 and achieve the same result #384
base: main
Are you sure you want to change the base?
Conversation
…with the same code
From M:\urban_modeling\baus\PBA50Plus\PBA50Plus_DraftBlueprint\PBA50Plus_Draft_Blueprint_v8_znupd_nodevfix\run_setup_PBA50Plus_Draft_Blueprint_v8_znupd_nodevfix.yaml
This commit reproduces PBA50+ DBP run
(baus-env-2023) E:\LUModel2Share\GitHub\bayarea_urbansim>git diff M:\urban_modeling\baus\PBA50Plus\PBA50Plus_DraftBlueprint\PBA50Plus_Draft_Blueprint_v8_znupd_nodevfix\geographic_summaries\PBA50Plus_Draft_Blueprint_v8_znupd_nodevfix_county_summary_2025.csv E:\LUModel2Share\PBA50Plus_DraftBlueprint\PBA50Plus_DraftBlueprint_v01\geographic_summaries\PBA50Plus_DraftBlueprint_v01_county_summary_2025.csv => no diffs (baus-env-2023) E:\LUModel2Share\GitHub\bayarea_urbansim>git diff M:\urban_modeling\baus\PBA50Plus\PBA50Plus_DraftBlueprint\PBA50Plus_Draft_Blueprint_v8_znupd_nodevfix\geographic_summaries\PBA50Plus_Draft_Blueprint_v8_znupd_nodevfix_county_summary_2050.csv E:\LUModel2Share\PBA50Plus_DraftBlueprint\PBA50Plus_DraftBlueprint_v01\geographic_summaries\PBA50Plus_DraftBlueprint_v01_county_summary_2050.csv => no diffs
PBA50Plus_DraftBlueprint_v02 results are identical to PBA50+ DBP
(baus-env-2023) E:\LUModel2Share\GitHub\bayarea_urbansim>git diff M:\urban_modeling\baus\PBA50Plus\PBA50Plus_DraftBlueprint\PBA50Plus_Draft_Blueprint_v8_znupd_nodevfix\geographic_summaries\PBA50Plus_Draft_Blueprint_v8_znupd_nodevfix_county_summary_2050.csv E:\LUModel2Share\PBA50Plus_DraftBlueprint\PBA50Plus_DraftBlueprint_v03\geographic_summaries\county_summary_2050.csv [no diffs] (baus-env-2023) E:\LUModel2Share\GitHub\bayarea_urbansim>git diff M:\urban_modeling\baus\PBA50Plus\PBA50Plus_DraftBlueprint\PBA50Plus_Draft_Blueprint_v8_znupd_nodevfix\travel_model_summaries\PBA50Plus_Draft_Blueprint_v8_znupd_nodevfix_taz1_summary_2050.csv E:\LUModel2Share\PBA50Plus_DraftBlueprint\PBA50Plus_DraftBlueprint_v03\travel_model_summaries\taz1_summary_2050.csv [no diffs[
And log about files read
And outputs the 2020 h5 file
Also add urbansim logging (but turn it off)
Since it's not really a summary Also add disaggregate households, jobs, and static parcels
parcel_id is the standard parcel identifier
As well as vacant_job_spaces and jobs index
Also print() -> logger.debug()
Prefix print statements for later conversion to log statements
And minimize diffs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a major improvement. I assume this runs from snout to tail - I like the many efficiencies and cleanings - will need to adjust off-model scripts to handle the simplified naming convensions, but seems worthwhile.
@@ -28,8 +28,10 @@ | |||
# this is similar to the code for settings in urbansim_defaults | |||
@orca.injectable('run_setup', cache=True) | |||
def run_setup(): | |||
with open("run_setup.yaml") as f: | |||
return yaml.load(f) | |||
run_setup_yaml = orca.get_injectable('run_setup_yaml') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very useful addition
def developer_settings(base_year): | ||
developer_settings_yaml = "developer_settings.yaml" | ||
full_path = os.path.join(misc.configs_dir(), "developer", developer_settings_yaml) | ||
logger.info("Reading developer settings from {}".format(full_path)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this addition - logging the files loaded at run time. It is not always clear from the setup file and the setup file is more likely to get corrupted than the log file. I may do that for all the yaml settings loaded.
static_parcels_list = developer_settings["static_parcels"] | ||
print("static_parcels(): {}".format(static_parcels_list)) | ||
|
||
return static_parcels_list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice simplification - and I see you got the corresponding source file, as appropriate too for consistency.
rates = rates.reset_index(drop=True) | ||
|
||
df = pd.merge(households.to_frame(["zone_id", "base_income_quartile", "tenure"]), rates, on=["zone_id", "base_income_quartile", "tenure"], how="left") | ||
df = pd.merge(households.to_frame(["zone_id", "base_income_quartile", "tenure", "move_in_year"]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the move_in_year addition
|
||
l1 = len(buildings) | ||
# the following function has `demolish` as an input, but it is not removing the buildings in the 'demolish' table, | ||
# instead, it removes existing buildings on parcels to be occupied by buildings in 'demolish' | ||
buildings = utils._remove_developed_buildings(buildings.to_frame(buildings.local_columns), demolish, | ||
unplace_agents=["households", "jobs"]) | ||
orca.add_injectable('static_parcels', np.append(static_parcels, demolish.loc[demolish.action == 'build', 'parcel_id'])) | ||
# TODO: I don't know if this line makes sense; why would this go on static_parcels? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya, that ended up being a long list - instead of just handling on the developer model config side where you can set filters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks useful. Do you have downstream steps for more or less systematically inspecting the outputs? I could imagine a bunch of vizzes built on top of these.
@@ -162,311 +170,281 @@ def run_models(mode, run_setup, years_to_run): | |||
|
|||
elif mode == "simulation": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should really move all the run lists to a separate module, or config file, out of baus.py
@@ -141,7 +141,7 @@ def acct_settings(account_strategies): | |||
|
|||
|
|||
@orca.step() | |||
def lump_sum_accounts(year, years_per_iter, run_setup): | |||
def lump_sum_accounts(year, base_year, years_per_iter, run_setup, logger): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convention: when do we pass logger as an arg as opposed to invoking at the top, like getlogger?
@@ -26,7 +26,7 @@ | |||
##################### | |||
|
|||
|
|||
@orca.column('households', cache=True) | |||
@orca.column('households', cache=True, cache_scope='step') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is the secret - much smaller caching scope.
# which ignore this list | ||
static_parcels: | ||
- 2489683204304 # ala fairgrounds 378337 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
This PR includes changes so that BAUS can be started in 2010 or 2020 and the results will be the same. This is achieved by:
debug
model as the first simulation model. When 2020 is not thebase_year
but the model year is 2020, this was used to write an h5 store with 2020 snapshots of the input tables. This was used to create the input table,2024_10_29_bayarea_2020start.h5
cache=True
, and weren't being updated when the tables were updated. These were modified to havecache_scope='step'
. This also requires using a local version of urbansim_defaults: https://github.com/BayAreaMetro/urbansim_defaults/commits/master/a.
scheduled_development_events()
: Convert special case frombase_year + years_per_iter
to2010 + years_per_iter
b.
scheduled_development_events()
: Don't add parcels to static_parcels until 2020.c. When
base_year
is 2020:store()
reads2024_10_29_bayarea_2020start.h5
rather than2015_09_01_bayarea_v3.h5
lump_sum_accounts()
: Add 2015 lump sum to account to be consistent with 2010 start. (I think this can be removed).Other changes:
--run_setup_yaml
, so multiple versions of BAUS can be tested simultaneously with the same code base via different run setup files.base_year
andfinal_year
into the run_setup_yaml.run_name
prefix from output filenames. This way output directories between runs can be diffed with other run output directories. Therun_name
prefix is still present when copied into the visualization directory.XX_table.csv
rather thanXX_summary.csv
yaml.load()
withyaml.safe_load()
configs/developer/developer_settings.yaml
to parcel ids rather than geom_idsmove_in_year
, for households and jobs to understand when they located