lair.transects.pool_routes#

lair.transects.pool_routes(matrices, index, n_network)[source]#

Stack per-route [transit, point] matrices onto the network points.

Where two route points of one route snap to the same network point, the last one wins.

Parameters:
  • matrices (list[np.ndarray]) – One [transit, point] matrix per route.

  • index (list[np.ndarray]) – Per route, the network point of each of its points, from merge_route_points().

  • n_network (int) – Number of network points.

Returns:

np.ndarray – A [sum of transits, n_network] matrix, NaN where a route has no point (or no data) at a network point.

Return type:

ndarray

See also

merge_route_points

Gives index and the network points.

Examples

One transit on each of the two routes of merge_route_points():

>>> import numpy as np
>>> from lair.transects import pool_routes
>>> index = [np.array([0, 1, 2]), np.array([1, 2, 3])]
>>> matrices = [np.array([[1.0, 2.0, 3.0]]), np.array([[10.0, 20.0, 30.0]])]
>>> pool_routes(matrices, index, n_network=4)
array([[ 1.,  2.,  3., nan],
       [nan, 10., 20., 30.]])