{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# HydroTrend, Ganges Basin, Q0 Climate Scenario\n", "\n", "\n", "### Created By: Abby Eckland and Irina Overeem, March 2020\n", "_____________________________________________________________________________________________" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### About this notebook\n", "This notebook replicates and improves upon simulations originally run by Frances Dunn and Stephen Darby, reported in Darby et al. 2015.\n", "\n", "This simulation is driven by climate predictions (daily temperature and precipitation) obtained from the Hadley Centre (HadRM3P) Regional Climate Model. The Q0 realization is utilized in this notebook.\n", "\n", "At the end of this notebook, questions are available to help analyze the model outputs.\n", "\n", "See the following links for more informaton and resources regarding the model HydroTrend:
\n", "https://csdms.colorado.edu/wiki/Model_help:HydroTrend
\n", "https://csdms.colorado.edu/wiki/Model:HydroTrend
\n", "______________________________________________________________________________________________________" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 125 year simulation: 1975-2100" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Import the pymt package. Create a new instance. With each new run, it is wise to rename the instance" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "import pymt.models\n", "\n", "hydrotrend_GQ0 = pymt.models.Hydrotrend()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "# Add directory for output files\n", "config_file, config_folder = \"hydro_config.txt\", \"Ganges\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that the following \"cat\" commands will allow you to view your input files. They are not required to run HydroTrend, but it is good measure to make sure the model you are running is using the correct basin information. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "cat Ganges/HYDRO.IN" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "cat Ganges/HYDRO0.HYPS" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "cat Ganges/HYDRO.CLIMATE" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In pymt one can always find out what output a model generates by using the .output_var_names method. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "hydrotrend_GQ0.output_var_names" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we initialize the model with the configure file and in the configure folder." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "hydrotrend_GQ0.initialize(config_file, config_folder)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This line of code lists time parameters: when, how long, and at what timestep the model simulation will work." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "(\n", " hydrotrend_GQ0.start_time,\n", " hydrotrend_GQ0.time,\n", " hydrotrend_GQ0.end_time,\n", " hydrotrend_GQ0.time_step,\n", " hydrotrend_GQ0.time_units,\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This code declares numpy arrays for several important parameters we want to save.\n", "Empty is declaring space in memory for info to go in." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "n_days_GQ0 = int(hydrotrend_GQ0.end_time)\n", "q_GQ0 = np.empty(n_days_GQ0) # river discharge at the outlet\n", "qs_GQ0 = np.empty(n_days_GQ0) # sediment load at the outlet\n", "cs_GQ0 = np.empty(\n", " n_days_GQ0\n", ") # suspended sediment concentration for different grainsize classes at the outlet\n", "qb_GQ0 = np.empty(n_days_GQ0) # bedload at the outlet" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here we have coded up the time loop using i as the index.\n", "We update the model with one timestep at the time, untill we reach the end time. \n", "For each time step, we also get the values for the output parameters we wish to. \n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "for i in range(n_days_GQ0):\n", " hydrotrend_GQ0.update()\n", " q_GQ0[i] = hydrotrend_GQ0.get_value(\"channel_exit_water__volume_flow_rate\")\n", " qs_GQ0[i] = hydrotrend_GQ0.get_value(\n", " \"channel_exit_water_sediment~suspended__mass_flow_rate\"\n", " )\n", " cs_GQ0[i] = hydrotrend_GQ0.get_value(\n", " \"channel_exit_water_sediment~suspended__mass_concentration\"\n", " )\n", " qb_GQ0[i] = hydrotrend_GQ0.get_value(\n", " \"channel_exit_water_sediment~bedload__mass_flow_rate\"\n", " )" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plot water discharge (q)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "plt.plot(q_GQ0, color=\"blue\")\n", "plt.title(\"Simulated water discharge, Ganges River (1975-2100)\", y=1.05)\n", "plt.xlabel(\"Day in simulation\")\n", "plt.ylabel(\"Water discharge (m^3/s)\")\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plot suspended sediment discharge (qs)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "plt.plot(qs_GQ0, color=\"tab:brown\")\n", "plt.title(\"Simulated suspended sediment flux, Ganges River (1975-2100)\", y=1.05)\n", "plt.xlabel(\"Day in simulation\")\n", "plt.ylabel(\"Sediment discharge (kg/s)\")\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Explore mean annual water discharge trends through time" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "# Reshape data array to find mean yearly water discharge\n", "q_reshape_GQ0 = q_GQ0.reshape(124, 365)\n", "q_mean_rows_GQ0 = np.mean(q_reshape_GQ0, axis=1)\n", "q_y_vals = np.arange(124)\n", "\n", "# Plot data, add trendline\n", "plt.plot(q_y_vals, q_mean_rows_GQ0, color=\"blue\")\n", "plt.xlabel(\"Year in simulation\")\n", "plt.ylabel(\"Discharge (m^3/s)\")\n", "plt.title(\"Simulated Mean Annual Water Discharge, Ganges River (1975-2100)\", y=1.05)\n", "\n", "z = np.polyfit(q_y_vals.flatten(), q_mean_rows_GQ0.flatten(), 1)\n", "p = np.poly1d(z)\n", "plt.plot(q_y_vals, p(q_y_vals), \"r--\")\n", "plt.suptitle(\"y={:.6f}x+{:.6f}\".format(z[0], z[1]), y=0.8)\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plot mean daily discharge over 125 year period" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "q_GQ0_daily = np.mean(q_reshape_GQ0, axis=0)\n", "\n", "plt.plot(q_GQ0_daily, color=\"blue\")\n", "plt.xlabel(\"Day of Year\")\n", "plt.ylabel(\"Discharge (m^3/s)\")\n", "plt.title(\"Simulated Mean Daily Water Discharge, Ganges River, 1975-2100\")\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Explore mean annual sediment discharge trends through time" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Reshape data array to find mean yearly sediment discharge\n", "qs_reshape_GQ0 = qs_GQ0.reshape(124, 365)\n", "qs_mean_rows_GQ0 = np.mean(qs_reshape_GQ0, axis=1)\n", "qs_y_vals = np.arange(124)\n", "\n", "# Plot data, add trendline\n", "plt.plot(qs_y_vals, qs_mean_rows_GQ0, color=\"tab:brown\")\n", "plt.xlabel(\"Year in simulation\")\n", "plt.ylabel(\"Discharge (kg/s)\")\n", "plt.title(\"Simulated Mean Annual Sediment Discharge, Ganges River (1975-2100)\", y=1.05)\n", "\n", "z = np.polyfit(qs_y_vals.flatten(), qs_mean_rows_GQ0.flatten(), 1)\n", "p = np.poly1d(z)\n", "plt.plot(qs_y_vals, p(qs_y_vals), \"r--\")\n", "plt.suptitle(\"y={:.6f}x+{:.6f}\".format(z[0], z[1]), y=0.85)\n", "plt.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Plot mean daily sediment discharge over 125 year period\n", "qs_GQ0_daily = np.mean(qs_reshape_GQ0, axis=0)\n", "plt.plot(qs_GQ0_daily, color=\"tab:brown\")\n", "plt.xlabel(\"Day of Year\")\n", "plt.ylabel(\"Discharge (kg/s)\")\n", "plt.title(\"Simulated Mean Daily Sediment Discharge, Ganges River, 1975-2100\")\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Get important mass balance information about your model run" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "scrolled": true }, "outputs": [], "source": [ "print(\n", " \"Mean Water Discharge = {} {}\".format(\n", " q_GQ0.mean(),\n", " hydrotrend_GQ0.get_var_units(\"channel_exit_water__volume_flow_rate\"),\n", " )\n", ")\n", "print(\n", " \"Mean Bedload Discharge = {} {}\".format(\n", " qb_GQ0.mean(),\n", " hydrotrend_GQ0.get_var_units(\n", " \"channel_exit_water_sediment~bedload__mass_flow_rate\"\n", " ),\n", " )\n", ")\n", "print(\n", " \"Mean Suspended Sediment Discharge = {} {}\".format(\n", " qs_GQ0.mean(),\n", " hydrotrend_GQ0.get_var_units(\n", " \"channel_exit_water_sediment~suspended__mass_flow_rate\"\n", " ),\n", " )\n", ")\n", "print(\n", " \"Mean Suspended Sediment Concentration = {} {}\".format(\n", " cs_GQ0.mean(),\n", " hydrotrend_GQ0.get_var_units(\n", " \"channel_exit_water_sediment~suspended__mass_concentration\"\n", " ),\n", " )\n", ")\n", "\n", "# Convert qs to MT/year\n", "AnnualQs_GQ0 = (qs_GQ0.mean() * 1e-9) / 3.17098e-8\n", "print(f\"Mean Annual Suspended Sediment Discharge = {AnnualQs_GQ0} MT / year\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create discharge-sedimentload relationship for this simulation" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": true }, "outputs": [], "source": [ "# Typically presented as a loglog pot\n", "plt.scatter(np.log(q_GQ0), np.log(cs_GQ0), s=5, color=\"0.7\")\n", "plt.title(\"HydroTrend simulation of 25 year water discharge, Ganges River (1975-2100)\")\n", "plt.xlabel(\"Log River Discharge in m3/s\")\n", "plt.ylabel(\"Log Sediment concentration in kg/m3\")\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Now let's answer some questions about the above Ganges River simulation in HydroTrend\n", "__________________________________________________________________________________________________________________" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercise 1: How water and sediment discharge is predicted to change over the next century in the Ganges Basin." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Q1a: How does water discharge and suspended sediment discharge in the Ganges River change over the 125 year time period? Describe the general trend.\n", "\n", "*A1a*:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Q1b: What is the percent change in average water discharge from the beginning to the end of the simulation? You will need to do some calculations in the cell below.\n", "\n", "*A1b*: " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# work for Q1b:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Q1c: What about the percent change in sediment discharge over the simulation time period?\n", "\n", "*A1c*: " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# work for Q1c:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercise 2: Explore the intra-annual variability of Ganges River discharge." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Q2a: Describe the general water discharge trends over an average year. During what month(s) does discharge peak? When is discharge low? Use the plots above to support your answer.\n", "\n", "*A2a*: " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Q2b: What climactic phenomenon drives the huge intra-annual variability in water discharge in the Ganges River?\n", "\n", "*A2b*:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Q2c: Does sediment discharge also have high intra-annual variability? If so, why? Use the plots above to support your answer.\n", "\n", "*A2c:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Exercise 3: The impact of climate change on water and sediment discharge in the Ganges Basin." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Q3a: What are the two major climate inputs that drive the HydroTrend model? See beginning of the notebook for information and links regarding the HydroTrend model.\n", "\n", "*A3a*:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Q3b: How must these climate inputs be changing in the future, given the impacts on water and sediment discharge over the simulation? Is this a surprising result?\n", "\n", "*A3b*:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Q3c: What impacts might decrease water and/or sediment discharge in the Ganges River in the future? These impacts could be natural or anthropogenic. The links above might also be of help in answering this question.\n", "\n", "*A3c*:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "celltoolbar": "Raw Cell Format", "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.2" } }, "nbformat": 4, "nbformat_minor": 4 }