smash.Model.get_rr_initial_states#

Model.get_rr_initial_states(key)[source]#

Get the values of a Model rainfall-runoff initial state.

Parameters:
keystr

The name of the rainfall-runoff initial state.

Returns:
valuenumpy.ndarray

An array of shape (nrow, ncol) representing the values of the rainfall-runoff initial state.

See also

Model.rr_initial_states

Model rainfall-runoff initial states.

Examples

>>> from smash.factory import load_dataset
>>> setup, mesh = load_dataset("cance")
>>> model = smash.Model(setup, mesh)

Access to a specific rainfall-runoff initial state grid

>>> model.get_rr_initial_states("hp")
array([[0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01,
        0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01,
        ...
        0.01, 0.01, 0.01, 0.01, 0.01, 0.01]], dtype=float32)

Note

This method is equivalent to directly slicing the rr_initial_states.values array (as shown below) but is simpler to use

Access the rainfall-runoff state keys

>>> model.rr_initial_states.keys
array(['hi', 'hp', 'ht', 'hlr'], dtype='<U3')

Get the index of the rainfall-runoff initial state 'hp'

>>> ind = np.argwhere(model.rr_initial_states.keys == "hp").item()
>>> ind
1

Slice the rr_initial_states.values array on the last axis

>>> model.rr_initial_states.values[..., ind]
array([[0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01,
        0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01,
        ...
        0.01, 0.01, 0.01, 0.01, 0.01, 0.01]], dtype=float32)