Skip to content

Commit 515017f

Browse files
committed
Updated notebooks, added model verification nb
1 parent d12121f commit 515017f

3 files changed

Lines changed: 320 additions & 15 deletions

File tree

notebooks/run_model_in_notebook.ipynb

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"# path to config file\n",
4747
"path_to_config_file = \"path_to_config_file\"\n",
4848
"# Instantiate working directories handler from PyStemmusScope\n",
49-
"config = PyStemmusScope.read_config(path_to_config_file)"
49+
"config_template = PyStemmusScope.read_config(path_to_config_file)"
5050
]
5151
},
5252
{
@@ -79,7 +79,7 @@
7979
}
8080
],
8181
"source": [
82-
"config"
82+
"config_template"
8383
]
8484
},
8585
{
@@ -113,8 +113,8 @@
113113
],
114114
"source": [
115115
"# edit config\n",
116-
"config[\"NumberOfTimeSteps\"] = \"5\"\n",
117-
"config"
116+
"config_template[\"NumberOfTimeSteps\"] = \"5\"\n",
117+
"config_template"
118118
]
119119
},
120120
{
@@ -145,15 +145,20 @@
145145
"\n",
146146
"full_run = False\n",
147147
"if full_run:\n",
148-
" forcing_filenames_list = [file.name for file in Path(config[\"ForcingPath\"]).iterdir()]\n",
148+
" forcing_filenames_list = [file.name for file in Path(config_template[\"ForcingPath\"]).iterdir()]\n",
149149
"\n",
150150
"# empty dict to store path to config file and work directory for each station\n",
151151
"config_path_dict = {}\n",
152152
"input_dir_dict = {}\n",
153153
"for nc_file in forcing_filenames_list:\n",
154-
" input_dir, output_dir, config_path = PyStemmusScope.create_io_dir(nc_file, config)\n",
154+
" input_dir, output_dir, config_path = PyStemmusScope.create_io_dir(nc_file, config_template)\n",
155155
" config_path_dict[nc_file] = config_path\n",
156156
" input_dir_dict[nc_file] = input_dir\n",
157+
" \n",
158+
" config_run = PyStemmusScope.read_config(config_path)\n",
159+
"\n",
160+
" forcing_io.prepare_forcing(input_dir, Path(config_run[\"ForcingPath\"]) / nc_file, config_run)\n",
161+
" \n",
157162
" print(input_dir, output_dir, config_path)"
158163
]
159164
},
@@ -277,7 +282,7 @@
277282
"name": "python",
278283
"nbconvert_exporter": "python",
279284
"pygments_lexer": "ipython3",
280-
"version": "3.9.12"
285+
"version": "3.9.13"
281286
}
282287
},
283288
"nbformat": 4,

notebooks/run_model_in_notebook_dev.ipynb

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
"# path to config file\n",
9999
"path_to_config_file = \"path_to_config_file\"\n",
100100
"# Instantiate working directories handler from PyStemmusScope\n",
101-
"config = PyStemmusScope.read_config(path_to_config_file)"
101+
"config_template = PyStemmusScope.read_config(path_to_config_file)"
102102
]
103103
},
104104
{
@@ -131,7 +131,7 @@
131131
}
132132
],
133133
"source": [
134-
"config"
134+
"config_template"
135135
]
136136
},
137137
{
@@ -165,8 +165,8 @@
165165
],
166166
"source": [
167167
"# edit config\n",
168-
"config[\"NumberOfTimeSteps\"] = \"5\"\n",
169-
"config"
168+
"config_template[\"NumberOfTimeSteps\"] = \"5\"\n",
169+
"config_template"
170170
]
171171
},
172172
{
@@ -191,9 +191,20 @@
191191
],
192192
"source": [
193193
"# specify the forcing filename\n",
194-
"forcing_filename = config[\"ForcingFileName\"]\n",
195-
"input_dir, output_dir, config_path = PyStemmusScope.create_io_dir(forcing_filename, config)\n",
196-
"print(input_dir, output_dir, config_path)"
194+
"forcing_filename = config_template[\"ForcingFileName\"]\n",
195+
"input_dir, output_dir, config_run_path = PyStemmusScope.create_io_dir(forcing_filename, config_template)\n",
196+
"print(input_dir, output_dir, config_run_path)"
197+
]
198+
},
199+
{
200+
"cell_type": "code",
201+
"execution_count": null,
202+
"metadata": {},
203+
"outputs": [],
204+
"source": [
205+
"config_run = PyStemmusScope.read_config(config_run_path)\n",
206+
"# Generate the forcing input data for STEMMUS_SCOPE\n",
207+
"forcing_io.prepare_forcing(input_dir, Path(config_run[\"ForcingPath\"]) / forcing_filename, config_run)"
197208
]
198209
},
199210
{
@@ -379,7 +390,7 @@
379390
"name": "python",
380391
"nbconvert_exporter": "python",
381392
"pygments_lexer": "ipython3",
382-
"version": "3.9.12"
393+
"version": "3.9.13"
383394
},
384395
"metadata": {
385396
"interpreter": {

0 commit comments

Comments
 (0)