smash.io.read_grid_parameters#

smash.io.read_grid_parameters(model, path, parameters=None)[source]#

Read the Model grid parameters (rainfall-runoff parameters and initial states) from GeoTIFF.

Grid parameters are read from GeoTIFF format in a specified directory.

Parameters:
modelModel

Primary data structure of the hydrological model smash.

pathstr

Directory path where the GeoTIFF files will be read. If the directory does not exist, an error will be raised.

parametersstr, list[str, …] or None, default None

Name of parameters grid to read. Should be one or a sequence of any key of:

>>> parameters = "cp"
>>> parameters = ["cp", "ct", "kexc", "llr"]

Note

If not given, all parameters in Model.rr_parameters will be read.

See also

save_grid_parameters

Save the Model grid parameters (rainfall-runoff parameters and initial states) to GeoTIFF.

Examples

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

Save all rr_parameters and rr_initial_states

>>> parameters = list(model.rr_parameters.keys) + list(model.rr_initial_states.keys)
>>> parameters
['ci', 'cp', 'ct', 'kexc', 'llr', 'hi', 'hp', 'ht', 'hlr']
>>> save_grid_parameters(model, "rr_parameters_initial_states_dir", parameters)

Read all rr_parameters

>>> read_grid_parameters(model, "rr_parameters_initial_states_dir")

Read only a subset of rr_parameters

>>> read_grid_parameters(model, "rr_parameters_initial_states_dir", ["cp", "ct"])

Read all rr_parameters and rr_initial_states

>>> parameters
['ci', 'cp', 'ct', 'kexc', 'llr', 'hi', 'hp', 'ht', 'hlr']
>>> read_grid_parameters(model, "rr_parameters_initial_states_dir", parameters)