smash.precipitation_indices#
- smash.precipitation_indices(model)[source]#
Compute precipitation indices of Model.
5 precipitation indices are calculated for each gauge and each time step:
'std'
: the precipitation spatial standard deviation'd1'
: the first scaled moment, [Zoccatelli et al., 2011]'d2'
: the second scaled moment, [Zoccatelli et al., 2011]'vg'
: the vertical gap [Emmanuel et al., 2015]'hg'
: the horizontal gap [Emmanuel et al., 2015]
- Parameters:
- Returns:
- precipitation_indices
PrecipitationIndices
It returns an object containing the results of the precipitation indices computation.
- precipitation_indices
See also
PrecipitationIndices
Represents precipitation indices computation result.
Examples
>>> from smash.factory import load_dataset >>> setup, mesh = load_dataset("cance") >>> model = smash.Model(setup, mesh)
Compute precipitation indices
>>> prcp_ind = smash.precipitation_indices(model) >>> prcp_ind d1: <class 'numpy.ndarray'> d2: <class 'numpy.ndarray'> hg: <class 'numpy.ndarray'> std: <class 'numpy.ndarray'> vg: <class 'numpy.ndarray'>
Each attribute is a
numpy.ndarray
of shape (ng, ntime_step) (i.e. number of gauges, number of time steps)Access a specific precipitation indice
>>> prcp_ind.d1 array([[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]], dtype=float32)
Note
NaN value means that there is no precipitation at this specific gauge and time step.
Access a specific precipitation indice for a single gauge
>>> ind = np.argwhere(model.mesh.code == "V3524010").item() >>> ind 0
>>> d1g = prcp_ind.d1[ind, :] >>> d1g array([nan, nan, nan, ..., nan, nan, nan], dtype=float32)
Access the time steps where rainfall occured for a specific precipitation indice and a single gauge
>>> ind = np.argwhere(~np.isnan(d1g)) >>> ind array([[ 11], [ 12], ... [1410], [1411]])
>>> d1gts = d1g[ind] >>> d1gts array([[1.2091751 ], [0.83805513], ... [0.89658403], [0.48382276]], dtype=float32) >>> d1gts[0].item(), d1gts[1].item() (1.2091751098632812, 0.8380551338195801)