Skip to content

Commit 8b14d43

Browse files
committed
Updated notebooks to include soil io routine
1 parent 1444c22 commit 8b14d43

3 files changed

Lines changed: 46 additions & 25 deletions

File tree

notebooks/run_model_in_notebook.ipynb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"from pathlib import Path\n",
1919
"import subprocess\n",
2020
"from PyStemmusScope import forcing_io\n",
21-
"from PyStemmusScope import iostreamer"
21+
"from PyStemmusScope import iostreamer\n",
22+
"from PyStemmusScope import soil_io"
2223
]
2324
},
2425
{
@@ -159,7 +160,7 @@
159160
" config_run = iostreamer.read_config(config_path)\n",
160161
"\n",
161162
" forcing_io.prepare_forcing(input_dir, Path(config_run[\"ForcingPath\"]) / nc_file, config_run)\n",
162-
" \n",
163+
" soil_io.prepare_soil_data(config_run['SoilPropertyPath'], input_dir, config_run)\n",
163164
" print(input_dir, output_dir, config_path)"
164165
]
165166
},

notebooks/run_model_in_notebook_dev.ipynb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"from pathlib import Path\n",
1919
"import subprocess\n",
2020
"from PyStemmusScope import forcing_io \n",
21-
"from PyStemmusScope import iostreamer"
21+
"from PyStemmusScope import iostreamer\n",
22+
"from PyStemmusScope import soil_io"
2223
]
2324
},
2425
{
@@ -205,7 +206,9 @@
205206
"source": [
206207
"config_run = iostreamer.read_config(config_run_path)\n",
207208
"# Generate the forcing input data for STEMMUS_SCOPE\n",
208-
"forcing_io.prepare_forcing(input_dir, Path(config_run[\"ForcingPath\"]) / forcing_filename, config_run)"
209+
"forcing_io.prepare_forcing(input_dir, Path(config_run[\"ForcingPath\"]) / forcing_filename, config_run)\n",
210+
"# Generate the soil parameter input data for STEMMUS_SCOPE\n",
211+
"soil_io.prepare_soil_data(config_run['SoilPropertyPath'], input_dir, config_run)"
209212
]
210213
},
211214
{

notebooks/verify_model_modifications.ipynb

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
{
1212
"cell_type": "code",
13-
"execution_count": 36,
13+
"execution_count": 3,
1414
"metadata": {},
1515
"outputs": [],
1616
"source": [
@@ -21,7 +21,8 @@
2121
"import matplotlib.pyplot as plt\n",
2222
"import xarray as xr\n",
2323
"from PyStemmusScope import forcing_io\n",
24-
"from PyStemmusScope import iostreamer"
24+
"from PyStemmusScope import iostreamer\n",
25+
"from PyStemmusScope import soil_io"
2526
]
2627
},
2728
{
@@ -33,12 +34,12 @@
3334
},
3435
{
3536
"cell_type": "code",
36-
"execution_count": 2,
37+
"execution_count": 4,
3738
"metadata": {},
3839
"outputs": [],
3940
"source": [
4041
"# path to model repository\n",
41-
"path_to_model = \"path to model repository\""
42+
"path_to_model = \"path to the stemmus scope model directory\""
4243
]
4344
},
4445
{
@@ -50,7 +51,7 @@
5051
},
5152
{
5253
"cell_type": "code",
53-
"execution_count": 3,
54+
"execution_count": 5,
5455
"metadata": {},
5556
"outputs": [],
5657
"source": [
@@ -63,7 +64,7 @@
6364
},
6465
{
6566
"cell_type": "code",
66-
"execution_count": 49,
67+
"execution_count": 6,
6768
"metadata": {},
6869
"outputs": [],
6970
"source": [
@@ -76,7 +77,7 @@
7677
},
7778
{
7879
"cell_type": "code",
79-
"execution_count": 50,
80+
"execution_count": 7,
8081
"metadata": {},
8182
"outputs": [],
8283
"source": [
@@ -93,17 +94,19 @@
9394
},
9495
{
9596
"cell_type": "code",
96-
"execution_count": 51,
97+
"execution_count": 10,
9798
"metadata": {},
9899
"outputs": [],
99100
"source": [
100101
"# Specify the forcing filename\n",
101102
"forcing_filename = config_template[\"ForcingFileName\"]\n",
102103
"input_dir, output_dir, config_run_path = iostreamer.create_io_dir(forcing_filename, config_template)\n",
103104
"\n",
104-
"run_config = iostreamer.read_config(config_run_path)\n",
105+
"config_run = iostreamer.read_config(config_run_path)\n",
105106
"# Prepare the forcing data\n",
106-
"forcing_io.prepare_forcing(input_dir, Path(run_config[\"ForcingPath\"]) / forcing_filename, run_config)"
107+
"forcing_io.prepare_forcing(input_dir, Path(config_run[\"ForcingPath\"]) / forcing_filename, config_run)\n",
108+
"# Generate the soil parameter input data for STEMMUS_SCOPE\n",
109+
"soil_io.prepare_soil_data(config_run['SoilPropertyPath'], input_dir, config_run)"
107110
]
108111
},
109112
{
@@ -115,15 +118,15 @@
115118
},
116119
{
117120
"cell_type": "code",
118-
"execution_count": 52,
121+
"execution_count": 11,
119122
"metadata": {},
120123
"outputs": [
121124
{
122125
"name": "stdout",
123126
"output_type": "stream",
124127
"text": [
125128
"MATLAB is selecting SOFTWARE OPENGL rendering.\n",
126-
"Opening log file: /scratch-shared/ecoextreml/stemmus_scope/input/US-GLE_2022-06-24-1318/java.log.36359\n",
129+
"Opening log file: /scratch-shared/ecoextreml/stemmus_scope/input/US-GLE_2022-07-05-1400/java.log.55686\n",
127130
"\n",
128131
" < M A T L A B (R) >\n",
129132
" Copyright 1984-2021 The MathWorks, Inc.\n",
@@ -134,7 +137,7 @@
134137
"To get started, type doc.\n",
135138
"For product information, visit www.mathworks.com.\n",
136139
" \n",
137-
"Reading config from /scratch-shared/ecoextreml/stemmus_scope/input/US-GLE_2022-06-24-1318/US-GLE_2022-06-24-1318_config.txt\n",
140+
"Reading config from /scratch-shared/ecoextreml/stemmus_scope/input/US-GLE_2022-07-05-1400/US-GLE_2022-07-05-1400_config.txt\n",
138141
"\n",
139142
" The calculations start now \n",
140143
" The calculations end now \r"
@@ -167,24 +170,24 @@
167170
},
168171
{
169172
"cell_type": "code",
170-
"execution_count": 53,
173+
"execution_count": 13,
171174
"metadata": {},
172175
"outputs": [
173176
{
174177
"name": "stdout",
175178
"output_type": "stream",
176179
"text": [
177-
"/scratch-shared/ecoextreml/stemmus_scope/output/US-GLE_2022-06-24-1318/ECdata.csv\n",
180+
"/scratch-shared/ecoextreml/stemmus_scope/output/US-GLE_2022-07-05-1400/ECdata.csv\n",
178181
"Reading variable metadata from /gpfs/home1/schilperb/STEMMUS_SCOPE/utils/csv_to_nc/Variables_will_be_in_NetCDF_file.csv\n",
179-
"Creating /scratch-shared/ecoextreml/stemmus_scope/output/US-GLE_2022-06-24-1318/US-GLE_2022-06-24-1318_STEMMUS_SCOPE.nc \n",
182+
"Creating /scratch-shared/ecoextreml/stemmus_scope/output/US-GLE_2022-07-05-1400/US-GLE_2022-07-05-1400_STEMMUS_SCOPE.nc \n",
180183
"Reading data from file: radiation.csv\n",
181184
"Reading data from file: fluxes.csv\n",
182185
"Reading data from file: surftemp.csv\n",
183186
"Reading data from file: Sim_Temp.csv\n",
184187
"Reading data from file: Sim_Theta.csv\n",
185188
"Reading data from file: aerodyn.csv\n",
186189
"Reading data from file: ECdata.csv\n",
187-
"Done writing /scratch-shared/ecoextreml/stemmus_scope/output/US-GLE_2022-06-24-1318/US-GLE_2022-06-24-1318_STEMMUS_SCOPE.nc\n"
190+
"Done writing /scratch-shared/ecoextreml/stemmus_scope/output/US-GLE_2022-07-05-1400/US-GLE_2022-07-05-1400_STEMMUS_SCOPE.nc\n"
188191
]
189192
}
190193
],
@@ -207,7 +210,7 @@
207210
},
208211
{
209212
"cell_type": "code",
210-
"execution_count": 54,
213+
"execution_count": 14,
211214
"metadata": {},
212215
"outputs": [],
213216
"source": [
@@ -233,12 +236,26 @@
233236
},
234237
{
235238
"cell_type": "code",
236-
"execution_count": 56,
239+
"execution_count": 52,
237240
"metadata": {},
238-
"outputs": [],
241+
"outputs": [
242+
{
243+
"ename": "AssertionError",
244+
"evalue": "\nNot equal to tolerance rtol=0.0001, atol=0.577427\n\nMismatched elements: 128 / 240 (53.3%)\nMax absolute difference: 5.8766937\nMax relative difference: 1.5478772\n x: array([ -22.8349 , -23.30592 , -24.5375 , -19.94353 , -20.57276 ,\n -23.40292 , -23.87448 , -25.19518 , -20.80424 , -19.41654 ,\n -17.32158 , -10.80373 , -9.585564, -9.994702, -7.649747,...\n y: array([ -23.14748 , -23.62176 , -24.9116 , -20.25259 , -20.8946 ,\n -23.72201 , -24.20266 , -25.53323 , -21.08464 , -19.66676 ,\n -17.54344 , -10.94056 , -9.69978 , -10.11492 , -7.739421,...",
245+
"output_type": "error",
246+
"traceback": [
247+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
248+
"\u001b[0;31mAssertionError\u001b[0m Traceback (most recent call last)",
249+
"Input \u001b[0;32mIn [52]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m key \u001b[38;5;129;01min\u001b[39;00m ds_ver\u001b[38;5;241m.\u001b[39mkeys():\n\u001b[1;32m 2\u001b[0m \u001b[38;5;66;03m# if key in ['LWnet', 'LWup', 'Qle', 'Qh', 'Qg', 'VegT']:\u001b[39;00m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;66;03m# pass\u001b[39;00m\n\u001b[1;32m 4\u001b[0m \u001b[38;5;66;03m# else:\u001b[39;00m\n\u001b[0;32m----> 5\u001b[0m \u001b[43mnp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtesting\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43massert_allclose\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 6\u001b[0m \u001b[43m \u001b[49m\u001b[43mds_ver\u001b[49m\u001b[43m[\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 7\u001b[0m \u001b[43m \u001b[49m\u001b[43mds_run\u001b[49m\u001b[43m[\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 8\u001b[0m \u001b[43m \u001b[49m\u001b[43mrtol\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m1e-4\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[1;32m 9\u001b[0m \u001b[43m \u001b[49m\u001b[43matol\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mnp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mabs\u001b[49m\u001b[43m(\u001b[49m\u001b[43mds_ver\u001b[49m\u001b[43m[\u001b[49m\u001b[43mkey\u001b[49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmean\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mvalues\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m/\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m100\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# to allow for a small difference when the variable's value crosses 0.\u001b[39;49;00m\n\u001b[1;32m 10\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n",
250+
" \u001b[0;31m[... skipping hidden 1 frame]\u001b[0m\n",
251+
"File \u001b[0;32m/gpfs/home1/schilperb/mamba/envs/stemmus/lib/python3.9/site-packages/numpy/testing/_private/utils.py:844\u001b[0m, in \u001b[0;36massert_array_compare\u001b[0;34m(comparison, x, y, err_msg, verbose, header, precision, equal_nan, equal_inf)\u001b[0m\n\u001b[1;32m 840\u001b[0m err_msg \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m'\u001b[39m \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(remarks)\n\u001b[1;32m 841\u001b[0m msg \u001b[38;5;241m=\u001b[39m build_err_msg([ox, oy], err_msg,\n\u001b[1;32m 842\u001b[0m verbose\u001b[38;5;241m=\u001b[39mverbose, header\u001b[38;5;241m=\u001b[39mheader,\n\u001b[1;32m 843\u001b[0m names\u001b[38;5;241m=\u001b[39m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mx\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124my\u001b[39m\u001b[38;5;124m'\u001b[39m), precision\u001b[38;5;241m=\u001b[39mprecision)\n\u001b[0;32m--> 844\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mAssertionError\u001b[39;00m(msg)\n\u001b[1;32m 845\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m:\n\u001b[1;32m 846\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mtraceback\u001b[39;00m\n",
252+
"\u001b[0;31mAssertionError\u001b[0m: \nNot equal to tolerance rtol=0.0001, atol=0.577427\n\nMismatched elements: 128 / 240 (53.3%)\nMax absolute difference: 5.8766937\nMax relative difference: 1.5478772\n x: array([ -22.8349 , -23.30592 , -24.5375 , -19.94353 , -20.57276 ,\n -23.40292 , -23.87448 , -25.19518 , -20.80424 , -19.41654 ,\n -17.32158 , -10.80373 , -9.585564, -9.994702, -7.649747,...\n y: array([ -23.14748 , -23.62176 , -24.9116 , -20.25259 , -20.8946 ,\n -23.72201 , -24.20266 , -25.53323 , -21.08464 , -19.66676 ,\n -17.54344 , -10.94056 , -9.69978 , -10.11492 , -7.739421,..."
253+
]
254+
}
255+
],
239256
"source": [
240257
"for key in ds_ver.keys():\n",
241-
"# if key == 'Qg':\n",
258+
"# if key in ['LWnet', 'LWup', 'Qle', 'Qh', 'Qg', 'VegT']:\n",
242259
"# pass\n",
243260
"# else:\n",
244261
" np.testing.assert_allclose(\n",

0 commit comments

Comments
 (0)