smash.multiset_estimate#

smash.multiset_estimate(model, multiset, alpha=None, common_options=None, return_options=None)[source]#

Model assimilation using Bayesian-like estimation on multiple sets of solutions.

Parameters:
modelModel

Primary data structure of the hydrological model smash.

multisetMultipleForwardRun or MultipleOptimize

The returned object created by multiple_forward_run or multiple_optimize method containing information about multiple sets of rainfall-runoff parameters or initial states.

alphafloat, list[float, …], or None, default None

A regularization parameter that controls the decay rate of the likelihood function. If alpha is a list, the L-curve approach will be used to find an optimal value for the regularization parameter.

Note

If not given, a default numeric range will be set for optimization through the L-curve process.

common_optionsdict[str, Any] or None, default None

Dictionary containing common options with two elements:

ncpuint, default 1

Number of CPU(s) to perform a parallel computation.

Warning

Parallel computation is not supported on Windows.

verbosebool, default False

Whether to display information about the running method.

return_optionsdict[str, Any] or None, default None

Dictionary containing return options to save intermediate variables. The elements are:

time_stepstr, pandas.Timestamp, pandas.DatetimeIndex or list[str, …], default ‘all’

Returned time steps. There are five ways to specify it:

>>> return_options = {
    "time_step": "all",
}
>>> return_options = {
    "time_step": "1997-12-21",
}
>>> return_options = {
    "time_step": pd.Timestamp("19971221"),
}
>>> return_options = {
    "time_step": pd.date_range(
        start="1997-12-21",
        end="1998-12-21",
        freq="1D"
    ),
}
>>> return_options = {
    "time_step": ["1998-05-23", "1998-05-24", "1998-05-25"],
}

Note

It only applies to the following variables: 'rr_states' and 'q_domain'

rr_statesbool, default False

Whether to return rainfall-runoff states for specific time steps.

q_domainbool, default False

Whether to return simulated discharge on the whole domain for specific time steps.

costbool, default False

Whether to return cost value.

jobsbool, default False

Whether to return jobs (observation component of cost) value.

lcurve_multisetbool, default False

Whether to return the multiset estimate L-curve.

Returns:
modelModel

It returns an updated copy of the initial Model object.

multiset_estimateMultisetEstimate or None, default None

It returns an object containing the intermediate variables defined in return_options. If no intermediate variables are defined, it returns None.

See also

MultisetEstimate

Represents multiset estimate optional results.

MultipleForwardRun

Represents multiple forward run computation result.

MultipleOptimize

Represents multiple optimize computation result.

Examples

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

Define sampling problem and generate samples

>>> problem = {
...    'num_vars': 4,
...    'names': ['cp', 'ct', 'kexc', 'llr'],
...    'bounds': [[1, 2000], [1, 1000], [-20, 5], [1, 1000]]
... }
>>> sr = generate_samples(problem, n=100, random_state=11)

Run Model with multiple sets of parameters

>>> mfr = smash.multiple_forward_run(model, samples=sr)
</> Multiple Forward Run
    Forward Run 100/100 (100%)

Estimate Model on multiple sets of solutions

>>> model_estim = smash.multiset_estimate(model, multiset=mfr)
</> Multiple Set Estimate
    L-curve Computing: 100%|████████████████████████████████████████| 50/50 [00:02<00:00, 17.75it/s]

Get the simulated discharges

>>> model_estim.response.q
array([[9.4571486e-05, 9.3920688e-05, 9.3143637e-05, ..., 1.7423288e+01,
        1.7193638e+01, 1.6963835e+01],
       [2.5758292e-05, 2.4744744e-05, 2.3561088e-05, ..., 3.6616585e+00,
        3.6165960e+00, 3.5724759e+00],
       [5.9654208e-06, 5.0872231e-06, 4.2139386e-06, ..., 9.0600485e-01,
        8.9525825e-01, 8.8473159e-01]], dtype=float32)