meshflow.utility.network.extract_rank_next

meshflow.utility.network.extract_rank_next(seg, ds_seg, outlet_value=-9999)[source]

Generate MESH-compatible rank and next variables for river segments.

Parameters:
  • seg (array-like or list-like) – Ordered segment IDs for river reaches in the area of interest.

  • ds_seg (array-like or list-like) – Ordered downstream segment IDs corresponding to seg elements.

  • outlet_value (int, optional) – Value assigned to to_segment indicating outlet/sink from the system. Default is -9999.

Returns:

  • rank_var (numpy.ndarray) – Rank of each segment ID, following MESH modelling standards.

  • next_var (numpy.ndarray) – Downstream segment index for each river reach, matching rank_var.

  • seg_id (numpy.ndarray) – Segment IDs reordered to match rank_var and next_var.

  • to_segment (numpy.ndarray) – Downstream segment IDs reordered to match rank_var and next_var.

Return type:

Tuple[ndarray, …]

Notes

Developed by Dr. Ala Bahrami and Cooper Albano for North American MESH model workflows. Minor changes by Kasra Keshavarz.

Original workflow:

https://github.com/MESH-Model/MESH-Scripts