pyflwdir.partition.PartitionPlan#

class pyflwdir.partition.PartitionPlan(parts: ndarray, loads: ndarray, basin_ids: ndarray, level: str, stems: tuple[MainstemSection, ...] = ())[source]#

How the cells of a raster divide over processes, from pyflwdir.FlwdirRaster.partition().

Pass it as partition_plan to pyflwdir.FlwdirRaster.upstream_area() or pyflwdir.FlwdirRaster.accuflux(), with parallel=True, to accumulate each part in its own process. The accumulation checks it against the flow directions first and refuses a plan that does not fit them.

parts#

Label of each cell, shaped like the raster: from 0 to n - 1 in a part, n in a mainstem section, and -1 off the network, on a basin of a single cell, and in or draining into a loop of the flow directions, where n is loads.size, the number of parts and of processes.

Type:

ndarray of int32

loads#

Cell count of each part. The mainstem sections are excluded.

Type:

ndarray of int64

basin_ids#

Basin label of each cell, shaped like the raster: those of pyflwdir.FlwdirRaster.basins(), 0 off the network.

Type:

ndarray of int

level#

The partition level.

Type:

{‘basin’, ‘subbasin’}

stems#

One section per opened basin; empty at basin level.

Type:

tuple of MainstemSection

__init__(parts: ndarray, loads: ndarray, basin_ids: ndarray, level: str, stems: tuple[MainstemSection, ...] = ()) → None#

Methods

__init__(parts, loads, basin_ids, level[, stems])

Attributes

cut_inlets

The cut_inlets of all sections; the accumulation reads stems.

cut_outlets

The cut_outlets of all sections; the accumulation reads stems.

cut_parts

The cut_parts of all sections, one after the other.

mainstem

The cells of every mainstem section, for plotting and inspection.

stems

parts

loads

basin_ids

level