From 5e4ac26272b094ae141ef17bfc4804f1a0f5cd94 Mon Sep 17 00:00:00 2001 From: Martijn Visser Date: Mon, 21 Oct 2024 13:19:08 +0200 Subject: [PATCH] pixi run pre-commit --- .../01_test_parse_crossings.ipynb | 6 +- .../02_crossings_to_ribasim_notebook.ipynb | 56 ++-------- .../AmstelGooienVecht_parametrize.ipynb | 102 +++++++----------- .../sturing_AmstelGooienVecht.json | 6 +- .../Parametrize/sturing_Scheldestromen.json | 6 +- .../crossings_to_ribasim.py | 3 +- .../ribasim_parametrization.py | 3 +- 7 files changed, 58 insertions(+), 124 deletions(-) diff --git a/src/peilbeheerst_model/01_test_parse_crossings.ipynb b/src/peilbeheerst_model/01_test_parse_crossings.ipynb index 4df0fd6..55b8c3d 100644 --- a/src/peilbeheerst_model/01_test_parse_crossings.ipynb +++ b/src/peilbeheerst_model/01_test_parse_crossings.ipynb @@ -577,9 +577,9 @@ ], "metadata": { "kernelspec": { - "display_name": "Python [conda env:ribasim]", + "display_name": "default", "language": "python", - "name": "conda-env-ribasim-py" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -591,7 +591,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.12.7" } }, "nbformat": 4, diff --git a/src/peilbeheerst_model/02_crossings_to_ribasim_notebook.ipynb b/src/peilbeheerst_model/02_crossings_to_ribasim_notebook.ipynb index ce06aa3..f1d6006 100644 --- a/src/peilbeheerst_model/02_crossings_to_ribasim_notebook.ipynb +++ b/src/peilbeheerst_model/02_crossings_to_ribasim_notebook.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "0", "metadata": {}, "outputs": [], @@ -30,7 +30,7 @@ "sys.path.append(str(module_path))\n", "\n", "# load crossings_to_ribasim.py\n", - "sys.path.append(\"peilbeheerst_model\")\n" + "sys.path.append(\"peilbeheerst_model\")" ] }, { @@ -43,22 +43,10 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "2", "metadata": {}, - "outputs": [ - { - "ename": "NameError", - "evalue": "name 'stop' is not defined", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[2], line 62\u001b[0m\n\u001b[1;32m 59\u001b[0m model \u001b[38;5;241m=\u001b[39m Model(starttime\u001b[38;5;241m=\u001b[39mmodel_characteristics[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mstarttime\u001b[39m\u001b[38;5;124m\"\u001b[39m], endtime\u001b[38;5;241m=\u001b[39mmodel_characteristics[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mendtime\u001b[39m\u001b[38;5;124m\"\u001b[39m], crs\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mEPSG:28992\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 61\u001b[0m model\u001b[38;5;241m.\u001b[39medge\u001b[38;5;241m.\u001b[39mdf \u001b[38;5;241m=\u001b[39m edge\n\u001b[0;32m---> 62\u001b[0m \u001b[43mstop\u001b[49m\n\u001b[1;32m 63\u001b[0m model\u001b[38;5;241m.\u001b[39mbasin\u001b[38;5;241m.\u001b[39mnode\u001b[38;5;241m.\u001b[39mdf \u001b[38;5;241m=\u001b[39m basin_node\n\u001b[1;32m 64\u001b[0m model\u001b[38;5;241m.\u001b[39mbasin\u001b[38;5;241m.\u001b[39mprofile \u001b[38;5;241m=\u001b[39m basin_profile\n", - "\u001b[0;31mNameError\u001b[0m: name 'stop' is not defined" - ] - } - ], + "outputs": [], "source": [ "model_characteristics = {\n", " # model description\n", @@ -389,18 +377,10 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "id": "9", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Done\n" - ] - } - ], + "outputs": [], "source": [ "model_characteristics = {\n", " # model description\n", @@ -504,18 +484,10 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "id": "11", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Done\n" - ] - } - ], + "outputs": [], "source": [ "model_characteristics = {\n", " # model description\n", @@ -750,18 +722,10 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "15", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Done\n" - ] - } - ], + "outputs": [], "source": [ "model_characteristics = {\n", " # model description\n", diff --git a/src/peilbeheerst_model/Parametrize/AmstelGooienVecht_parametrize.ipynb b/src/peilbeheerst_model/Parametrize/AmstelGooienVecht_parametrize.ipynb index 6f400b9..b396128 100644 --- a/src/peilbeheerst_model/Parametrize/AmstelGooienVecht_parametrize.ipynb +++ b/src/peilbeheerst_model/Parametrize/AmstelGooienVecht_parametrize.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -13,10 +13,9 @@ "\n", "import load_ribasim # noqa: F401\n", "import pandas as pd\n", + "import peilbeheerst_model.ribasim_parametrization as ribasim_param\n", "import ribasim\n", "import ribasim.nodes\n", - "\n", - "import peilbeheerst_model.ribasim_parametrization as ribasim_param\n", "from peilbeheerst_model.add_storage_basins import AddStorageBasins\n", "from peilbeheerst_model.controle_output import *\n", "from peilbeheerst_model.ribasim_feedback_processor import RibasimFeedbackProcessor\n", @@ -42,7 +41,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -77,17 +76,9 @@ }, { "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Processed all actions\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "name = \"Ron Bruijns (HKV)\"\n", "versie = \"2024_10_5\"\n", @@ -115,7 +106,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -148,26 +139,16 @@ }, { "cell_type": "code", - "execution_count": 35, - "metadata": { - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Basin with Node ID 187 has an area smaller than 100 m²: 0.0017139832034533953 m²\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "ribasim_param.validate_basin_area(ribasim_model)" ] }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -183,7 +164,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -192,7 +173,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -207,7 +188,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -218,7 +199,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -234,7 +215,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -250,7 +231,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -261,7 +242,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -269,7 +250,7 @@ " ribasim_model=ribasim_model, exclude_hoofdwater=True, additional_basins_to_exclude=[]\n", ")\n", "\n", - "add_storage_basins.create_bergende_basins()\n" + "add_storage_basins.create_bergende_basins()" ] }, { @@ -281,7 +262,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -306,7 +287,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -323,7 +304,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -340,7 +321,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -356,7 +337,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -365,17 +346,17 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ribasim_param.find_upstream_downstream_target_levels(ribasim_model, node=\"outlet\")\n", - "ribasim_param.find_upstream_downstream_target_levels(ribasim_model, node=\"pump\")\n" + "ribasim_param.find_upstream_downstream_target_levels(ribasim_model, node=\"pump\")" ] }, { "cell_type": "code", - "execution_count": 24, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -384,7 +365,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -400,7 +381,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -417,7 +398,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -427,7 +408,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -443,7 +424,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -452,7 +433,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -480,7 +461,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -516,18 +497,9 @@ }, { "cell_type": "code", - "execution_count": 34, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "../../../../../Ribasim_networks/Waterschappen/AmstelGooienVecht/modellen/AmstelGooienVecht_parametrized/results\n", - "The model of waterboard AmstelGooienVecht has been uploaded to the goodcloud in the directory of boezemmodel!\n" - ] - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "# control_dict = Control(work_dir = work_dir).run_all()\n", "ribasim_param.write_ribasim_model_GoodCloud(\n", diff --git a/src/peilbeheerst_model/Parametrize/sturing_AmstelGooienVecht.json b/src/peilbeheerst_model/Parametrize/sturing_AmstelGooienVecht.json index ec0ee12..47bfc90 100644 --- a/src/peilbeheerst_model/Parametrize/sturing_AmstelGooienVecht.json +++ b/src/peilbeheerst_model/Parametrize/sturing_AmstelGooienVecht.json @@ -28,7 +28,7 @@ "downstream_level_offset": 0.15, "max_flow_rate": 1 }, - + "Uitlaat buitenwater boezem, stuw": { "upstream_level_offset": 0, "downstream_level_offset": 0.30, @@ -40,7 +40,7 @@ "downstream_level_offset": 0, "max_flow_rate": 10 }, - + "Boezem boezem, stuw": { "upstream_level_offset": 0, "downstream_level_offset": 0.10, @@ -136,7 +136,7 @@ "downstream_level_offset": 0.15, "max_flow_rate": 10 }, - + "Boezem boezem, aanvoer gemaal": { "upstream_level_offset": 0.15, "downstream_level_offset": 0, diff --git a/src/peilbeheerst_model/Parametrize/sturing_Scheldestromen.json b/src/peilbeheerst_model/Parametrize/sturing_Scheldestromen.json index ec0ee12..47bfc90 100644 --- a/src/peilbeheerst_model/Parametrize/sturing_Scheldestromen.json +++ b/src/peilbeheerst_model/Parametrize/sturing_Scheldestromen.json @@ -28,7 +28,7 @@ "downstream_level_offset": 0.15, "max_flow_rate": 1 }, - + "Uitlaat buitenwater boezem, stuw": { "upstream_level_offset": 0, "downstream_level_offset": 0.30, @@ -40,7 +40,7 @@ "downstream_level_offset": 0, "max_flow_rate": 10 }, - + "Boezem boezem, stuw": { "upstream_level_offset": 0, "downstream_level_offset": 0.10, @@ -136,7 +136,7 @@ "downstream_level_offset": 0.15, "max_flow_rate": 10 }, - + "Boezem boezem, aanvoer gemaal": { "upstream_level_offset": 0.15, "downstream_level_offset": 0, diff --git a/src/peilbeheerst_model/peilbeheerst_model/crossings_to_ribasim.py b/src/peilbeheerst_model/peilbeheerst_model/crossings_to_ribasim.py index 5ae2b7e..3f9521a 100644 --- a/src/peilbeheerst_model/peilbeheerst_model/crossings_to_ribasim.py +++ b/src/peilbeheerst_model/peilbeheerst_model/crossings_to_ribasim.py @@ -7,11 +7,10 @@ import pandas as pd import ribasim from bokeh.palettes import Category10 +from ribasim_nl import CloudStorage from shapely.geometry import LineString, MultiPolygon, Point, Polygon from shapely.wkt import loads -from ribasim_nl import CloudStorage - class CrossingsToRibasim: """Create a Ribasim network from crossings diff --git a/src/peilbeheerst_model/peilbeheerst_model/ribasim_parametrization.py b/src/peilbeheerst_model/peilbeheerst_model/ribasim_parametrization.py index b81a9b8..71b1048 100644 --- a/src/peilbeheerst_model/peilbeheerst_model/ribasim_parametrization.py +++ b/src/peilbeheerst_model/peilbeheerst_model/ribasim_parametrization.py @@ -11,9 +11,8 @@ import pandas as pd import ribasim import tqdm.auto as tqdm -from shapely.geometry import LineString - from ribasim_nl import CloudStorage +from shapely.geometry import LineString def get_current_max_nodeid(ribasim_model):