easy_vic_build.tools.nested_basin_func.nested_basin_func

Utilities for nested-basin topology and unique mask construction.

Functions

cal_unique_mask_nested_basin(station_names, ...)

Build mutually exclusive grid masks for nested basins.

get_all_upstreams(station, nest_upstream_map)

Collect all upstream stations for a target station.

get_topo_order(station_names, nest_map)

Return stations in upstream-to-downstream topological order.

easy_vic_build.tools.nested_basin_func.nested_basin_func.get_all_upstreams(station, nest_upstream_map)[source]

Collect all upstream stations for a target station.

Parameters:
  • station (str) – Target station name.

  • nest_upstream_map (dict) – Mapping {station: [direct_upstream_stations]}.

Returns:

All upstream stations reachable from station.

Return type:

list of str

easy_vic_build.tools.nested_basin_func.nested_basin_func.get_topo_order(station_names, nest_map)[source]

Return stations in upstream-to-downstream topological order.

Parameters:
  • station_names (sequence of str) – Station names to be ordered.

  • nest_map (dict) – Mapping {station: [direct_upstream_stations]}.

Returns:

Topological order where upstream stations appear before downstream stations.

Return type:

list of str

easy_vic_build.tools.nested_basin_func.nested_basin_func.cal_unique_mask_nested_basin(station_names, grid_shp, basin_shps, main_basin_shp, plot=False, reverse_lat=True)[source]

Build mutually exclusive grid masks for nested basins.

Parameters:
  • station_names (sequence of str) – Station names that define the nested basin set.

  • grid_shp (geopandas.GeoDataFrame) – Grid polygons used as target cells for mask assignment.

  • basin_shps (dict) – Mapping {station_name: basin_geodataframe}.

  • main_basin_shp (geopandas.GeoDataFrame) – Main-basin geometry used to determine UTM projection.

  • plot (bool, optional) – Whether to plot masks for visual inspection.

  • reverse_lat (bool, optional) – Whether standard latitude ordering is reversed.

Returns:

(unique_masks, grid_shp_unique_mask) where: unique_masks is a dict mapping station name to 2D binary mask array, and grid_shp_unique_mask is a GeoDataFrame with assigned station index.

Return type:

tuple