From 106e631892e8e7fd437f238dc1aafc6dafe42dae Mon Sep 17 00:00:00 2001 From: Jeff Newman Date: Wed, 1 May 2024 16:29:06 -0500 Subject: [PATCH] annotate_land_use_taz --- configs/resident/annotate_landuse_taz.csv | 2 ++ configs/resident/initialize_landuse_taz.yaml | 7 +++++ configs/resident/settings.yaml | 1 + extensions/__init__.py | 1 + extensions/annotate_landuse_taz.py | 32 ++++++++++++++++++++ 5 files changed, 43 insertions(+) create mode 100644 configs/resident/annotate_landuse_taz.csv create mode 100644 configs/resident/initialize_landuse_taz.yaml create mode 100644 extensions/annotate_landuse_taz.py diff --git a/configs/resident/annotate_landuse_taz.csv b/configs/resident/annotate_landuse_taz.csv new file mode 100644 index 0000000..774b9a6 --- /dev/null +++ b/configs/resident/annotate_landuse_taz.csv @@ -0,0 +1,2 @@ +Description,Target,Expression +micro access time at taz,taz_microAccTime,"land_use.sort_values(by='MicroAccessTime',ascending=False).drop_duplicates('TAZ',keep='first').set_index('TAZ')['MicroAccessTime'].reindex(df.index)" diff --git a/configs/resident/initialize_landuse_taz.yaml b/configs/resident/initialize_landuse_taz.yaml new file mode 100644 index 0000000..badaffd --- /dev/null +++ b/configs/resident/initialize_landuse_taz.yaml @@ -0,0 +1,7 @@ +annotate_tables: + - tablename: land_use_taz + annotate: + SPEC: annotate_landuse_taz + DF: land_use_taz + TABLES: + - land_use diff --git a/configs/resident/settings.yaml b/configs/resident/settings.yaml index d9506ef..7cfa97c 100644 --- a/configs/resident/settings.yaml +++ b/configs/resident/settings.yaml @@ -135,6 +135,7 @@ models: - compute_disaggregate_accessibility ### mp_initialize_hhs (single process) - initialize_landuse + - initialize_landuse_taz - initialize_households ### mp_accessibility - compute_accessibility diff --git a/extensions/__init__.py b/extensions/__init__.py index f052183..40015fd 100644 --- a/extensions/__init__.py +++ b/extensions/__init__.py @@ -4,3 +4,4 @@ from . import transponder_ownership from . import airport_returns from . import adjust_auto_operating_cost +from . import annotate_landuse_taz diff --git a/extensions/annotate_landuse_taz.py b/extensions/annotate_landuse_taz.py new file mode 100644 index 0000000..79336f3 --- /dev/null +++ b/extensions/annotate_landuse_taz.py @@ -0,0 +1,32 @@ +from __future__ import annotations + +import logging + +from activitysim.core import chunk, workflow +from activitysim.abm.models.initialize import InitializeTableSettings, annotate_tables + +logger = logging.getLogger(__name__) + + +@workflow.step +def initialize_landuse_taz( + state: workflow.State, + model_settings: InitializeTableSettings | None = None, + model_settings_file_name: str = "initialize_landuse_taz.yaml", + trace_label: str = "initialize_landuse_taz", +) -> None: + """ + Initialize the land use table. + + Parameters + ---------- + state : State + """ + if model_settings is None: + model_settings = InitializeTableSettings.read_settings_file( + state.filesystem, + model_settings_file_name, + mandatory=True, + ) + with chunk.chunk_log(state, trace_label, base=True) as chunk_sizer: + annotate_tables(state, model_settings, trace_label, chunk_sizer)