smash.Model.get_serr_mu#

Model.get_serr_mu()[source]#

Get the structural error mu value by applying the mu mapping.

Hint

See the Bayesian Estimation section

Returns:
valuenumpy.ndarray

An array of shape (ng, ntime_step) representing the values of the structural error mu for each gauge and each time step.

Examples

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

Set the structural error mu mapping to 'Linear' (see Model). Default value in the Cance dataset is 'Zero' (equivalent to no mu mapping)

>>> setup["serr_mu_mapping"] = "Linear"
>>> model = smash.Model(setup, mesh)

The structural error mu mapping is set to 'Linear'. Therefore, the mapping of mu parameters to mu is: \(\mu(g,t)=\mu_0(g)+\mu_1(g)q(g,t)\) with:

  • \(\mu\), the mean of structural errors,

  • \(\mu_0\) and \(\mu_1\), the structural error mu parameters with respect to 'Linear' mapping,

  • \(q\), the model response (i.e. the discharge),

  • \(g\) and \(t\), the index refering to the gauge and time step respectively

Run the direct Model to generate discharge responses

>>> model.forward_run()

Set arbitrary values to structural error mu parameters

>>> model.set_serr_mu_parameters("mg0", 1)
>>> model.set_serr_mu_parameters("mg1", 2)

Retrieve the mu value with the get_serr_mu method

>>> mu = model.get_serr_mu()
>>> mu
array([[ 1.0039653,  1.0000002,  1.       , ..., 46.5925   , 46.311882 ,
        46.034615 ],
       [ 1.0004755,  1.       ,  1.       , ..., 10.65963  , 10.61587  ,
        10.572574 ],
       [ 1.0000595,  1.       ,  1.       , ...,  3.563775 ,  3.5520396,
         3.5404253]], dtype=float32)

This is equivalent to

>>> mg0 = model.get_serr_mu_parameters("mg0").reshape(-1, 1)
>>> mg1 = model.get_serr_mu_parameters("mg1").reshape(-1, 1)
>>> q = model.response.q
>>> mu2 = mg0 + mg1 * q
>>> np.allclose(mu, mu2)
True