|
221 | 221 | "solution2_first": true
|
222 | 222 | },
|
223 | 223 | "source": [
|
224 |
| - "## Exercise 1\n", |
225 |
| - "\n", |
226 |
| - "### Run for 100 years, calculate 100 year means\n", |
| 224 | + "## Exercise 1: Calculate 100 year means\n", |
227 | 225 | "\n",
|
228 | 226 | "For this case study, we will run a simulation for 100 years at daily time-step.\n",
|
229 | 227 | "This means you run Hydrotrend for 36,500 days total. Later on we will change\n",
|
230 | 228 | "other input parameters but, for now, we'll just stick with the defaults.\n",
|
231 | 229 | "\n",
|
232 |
| - "Calculate mean water discharge Q, mean suspended load Qs, mean sediment concentration Cs, and mean bedload Qb.\n", |
| 230 | + "Calculate mean water discharge $Q$, mean suspended load $Q_s$, mean sediment concentration Cs, and mean bedload $Q_b$.\n", |
233 | 231 | "\n",
|
234 | 232 | "*Note that all values are reported as daily averages. What are the units?*"
|
235 | 233 | ]
|
|
243 | 241 | "# Your code here"
|
244 | 242 | ]
|
245 | 243 | },
|
| 244 | + { |
| 245 | + "cell_type": "markdown", |
| 246 | + "metadata": {}, |
| 247 | + "source": [ |
| 248 | + "<details>\n", |
| 249 | + " <summary><b>Click here to see a solution</b></summary>\n", |
| 250 | + "\n", |
| 251 | + "```python\n", |
| 252 | + "from pymt import MODELS\n", |
| 253 | + "\n", |
| 254 | + "hydrotrend = MODELS.Hydrotrend()\n", |
| 255 | + "config_file, config_dir = hydrotrend.setup(\"hydrotrend-default\", run_duration=100)\n", |
| 256 | + "\n", |
| 257 | + "hydrotrend.initialize(config_file, dir=config_dir)\n", |
| 258 | + "\n", |
| 259 | + "n_steps = int(hydrotrend.end_time / hydrotrend.time_step)\n", |
| 260 | + "\n", |
| 261 | + "q = np.empty(n_steps)\n", |
| 262 | + "qs = np.empty(n_steps)\n", |
| 263 | + "cs = np.empty(n_steps)\n", |
| 264 | + "qb = np.empty(n_steps)\n", |
| 265 | + "\n", |
| 266 | + "for i in tqdm(range(n_steps)):\n", |
| 267 | + " hydrotrend.update()\n", |
| 268 | + " \n", |
| 269 | + " q[i] = hydrotrend.get_value(\"channel_exit_water__volume_flow_rate\")\n", |
| 270 | + " qs[i] = hydrotrend.get_value(\"channel_exit_water_sediment~suspended__mass_flow_rate\")\n", |
| 271 | + " cs[i] = hydrotrend.get_value(\"channel_exit_water_sediment~suspended__mass_concentration\")\n", |
| 272 | + " qb[i] = hydrotrend.get_value(\"channel_exit_water_sediment~bedload__mass_flow_rate\")\n", |
| 273 | + "\n", |
| 274 | + "(\n", |
| 275 | + " (q.mean(), hydrotrend.var_units(\"channel_exit_water__volume_flow_rate\")),\n", |
| 276 | + " (cs.mean(), hydrotrend.var_units(\"channel_exit_water_sediment~suspended__mass_flow_rate\")),\n", |
| 277 | + " (qs.mean(), hydrotrend.var_units(\"channel_exit_water_sediment~suspended__mass_concentration\")),\n", |
| 278 | + " (qb.mean(), hydrotrend.var_units(\"channel_exit_water_sediment~bedload__mass_flow_rate\"))\n", |
| 279 | + ")\n", |
| 280 | + "\n", |
| 281 | + "hydrotrend.var_units(\"channel_exit_water__volume_flow_rate\")\n", |
| 282 | + "\n", |
| 283 | + "print(f\"River discharge: {q.mean()} m3 / s\")\n", |
| 284 | + "print(f\"Suspended load: {qs.mean()} kg / s\")\n", |
| 285 | + "print(f\"bedload: {qb.mean()} kg / s\")\n", |
| 286 | + "```\n", |
| 287 | + "\n", |
| 288 | + "</details>" |
| 289 | + ] |
| 290 | + }, |
246 | 291 | {
|
247 | 292 | "cell_type": "markdown",
|
248 | 293 | "metadata": {
|
249 | 294 | "solution2": "shown",
|
250 | 295 | "solution2_first": true
|
251 | 296 | },
|
252 | 297 | "source": [
|
253 |
| - "**Identify the highest flood event for this simulation. Is this the 50-year flood? Plot the year of Q-data which includes the flood.**\n" |
| 298 | + "Identify the highest flood event for this simulation. Is this the 50-year flood? Plot the year of Q-data which includes the flood.\n" |
254 | 299 | ]
|
255 | 300 | },
|
256 | 301 | {
|
|
262 | 307 | "# Your code here"
|
263 | 308 | ]
|
264 | 309 | },
|
| 310 | + { |
| 311 | + "cell_type": "markdown", |
| 312 | + "metadata": {}, |
| 313 | + "source": [ |
| 314 | + "<details>\n", |
| 315 | + " <summary><b>Click here to see a solution</b></summary>\n", |
| 316 | + "\n", |
| 317 | + "```python\n", |
| 318 | + "flood_day = q.argmax()\n", |
| 319 | + "flood_year = flood_day // 365\n", |
| 320 | + "plt.plot(q[flood_year * 365: (flood_year + 1) * 365])\n", |
| 321 | + "\n", |
| 322 | + "print(f\"Year of max flood: {flood_year}\")\n", |
| 323 | + "print(f\"Day of year of max flood: {flood_day % 365}\")\n", |
| 324 | + "```\n", |
| 325 | + "\n", |
| 326 | + "</details>" |
| 327 | + ] |
| 328 | + }, |
265 | 329 | {
|
266 | 330 | "cell_type": "markdown",
|
267 | 331 | "metadata": {
|
268 | 332 | "solution2": "shown",
|
269 | 333 | "solution2_first": true
|
270 | 334 | },
|
271 | 335 | "source": [
|
272 |
| - "## Exercise 2\n", |
273 |
| - "\n", |
274 |
| - "### How does a river system respond to climate change? A few simple scenarios for the coming century.\n", |
| 336 | + "## Exercise 2: How does a river system respond to climate change?\n", |
| 337 | + "### A few simple scenarios for the coming century.\n", |
275 | 338 | "\n",
|
276 |
| - "#### What happens to river discharge, suspended load and bedload if the mean annual temperature in this specific river basin increases by 4 °C over the next 50 years?" |
| 339 | + "What happens to river discharge, suspended load and bedload if the mean annual temperature in this specific river basin increases by 4 °C over the next 50 years?" |
277 | 340 | ]
|
278 | 341 | },
|
279 | 342 | {
|
|
284 | 347 | "source": [
|
285 | 348 | "# Your code here"
|
286 | 349 | ]
|
| 350 | + }, |
| 351 | + { |
| 352 | + "cell_type": "markdown", |
| 353 | + "metadata": {}, |
| 354 | + "source": [ |
| 355 | + "<details>\n", |
| 356 | + " <summary><b>Click here to see a solution</b></summary>\n", |
| 357 | + "\n", |
| 358 | + "```python\n", |
| 359 | + "from pymt import MODELS\n", |
| 360 | + "\n", |
| 361 | + "hydrotrend = MODELS.Hydrotrend()\n", |
| 362 | + "\n", |
| 363 | + "config_file, config_folder = hydrotrend.setup(run_duration=50, change_in_mean_annual_temperature=4.0 / 50.0)\n", |
| 364 | + "hydrotrend.initialize(config_file, config_folder)\n", |
| 365 | + "\n", |
| 366 | + "n_steps = int(hydrotrend.end_time / hydrotrend.time_step)\n", |
| 367 | + "\n", |
| 368 | + "q = np.empty(n_steps)\n", |
| 369 | + "qs = np.empty(n_steps)\n", |
| 370 | + "cs = np.empty(n_steps)\n", |
| 371 | + "qb = np.empty(n_steps)\n", |
| 372 | + "\n", |
| 373 | + "for i in tqdm(range(n_steps)):\n", |
| 374 | + " hydrotrend.update()\n", |
| 375 | + " \n", |
| 376 | + " q[i] = hydrotrend.get_value(\"channel_exit_water__volume_flow_rate\")\n", |
| 377 | + " qs[i] = hydrotrend.get_value(\"channel_exit_water_sediment~suspended__mass_flow_rate\")\n", |
| 378 | + " cs[i] = hydrotrend.get_value(\"channel_exit_water_sediment~suspended__mass_concentration\")\n", |
| 379 | + " qb[i] = hydrotrend.get_value(\"channel_exit_water_sediment~bedload__mass_flow_rate\")\n", |
| 380 | + " \n", |
| 381 | + "(\n", |
| 382 | + " (q.mean(), hydrotrend.var_units(\"channel_exit_water__volume_flow_rate\")),\n", |
| 383 | + " (qs.mean(), hydrotrend.var_units(\"channel_exit_water_sediment~suspended__mass_flow_rate\")),\n", |
| 384 | + " (cs.mean(), hydrotrend.var_units(\"channel_exit_water_sediment~suspended__mass_concentration\")),\n", |
| 385 | + " (qb.mean(), hydrotrend.var_units(\"channel_exit_water_sediment~bedload__mass_flow_rate\"))\n", |
| 386 | + ")\n", |
| 387 | + "\n", |
| 388 | + "print(f\"River discharge: {q.mean()} m3 / s\")\n", |
| 389 | + "print(f\"Suspended load: {qs.mean()} kg / s\")\n", |
| 390 | + "print(f\"bedload: {qb.mean()} kg / s\")\n", |
| 391 | + "```\n", |
| 392 | + "\n", |
| 393 | + "</details>" |
| 394 | + ] |
287 | 395 | }
|
288 | 396 | ],
|
289 | 397 | "metadata": {
|
290 | 398 | "kernelspec": {
|
291 |
| - "display_name": "Python 3", |
| 399 | + "display_name": "Python 3 (ipykernel)", |
292 | 400 | "language": "python",
|
293 | 401 | "name": "python3"
|
294 | 402 | },
|
|
302 | 410 | "name": "python",
|
303 | 411 | "nbconvert_exporter": "python",
|
304 | 412 | "pygments_lexer": "ipython3",
|
305 |
| - "version": "3.9.4" |
| 413 | + "version": "3.9.7" |
306 | 414 | }
|
307 | 415 | },
|
308 | 416 | "nbformat": 4,
|
|
0 commit comments