earthkit.hydro.data_structures¶
Module contents¶
- class earthkit.hydro.data_structures.RiverNetwork(river_network_storage: RiverNetworkStorage)[source]¶
Bases:
objectA class representing a river network for hydrological processing.
- n_nodes¶
The number of nodes in the river network.
- Type:
int
- n_edges¶
The number of nodes in the river network.
- Type:
int
- sinks¶
Nodes with no downstream connections.
- Type:
array-like
- sources¶
Nodes with no upstream connections.
- Type:
array-like
- bifurcates¶
Whether the river network has bifurcations.
- Type:
bool
- shape¶
The size of the river network grid. None if the network is vector-based.
- Type:
tuple
- mask¶
Flattened 1D indices on the raster grid corresponding to river network nodes.
- Type:
array-like
- array_backend¶
The array backend of the river network.
- Type:
str
- device¶
The device of the river network.
- Type:
str
- return_type¶
The default return type of the river network. Either “gridded” or “masked”.
- Type:
str
- export(fpath='river_network.joblib', compression=1)[source]¶
Save the river network to a local file.
- Parameters:
fpath (str, optional) – The filepath specifying where to save the RiverNetwork. Default is ‘river_network.joblib’.
compression (str, optional) – The compression factor used for saving. Default is 1.
- Return type:
None
- set_default_return_type(return_type)[source]¶
Set the default return type for the river network.
- Parameters:
return_type (str) – The default return_type to use.
- Return type:
None
- to_device(device=None, array_backend=None)[source]¶
Change the RiverNetwork’s array backend and/or move it to a different device.
- Parameters:
device (str, optional) – The device to which to transfer. Default is None, which is ‘cpu’ for all backends except cupy, which is ‘gpu’.
array_backend (str, optional) – The array backend. One of “numpy”, “np”, “cupy”, “cp”, “pytorch”, “torch”, “jax”, “jnp”, “tensorflow”, “tf”, “mlx” or “mx”. Default is None, which uses self.array_backend.
- Returns:
The modified RiverNetwork.
- Return type: