smashbox 1.0__py2.py3-none-any.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.
- smashbox/.spyproject/config/backups/codestyle.ini.bak +8 -0
- smashbox/.spyproject/config/backups/encoding.ini.bak +6 -0
- smashbox/.spyproject/config/backups/vcs.ini.bak +7 -0
- smashbox/.spyproject/config/backups/workspace.ini.bak +12 -0
- smashbox/.spyproject/config/codestyle.ini +8 -0
- smashbox/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini +5 -0
- smashbox/.spyproject/config/defaults/defaults-encoding-0.2.0.ini +3 -0
- smashbox/.spyproject/config/defaults/defaults-vcs-0.2.0.ini +4 -0
- smashbox/.spyproject/config/defaults/defaults-workspace-0.2.0.ini +6 -0
- smashbox/.spyproject/config/encoding.ini +6 -0
- smashbox/.spyproject/config/vcs.ini +7 -0
- smashbox/.spyproject/config/workspace.ini +12 -0
- smashbox/__init__.py +8 -0
- smashbox/asset/flwdir/flowdir_fr_1000m.tif +0 -0
- smashbox/asset/outlets/.Rhistory +0 -0
- smashbox/asset/outlets/db_bnbv_fr.csv +142704 -0
- smashbox/asset/outlets/db_bnbv_light.csv +42084 -0
- smashbox/asset/outlets/db_sites.csv +8700 -0
- smashbox/asset/outlets/db_stations.csv +2916 -0
- smashbox/asset/outlets/db_stations_example.csv +19 -0
- smashbox/asset/outlets/edit_database.py +185 -0
- smashbox/asset/outlets/readme.txt +5 -0
- smashbox/asset/params/ci.tif +0 -0
- smashbox/asset/params/cp.tif +0 -0
- smashbox/asset/params/ct.tif +0 -0
- smashbox/asset/params/kexc.tif +0 -0
- smashbox/asset/params/kmlt.tif +0 -0
- smashbox/asset/params/llr.tif +0 -0
- smashbox/asset/setup/setup_rhax_gr4_dt3600.yaml +15 -0
- smashbox/asset/setup/setup_rhax_gr4_dt900.yaml +15 -0
- smashbox/asset/setup/setup_rhax_gr5_dt3600.yaml +15 -0
- smashbox/asset/setup/setup_rhax_gr5_dt900.yaml +15 -0
- smashbox/init/README.md +3 -0
- smashbox/init/__init__.py +3 -0
- smashbox/init/multimodel_statistics.py +405 -0
- smashbox/init/param.py +799 -0
- smashbox/init/smashbox.py +186 -0
- smashbox/model/__init__.py +1 -0
- smashbox/model/atmos_data_connector.py +518 -0
- smashbox/model/mesh.py +185 -0
- smashbox/model/model.py +829 -0
- smashbox/model/setup.py +109 -0
- smashbox/plot/__init__.py +1 -0
- smashbox/plot/myplot.py +1133 -0
- smashbox/plot/plot.py +1662 -0
- smashbox/read_inputdata/__init__.py +1 -0
- smashbox/read_inputdata/read_data.py +1229 -0
- smashbox/read_inputdata/smashmodel.py +395 -0
- smashbox/stats/__init__.py +1 -0
- smashbox/stats/mystats.py +1632 -0
- smashbox/stats/stats.py +2022 -0
- smashbox/test.py +532 -0
- smashbox/test_average_stats.py +122 -0
- smashbox/test_mesh.r +8 -0
- smashbox/test_mesh_from_graffas.py +69 -0
- smashbox/tools/__init__.py +1 -0
- smashbox/tools/geo_toolbox.py +1028 -0
- smashbox/tools/tools.py +461 -0
- smashbox/tutorial_R.r +182 -0
- smashbox/tutorial_R_graffas.r +88 -0
- smashbox/tutorial_R_graffas_local.r +33 -0
- smashbox/tutorial_python.py +102 -0
- smashbox/tutorial_readme.py +261 -0
- smashbox/tutorial_report.py +58 -0
- smashbox/tutorials/Python_tutorial.md +124 -0
- smashbox/tutorials/R_Graffas_tutorial.md +153 -0
- smashbox/tutorials/R_tutorial.md +121 -0
- smashbox/tutorials/__init__.py +6 -0
- smashbox/tutorials/generate_doc.md +7 -0
- smashbox-1.0.dist-info/METADATA +998 -0
- smashbox-1.0.dist-info/RECORD +73 -0
- smashbox-1.0.dist-info/WHEEL +5 -0
- smashbox-1.0.dist-info/licenses/LICENSE +100 -0
smashbox/model/setup.py
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import yaml
|
|
2
|
+
import os
|
|
3
|
+
from smashbox.tools.tools import check_asset_path, print_tree
|
|
4
|
+
from smashbox.init import param
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class setup:
|
|
8
|
+
"""The class setup stores the Smash model setup and functions to manipulate
|
|
9
|
+
the setup"""
|
|
10
|
+
|
|
11
|
+
def __init__(self, param: param = None):
|
|
12
|
+
|
|
13
|
+
self.setup = None
|
|
14
|
+
"""The smash model setup"""
|
|
15
|
+
|
|
16
|
+
self._setup_file = None
|
|
17
|
+
"""The preconfigured setup file to use."""
|
|
18
|
+
|
|
19
|
+
self._param = param
|
|
20
|
+
"""The easy smash parameters src.param.param"""
|
|
21
|
+
|
|
22
|
+
if param.setup_file is not None:
|
|
23
|
+
self._setup_file = param.setup_file
|
|
24
|
+
else:
|
|
25
|
+
self._setup_file = os.path.join(
|
|
26
|
+
self._param.asset_dir, "setup", "setup_rhax_gr4_dt3600.yaml"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
self.load_setup(self._setup_file)
|
|
30
|
+
|
|
31
|
+
@property
|
|
32
|
+
def setup_file(self):
|
|
33
|
+
"""The current selected setup file in the preconfigured list."""
|
|
34
|
+
return self._setup_file
|
|
35
|
+
|
|
36
|
+
@setup_file.setter
|
|
37
|
+
def setup_file(self, value: os.PathLike):
|
|
38
|
+
"""Set and load the a preconfigured setup file."""
|
|
39
|
+
self._setup_file = check_asset_path("setup", value)
|
|
40
|
+
self.load_setup(self._setup_file)
|
|
41
|
+
|
|
42
|
+
def list_available_setup(self):
|
|
43
|
+
"""List available preconfigured setup"""
|
|
44
|
+
print_tree(os.path.join(self._param.asset_dir, "setup"))
|
|
45
|
+
|
|
46
|
+
def set_setup(self, attr: str | None = None, value: any = None):
|
|
47
|
+
"""
|
|
48
|
+
Change the value of an attribute of the setup in setup.setup.
|
|
49
|
+
:param attr: Name of the attribute, defaults to None
|
|
50
|
+
:type attr: str | None, optional
|
|
51
|
+
:param value: value of the attribute, defaults to None
|
|
52
|
+
:type value: any, optional
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
if attr is not None:
|
|
56
|
+
self.setup.update({attr: value})
|
|
57
|
+
|
|
58
|
+
def get_setup(self, attr: str | None = None):
|
|
59
|
+
"""
|
|
60
|
+
Get the value of an attribute in setup.setup
|
|
61
|
+
:param attr: name of the attribute, defaults to None
|
|
62
|
+
:type attr: str | None, optional
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
if attr in self.setup.keys():
|
|
66
|
+
return self.setup["attr"]
|
|
67
|
+
else:
|
|
68
|
+
raise ValueError(f"attribute '{attr}' not found in setup.")
|
|
69
|
+
|
|
70
|
+
def update_setup(self, options: dict = {}):
|
|
71
|
+
"""
|
|
72
|
+
Update the value of the setup with a dictionnary.
|
|
73
|
+
:param options: Dictionnary with some setup options, defaults to {}
|
|
74
|
+
"""
|
|
75
|
+
|
|
76
|
+
self.setup.update(options)
|
|
77
|
+
|
|
78
|
+
def load_setup(self, filename: os.PathLike = None):
|
|
79
|
+
"""
|
|
80
|
+
Load an existing setup file (.yaml)
|
|
81
|
+
:param filename: Path to the setup file, defaults to None
|
|
82
|
+
:type filename: : os.PathLike, optional
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
filename = check_asset_path(
|
|
86
|
+
os.path.join(self._param.asset_dir, "setup"), filename
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
if os.path.exists(filename):
|
|
90
|
+
|
|
91
|
+
with open(filename, "r") as file:
|
|
92
|
+
|
|
93
|
+
self.setup = yaml.safe_load(file)
|
|
94
|
+
|
|
95
|
+
self._setup_file = filename
|
|
96
|
+
|
|
97
|
+
else:
|
|
98
|
+
raise ValueError(f"{filename} does not exist.")
|
|
99
|
+
|
|
100
|
+
def write_setup(self, filename: os.PathLike = None):
|
|
101
|
+
"""
|
|
102
|
+
Write the setup to a file
|
|
103
|
+
:param filename: Path to the file
|
|
104
|
+
:type filename: os.PathLike
|
|
105
|
+
"""
|
|
106
|
+
|
|
107
|
+
with open(filename, "w") as file:
|
|
108
|
+
|
|
109
|
+
yaml.dump(self.setup, file)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|