iduedu.apply_grade_speed¶
- iduedu.apply_grade_speed(urban_graph, model='tobler', *, edge_types=None)[source]¶
Rescale the travel times of a graph with elevation by a speed model that depends on the grade.
The time of an edge is divided by the relative speed the model gives for its grade. An edge that goes up and down is taken as a climb of
ascentfollowed by a drop ofdescent, both at the mean absolute grade(ascent + descent) / length. A row that serves both directions (an edge of an undirected graph, or a two-way edge of a directed one) gets the mean of the two directions.The times before the change are kept in
time_min_flat, and a repeated call starts from them.- Parameters:
urban_graph (
UrbanGraph) – Graph withascentanddescenton its edges (seeadd_elevation()).model (
Union[Literal['tobler','cycling'],Callable[[ndarray],ndarray]]) –"tobler"(tobler(), walking),"cycling"(cycling()) or a function that maps an array of signed grades to speeds relative to flat ground.edge_types (
Optional[Iterable[str]]) – Change only edges whosetypeis one of these, for example["walk"]in an intermodal graph.
- Return type:
- Returns:
A new
UrbanGraphwith changedtime_min.- Raises:
KeyError – If the edges have no
ascentanddescent.ValueError – If the model is unknown or returns speeds that are not positive.