earthkit.hydro.move¶
Subpackages¶
Module contents¶
- earthkit.hydro.move.downstream(river_network, field, node_weights=None, edge_weights=None, metric='sum', return_type=None, input_core_dims=None)[source]¶
Moves a field downstream.
Computes a one-step neighbor accumulation (local aggregation) moving downstream only.
The accumulation is defined as:
\begin{align*} x'_i &= w'_i \cdot x_i \\ n_j &= \bigoplus_{i \in \mathrm{Up}(j)} w_{ij} \cdot x'_i \end{align*}where:
\(x_i\) is the input value at node \(i\) (e.g., rainfall),
\(w'_i\) is the node weight (e.g., pixel area),
\(w_{ij}\) is the edge weight from node \(i\) to node \(j\) (e.g. discharge partitioning ratio),
\(\mathrm{Up}(j)\) is the set of upstream nodes flowing into node \(j\),
\(\bigoplus\) is the aggregation function (e.g. a summation).
\(n_j\) is the weighted aggregated value at node \(j\).
- Parameters:
river_network (RiverNetwork) – A river network object.
field (array-like or xarray object) – An array containing field values defined on river network nodes or gridcells.
node_weights (array-like or xarray object, optional) – Array of weights for each river network node or gridcell. Default is None (unweighted).
edge_weights (array-like or xarray object, optional) – Array of weights for each edge. Default is None (unweighted).
metric (str, optional) – Aggregation function to apply. Options are ‘var’, ‘std’, ‘mean’, ‘sum’, ‘min’ and ‘max’. Default is ‘sum’.
return_type (str, optional) – Either “masked”, “gridded” or None. If None (default), uses river_network.return_type.
input_core_dims (sequence of sequence, optional) – List of core dimensions on each input xarray argument that should not be broadcast. Default is None, which attempts to autodetect input_core_dims from the xarray inputs. Ignored if no xarray inputs passed.
- Returns:
Array of values after movement down the river network for every river network node or gridcell, depending on return_type.
- Return type:
xarray object
- earthkit.hydro.move.upstream(river_network, field, node_weights=None, edge_weights=None, metric='sum', return_type=None, input_core_dims=None)[source]¶
Moves a field upstream.
Computes a one-step neighbor accumulation (local aggregation) moving upstream only.
The accumulation is defined as:
\begin{align*} x'_i &= w'_i \cdot x_i \\ n_j &= \bigoplus_{i \in \mathrm{Down}(j)} w_{ij} \cdot x'_i \end{align*}where:
\(x_i\) is the input value at node \(i\) (e.g., rainfall),
\(w'_i\) is the node weight (e.g., pixel area),
\(w_{ij}\) is the edge weight from node \(i\) to node \(j\) (e.g. discharge partitioning ratio),
\(\mathrm{Down}(j)\) is the set of downstream nodes flowing out of node \(j\),
\(\bigoplus\) is the aggregation function (e.g. a summation).
\(n_j\) is the weighted aggregated value at node \(j\).
- Parameters:
river_network (RiverNetwork) – A river network object.
field (array-like or xarray object) – An array containing field values defined on river network nodes or gridcells.
node_weights (array-like or xarray object, optional) – Array of weights for each river network node or gridcell. Default is None (unweighted).
edge_weights (array-like or xarray object, optional) – Array of weights for each edge. Default is None (unweighted).
metric (str, optional) – Aggregation function to apply. Options are ‘var’, ‘std’, ‘mean’, ‘sum’, ‘min’ and ‘max’. Default is ‘sum’.
return_type (str, optional) – Either “masked”, “gridded” or None. If None (default), uses river_network.return_type.
input_core_dims (sequence of sequence, optional) – List of core dimensions on each input xarray argument that should not be broadcast. Default is None, which attempts to autodetect input_core_dims from the xarray inputs. Ignored if no xarray inputs passed.
- Returns:
Array of values after movement up the river network for every river network node or gridcell, depending on return_type.
- Return type:
xarray object