Skip to content

Commit

Permalink
Merge pull request #1278 from cal-itp/speedmaps-split-peaks
Browse files Browse the repository at this point in the history
segment speeds for speedmaps part 2
  • Loading branch information
edasmalchi authored Nov 7, 2024
2 parents 6adecac + 0287a8f commit 0c9b600
Show file tree
Hide file tree
Showing 92 changed files with 1,093 additions and 2,459 deletions.
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

0 comments on commit 0c9b600

Please sign in to comment.