Skip to content

Commit

Permalink
Merge pull request #243 from SANDAG/fix-maz-stop-inaccessible
Browse files Browse the repository at this point in the history
Fix inaccessible premium MAZ-stop pairs
  • Loading branch information
bhargavasana authored Nov 8, 2024
2 parents 4500ac2 + 6ffd5fb commit 88ffb55
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/asim/scripts/resident/2zoneSkim.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,26 +221,14 @@ def add_missing_mazs_to_skim_table(centroids, maz_to_maz_walk_cost_out, maz_to_m
max_walk_dist = parms['mmms']['max_maz_' + output + '_stop_walk_dist_feet'] / 5280.0
maz_to_stop_walk_cost_out_mode = maz_to_stop_walk_cost_out[maz_to_stop_walk_cost_out['MODE'].str.contains(mode)].copy()
maz_to_stop_walk_cost_out_mode.loc[:, 'MODE'] = mode
# peforms a similar operation as the add_missing_mazs_to_skim_table() function
missing_maz = pd.DataFrame(
centroids[~centroids["MAZ"].isin(maz_to_stop_walk_cost_out_mode["MAZ"])]["MAZ"]
).merge(
maz_to_stop_cost.sort_values("DISTANCE")
.groupby(["MAZ", "MODE"])
.agg({"stop": "first", "DISTANCE": "first"})
.reset_index(),
on="MAZ",
how="left",
)
maz_to_stop_walk_cost = maz_to_stop_walk_cost_out_mode.append(missing_maz.rename(columns = {'DISTANCE': 'DISTWALK'})).sort_values(['MAZ', 'stop'])
maz_to_stop_walk_cost = maz_to_stop_walk_cost_out_mode.sort_values(['MAZ', 'stop'])
del(maz_to_stop_walk_cost_out_mode)
del(missing_maz)
maz_stop_walk = maz_to_stop_walk_cost[maz_to_stop_walk_cost.MODE==mode].groupby('MAZ')['DISTWALK'].min().reset_index()
maz_stop_walk.loc[maz_stop_walk['DISTWALK'] > max_walk_dist, 'DISTWALK'] = np.nan
#maz_stop_walk["walk_time"] = maz_stop_walk["DISTWALK"].apply(lambda x: x / parms['mmms']['walk_speed_mph'] * 60.0)
maz_stop_walk['DISTWALK'].fillna(999999, inplace = True)
maz_stop_walk.rename({'MAZ': 'maz', 'DISTWALK': 'walk_dist_' + output}, axis='columns', inplace=True)
maz_stop_walk0 = maz_stop_walk0.merge(maz_stop_walk, left_on='maz', right_on='maz')
maz_stop_walk0 = maz_stop_walk0.merge(maz_stop_walk, left_on='maz', right_on='maz', how='outer')
maz_stop_walk0['walk_dist_' + output].fillna(999999, inplace = True)

maz_stop_walk0.sort_values(by=['maz'], inplace=True)
print(f"{datetime.now().strftime('%H:%M:%S')} Write Results...")
Expand Down

0 comments on commit 88ffb55

Please sign in to comment.