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.
Files changed (73) hide show
  1. smashbox/.spyproject/config/backups/codestyle.ini.bak +8 -0
  2. smashbox/.spyproject/config/backups/encoding.ini.bak +6 -0
  3. smashbox/.spyproject/config/backups/vcs.ini.bak +7 -0
  4. smashbox/.spyproject/config/backups/workspace.ini.bak +12 -0
  5. smashbox/.spyproject/config/codestyle.ini +8 -0
  6. smashbox/.spyproject/config/defaults/defaults-codestyle-0.2.0.ini +5 -0
  7. smashbox/.spyproject/config/defaults/defaults-encoding-0.2.0.ini +3 -0
  8. smashbox/.spyproject/config/defaults/defaults-vcs-0.2.0.ini +4 -0
  9. smashbox/.spyproject/config/defaults/defaults-workspace-0.2.0.ini +6 -0
  10. smashbox/.spyproject/config/encoding.ini +6 -0
  11. smashbox/.spyproject/config/vcs.ini +7 -0
  12. smashbox/.spyproject/config/workspace.ini +12 -0
  13. smashbox/__init__.py +8 -0
  14. smashbox/asset/flwdir/flowdir_fr_1000m.tif +0 -0
  15. smashbox/asset/outlets/.Rhistory +0 -0
  16. smashbox/asset/outlets/db_bnbv_fr.csv +142704 -0
  17. smashbox/asset/outlets/db_bnbv_light.csv +42084 -0
  18. smashbox/asset/outlets/db_sites.csv +8700 -0
  19. smashbox/asset/outlets/db_stations.csv +2916 -0
  20. smashbox/asset/outlets/db_stations_example.csv +19 -0
  21. smashbox/asset/outlets/edit_database.py +185 -0
  22. smashbox/asset/outlets/readme.txt +5 -0
  23. smashbox/asset/params/ci.tif +0 -0
  24. smashbox/asset/params/cp.tif +0 -0
  25. smashbox/asset/params/ct.tif +0 -0
  26. smashbox/asset/params/kexc.tif +0 -0
  27. smashbox/asset/params/kmlt.tif +0 -0
  28. smashbox/asset/params/llr.tif +0 -0
  29. smashbox/asset/setup/setup_rhax_gr4_dt3600.yaml +15 -0
  30. smashbox/asset/setup/setup_rhax_gr4_dt900.yaml +15 -0
  31. smashbox/asset/setup/setup_rhax_gr5_dt3600.yaml +15 -0
  32. smashbox/asset/setup/setup_rhax_gr5_dt900.yaml +15 -0
  33. smashbox/init/README.md +3 -0
  34. smashbox/init/__init__.py +3 -0
  35. smashbox/init/multimodel_statistics.py +405 -0
  36. smashbox/init/param.py +799 -0
  37. smashbox/init/smashbox.py +186 -0
  38. smashbox/model/__init__.py +1 -0
  39. smashbox/model/atmos_data_connector.py +518 -0
  40. smashbox/model/mesh.py +185 -0
  41. smashbox/model/model.py +829 -0
  42. smashbox/model/setup.py +109 -0
  43. smashbox/plot/__init__.py +1 -0
  44. smashbox/plot/myplot.py +1133 -0
  45. smashbox/plot/plot.py +1662 -0
  46. smashbox/read_inputdata/__init__.py +1 -0
  47. smashbox/read_inputdata/read_data.py +1229 -0
  48. smashbox/read_inputdata/smashmodel.py +395 -0
  49. smashbox/stats/__init__.py +1 -0
  50. smashbox/stats/mystats.py +1632 -0
  51. smashbox/stats/stats.py +2022 -0
  52. smashbox/test.py +532 -0
  53. smashbox/test_average_stats.py +122 -0
  54. smashbox/test_mesh.r +8 -0
  55. smashbox/test_mesh_from_graffas.py +69 -0
  56. smashbox/tools/__init__.py +1 -0
  57. smashbox/tools/geo_toolbox.py +1028 -0
  58. smashbox/tools/tools.py +461 -0
  59. smashbox/tutorial_R.r +182 -0
  60. smashbox/tutorial_R_graffas.r +88 -0
  61. smashbox/tutorial_R_graffas_local.r +33 -0
  62. smashbox/tutorial_python.py +102 -0
  63. smashbox/tutorial_readme.py +261 -0
  64. smashbox/tutorial_report.py +58 -0
  65. smashbox/tutorials/Python_tutorial.md +124 -0
  66. smashbox/tutorials/R_Graffas_tutorial.md +153 -0
  67. smashbox/tutorials/R_tutorial.md +121 -0
  68. smashbox/tutorials/__init__.py +6 -0
  69. smashbox/tutorials/generate_doc.md +7 -0
  70. smashbox-1.0.dist-info/METADATA +998 -0
  71. smashbox-1.0.dist-info/RECORD +73 -0
  72. smashbox-1.0.dist-info/WHEEL +5 -0
  73. smashbox-1.0.dist-info/licenses/LICENSE +100 -0
@@ -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
+