Skip to content

Commit

Permalink
Merge pull request #65 from SANDAG/parkloc_fix2
Browse files Browse the repository at this point in the history
Further parking location fix update
  • Loading branch information
JoeJimFlood authored Mar 13, 2024
2 parents 2a99bed + 11a3d33 commit 8fa7202
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion activitysim/abm/models/trip_matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ def write_trip_matrices(network_los):
if "parking_location" in config.setting("models"):
parking_settings = config.read_model_settings("parking_location_choice.yaml")
parking_taz_col_name = parking_settings["ALT_DEST_COL_NAME"]
assert "AUTO_MODES" in parking_settings, "AUTO_MODES must be specified in parking location settings to properly adjust trip tables for assignment"
auto_modes = parking_settings["AUTO_MODES"]

if parking_taz_col_name in trips_df:

trips_df["true_origin"] = trips_df["origin"]
Expand All @@ -59,7 +62,11 @@ def write_trip_matrices(network_los):
# Get origin parking zone if vehicle not parked at origin
trips_df["origin_parking_zone"] = np.where(
trips_df["tour_id"] == trips_df["tour_id"].shift(1),
trips_df[parking_taz_col_name].shift(1),
np.where(
trip_df["trip_mode"].apply(lambda x: x in auto_modes),
trips_df[parking_taz_col_name].shift(1),
-1
)
-1
)

Expand Down Expand Up @@ -232,6 +239,14 @@ def write_trip_matrices(network_los):
trips_df["destination"] = trips_df["true_destination"]
del trips_df["true_origin"], trips_df["true_destination"]

if network_los.zone_system == los.TWO_ZONE or network_los.zone_system == los.THREE_ZONE:
trips_df["otaz"] = (
pipeline.get_table("land_use").reindex(trips_df["origin"]).TAZ.tolist()
)
trips_df["dtaz"] = (
pipeline.get_table("land_use").reindex(trips_df["destination"]).TAZ.tolist()
)


def annotate_trips(trips, network_los, model_settings):
"""
Expand Down

0 comments on commit 8fa7202

Please sign in to comment.