smash.Model.copy#

Model.copy()[source]#

Create a deep copy of Model.

Returns:
modelModel

It returns a deep copy of Model.

Examples

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

Create a shallow copy of Model

>>> model_sc = model

Access to the rainfall-runoff parameter grid 'cp' of the shallow copy

>>> model_sc.get_rr_parameters("cp")
array([[200., 200., 200., 200., 200., 200., 200., 200., 200., 200., 200.,
        200., 200., 200., 200., 200., 200., 200., 200., 200., 200., 200.,
        ...
        200., 200., 200., 200., 200., 200.]], dtype=float32)

Change the values of the rainfall-runoff parameter grid 'cp' of the initial Model

>>> model.set_rr_parameters("cp", 63)

View the result on the shallow copy

>>> model_sc.get_rr_parameters("cp")
array([[63., 63., 63., 63., 63., 63., 63., 63., 63., 63., 63., 63., 63.,
        63., 63., 63., 63., 63., 63., 63., 63., 63., 63., 63., 63., 63.,
        ...
        63., 63.]], dtype=float32)

Create a deep copy of Model

>>> model_dc = model.copy()

Access to the rainfall-runoff parameter grid 'cp' of the deep copy

>>> model_dc.get_rr_parameters("cp")
array([[63., 63., 63., 63., 63., 63., 63., 63., 63., 63., 63., 63., 63.,
        63., 63., 63., 63., 63., 63., 63., 63., 63., 63., 63., 63., 63.,
        ...
        63., 63.]], dtype=float32)

Change the values of the rainfall-runoff parameter grid 'cp' of the initial Model

>>> model.set_rr_parameters("cp", 362)

View the result on the deep copy

>>> model_dc.get_rr_parameters("cp")
array([[63., 63., 63., 63., 63., 63., 63., 63., 63., 63., 63., 63., 63.,
        63., 63., 63., 63., 63., 63., 63., 63., 63., 63., 63., 63., 63.,
        ...
        63., 63.]], dtype=float32)