Demands¶
OD demand distributions for simulation and empirical data.
- class micropurc.demands.ODDistribution(origins, dests, weights)[source]¶
Bases:
objectDistribution over origin-destination pairs.
- Variables:
origins (numpy.ndarray) – Origin node indices (internal), shape (M,).
dests (numpy.ndarray) – Destination node indices (internal), shape (M,).
weights (numpy.ndarray) – Sampling probabilities, shape (M,), normalized on construction, so a caller may pass raw counts.
- Parameters:
- micropurc.demands.od_from_csv(network, trips_csv, *, origin_col='origin', dest_col='destination', weight_col='sampling_weight', use_node_index=True)[source]¶
Build an ODDistribution from a CSV file.
- Parameters:
network (Network) – Network for mapping raw node IDs.
trips_csv (str) – Path to CSV with OD demands.
origin_col (str) – Column name for origin node IDs.
dest_col (str) – Column name for destination node IDs.
weight_col (str | None) – Column holding the weights. When it is
Noneor absent from the file, the OD pairs are weighted equally.use_node_index (bool) – Map the raw IDs through
network.node_index. With this off, or with no index on the network, the IDs are cast to int and used as internal indices.
- Returns:
The origin-destination distribution parsed from the file.
- Raises:
ValueError – If the origin or destination column is absent.
- Return type: