pyflwdir.FlwdirRaster.accuflux#
- FlwdirRaster.accuflux(data: ndarray, nodata: float = -9999, direction: Literal['up', 'down'] = 'up', parallel: bool = False, partition_plan: PartitionPlan | None = None, threads_per_process: int | None = None, layering: Literal['asap', 'cfds', 'alap'] = 'cfds', manner: Literal['push', 'pull'] = 'push', start_method: str = 'spawn') ndarray#
Return accumulated data values along the flow directions.
- Parameters:
data (array-like) – Values associated with graph cells. Use a 1D array for Flwdir and an array matching the raster shape for FlwdirRaster.
nodata (int or float) – Missing data value for cells outside domain
direction ({'up', 'down'}, optional) – direction in which to accumulate data, by default upstream
parallel (bool, optional) – Accumulate one layer at a time in threads, by default False. Available for upstream accumulation only.
partition_plan (PartitionPlan, optional) – How to divide the raster over processes, made with
FlwdirRaster.partition(). With a plan, each part is accumulated in its own process with threads, one process a part, and any mainstem sections are accumulated after the processes finish. Without one, the default, everything runs in this process. A plan can be reused for any number of calls on the same flow directions. It needsparallel=Trueand the default layering and manner, and it is checked against the flow directions first.threads_per_process (int, optional) – Numba threads inside each process, used only with a partition_plan. By default the available threads are divided over the processes. Without a plan, the threads are the current Numba thread count.
layering ({'asap', 'cfds', 'alap'}, optional) – Layering used with
parallel=True, by default"cfds".manner ({'push', 'pull'}, optional) – Propagation manner used with
parallel=True, by default"push". Push needs the conflict-free"cfds"layering. Pull is safe with all three layerings but builds and reads the upstream-cell index.start_method (str, optional) – Multiprocessing start method, used only with a partition_plan, by default
"spawn". With"spawn", call it from an importable script, below anif __name__ == "__main__":guard.
- Returns:
Accumulated values, with the same shape as data.
- Return type:
array with data.dtype
- Raises:
ValueError – If direction is invalid, if parallel=True is requested for downstream accumulation, or if partition_plan does not fit the flow directions.