{ "cells": [ { "cell_type": "markdown", "id": "28164d02-8c37-4572-b451-af891e5d8e19", "metadata": {}, "source": [ "# This notebook demonstrates the query to get all necessary data to calculate runoff coefficients" ] }, { "cell_type": "code", "execution_count": null, "id": "6ca132f3-b5d7-4016-b3a2-dbc8c028fd11", "metadata": {}, "outputs": [], "source": [ "templates = {\n", "'template_runoff_coefficient': {\n", " 'target_concept': 'https://dbpedia.org/resource/Runoff_curve_number', # concept for \n", " 'target_unit': '[%]',\n", " 'target_method': 'df[\"runoff_coefficient\"] = round(df.Q_OF_mean_selected/ df.P_mean_selected * 100, 1)',\n", " 'requires':\n", " [\n", " {'concept': 'https://dbpedia.org/resource/Runoff',\n", " 'alternative_concept': 'http://aims.fao.org/aos/agrovoc/c_35388',\n", " 'name': 'runoff_volume',\n", " 'unit': '[mm]',\n", " 'method': 'template_runoff_volume'\n", " },\n", " {'concept': 'https://dbpedia.org/resource/Rain',\n", " 'alternative_concept': 'http://aims.fao.org/aos/agrovoc/c_25202',\n", " 'name': 'rainfall_volume',\n", " 'unit': '[mm]',\n", " 'method': 'template_rainfall_volume'\n", " }\n", " ]\n", "},\n", "\n", "'template_runoff_volume_Ries': {\n", " 'target_concept': 'https://dbpedia.org/resource/Runoff',\n", " 'target_unit': '[mm]',\n", " 'target_method': 'df_target = df.pivot_table(values=[\"P_mean_selected\",\"Q_OF_mean_selected\"], columns=[\"Site_number\",\"Experiment_numbe\"], aggfunc=\"sum\", dropna=True)',\n", " 'requires':\n", " [\n", " {'concept': 'https://dbpedia.org/resource/Runoff',\n", " 'alternative_concept': 'http://aims.fao.org/aos/agrovoc/c_35388',\n", " 'name': 'runoff_rate',\n", " 'unit': '[mm]',\n", " },\n", " {'concept': 'http://aims.fao.org/aos/agrovoc/c_7778',\n", " 'name': 'duration',\n", " 'unit': '[mm]'\n", " }\n", " ]\n", "},\n", "\n", "'template_runoff_volume_TUBAF': {\n", " 'target_concept': 'https://dbpedia.org/resource/Runoff',\n", " 'target_unit': '[l]',\n", " 'target_method': 'runoff_volume = [sum_timesteps(\"ruoff_rate * duration\") for row in data.rows \"]', # we need to aggregate timesteps here\n", " 'requires':\n", " [\n", " {'concept': 'https://dbpedia.org/resource/Runoff',\n", " 'alternative_concept': 'http://aims.fao.org/aos/agrovoc/c_35388',\n", " 'name': 'runoff_rate',\n", " 'unit': '[l/s]',\n", " },\n", " {'concept': 'http://aims.fao.org/aos/agrovoc/c_7778',\n", " 'name': 'duration',\n", " 'unit': '[s]'\n", " }\n", " ]\n", "},\n", "\n", "'template_rainfall_volume': {\n", " 'target_concept': 'https://dbpedia.org/resource/Rain', \n", " 'target_unit': '[l]',\n", " 'target_method': 'ruoff_volume = [sum_timesteps(\"rainfall_rate * duration\", id) for id in data.ids \"]', # we need to aggregate timesteps here\n", " 'requires':\n", " [\n", " {'concept': 'https://dbpedia.org/resource/Rain',\n", " 'alternative_concept': 'http://aims.fao.org/aos/agrovoc/c_25202',\n", " 'name': 'rainfall_rate',\n", " 'unit': '[l/s]'\n", " },\n", " {'concept': 'http://aims.fao.org/aos/agrovoc/c_7778',\n", " 'name': 'duration',\n", " 'unit': '[s]'\n", " }\n", " ]\n", "}\n", "}\n", "#def sum_timesteps(operation, data):\n", "# ... see Jonas dissertation functions...{\n", "# rainfall https://github.com/jonaslenz/diss/blob/gitbook/database/hydraulic_func.R#L45-L59\n", "# runoff https://github.com/jonaslenz/diss/blob/gitbook/database/hydraulic_func.R#L29-L43" ] }, { "cell_type": "code", "execution_count": null, "id": "624b419a-215e-470a-909f-2f7c1e5abfc6", "metadata": {}, "outputs": [], "source": [ "templates['template_rainfall_volume']" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.11.7" } }, "nbformat": 4, "nbformat_minor": 5 }