Skip to content
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

segment speeds for speedmaps part 2 #1278

Merged
merged 16 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion _shared_utils/shared_utils/gtfs_analytics_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ speedmap_segments:
trip_stop_cols: ["trip_instance_key", "stop_sequence", "stop_sequence1"]
shape_stop_cols: ["shape_array_key", "shape_id"]
stop_pair_cols: ["stop_pair", "stop_pair_name", "segment_id"]
route_dir_cols: ["route_id", "route_short_name"]
route_dir_cols: ["route_id", "direction_id"]
segments_file: "segment_options/speedmap_segments"
shape_stop_single_segment: "rollup_singleday/speeds_shape_speedmap_segments"
shape_stop_single_segment_detail: "rollup_singleday/speeds_shape_speedmap_segments_detail"
route_dir_single_segment: "rollup_singleday/speeds_route_dir_speedmap_segments"
route_dir_multi_segment: "rollup_multiday/speeds_route_dir_speedmap_segments"
min_trip_minutes: ${speed_vars.time_min_cutoff}
Expand Down
11 changes: 9 additions & 2 deletions _shared_utils/shared_utils/rt_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
MPH_PER_MPS = 2.237 # use to convert meters/second to miles/hour
METERS_PER_MILE = 1609.34
# Colorscale
ZERO_THIRTY_COLORSCALE = branca.colormap.step.RdYlGn_10.scale(vmin=0, vmax=30)
ZERO_THIRTY_COLORSCALE.caption = "Speed (miles per hour)"
# ZERO_THIRTY_COLORSCALE = branca.colormap.step.RdYlGn_10.scale(vmin=0, vmax=30)
# ZERO_THIRTY_COLORSCALE.caption = "Speed (miles per hour)"
ACCESS_ZERO_THIRTY_COLORSCALE = branca.colormap.step.RdBu_10.scale(vmin=0, vmax=30)
ACCESS_ZERO_THIRTY_COLORSCALE.caption = "Speed (miles per hour)"
VARIANCE_COLORS = branca.colormap.step.Blues_06.colors[1:] # actual breaks will vary
Expand Down Expand Up @@ -562,6 +562,13 @@ def categorize_time_of_day(value: Union[int, dt.datetime]) -> str:
return "Evening"


def time_of_day_durations() -> pd.Series:
"""
Get duration in hours of each time of day classification.
"""
return pd.Series([categorize_time_of_day(x) for x in range(25)]).value_counts()


@jit(nopython=True) # numba gives huge speedup here (~60x)
def time_at_position_numba(desired_position, shape_array, dt_float_array):
if desired_position < shape_array.max() and desired_position > shape_array.min():
Expand Down
Loading
Loading