|
15 | 15 | "outputs": [], |
16 | 16 | "source": [ |
17 | 17 | "import os\n", |
18 | | - "from PyStemmusScope import StemmusScope" |
| 18 | + "from PyStemmusScope import StemmusScope\n", |
| 19 | + "from PyStemmusScope import save" |
19 | 20 | ] |
20 | 21 | }, |
21 | 22 | { |
|
87 | 88 | }, |
88 | 89 | { |
89 | 90 | "cell_type": "code", |
90 | | - "execution_count": 4, |
| 91 | + "execution_count": 9, |
91 | 92 | "metadata": {}, |
92 | 93 | "outputs": [ |
93 | 94 | { |
|
96 | 97 | "{'WorkDir': '/home/sarah/temp/ecoextreml/test/',\n", |
97 | 98 | " 'SoilPropertyPath': '/home/sarah/temp/ecoextreml/data/model_parameters/soil_property/',\n", |
98 | 99 | " 'ForcingPath': '/home/sarah/temp/ecoextreml/data/forcing/plumber2_data/',\n", |
99 | | - " 'ForcingFileName': 'AU-DaS_2010-2017_OzFlux_Met.nc',\n", |
| 100 | + " 'ForcingFileName': 'AR-SLu_2010-2010_FLUXNET2015_Met.nc',\n", |
100 | 101 | " 'directional': '/home/sarah/temp/ecoextreml/data/model_parameters/vegetation_property/directional/',\n", |
101 | 102 | " 'fluspect_parameters': '/home/sarah/temp/ecoextreml/data/model_parameters/vegetation_property/fluspect_parameters/',\n", |
102 | 103 | " 'leafangles': '/home/sarah/temp/ecoextreml/data/model_parameters/vegetation_property/leafangles/',\n", |
103 | 104 | " 'radiationdata': '/home/sarah/temp/ecoextreml/data/model_parameters/vegetation_property/radiationdata/',\n", |
104 | 105 | " 'soil_spectrum': '/home/sarah/temp/ecoextreml/data/model_parameters/vegetation_property/soil_spectrum/',\n", |
105 | 106 | " 'InitialConditionPath': '/home/sarah/temp/ecoextreml/soil_initialcondition/',\n", |
106 | 107 | " 'input_data': '/home/sarah/temp/ecoextreml/data/model_parameters/vegetation_property/input_data.xlsx',\n", |
107 | | - " 'NumberOfTimeSteps': 'NA',\n", |
| 108 | + " 'NumberOfTimeSteps': '5',\n", |
108 | 109 | " 'InputPath': '/will_be_created_under_WorkDir/input/AU-DaS_2022-05-11-1705/',\n", |
109 | | - " 'OutputPath': '/will_be_created_under_WorkDir/output/AU-DaS_2022-05-11-1705/'}" |
| 110 | + " 'OutputPath': '/home/sarah/temp/ecoextreml/output/AR-SLu_2022-07-29-1451/'}" |
110 | 111 | ] |
111 | 112 | }, |
112 | | - "execution_count": 4, |
| 113 | + "execution_count": 9, |
113 | 114 | "metadata": {}, |
114 | 115 | "output_type": "execute_result" |
115 | 116 | } |
|
124 | 125 | }, |
125 | 126 | { |
126 | 127 | "cell_type": "code", |
127 | | - "execution_count": 6, |
| 128 | + "execution_count": 10, |
128 | 129 | "metadata": {}, |
129 | 130 | "outputs": [ |
130 | 131 | { |
131 | 132 | "name": "stdout", |
132 | 133 | "output_type": "stream", |
133 | 134 | "text": [ |
134 | | - "/home/sarah/temp/ecoextreml/test/input/ZA-Kru_2022-07-18-1630/ZA-Kru_2022-07-18-1630_config.txt\n" |
| 135 | + "/home/sarah/temp/ecoextreml/test/input/ZA-Kru_2022-08-03-1537/ZA-Kru_2022-08-03-1537_config.txt\n" |
135 | 136 | ] |
136 | 137 | } |
137 | 138 | ], |
|
146 | 147 | }, |
147 | 148 | { |
148 | 149 | "cell_type": "code", |
149 | | - "execution_count": 7, |
| 150 | + "execution_count": 11, |
150 | 151 | "metadata": {}, |
151 | 152 | "outputs": [ |
152 | 153 | { |
|
164 | 165 | " 'InitialConditionPath': '/home/sarah/temp/ecoextreml/soil_initialcondition/',\n", |
165 | 166 | " 'input_data': '/home/sarah/temp/ecoextreml/data/model_parameters/vegetation_property/input_data.xlsx',\n", |
166 | 167 | " 'NumberOfTimeSteps': '10',\n", |
167 | | - " 'InputPath': '/home/sarah/temp/ecoextreml/test/input/ZA-Kru_2022-07-18-1630/',\n", |
168 | | - " 'OutputPath': '/home/sarah/temp/ecoextreml/test/output/ZA-Kru_2022-07-18-1630/'}" |
| 168 | + " 'InputPath': '/home/sarah/temp/ecoextreml/test/input/ZA-Kru_2022-08-03-1537/',\n", |
| 169 | + " 'OutputPath': '/home/sarah/temp/ecoextreml/test/output/ZA-Kru_2022-08-03-1537/'}" |
169 | 170 | ] |
170 | 171 | }, |
171 | | - "execution_count": 7, |
| 172 | + "execution_count": 11, |
172 | 173 | "metadata": {}, |
173 | 174 | "output_type": "execute_result" |
174 | 175 | } |
|
180 | 181 | }, |
181 | 182 | { |
182 | 183 | "cell_type": "code", |
183 | | - "execution_count": 8, |
| 184 | + "execution_count": 12, |
184 | 185 | "metadata": {}, |
185 | 186 | "outputs": [ |
186 | 187 | { |
187 | 188 | "data": { |
188 | 189 | "text/plain": [ |
189 | | - "b'Reading config from /home/sarah/temp/ecoextreml/test/input/ZA-Kru_2022-07-18-1630/ZA-Kru_2022-07-18-1630_config.txt\\n\\n The calculations start now \\r\\n The calculations end now \\r'" |
| 190 | + "b'Reading config from /home/sarah/temp/ecoextreml/test/input/ZA-Kru_2022-08-03-1537/ZA-Kru_2022-08-03-1537_config.txt\\n\\n The calculations start now \\r\\n The calculations end now \\r'" |
190 | 191 | ] |
191 | 192 | }, |
192 | | - "execution_count": 8, |
| 193 | + "execution_count": 12, |
193 | 194 | "metadata": {}, |
194 | 195 | "output_type": "execute_result" |
195 | 196 | } |
|
200 | 201 | "result" |
201 | 202 | ] |
202 | 203 | }, |
| 204 | + { |
| 205 | + "cell_type": "code", |
| 206 | + "execution_count": 14, |
| 207 | + "metadata": {}, |
| 208 | + "outputs": [ |
| 209 | + { |
| 210 | + "name": "stdout", |
| 211 | + "output_type": "stream", |
| 212 | + "text": [ |
| 213 | + "/home/sarah/temp/ecoextreml/test/output/ZA-Kru_2022-08-03-1537/ZA-Kru_2022-08-03-1537_STEMMUS_SCOPE.nc\n" |
| 214 | + ] |
| 215 | + } |
| 216 | + ], |
| 217 | + "source": [ |
| 218 | + "# save output in nercdf format\n", |
| 219 | + "variables_will_be_in_NetCDF_file = \"./STEMMUS_SCOPE/utils/csv_to_nc/Variables_will_be_in_NetCDF_file.csv\"\n", |
| 220 | + "nc_file_name = save.to_netcdf(model.config, variables_will_be_in_NetCDF_file)\n", |
| 221 | + "print(nc_file_name)" |
| 222 | + ] |
| 223 | + }, |
203 | 224 | { |
204 | 225 | "cell_type": "markdown", |
205 | 226 | "metadata": {}, |
|
209 | 230 | }, |
210 | 231 | { |
211 | 232 | "cell_type": "code", |
212 | | - "execution_count": 9, |
| 233 | + "execution_count": 15, |
213 | 234 | "metadata": {}, |
214 | 235 | "outputs": [ |
215 | 236 | { |
216 | 237 | "name": "stdout", |
217 | 238 | "output_type": "stream", |
218 | 239 | "text": [ |
219 | | - "b'Reading config from /home/sarah/temp/ecoextreml/test/input/ZA-Kru_2022-07-18-1631/ZA-Kru_2022-07-18-1631_config.txt\\n\\n The calculations start now \\r\\n The calculations end now \\r'\n", |
220 | | - "b'Reading config from /home/sarah/temp/ecoextreml/test/input/AR-SLu_2022-07-18-1631/AR-SLu_2022-07-18-1631_config.txt\\n\\n The calculations start now \\r\\n The calculations end now \\r'\n" |
| 240 | + "b'Reading config from /home/sarah/temp/ecoextreml/test/input/ZA-Kru_2022-08-03-1541/ZA-Kru_2022-08-03-1541_config.txt\\n\\n The calculations start now \\r\\n The calculations end now \\r'\n", |
| 241 | + "/home/sarah/temp/ecoextreml/test/output/ZA-Kru_2022-08-03-1541/ZA-Kru_2022-08-03-1541_STEMMUS_SCOPE.nc\n", |
| 242 | + "b'Reading config from /home/sarah/temp/ecoextreml/test/input/AR-SLu_2022-08-03-1541/AR-SLu_2022-08-03-1541_config.txt\\n\\n The calculations start now \\r\\n The calculations end now \\r'\n", |
| 243 | + "/home/sarah/temp/ecoextreml/test/output/AR-SLu_2022-08-03-1541/AR-SLu_2022-08-03-1541_STEMMUS_SCOPE.nc\n" |
221 | 244 | ] |
222 | 245 | } |
223 | 246 | ], |
|
241 | 264 | " # run the model\n", |
242 | 265 | " result = model.run()\n", |
243 | 266 | " print(result)\n", |
| 267 | + " \n", |
| 268 | + " # save results in a netcdf file\n", |
| 269 | + " nc_file_name = save.to_netcdf(model.config, variables_will_be_in_NetCDF_file)\n", |
| 270 | + " print(nc_file_name)\n", |
244 | 271 | " " |
245 | 272 | ] |
246 | | - }, |
247 | | - { |
248 | | - "cell_type": "markdown", |
249 | | - "metadata": {}, |
250 | | - "source": [ |
251 | | - "#### TODO: Create output directories, prepare output files" |
252 | | - ] |
253 | | - }, |
254 | | - { |
255 | | - "cell_type": "code", |
256 | | - "execution_count": 7, |
257 | | - "metadata": {}, |
258 | | - "outputs": [], |
259 | | - "source": [ |
260 | | - "# convert csv files to nc files\n", |
261 | | - "# path_to_generate_netcdf_script = \"path_to_generate_netcdf_script\"\n", |
262 | | - "# path_to_Variables_will_be_in_NetCDF_file = \"path_to_Variables_will_be_in_NetCDF_file\"\n", |
263 | | - "# for ncfile in forcing_filenames_list:\n", |
264 | | - "# path_to_config = config_path_dict[ncfile]\n", |
265 | | - "# result = subprocess.run([\"python\", path_to_generate_netcdf_script,\n", |
266 | | - "# \"--config_file\", path_to_config, \"--variable_file\",\n", |
267 | | - "# path_to_Variables_will_be_in_NetCDF_file])\n", |
268 | | - "# result.check_returncode()" |
269 | | - ] |
270 | 273 | } |
271 | 274 | ], |
272 | 275 | "metadata": { |
|
0 commit comments