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,186 @@
1
+ from smashbox.init import param
2
+ from smashbox.model import model
3
+ from smashbox.stats import mystats
4
+ from smashbox.plot import myplot
5
+ from smashbox.init import multimodel_statistics
6
+ import smashbox
7
+
8
+ import os
9
+ import shutil
10
+ import copy
11
+
12
+
13
+ class SmashBox:
14
+ """
15
+ Main class which store main parameters 'myparam' and functions to create or delete
16
+ models.
17
+ """
18
+
19
+ def __init__(self):
20
+
21
+ if not os.path.exists(
22
+ os.path.join(os.path.expanduser("~"), ".smashbox", "asset")
23
+ ):
24
+ shutil.copytree(
25
+ os.path.join(smashbox.__path__[0], "asset"),
26
+ os.path.join(os.path.expanduser("~"), ".smashbox", "asset"),
27
+ )
28
+
29
+ self.myparam = param.param()
30
+ if os.path.exists(
31
+ os.path.join(os.path.expanduser("~"), ".smashbox", "param.yaml")
32
+ ):
33
+ self.myparam.load_param(
34
+ os.path.join(os.path.expanduser("~"), ".smashbox", "default_param.yaml")
35
+ )
36
+ else:
37
+ self.myparam.write_param(
38
+ os.path.join(os.path.expanduser("~"), ".smashbox", "default_param.yaml")
39
+ )
40
+
41
+ def help(self):
42
+ """Display help..."""
43
+
44
+ print("! Welcome to SmashBox !")
45
+ print(
46
+ "First of all, you must configure main parameters stored in 'myparam' attribute."
47
+ )
48
+ print(
49
+ " - self.myparam.list_param() : list all parameters to configure in self.myparam.param."
50
+ )
51
+ print(" - self.myparam.set_param(attr, value) : set value to attribute attr.")
52
+ print(" - self.myparam.get_param(attr) : get the value of attribute attr.")
53
+ print(" - self.myparam.list_asset_files() : list data available with SmashBox.")
54
+ print(" - self.myparam.param : attribute which contains all parameters.")
55
+ print("")
56
+ print("When ready, you will able to create a new model attribute:")
57
+ print(" - self.newmodel('mymodel')")
58
+ print("")
59
+ print(
60
+ "After the model 'mymodel' has been created, you can adjust the model setup 'self.mymodel.mysetup':"
61
+ )
62
+ print(" - self.mymodel.mysetup.setup: dictionnary which contain the setup")
63
+ print(
64
+ " - self.mymodel.mysetup.list_available_setup(): list preconfigured and ready to use setup in SmashBox"
65
+ )
66
+ print(
67
+ " - self.mymodel.mysetup.update_setup(dict): update the smash setup with the input dictionary dict."
68
+ )
69
+ print("")
70
+ print(
71
+ "When ready, you will be able to create the mesh, the Smash model and run a simulation:"
72
+ )
73
+ print(" - self.mymodel.make_mesh()")
74
+ print(" - self.mymodel.make_model()")
75
+
76
+ def newmodel(self, name="mymodel"):
77
+ """
78
+ Create a new model attribute. This attribute will handle meshing, hydrological modelisation, plot and stattistics.
79
+
80
+ Parameters
81
+ ----------
82
+
83
+ name : str
84
+ The name of the attribute.
85
+
86
+ Examples
87
+ --------
88
+
89
+ >>> es=smashbox.SmashBox()
90
+ >>> sb.newmodel("RealCollobrier")
91
+
92
+ """
93
+ if not hasattr(self, name):
94
+
95
+ setattr(self, name, model.model(self.myparam))
96
+
97
+ else:
98
+ raise ValueError(
99
+ f"Error: Cannot create model '{name}', model attribute '{name}' already exist"
100
+ )
101
+
102
+ if not hasattr(self, "multimodel_statistics"):
103
+
104
+ setattr(
105
+ self, "multimodel_statistics", multimodel_statistics.multimodel_statistics(self)
106
+ )
107
+
108
+ def delmodel(self, modelname):
109
+ """
110
+ Delete a model attribute.
111
+
112
+ Parameters
113
+ ----------
114
+
115
+ modelname : str
116
+ The name of the attribute to delete.
117
+
118
+ Examples
119
+ --------
120
+
121
+ >>> es=smashbox.SmashBox()
122
+ >>> sb.newmodel("RealCollobrier")
123
+ >>> sb.delmodel("RealCollobrier")
124
+
125
+ """
126
+ if hasattr(self, modelname) and isinstance(getattr(self, modelname), model.model):
127
+ delattr(self, modelname)
128
+
129
+ else:
130
+
131
+ raise ValueError(f"Error: {modelname} is not a valid model name.")
132
+
133
+ def copymodel(self, modelsource, modelname):
134
+ """
135
+ Copy a model contener
136
+
137
+ Parameters
138
+ ----------
139
+
140
+ modelsource : str
141
+ The name of the source model attribute
142
+ modelname : str
143
+ The name of the new model attribute.
144
+
145
+ Examples
146
+ --------
147
+
148
+ >>> es=smashbox.SmashBox()
149
+ >>> sb.newmodel("RealCollobrier")
150
+ >>> sb.copymodel("RealCollobrier", RealCollobrier2")
151
+ """
152
+ if not hasattr(self, modelsource):
153
+ raise ValueError(f"Error: Source model '{modelsource}' does not exist")
154
+
155
+ if not hasattr(self, modelname):
156
+
157
+ self.newmodel(modelname)
158
+
159
+ source = getattr(self, modelsource)
160
+ destination = getattr(self, modelname)
161
+
162
+ setattr(
163
+ destination,
164
+ "_myparam",
165
+ copy.deepcopy(getattr(source, "_myparam")),
166
+ )
167
+ setattr(destination, "mymesh", copy.deepcopy(getattr(source, "mymesh")))
168
+ setattr(destination, "mysetup", copy.deepcopy(getattr(source, "mysetup")))
169
+
170
+ else:
171
+ raise ValueError(
172
+ f"Error: Cannot copy model '{modelsource}', model attribute '{modelname}' already exist"
173
+ )
174
+
175
+ # get new model object
176
+ # mynewmodel = getattr(self, modelname)
177
+
178
+ # reset attributes
179
+ # mynewmodel.mysmashmodel = None
180
+ # mynewmodel.extra_smash_results = None
181
+ # mynewmodel._fstates = None
182
+ # mynewmodel._istates = None
183
+ # mynewmodel._myatmos_data_connector = None
184
+ # mynewmodel.warmup_model = None
185
+ # mynewmodel.mystats = mystats.mystats(self)
186
+ # mynewmodel.myplot = myplot.myplot(self)
@@ -0,0 +1 @@
1
+