rameau 0.0.5.dev0__cp312-cp312-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rameau might be problematic. Click here for more details.
- rameau/__init__.py +25 -0
- rameau/_typing.py +23 -0
- rameau/core/__init__.py +70 -0
- rameau/core/_abstract_wrapper.py +56 -0
- rameau/core/_utils.py +130 -0
- rameau/core/correction.py +143 -0
- rameau/core/files.py +177 -0
- rameau/core/forecast/__init__.py +23 -0
- rameau/core/forecast/forecast_correction.py +116 -0
- rameau/core/forecast/forecast_parameter.py +90 -0
- rameau/core/groundwater/__init__.py +25 -0
- rameau/core/groundwater/groundwater.py +166 -0
- rameau/core/groundwater/groundwater_reservoir.py +155 -0
- rameau/core/groundwater/storage.py +87 -0
- rameau/core/inputs/__init__.py +25 -0
- rameau/core/inputs/input.py +142 -0
- rameau/core/inputs/input_collection.py +295 -0
- rameau/core/inputs/input_format.py +111 -0
- rameau/core/meteo.py +101 -0
- rameau/core/model.py +533 -0
- rameau/core/overflow.py +122 -0
- rameau/core/parameter.py +115 -0
- rameau/core/progressive_reservoir.py +151 -0
- rameau/core/pumping/__init__.py +23 -0
- rameau/core/pumping/pumping.py +72 -0
- rameau/core/pumping/pumping_reservoir.py +97 -0
- rameau/core/river.py +135 -0
- rameau/core/settings/__init__.py +27 -0
- rameau/core/settings/forecast_settings.py +266 -0
- rameau/core/settings/optimization_settings.py +319 -0
- rameau/core/settings/simulation_settings.py +119 -0
- rameau/core/settings/spinup_settings.py +198 -0
- rameau/core/simulation.py +535 -0
- rameau/core/snow/__init__.py +25 -0
- rameau/core/snow/degree_day.py +102 -0
- rameau/core/snow/snow_correction.py +111 -0
- rameau/core/snow/snow_reservoir.py +250 -0
- rameau/core/states/__init__.py +23 -0
- rameau/core/states/states.py +151 -0
- rameau/core/states/states_collection.py +130 -0
- rameau/core/thornthwaite_reservoir.py +132 -0
- rameau/core/transfer_reservoir.py +183 -0
- rameau/core/tree.py +231 -0
- rameau/core/watershed.py +270 -0
- rameau/tests/examples/durance_snow/data/durance.toml +25 -0
- rameau/tests/examples/durance_snow/data/pet_durance_1971_2009.prn +14246 -0
- rameau/tests/examples/durance_snow/data/rainfall_durance_1971_2009.prn +14246 -0
- rameau/tests/examples/durance_snow/data/riverflow_durance_1971_2009.prn +14246 -0
- rameau/tests/examples/durance_snow/data/temp_durance_1971_2009.prn +14246 -0
- rameau/tests/examples/durance_snow/test_durance.py +34 -0
- rameau/tests/examples/perpignan_gw_pumping/data/perpignan.csv +2 -0
- rameau/tests/examples/perpignan_gw_pumping/data/perpignan.toml +25 -0
- rameau/tests/examples/perpignan_gw_pumping/data/pet_perpignan_1970_2006.prn +13150 -0
- rameau/tests/examples/perpignan_gw_pumping/data/pumping_perpignan_1970_2007.prn +13150 -0
- rameau/tests/examples/perpignan_gw_pumping/data/rainfall_perpignan_1970_2006.prn +13150 -0
- rameau/tests/examples/perpignan_gw_pumping/data/watertable_perpignan_1970_2006.prn +13150 -0
- rameau/tests/examples/perpignan_gw_pumping/test_perpignan.py +78 -0
- rameau/tests/examples/selle_morvillers/data/pet_mean_9_stat_selle_1985_2003.prn +6787 -0
- rameau/tests/examples/selle_morvillers/data/rainfall_mean_9_stat_selle_1985_2003.prn +6787 -0
- rameau/tests/examples/selle_morvillers/data/riverflow_selle_plachy_1985_2003.prn +6787 -0
- rameau/tests/examples/selle_morvillers/data/selle_morvillers.csv +2 -0
- rameau/tests/examples/selle_morvillers/data/selle_morvillers.toml +28 -0
- rameau/tests/examples/selle_morvillers/data/watertable_morvillers_00608X0028_1985_2003.prn +6787 -0
- rameau/tests/examples/selle_morvillers/test_selle_morvillers.py +375 -0
- rameau/tests/examples/touques/data/groundwaterobs_touques.csv +19359 -0
- rameau/tests/examples/touques/data/pet_touques.csv +19359 -0
- rameau/tests/examples/touques/data/rainfall_touques.csv +19359 -0
- rameau/tests/examples/touques/data/riverobs_touques.csv +19359 -0
- rameau/tests/examples/touques/data/riverpumping_touques.csv +19359 -0
- rameau/tests/examples/touques/data/touques.csv +4 -0
- rameau/tests/examples/touques/data/touques.toml +140 -0
- rameau/tests/examples/touques/test_touques.py +231 -0
- rameau/tests/test_correction.py +61 -0
- rameau/tests/test_degreeday.py +66 -0
- rameau/tests/test_files.py +60 -0
- rameau/tests/test_forecast_correction.py +60 -0
- rameau/tests/test_forecast_parameter.py +63 -0
- rameau/tests/test_forecast_settings.py +84 -0
- rameau/tests/test_groundwater.py +79 -0
- rameau/tests/test_groundwater_reservoir.py +103 -0
- rameau/tests/test_input.py +76 -0
- rameau/tests/test_input_collection.py +146 -0
- rameau/tests/test_input_format.py +68 -0
- rameau/tests/test_meteo.py +70 -0
- rameau/tests/test_model.py +632 -0
- rameau/tests/test_multiprocessing.py +64 -0
- rameau/tests/test_optimization_settings.py +82 -0
- rameau/tests/test_overflow.py +59 -0
- rameau/tests/test_parameter.py +77 -0
- rameau/tests/test_progressive_reservoir.py +72 -0
- rameau/tests/test_pumping.py +64 -0
- rameau/tests/test_pumping_reservoir.py +66 -0
- rameau/tests/test_river.py +79 -0
- rameau/tests/test_simulation_settings.py +73 -0
- rameau/tests/test_snow_correction.py +61 -0
- rameau/tests/test_snow_reservoir.py +98 -0
- rameau/tests/test_spinup_settings.py +69 -0
- rameau/tests/test_states.py +89 -0
- rameau/tests/test_states_collection.py +102 -0
- rameau/tests/test_storage.py +65 -0
- rameau/tests/test_thornthwaite_reservoir.py +80 -0
- rameau/tests/test_transfer_reservoir.py +86 -0
- rameau/tests/test_tree.py +240 -0
- rameau/tests/test_watershed.py +131 -0
- rameau/tests/utils/data/data/fake_groundwaterobs.prn +2 -0
- rameau/tests/utils/data/data/fake_pet.prn +2 -0
- rameau/tests/utils/data/data/fake_rainfall.prn +2 -0
- rameau/tests/utils/data/data/fake_riverflow.prn +2 -0
- rameau/tests/utils/data/eros_marne_v73.arbros +15 -0
- rameau/tests/utils/data/eros_marne_v73a.eros +26 -0
- rameau/tests/utils/data/eros_marne_v73c.ros +908 -0
- rameau/tests/utils/data/eros_marne_v73e.ros +910 -0
- rameau/tests/utils/data/gardenia_buclay_v881.gar +180 -0
- rameau/tests/utils/data/gardenia_buclay_v881.rga +16 -0
- rameau/tests/utils/data/gardenia_buclay_v881.toml +73 -0
- rameau/tests/utils/data/gardenia_chateauneuf_v881.gar +180 -0
- rameau/tests/utils/data/gardenia_chateauneuf_v881.rga +16 -0
- rameau/tests/utils/data/gardenia_chateauneuf_v881.toml +73 -0
- rameau/tests/utils/data/gardenia_savigne_v881.gar +180 -0
- rameau/tests/utils/data/gardenia_savigne_v881.rga +16 -0
- rameau/tests/utils/data/gardenia_savigne_v881.toml +74 -0
- rameau/tests/utils/test_eros_reader.py +193 -0
- rameau/tests/utils/test_gardenia_parser.py +96 -0
- rameau/utils/__init__.py +31 -0
- rameau/utils/eros_reader.py +631 -0
- rameau/utils/gardenia_converter.py +236 -0
- rameau/utils/gardenia_converters/gardenia+gar+v8.8-to-v9.csv +193 -0
- rameau/utils/gardenia_converters/gardenia+rga+v8.8-to-v9.csv +16 -0
- rameau/wrapper/__init__.py +59 -0
- rameau/wrapper/cwrapper.cp312-win_amd64.pyd +0 -0
- rameau-0.0.5.dev0.dist-info/COPYING +674 -0
- rameau-0.0.5.dev0.dist-info/METADATA +790 -0
- rameau-0.0.5.dev0.dist-info/RECORD +134 -0
- rameau-0.0.5.dev0.dist-info/WHEEL +4 -0
rameau/__init__.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Copyright 2025, BRGM
|
|
2
|
+
#
|
|
3
|
+
# This file is part of Rameau.
|
|
4
|
+
#
|
|
5
|
+
# Rameau is free software: you can redistribute it and/or modify it under the
|
|
6
|
+
# terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
# version.
|
|
9
|
+
#
|
|
10
|
+
# Rameau is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
11
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
12
|
+
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU General Public License along with
|
|
15
|
+
# Rameau. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
#
|
|
17
|
+
from rameau import core, utils
|
|
18
|
+
from rameau.core import *
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
"core",
|
|
22
|
+
"utils"
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
__all__.extend(core.__all__)
|
rameau/_typing.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Copyright 2025, BRGM
|
|
2
|
+
#
|
|
3
|
+
# This file is part of Rameau.
|
|
4
|
+
#
|
|
5
|
+
# Rameau is free software: you can redistribute it and/or modify it under the
|
|
6
|
+
# terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
# version.
|
|
9
|
+
#
|
|
10
|
+
# Rameau is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
11
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
12
|
+
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU General Public License along with
|
|
15
|
+
# Rameau. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
#
|
|
17
|
+
from typing import Optional, Union, Literal
|
|
18
|
+
from rameau.core import Parameter
|
|
19
|
+
|
|
20
|
+
ParameterType = Optional[Union[dict, Parameter]]
|
|
21
|
+
MethodType = Optional[Literal["all", "strahler", "independent"]]
|
|
22
|
+
TransformationType = Optional[Literal["no", "square root", "inverse", "fifth root", "log"]]
|
|
23
|
+
ObjFunctionType = Optional[Literal["nse", "kge", "kge_2012"]]
|
rameau/core/__init__.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Copyright 2025, BRGM
|
|
2
|
+
#
|
|
3
|
+
# This file is part of Rameau.
|
|
4
|
+
#
|
|
5
|
+
# Rameau is free software: you can redistribute it and/or modify it under the
|
|
6
|
+
# terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
# version.
|
|
9
|
+
#
|
|
10
|
+
# Rameau is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
11
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
12
|
+
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU General Public License along with
|
|
15
|
+
# Rameau. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
#
|
|
17
|
+
# Orders of import matters.
|
|
18
|
+
#
|
|
19
|
+
from rameau.core.parameter import Parameter
|
|
20
|
+
from rameau.core.correction import CorrectionParameters
|
|
21
|
+
from rameau.core.thornthwaite_reservoir import ThornthwaiteReservoir
|
|
22
|
+
from rameau.core.progressive_reservoir import ProgressiveReservoir
|
|
23
|
+
from rameau.core.overflow import OverflowParameters
|
|
24
|
+
from rameau.core.files import FilePaths
|
|
25
|
+
from rameau.core.transfer_reservoir import TransferReservoir
|
|
26
|
+
from rameau.core.meteo import Meteo
|
|
27
|
+
from rameau.core.river import RiverParameters
|
|
28
|
+
from rameau.core.watershed import Watershed
|
|
29
|
+
from rameau.core.tree import Tree
|
|
30
|
+
from rameau.core.settings import (
|
|
31
|
+
SimulationSettings,
|
|
32
|
+
OptimizationSettings,
|
|
33
|
+
ForecastSettings
|
|
34
|
+
)
|
|
35
|
+
from rameau.core.model import Model
|
|
36
|
+
|
|
37
|
+
from rameau.core import (
|
|
38
|
+
snow,
|
|
39
|
+
pumping,
|
|
40
|
+
groundwater,
|
|
41
|
+
settings,
|
|
42
|
+
inputs,
|
|
43
|
+
states,
|
|
44
|
+
forecast
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
__all__ = [
|
|
48
|
+
"Parameter",
|
|
49
|
+
"CorrectionParameters",
|
|
50
|
+
"ThornthwaiteReservoir",
|
|
51
|
+
"ProgressiveReservoir",
|
|
52
|
+
"OverflowParameters",
|
|
53
|
+
"FilePaths",
|
|
54
|
+
"TransferReservoir",
|
|
55
|
+
"Meteo",
|
|
56
|
+
"RiverParameters",
|
|
57
|
+
"Watershed",
|
|
58
|
+
"Tree",
|
|
59
|
+
"SimulationSettings",
|
|
60
|
+
"OptimizationSettings",
|
|
61
|
+
"ForecastSettings",
|
|
62
|
+
"Model",
|
|
63
|
+
"snow",
|
|
64
|
+
"pumping",
|
|
65
|
+
"groundwater",
|
|
66
|
+
"settings",
|
|
67
|
+
"inputs",
|
|
68
|
+
"states",
|
|
69
|
+
"forecast"
|
|
70
|
+
]
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Copyright 2025, BRGM
|
|
2
|
+
#
|
|
3
|
+
# This file is part of Rameau.
|
|
4
|
+
#
|
|
5
|
+
# Rameau is free software: you can redistribute it and/or modify it under the
|
|
6
|
+
# terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
# version.
|
|
9
|
+
#
|
|
10
|
+
# Rameau is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
11
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
12
|
+
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU General Public License along with
|
|
15
|
+
# Rameau. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
#
|
|
17
|
+
from collections.abc import MutableMapping
|
|
18
|
+
class AbstractWrapper(MutableMapping):
|
|
19
|
+
def _init_c(self):
|
|
20
|
+
self._m = self._c_class()
|
|
21
|
+
|
|
22
|
+
def __getitem__(self, __key):
|
|
23
|
+
return getattr(self, __key)
|
|
24
|
+
|
|
25
|
+
def __setitem__(self, __key, __value):
|
|
26
|
+
if __key not in self._computed_attributes:
|
|
27
|
+
raise KeyError(f'{__key} is not an attribute of {self}')
|
|
28
|
+
setattr(self, __key, __value)
|
|
29
|
+
|
|
30
|
+
def __delitem__(self, _):
|
|
31
|
+
raise RuntimeError(
|
|
32
|
+
f"rameau parameters cannot be deleted"
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
def __iter__(self):
|
|
36
|
+
for key in self._computed_attributes:
|
|
37
|
+
yield key
|
|
38
|
+
|
|
39
|
+
def __len__(self):
|
|
40
|
+
return len(self._computed_attributes)
|
|
41
|
+
|
|
42
|
+
# For pickling
|
|
43
|
+
def __getstate__(self):
|
|
44
|
+
return {key: getattr(self, key) for key in self._computed_attributes}
|
|
45
|
+
|
|
46
|
+
# For pickling
|
|
47
|
+
def __setstate__(self, state: dict):
|
|
48
|
+
self._init_c()
|
|
49
|
+
for key, value in state.items():
|
|
50
|
+
setattr(self, key, value)
|
|
51
|
+
|
|
52
|
+
#def __eq__(self, other):
|
|
53
|
+
# a = []
|
|
54
|
+
# for key in self._computed_attributes:
|
|
55
|
+
# a.append(getattr(self, key) == getattr(other, key))
|
|
56
|
+
# return isinstance(other, type(self)) and all(a)
|
rameau/core/_utils.py
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Copyright 2025, BRGM
|
|
2
|
+
#
|
|
3
|
+
# This file is part of Rameau.
|
|
4
|
+
#
|
|
5
|
+
# Rameau is free software: you can redistribute it and/or modify it under the
|
|
6
|
+
# terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
# version.
|
|
9
|
+
#
|
|
10
|
+
# Rameau is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
11
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
12
|
+
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU General Public License along with
|
|
15
|
+
# Rameau. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
#
|
|
17
|
+
import datetime
|
|
18
|
+
import functools
|
|
19
|
+
from rameau.core import Parameter
|
|
20
|
+
|
|
21
|
+
class _FloatDescriptor():
|
|
22
|
+
"""
|
|
23
|
+
Float descriptor.
|
|
24
|
+
"""
|
|
25
|
+
def __init__(self, id):
|
|
26
|
+
self._id = id
|
|
27
|
+
|
|
28
|
+
def __get__(self, instance, type=None) -> float:
|
|
29
|
+
return instance._m.getFloat(self._id)
|
|
30
|
+
|
|
31
|
+
def __set__(self, instance, value) -> None:
|
|
32
|
+
instance._m.setFloat(value, self._id)
|
|
33
|
+
|
|
34
|
+
# Decorator of getter property
|
|
35
|
+
# Convert C++ subclass in Python class
|
|
36
|
+
def wrap_property(cls):
|
|
37
|
+
def decorator(func):
|
|
38
|
+
@functools.wraps(func) # Needed for correct docstring in sphinx
|
|
39
|
+
def factory(self, *args, **kwargs):
|
|
40
|
+
b = cls.__new__(cls)
|
|
41
|
+
b._m = func(self, *args, **kwargs)
|
|
42
|
+
return b
|
|
43
|
+
|
|
44
|
+
# inherit docstring
|
|
45
|
+
factory.__doc__ = func.__doc__
|
|
46
|
+
|
|
47
|
+
return factory
|
|
48
|
+
return decorator
|
|
49
|
+
|
|
50
|
+
def _get_datetime(func):
|
|
51
|
+
def factory(self, *args):
|
|
52
|
+
v = func(self, *args)
|
|
53
|
+
toto = datetime.datetime(
|
|
54
|
+
v["year"], v["month"], v["day"],
|
|
55
|
+
v["hour"], v["minute"], v["second"]
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
if toto == datetime.datetime(9999, 12 ,31):
|
|
59
|
+
return
|
|
60
|
+
return toto
|
|
61
|
+
return factory
|
|
62
|
+
|
|
63
|
+
def _set_datetime(func):
|
|
64
|
+
def factory(self, v):
|
|
65
|
+
if v == None:
|
|
66
|
+
v = datetime.datetime(9999, 12 ,31)
|
|
67
|
+
_check_datetime(v)
|
|
68
|
+
v2 = {
|
|
69
|
+
"year":v.year, "month":v.month, "day":v.day,
|
|
70
|
+
"hour":v.hour, "minute":v.minute, "second":v.second
|
|
71
|
+
}
|
|
72
|
+
func(self, v2)
|
|
73
|
+
return factory
|
|
74
|
+
|
|
75
|
+
# rsetattr and rgetattr from :
|
|
76
|
+
# https://stackoverflow.com/questions/31174295/getattr-and-setattr-on-nested-subobjects-chained-properties/31174427#31174427
|
|
77
|
+
def rsetattr(obj, attr, val):
|
|
78
|
+
pre, _, post = attr.rpartition('.')
|
|
79
|
+
return setattr(rgetattr(obj, pre) if pre else obj, post, val)
|
|
80
|
+
|
|
81
|
+
def rgetattr(obj, attr, *args):
|
|
82
|
+
def _getattr(obj, attr):
|
|
83
|
+
return getattr(obj, attr, *args)
|
|
84
|
+
return functools.reduce(_getattr, [obj] + attr.split('.'))
|
|
85
|
+
|
|
86
|
+
def _raise_type_error(var):
|
|
87
|
+
raise TypeError(f"Type {type(var)} not allowed.")
|
|
88
|
+
|
|
89
|
+
def _build_parameter(var):
|
|
90
|
+
if isinstance(var, float) or isinstance(var, int):
|
|
91
|
+
return Parameter(value=var)
|
|
92
|
+
else:
|
|
93
|
+
return _build_type(var, Parameter)
|
|
94
|
+
|
|
95
|
+
def _build_type(var, Partype):
|
|
96
|
+
if isinstance(var, dict):
|
|
97
|
+
svar = Partype(**var)
|
|
98
|
+
return svar
|
|
99
|
+
elif isinstance(var, Partype):
|
|
100
|
+
svar = var
|
|
101
|
+
return svar
|
|
102
|
+
else:
|
|
103
|
+
_raise_type_error(var)
|
|
104
|
+
|
|
105
|
+
def _check_literal(val, auths):
|
|
106
|
+
if isinstance(val, str):
|
|
107
|
+
if val not in auths:
|
|
108
|
+
raise ValueError(f"Value {val} not allowed.")
|
|
109
|
+
else:
|
|
110
|
+
_raise_type_error(val)
|
|
111
|
+
|
|
112
|
+
def _check_datetime(val):
|
|
113
|
+
if not isinstance(val, datetime.datetime):
|
|
114
|
+
_raise_type_error(val)
|
|
115
|
+
|
|
116
|
+
def _check_bool(val):
|
|
117
|
+
if not isinstance(val, bool):
|
|
118
|
+
_raise_type_error(val)
|
|
119
|
+
|
|
120
|
+
def _check_str(val):
|
|
121
|
+
if not isinstance(val, str):
|
|
122
|
+
_raise_type_error(val)
|
|
123
|
+
|
|
124
|
+
def _check_scalar(val):
|
|
125
|
+
if not isinstance(val, (int, float)):
|
|
126
|
+
_raise_type_error(val)
|
|
127
|
+
|
|
128
|
+
def _check_timedelta(val):
|
|
129
|
+
if not isinstance(val, datetime.timedelta):
|
|
130
|
+
_raise_type_error(val)
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Copyright 2025, BRGM
|
|
2
|
+
#
|
|
3
|
+
# This file is part of Rameau.
|
|
4
|
+
#
|
|
5
|
+
# Rameau is free software: you can redistribute it and/or modify it under the
|
|
6
|
+
# terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
# version.
|
|
9
|
+
#
|
|
10
|
+
# Rameau is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
11
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
12
|
+
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU General Public License along with
|
|
15
|
+
# Rameau. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
#
|
|
17
|
+
"""
|
|
18
|
+
Correction parameters.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from rameau.wrapper import CCorrection
|
|
22
|
+
|
|
23
|
+
from rameau.core import Parameter
|
|
24
|
+
from rameau.core._abstract_wrapper import AbstractWrapper
|
|
25
|
+
|
|
26
|
+
from rameau._typing import ParameterType
|
|
27
|
+
from rameau.core._utils import _build_parameter, wrap_property
|
|
28
|
+
|
|
29
|
+
class CorrectionParameters(AbstractWrapper):
|
|
30
|
+
"""Correction parameters.
|
|
31
|
+
|
|
32
|
+
Parameters
|
|
33
|
+
----------
|
|
34
|
+
area: `float` or `dict` or `Parameter`, optional
|
|
35
|
+
Factor correcting the drainage area of the watershed (-). Should be
|
|
36
|
+
optimised only when drainage area is poorly known (e.g. loss in karstic
|
|
37
|
+
watershed, multiple watershed outlets, water source supply).
|
|
38
|
+
|
|
39
|
+
pet: `float` or `dict` or `Parameter`, optional
|
|
40
|
+
|PET| correction factor (%) designed to compensate for any poor
|
|
41
|
+
representativeness of observed |PET| data obtained from scattered
|
|
42
|
+
meteorological stations. This correction is applied to all time steps.
|
|
43
|
+
|
|
44
|
+
rainfall: `float` or `dict` or `Parameter`, optional
|
|
45
|
+
Rainfall correction factor (%) designed to compensate for any poor
|
|
46
|
+
representativeness of observed rainfall data obtained from scattered
|
|
47
|
+
meteorological stations. This correction is applied both to liquid and
|
|
48
|
+
solid precipitation at all time steps. Should be optimised only when
|
|
49
|
+
rainfall is poorly known (e.g. mountainous areas).
|
|
50
|
+
|
|
51
|
+
Returns
|
|
52
|
+
-------
|
|
53
|
+
`CorrectionParameters`
|
|
54
|
+
|
|
55
|
+
Notes
|
|
56
|
+
-----
|
|
57
|
+
The |PET| correction coefficient also takes into account cultural factors
|
|
58
|
+
defining maximum evaporation at a given vegetative stage.
|
|
59
|
+
|
|
60
|
+
Examples
|
|
61
|
+
--------
|
|
62
|
+
|
|
63
|
+
To multiply the drainage area by 1.2 and to increase |PET| by 5% at
|
|
64
|
+
all time steps:
|
|
65
|
+
|
|
66
|
+
>>> area = rm.Parameter(value=0.2)
|
|
67
|
+
>>> pet = dict(value=5)
|
|
68
|
+
>>> corrections = rm.CorrectionParameters(area=area, pet=pet)
|
|
69
|
+
>>> round(corrections.area.value, 6)
|
|
70
|
+
0.2
|
|
71
|
+
>>> corrections.pet.value
|
|
72
|
+
5.0
|
|
73
|
+
|
|
74
|
+
To optimise the correction coefficient of drainage area between 0.3 and 3:
|
|
75
|
+
|
|
76
|
+
>>> area = rm.Parameter(lower=0.3, upper=3, opti=True)
|
|
77
|
+
>>> corrections = rm.CorrectionParameters(area=area)
|
|
78
|
+
>>> corrections.area.opti
|
|
79
|
+
True
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
_computed_attributes = "area", "pet", "rainfall"
|
|
83
|
+
_c_class = CCorrection
|
|
84
|
+
|
|
85
|
+
def __init__(
|
|
86
|
+
self,
|
|
87
|
+
area: ParameterType = None,
|
|
88
|
+
pet: ParameterType = None,
|
|
89
|
+
rainfall: ParameterType = None,
|
|
90
|
+
) -> None:
|
|
91
|
+
self._init_c()
|
|
92
|
+
|
|
93
|
+
if area is not None:
|
|
94
|
+
self.area = _build_parameter(area)
|
|
95
|
+
if pet is not None:
|
|
96
|
+
self.pet = _build_parameter(pet)
|
|
97
|
+
if rainfall is not None:
|
|
98
|
+
self.rainfall = _build_parameter(rainfall)
|
|
99
|
+
|
|
100
|
+
@property
|
|
101
|
+
@wrap_property(Parameter)
|
|
102
|
+
def area(self) -> Parameter:
|
|
103
|
+
"""Factor correcting the drainage area of the watershed (-).
|
|
104
|
+
|
|
105
|
+
Returns
|
|
106
|
+
-------
|
|
107
|
+
`Parameter`
|
|
108
|
+
"""
|
|
109
|
+
return self._m.getArea()
|
|
110
|
+
|
|
111
|
+
@area.setter
|
|
112
|
+
def area(self, v: Parameter) -> None:
|
|
113
|
+
self._m.setArea(v._m)
|
|
114
|
+
|
|
115
|
+
@property
|
|
116
|
+
@wrap_property(Parameter)
|
|
117
|
+
def pet(self):
|
|
118
|
+
"""|PET| correction factor (%).
|
|
119
|
+
|
|
120
|
+
Returns
|
|
121
|
+
-------
|
|
122
|
+
`Parameter`
|
|
123
|
+
"""
|
|
124
|
+
return self._m.getPet()
|
|
125
|
+
|
|
126
|
+
@pet.setter
|
|
127
|
+
def pet(self, v: Parameter) -> None:
|
|
128
|
+
self._m.setPet(v._m)
|
|
129
|
+
|
|
130
|
+
@property
|
|
131
|
+
@wrap_property(Parameter)
|
|
132
|
+
def rainfall(self):
|
|
133
|
+
"""Rainfall correction factor (%).
|
|
134
|
+
|
|
135
|
+
Returns
|
|
136
|
+
-------
|
|
137
|
+
`Parameter`
|
|
138
|
+
"""
|
|
139
|
+
return self._m.getRainfall()
|
|
140
|
+
|
|
141
|
+
@rainfall.setter
|
|
142
|
+
def rainfall(self, v: Parameter) -> None:
|
|
143
|
+
self._m.setRainfall(v._m)
|
rameau/core/files.py
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# Copyright 2025, BRGM
|
|
2
|
+
#
|
|
3
|
+
# This file is part of Rameau.
|
|
4
|
+
#
|
|
5
|
+
# Rameau is free software: you can redistribute it and/or modify it under the
|
|
6
|
+
# terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
# version.
|
|
9
|
+
#
|
|
10
|
+
# Rameau is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
11
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
12
|
+
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU General Public License along with
|
|
15
|
+
# Rameau. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
#
|
|
17
|
+
"""
|
|
18
|
+
File paths.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from rameau.wrapper import CFiles
|
|
22
|
+
|
|
23
|
+
from rameau.core._abstract_wrapper import AbstractWrapper
|
|
24
|
+
|
|
25
|
+
class FilePaths(AbstractWrapper):
|
|
26
|
+
"""File paths.
|
|
27
|
+
|
|
28
|
+
Parameters
|
|
29
|
+
----------
|
|
30
|
+
rainfall : `str`, optional
|
|
31
|
+
Path to rainfall data file.
|
|
32
|
+
|
|
33
|
+
pet : `str`, optional
|
|
34
|
+
Path to |PET| data file.
|
|
35
|
+
|
|
36
|
+
temperature : `str`, optional
|
|
37
|
+
Path to temperature data file.
|
|
38
|
+
|
|
39
|
+
snow : `str`, optional
|
|
40
|
+
Path to snow data file.
|
|
41
|
+
|
|
42
|
+
riverobs : `str`, optional
|
|
43
|
+
Path to river flow observation data file.
|
|
44
|
+
|
|
45
|
+
groundwaterobs : `str`, optional
|
|
46
|
+
Path to groundwater level observation data file.
|
|
47
|
+
|
|
48
|
+
riverpumping : `str`, optional
|
|
49
|
+
path to river pumping data file.
|
|
50
|
+
|
|
51
|
+
groundwaterpumping : `str`, optional
|
|
52
|
+
path to groundwater pumping data file.
|
|
53
|
+
|
|
54
|
+
tree : `str`, optional
|
|
55
|
+
Path to tree connection CSV file.
|
|
56
|
+
|
|
57
|
+
states : str, optional
|
|
58
|
+
Path to model states file.
|
|
59
|
+
|
|
60
|
+
Returns
|
|
61
|
+
-------
|
|
62
|
+
`FilePaths`
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
_computed_attributes = (
|
|
66
|
+
"rainfall", "pet", "temperature",
|
|
67
|
+
"snow", "riverobs", "riverpumping",
|
|
68
|
+
"groundwaterobs", "groundwaterpumping",
|
|
69
|
+
"tree", "states"
|
|
70
|
+
)
|
|
71
|
+
_c_class = CFiles
|
|
72
|
+
|
|
73
|
+
def __init__(
|
|
74
|
+
self,
|
|
75
|
+
rainfall: str = '',
|
|
76
|
+
pet: str = '',
|
|
77
|
+
temperature: str = '',
|
|
78
|
+
snow: str = '',
|
|
79
|
+
riverobs: str = '',
|
|
80
|
+
riverpumping: str = '',
|
|
81
|
+
groundwaterobs: str ='',
|
|
82
|
+
groundwaterpumping: str = '',
|
|
83
|
+
tree: str = '',
|
|
84
|
+
states: str =''
|
|
85
|
+
) -> None:
|
|
86
|
+
self._init_c()
|
|
87
|
+
|
|
88
|
+
self.rainfall = rainfall
|
|
89
|
+
self.pet = pet
|
|
90
|
+
self.snow = snow
|
|
91
|
+
self.temperature = temperature
|
|
92
|
+
self.tree = tree
|
|
93
|
+
self.riverobs = riverobs
|
|
94
|
+
self.riverpumping = riverpumping
|
|
95
|
+
self.groundwaterobs = groundwaterobs
|
|
96
|
+
self.groundwaterpumping = groundwaterpumping
|
|
97
|
+
self.states = states
|
|
98
|
+
|
|
99
|
+
@property
|
|
100
|
+
def rainfall(self):
|
|
101
|
+
return self._m.getRainfall()
|
|
102
|
+
|
|
103
|
+
@rainfall.setter
|
|
104
|
+
def rainfall(self, v: str):
|
|
105
|
+
self._m.setRainfall(v)
|
|
106
|
+
|
|
107
|
+
@property
|
|
108
|
+
def pet(self):
|
|
109
|
+
return self._m.getPet()
|
|
110
|
+
|
|
111
|
+
@pet.setter
|
|
112
|
+
def pet(self, v: str):
|
|
113
|
+
self._m.setPet(v)
|
|
114
|
+
|
|
115
|
+
@property
|
|
116
|
+
def snow(self):
|
|
117
|
+
return self._m.getSnow()
|
|
118
|
+
|
|
119
|
+
@snow.setter
|
|
120
|
+
def snow(self, v: str):
|
|
121
|
+
self._m.setSnow(v)
|
|
122
|
+
|
|
123
|
+
@property
|
|
124
|
+
def temperature(self):
|
|
125
|
+
return self._m.getTemperature()
|
|
126
|
+
|
|
127
|
+
@temperature.setter
|
|
128
|
+
def temperature(self, v: str):
|
|
129
|
+
self._m.setTemperature(v)
|
|
130
|
+
|
|
131
|
+
@property
|
|
132
|
+
def riverobs(self):
|
|
133
|
+
return self._m.getRiverobs()
|
|
134
|
+
|
|
135
|
+
@riverobs.setter
|
|
136
|
+
def riverobs(self, v: str):
|
|
137
|
+
self._m.setRiverobs(v)
|
|
138
|
+
|
|
139
|
+
@property
|
|
140
|
+
def riverpumping(self):
|
|
141
|
+
return self._m.getRiverpumping()
|
|
142
|
+
|
|
143
|
+
@riverpumping.setter
|
|
144
|
+
def riverpumping(self, v: str):
|
|
145
|
+
self._m.setRiverpumping(v)
|
|
146
|
+
|
|
147
|
+
@property
|
|
148
|
+
def groundwaterobs(self):
|
|
149
|
+
return self._m.getGroundwaterobs()
|
|
150
|
+
|
|
151
|
+
@groundwaterobs.setter
|
|
152
|
+
def groundwaterobs(self, v: str):
|
|
153
|
+
self._m.setGroundwaterobs(v)
|
|
154
|
+
|
|
155
|
+
@property
|
|
156
|
+
def groundwaterpumping(self):
|
|
157
|
+
return self._m.getGroundwaterpumping()
|
|
158
|
+
|
|
159
|
+
@groundwaterpumping.setter
|
|
160
|
+
def groundwaterpumping(self, v: str):
|
|
161
|
+
self._m.setGroundwaterpumping(v)
|
|
162
|
+
|
|
163
|
+
@property
|
|
164
|
+
def tree(self):
|
|
165
|
+
return self._m.getTree()
|
|
166
|
+
|
|
167
|
+
@tree.setter
|
|
168
|
+
def tree(self, v: str):
|
|
169
|
+
self._m.setTree(v)
|
|
170
|
+
|
|
171
|
+
@property
|
|
172
|
+
def states(self):
|
|
173
|
+
return self._m.getStates()
|
|
174
|
+
|
|
175
|
+
@states.setter
|
|
176
|
+
def states(self, v: str):
|
|
177
|
+
self._m.setStates(v)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Copyright 2025, BRGM
|
|
2
|
+
#
|
|
3
|
+
# This file is part of Rameau.
|
|
4
|
+
#
|
|
5
|
+
# Rameau is free software: you can redistribute it and/or modify it under the
|
|
6
|
+
# terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
# Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
# version.
|
|
9
|
+
#
|
|
10
|
+
# Rameau is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
11
|
+
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
12
|
+
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU General Public License along with
|
|
15
|
+
# Rameau. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
#
|
|
17
|
+
from rameau.core.forecast.forecast_parameter import ForecastParameter
|
|
18
|
+
from rameau.core.forecast.forecast_correction import ForecastCorrection
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
"ForecastParameter",
|
|
22
|
+
"ForecastCorrection"
|
|
23
|
+
]
|