From cdcd57712f2b957b4bb21cd640241873a7667cef Mon Sep 17 00:00:00 2001 From: Frederique Date: Thu, 19 Oct 2023 15:57:30 +0200 Subject: [PATCH 01/14] test --- .github/workflows/docs.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 522378a9..571fd325 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -2,7 +2,7 @@ name: Build Documentation on: push: - branches: [ main ] + branches: [ main, docs ] paths: - tests/* - hydromt_fiat/* @@ -10,7 +10,7 @@ on: - examples/* - pyproject.toml pull_request: - branches: [ main ] + branches: [ main, docs ] paths: - tests/* - hydromt_fiat/* @@ -75,14 +75,14 @@ jobs: run: pip install . - name: Generate docs - # if: ${{ github.event_name != 'pull_request' && !github.event.act }} + if: ${{ github.event_name != 'pull_request' && !github.event.act }} run: | export PATH=/usr/share/miniconda3/bin:$PATH PYTHONPYCACHEPREFIX=~/pycache mamba run -n hydromt-fiat-docs sphinx-build -M html ./docs ./docs/_build echo "DOC_VERSION=$(mamba run -n hydromt-fiat-docs python -c 'from hydromt_fiat import __version__ as v; print("dev" if "dev" in v else "v"+v.replace(".dev",""))')" >> $GITHUB_ENV - name: Upload to GitHub Pages - # if: ${{ github.event_name != 'pull_request' && !github.event.act }} + if: ${{ github.event_name != 'pull_request' && !github.event.act }} uses: peaceiris/actions-gh-pages@v3.9.3 with: github_token: ${{ secrets.GITHUB_TOKEN }} From db729f7e0068d0ec1f66135b3f9c91052b3d7a77 Mon Sep 17 00:00:00 2001 From: Frederique Date: Thu, 19 Oct 2023 16:07:20 +0200 Subject: [PATCH 02/14] added aggregation zones example --- docs/examples/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/examples/index.rst b/docs/examples/index.rst index 47354e42..dbbee426 100644 --- a/docs/examples/index.rst +++ b/docs/examples/index.rst @@ -12,4 +12,5 @@ Offline example access Below you can access some of the main examples and go through them in an off-line manner. More examples will be added soon. 1. `Creating a Delft-FIAT model anywhere in the world from OSM and JRC data <../_examples/global_OSM_JRC.ipynb>`_ +2. `Adding aggregation zones to your Delft-FIAT model <../_examples/aggreagation_zones_example.ipynb>`_ From da9125b73309fce2929ca890f3f4db415c0de667 Mon Sep 17 00:00:00 2001 From: Frederique Date: Thu, 19 Oct 2023 16:39:05 +0200 Subject: [PATCH 03/14] test docs workflow --- .github/workflows/docs.yml | 55 ++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 571fd325..3305e98e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -42,34 +42,37 @@ jobs: activate-environment: hydromt-fiat-docs use-mamba: true - - name: load from cache - id: cache - uses: actions/cache/restore@v3 - with: - path: | - /usr/share/miniconda3 - ~/pycache - ./docs/_build - # the below two settings mean we'll alway srestore the cache - # but the cache hit output can tell us if we have to update afterwards - key: docs-${{ hashFiles('envs/hydromt-fiat-docs.yml') }} - restore-keys: | - docs + # - name: load from cache + # id: cache + # uses: actions/cache/restore@v3 + # with: + # path: | + # /usr/share/miniconda3 + # ~/pycache + # ./docs/_build + # # the below two settings mean we'll alway srestore the cache + # # but the cache hit output can tell us if we have to update afterwards + # key: docs-${{ hashFiles('envs/hydromt-fiat-docs.yml') }} + # restore-keys: | + # docs - - name: Fail on no cache restore - if: steps.cache.outputs.cache-matched-key == '' - run: | - echo "Failed to restore any cache. exiting..." - exit 1 + # - name: Fail on no cache restore + # if: steps.cache.outputs.cache-matched-key == '' + # run: | + # echo "Failed to restore any cache. exiting..." + # exit 1 - # by avoiding the mamba setup stage by loading it from cache instead we save - # a lot of setup time, but we do have to do our own PATH management - # hence the exports - - name: Update environment - if: steps.cache.outputs.cache-hit != 'true' - run: | - export PATH=/usr/share/miniconda3/bin:$PATH - mamba env update -n hydromt-fiat-docs -f envs/hydromt-fiat-docs.yml + # # by avoiding the mamba setup stage by loading it from cache instead we save + # # a lot of setup time, but we do have to do our own PATH management + # # hence the exports + # - name: Update environment + # if: steps.cache.outputs.cache-hit != 'true' + # run: | + # export PATH=/usr/share/miniconda3/bin:$PATH + # mamba env update -n hydromt-fiat-docs -f envs/hydromt-fiat-docs.yml + + - name: Install environment + run: mamba env update -n hydromt-fiat-docs -f envs/hydromt-fiat-docs.yml - name: Install hydromt-fiat run: pip install . From e64627cc125e064912e799433212e47dd2f5ef22 Mon Sep 17 00:00:00 2001 From: Frederique Date: Thu, 19 Oct 2023 16:39:57 +0200 Subject: [PATCH 04/14] update --- .github/workflows/docs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 3305e98e..d5c04d4c 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,6 +1,7 @@ name: Build Documentation on: + workflow_dispatch: push: branches: [ main, docs ] paths: From df7fc18df37a6332c6c1ba3ff6304b85bbe6b9a0 Mon Sep 17 00:00:00 2001 From: Frederique Date: Thu, 19 Oct 2023 16:44:36 +0200 Subject: [PATCH 05/14] another try --- .github/workflows/docs.yml | 40 +++++--------------------------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index d5c04d4c..3257f1ff 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -40,43 +40,13 @@ jobs: miniforge-variant: Mambaforge miniforge-version: latest channels: conda-forge - activate-environment: hydromt-fiat-docs use-mamba: true - # - name: load from cache - # id: cache - # uses: actions/cache/restore@v3 - # with: - # path: | - # /usr/share/miniconda3 - # ~/pycache - # ./docs/_build - # # the below two settings mean we'll alway srestore the cache - # # but the cache hit output can tell us if we have to update afterwards - # key: docs-${{ hashFiles('envs/hydromt-fiat-docs.yml') }} - # restore-keys: | - # docs - - # - name: Fail on no cache restore - # if: steps.cache.outputs.cache-matched-key == '' - # run: | - # echo "Failed to restore any cache. exiting..." - # exit 1 - - # # by avoiding the mamba setup stage by loading it from cache instead we save - # # a lot of setup time, but we do have to do our own PATH management - # # hence the exports - # - name: Update environment - # if: steps.cache.outputs.cache-hit != 'true' - # run: | - # export PATH=/usr/share/miniconda3/bin:$PATH - # mamba env update -n hydromt-fiat-docs -f envs/hydromt-fiat-docs.yml - - - name: Install environment - run: mamba env update -n hydromt-fiat-docs -f envs/hydromt-fiat-docs.yml - - - name: Install hydromt-fiat - run: pip install . + - name: Install and activate environment + run: | + mamba env create -f envs/hydromt-fiat-docs.yml + conda activate hydromt-fiat-docs + pip install . - name: Generate docs if: ${{ github.event_name != 'pull_request' && !github.event.act }} From 79a94fbb58682b74330921ac203f799d8a3ea742 Mon Sep 17 00:00:00 2001 From: Frederique Date: Thu, 19 Oct 2023 16:46:50 +0200 Subject: [PATCH 06/14] update --- docs/index.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/index.rst b/docs/index.rst index b346e85e..5b285644 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -17,6 +17,10 @@ by configuring the model building process from single *yml* file. For detailed information on HydroMT itself, you can visit the `core documentation `_. +:: + + Note: This repository is under development, the documentation is not yet complete! + Overview ============= From 28feee3569774e285733683912f9e7b0011b65c7 Mon Sep 17 00:00:00 2001 From: Frederique Date: Thu, 19 Oct 2023 16:52:21 +0200 Subject: [PATCH 07/14] try again --- docs/index.rst | 2 +- envs/hydromt-fiat-docs.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index 5b285644..77a13f2a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -19,7 +19,7 @@ For detailed information on HydroMT itself, you can visit the `core documentatio :: - Note: This repository is under development, the documentation is not yet complete! + Note: This repository is under development, the documentation is not yet complete... Overview diff --git a/envs/hydromt-fiat-docs.yml b/envs/hydromt-fiat-docs.yml index 0fff25aa..4c42a90e 100644 --- a/envs/hydromt-fiat-docs.yml +++ b/envs/hydromt-fiat-docs.yml @@ -18,6 +18,7 @@ dependencies: - pip - pyogrio - pydata-sphinx-theme +- python=3.10 - rasterio - requests - rioxarray From a1b44737229070fdd76623f35cf0c33758fa8d70 Mon Sep 17 00:00:00 2001 From: Frederique Date: Thu, 19 Oct 2023 16:59:02 +0200 Subject: [PATCH 08/14] Update paths --- examples/aggregation_zones_example.ipynb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/aggregation_zones_example.ipynb b/examples/aggregation_zones_example.ipynb index 152d80dc..967e01c8 100644 --- a/examples/aggregation_zones_example.ipynb +++ b/examples/aggregation_zones_example.ipynb @@ -58,8 +58,8 @@ "from pathlib import Path\n", "import os \n", "#Load aggregation zones as GeoDataFrames\n", - "exposure=gpd.read_file(Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones_example\" / \"exposure\" / \"buildings.gpkg\")\n", - "base_zone=gpd.read_file(Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones_example\" / \"aggregation_zones\" / \"base_zones.gpkg\")\n", + "exposure=gpd.read_file(Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones\" / \"exposure\" / \"buildings.gpkg\")\n", + "base_zone=gpd.read_file(Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones\" / \"aggregation_zones\" / \"base_zones.gpkg\")\n", "\n", "m = base_zone.explore(column = 'ZONE_BASE')\n", "m = exposure.explore(m=m, color = '#FFFACD')\n", @@ -179,7 +179,7 @@ "#Let's read the yaml file with the required information \n", "#and set up the FIAT model for the two test cases. \n", "\n", - "with open(Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones_example\" / \"config_aggregation.yml\", 'r') as file:\n", + "with open(Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones\" / \"config_aggregation.yml\", 'r') as file:\n", " config_aggregation = yaml.safe_load(file)\n", "\n", "print(json.dumps(config_aggregation, indent=4, sort_keys=False))" @@ -208,7 +208,7 @@ "outputs": [], "source": [ "# Set up Fiat Model\n", - "root = Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones_example\"\n", + "root = Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones\" / \"fiat_model\"\n", "\n", "#If case exist\n", "if Path(config_aggregation[\"cases\"][\"test1_single_aggregation\"][\"new_root\"]).exists():\n", @@ -320,10 +320,10 @@ "outputs": [], "source": [ "#Load *.csv into dataframe\n", - "df_single_aggregation = pd.read_csv(Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones_example\" / \"output\" / \"aggregation_zones_test1\" / \"exposure\" / \"exposure.csv\")\n", + "df_single_aggregation = pd.read_csv(Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones\" / \"output\" / \"aggregation_zones_test1\" / \"exposure\" / \"exposure.csv\")\n", "\n", "#Load original exposure geopackage into GeoDataFrame\n", - "new_exposure=gpd.read_file(Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones_example\" / \"output\" / \"aggregation_zones_test1\" / \"exposure\" / \"buildings.gpkg\")\n", + "new_exposure=gpd.read_file(Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones\" / \"output\" / \"aggregation_zones_test1\" / \"exposure\" / \"buildings.gpkg\")\n", "\n", "#Merge dataframe with GeoDataFrame\n", "merged_gdf = new_exposure.merge(df_single_aggregation, left_on='Object ID', right_on='Object ID', how='inner')\n", @@ -354,10 +354,10 @@ "outputs": [], "source": [ "#Load *.csv into dataframe\n", - "df_multiple_aggregation = pd.read_csv(Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones_example\" / \"output\" / \"aggregation_zones_test2\" / \"exposure\" / \"exposure.csv\")\n", + "df_multiple_aggregation = pd.read_csv(Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones\" / \"output\" / \"aggregation_zones_test2\" / \"exposure\" / \"exposure.csv\")\n", "\n", "#Load original exposure geopackage into GeoDataFrame\n", - "new_exposure=gpd.read_file(Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones_example\" / \"output\" / \"aggregation_zones_test2\" / \"exposure\" / \"buildings.gpkg\")\n", + "new_exposure=gpd.read_file(Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones\" / \"output\" / \"aggregation_zones_test2\" / \"exposure\" / \"buildings.gpkg\")\n", "\n", "#Merge dataframe with GeoDataFrame\n", "merged_gdf_multiple = new_exposure.merge(df_multiple_aggregation, left_on='Object ID', right_on='Object ID', how='inner')" From 82b2762f7eb8d311fac4fa9279ce06c2b291cb55 Mon Sep 17 00:00:00 2001 From: Frederique Date: Thu, 19 Oct 2023 17:06:34 +0200 Subject: [PATCH 09/14] update paths --- examples/aggregation_zones_example.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/aggregation_zones_example.ipynb b/examples/aggregation_zones_example.ipynb index 967e01c8..c273ea99 100644 --- a/examples/aggregation_zones_example.ipynb +++ b/examples/aggregation_zones_example.ipynb @@ -58,7 +58,7 @@ "from pathlib import Path\n", "import os \n", "#Load aggregation zones as GeoDataFrames\n", - "exposure=gpd.read_file(Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones\" / \"exposure\" / \"buildings.gpkg\")\n", + "exposure=gpd.read_file(Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones\" / \"fiat_model\" / \"exposure\" / \"buildings.gpkg\")\n", "base_zone=gpd.read_file(Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones\" / \"aggregation_zones\" / \"base_zones.gpkg\")\n", "\n", "m = base_zone.explore(column = 'ZONE_BASE')\n", From f62817ff7b33dec89b05c16e8c2498b2025c5d24 Mon Sep 17 00:00:00 2001 From: Frederique Date: Fri, 20 Oct 2023 09:43:48 +0200 Subject: [PATCH 10/14] Fixed small bugs in example --- .gitignore | 4 +--- examples/aggregation_zones_example.ipynb | 10 ++-------- .../data/aggregation_zones/config_aggregation.yml | 12 ++++++------ 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 143ade5b..7e3a8fb7 100644 --- a/.gitignore +++ b/.gitignore @@ -121,7 +121,5 @@ venv.bak/ cache /examples/FIAT_database hydromt_fiat/data/damage_functions/flooding/AllDDF_HAZUS_fractions.xlsx -hydromt_fiat/data/damage_functions/flooding/~$AllDDF_HAZUS_fractions.xlsx examples/data/building_footprints/fiat_model_bfs -examples/data/aggregation_zones_example/aggregation_test_1_output -examples/data/aggregation_zones_example/aggregation_test_2_output \ No newline at end of file +examples/data/aggregation_zones/output \ No newline at end of file diff --git a/examples/aggregation_zones_example.ipynb b/examples/aggregation_zones_example.ipynb index c273ea99..e26cd002 100644 --- a/examples/aggregation_zones_example.ipynb +++ b/examples/aggregation_zones_example.ipynb @@ -14,7 +14,7 @@ "In spatial analysis and urban planning the division of objects into spatial zones is a pivotal tool to facilitate analysis and/or visualization. This jupyter notebook demonstrates how to create a **spatial joint** of the FIAT model data with single or multiple **aggregation zones** in order to link an the zone and objects of interest. \n", "

The base for this notebook is the DELFT FIAT toolbox.

\n", "\n", - "Note: In this notebook the model was already initialized. Unless the user does not wish to use own data, there is `no need` to create a new model and the user can simply continue with the example data found in the / \"example\" / \"data\"/ \"aggregation_zone_example\" - directory.

" + "Note: In this notebook the model was already initialized. Unless the user does not wish to use own data, there is `no need` to create a new model and the user can simply continue with the example data found in the / \"example\" / \"data\"/ \"aggregation_zone\" - directory.

" ] }, { @@ -95,17 +95,11 @@ "metadata": {}, "outputs": [], "source": [ - "from typing import Sequence\n", - "from _pytest.mark.structures import ParameterSet\n", "from hydromt_fiat.fiat import FiatModel\n", "from hydromt.log import setuplog\n", - "import pytest\n", "import pandas as pd\n", - "from hydromt_fiat.workflows.aggregation_areas import join_exposure_aggregation_areas\n", "import yaml\n", "import json\n", - "from hydromt_fiat.workflows.exposure_vector import ExposureVector\n", - "from hydromt_fiat.workflows.vulnerability import Vulnerability\n", "import shutil" ] }, @@ -270,7 +264,7 @@ "outputs": [], "source": [ "#If case exist\n", - "if Path(config_aggregation[\"cases\"][\"test1_single_aggregation\"][\"new_root\"]).exists():\n", + "if Path(config_aggregation[\"cases\"][\"test2_multiple_aggregation\"][\"new_root\"]).exists():\n", " shutil.rmtree(config_aggregation[\"cases\"][\"test2_multiple_aggregation\"][\"new_root\"])\n", " \n", "# Set up the logger\n", diff --git a/examples/data/aggregation_zones/config_aggregation.yml b/examples/data/aggregation_zones/config_aggregation.yml index ee763e4d..ae077966 100644 --- a/examples/data/aggregation_zones/config_aggregation.yml +++ b/examples/data/aggregation_zones/config_aggregation.yml @@ -1,20 +1,20 @@ cases: test1_single_aggregation: - new_root: "./data/Aggregation_zones_example/output/aggregation_zones_test1" + new_root: "./data/Aggregation_zones/output/aggregation_zones_test1" configuration: setup_aggregation_areas: - aggregation_area_fn: "./data/Aggregation_zones_example/aggregation_zones/base_zones.gpkg" + aggregation_area_fn: "./data/Aggregation_zones/aggregation_zones/base_zones.gpkg" attribute_names: ZONE_BASE label_names: Base_zones test2_multiple_aggregation: - new_root: "./data/Aggregation_zones_example/output/aggregation_zones_test2" + new_root: "./data/Aggregation_zones/output/aggregation_zones_test2" configuration: setup_aggregation_areas: aggregation_area_fn: - - "./data/Aggregation_zones_example/aggregation_zones/base_zones.gpkg" - - "./data/Aggregation_zones_example/aggregation_zones/land_use.gpkg" - - "./data/Aggregation_zones_example/aggregation_zones/accomodation_type.gpkg" + - "./data/Aggregation_zones/aggregation_zones/base_zones.gpkg" + - "./data/Aggregation_zones/aggregation_zones/land_use.gpkg" + - "./data/Aggregation_zones/aggregation_zones/accomodation_type.gpkg" attribute_names: - ZONE_BASE - LAND_USE From e8d5313b84e5d67ec7a1fe2e81c788e64d4883c6 Mon Sep 17 00:00:00 2001 From: Frederique Date: Fri, 20 Oct 2023 09:52:45 +0200 Subject: [PATCH 11/14] Added Sarah as author --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 1a871285..117e1efb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,6 +10,7 @@ authors = [ {name = "Mario Fuentes Monjaraz", email = "mario.fuentesmonjaraz@deltares.nl"}, {name = "Luis Rodriguez Galvez", email = "luis.rodriguez@deltares.nl"}, {name = "Lieke Meijer", email = "lieke.meijer@deltares.nl"}, + {name = "Sarah Rautenbach", email = "sarah.rautenbach@deltares.nl"}, ] requires-python = ">=3.8" dependencies = [ From 3b6530ca2907f761de2de551de19db1c3825c475 Mon Sep 17 00:00:00 2001 From: Frederique Date: Fri, 20 Oct 2023 10:00:23 +0200 Subject: [PATCH 12/14] Bug fixes and update in fiat.py to read from the correct config variable --- examples/aggregation_zones_example.ipynb | 516 +++++++++++++++++- .../fiat_model/settings.toml | 4 +- hydromt_fiat/fiat.py | 2 +- 3 files changed, 507 insertions(+), 15 deletions(-) diff --git a/examples/aggregation_zones_example.ipynb b/examples/aggregation_zones_example.ipynb index e26cd002..e965cf44 100644 --- a/examples/aggregation_zones_example.ipynb +++ b/examples/aggregation_zones_example.ipynb @@ -50,9 +50,415 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
Make this Notebook Trusted to load map: File -> Trust Notebook
" + ], + "text/plain": [ + "" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "import geopandas as gpd\n", "from pathlib import Path\n", @@ -91,7 +497,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -166,9 +572,52 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{\n", + " \"cases\": {\n", + " \"test1_single_aggregation\": {\n", + " \"new_root\": \"./data/Aggregation_zones/output/aggregation_zones_test1\",\n", + " \"configuration\": {\n", + " \"setup_aggregation_areas\": {\n", + " \"aggregation_area_fn\": \"./data/Aggregation_zones/aggregation_zones/base_zones.gpkg\",\n", + " \"attribute_names\": \"ZONE_BASE\",\n", + " \"label_names\": \"Base_zones\"\n", + " }\n", + " }\n", + " },\n", + " \"test2_multiple_aggregation\": {\n", + " \"new_root\": \"./data/Aggregation_zones/output/aggregation_zones_test2\",\n", + " \"configuration\": {\n", + " \"setup_aggregation_areas\": {\n", + " \"aggregation_area_fn\": [\n", + " \"./data/Aggregation_zones/aggregation_zones/base_zones.gpkg\",\n", + " \"./data/Aggregation_zones/aggregation_zones/land_use.gpkg\",\n", + " \"./data/Aggregation_zones/aggregation_zones/accomodation_type.gpkg\"\n", + " ],\n", + " \"attribute_names\": [\n", + " \"ZONE_BASE\",\n", + " \"LAND_USE\",\n", + " \"ACCOM\"\n", + " ],\n", + " \"label_names\": [\n", + " \"Base_zones\",\n", + " \"Land_use\",\n", + " \"Accommodation_type\"\n", + " ]\n", + " }\n", + " }\n", + " }\n", + " }\n", + "}\n" + ] + } + ], "source": [ "#Let's read the yaml file with the required information \n", "#and set up the FIAT model for the two test cases. \n", @@ -197,9 +646,17 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2023-10-20 09:59:17,072 - hydromt_fiat - log - INFO - HydroMT version: 0.8.0\n" + ] + } + ], "source": [ "# Set up Fiat Model\n", "root = Path(os.path.abspath(\"\")) / \"data\" / \"aggregation_zones\" / \"fiat_model\"\n", @@ -229,9 +686,42 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2023-10-20 09:59:18,050 - hydromt_fiat - log - DEBUG - Appending log messages to file c:\\Repositories\\hydromt_fiat\\examples\\data\\aggregation_zones\\fiat_model\\hydromt.log.\n", + "2023-10-20 09:59:18,051 - hydromt_fiat - model_api - INFO - Initializing fiat model from hydromt_fiat (v0.2.1.dev0).\n", + "2023-10-20 09:59:18,052 - hydromt_fiat - fiat - INFO - Reading model data from c:\\Repositories\\hydromt_fiat\\examples\\data\\aggregation_zones\\fiat_model\n", + "2023-10-20 09:59:18,053 - hydromt_fiat - model_api - DEBUG - User defined config read from c:\\Repositories\\hydromt_fiat\\examples\\data\\aggregation_zones\\fiat_model\\settings.toml\n", + "2023-10-20 09:59:18,054 - hydromt_fiat - fiat - INFO - Reading model table files.\n", + "2023-10-20 09:59:18,055 - hydromt_fiat - fiat - DEBUG - Reading vulnerability table c:\\Repositories\\hydromt_fiat\\examples\\data\\aggregation_zones\\fiat_model\\vulnerability\\vulnerability_curves.csv\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2023-10-20 09:59:18,085 - hydromt_fiat - fiat - DEBUG - Reading exposure table c:\\Repositories\\hydromt_fiat\\examples\\data\\aggregation_zones\\fiat_model\\exposure\\exposure.csv\n", + "2023-10-20 09:59:18,092 - hydromt_fiat - fiat - INFO - Reading exposure geometries.\n", + "2023-10-20 09:59:18,093 - hydromt_fiat - exposure_vector - INFO - Setting geometry name to buildings...\n", + "2023-10-20 09:59:18,181 - hydromt_fiat - exposure_vector - INFO - Setting exposure geometries...\n", + "2023-10-20 09:59:18,181 - hydromt_fiat - model_api - INFO - setup_aggregation_areas.aggregation_area_fn: ./data/Aggregation_zones/aggregation_zones/base_zones.gpkg\n", + "2023-10-20 09:59:18,182 - hydromt_fiat - model_api - INFO - setup_aggregation_areas.attribute_names: ZONE_BASE\n", + "2023-10-20 09:59:18,182 - hydromt_fiat - model_api - INFO - setup_aggregation_areas.label_names: Base_zones\n", + "2023-10-20 09:59:18,285 - hydromt_fiat - log - DEBUG - Writing log messages to new file c:\\Repositories\\hydromt_fiat\\examples\\data\\Aggregation_zones\\output\\aggregation_zones_test1\\hydromt.log.\n", + "2023-10-20 09:59:18,286 - hydromt_fiat - fiat - INFO - Updating all data objects...\n", + "2023-10-20 09:59:18,287 - hydromt_fiat - fiat - INFO - Writing model data to c:\\Repositories\\hydromt_fiat\\examples\\data\\Aggregation_zones\\output\\aggregation_zones_test1\n", + "2023-10-20 09:59:18,288 - hydromt_fiat - model_api - INFO - Writing model config to c:\\Repositories\\hydromt_fiat\\examples\\data\\Aggregation_zones\\output\\aggregation_zones_test1\\settings.toml\n", + "2023-10-20 09:59:18,289 - hydromt_fiat - model_api - DEBUG - Writing file exposure/buildings.gpkg\n", + "2023-10-20 09:59:18,396 - hydromt_fiat - fiat - INFO - Writing model exposure table file to exposure/exposure.csv.\n", + "2023-10-20 09:59:18,411 - hydromt_fiat - fiat - INFO - Writing model vulnerability_curves table file to vulnerability/vulnerability_curves.csv.\n" + ] + } + ], "source": [ "#Start running the new model with the new exposure output \n", "fm = FiatModel(root=root, mode=\"r\", logger=logger)\n", diff --git a/examples/data/aggregation_zones/fiat_model/settings.toml b/examples/data/aggregation_zones/fiat_model/settings.toml index 44b60c5b..3ae7d2ea 100644 --- a/examples/data/aggregation_zones/fiat_model/settings.toml +++ b/examples/data/aggregation_zones/fiat_model/settings.toml @@ -15,8 +15,10 @@ file = "./vulnerability/vulnerability_curves.csv" unit = "feet" step_size = 0.1 +[exposure.csv] +file = "./exposure/exposure.csv" + [exposure.geom] -csv = "./exposure/exposure.csv" crs = "EPSG:4326" unit = "ft" file1 = "./exposure/buildings.gpkg" diff --git a/hydromt_fiat/fiat.py b/hydromt_fiat/fiat.py index ab7128bd..c1dd90e6 100644 --- a/hydromt_fiat/fiat.py +++ b/hydromt_fiat/fiat.py @@ -718,7 +718,7 @@ def read_tables(self): logging.warning(f"File {vulnerability_fn} does not exist!") # Now with exposure - exposure_fn = Path(self.root) / self.get_config("exposure.geom.csv") + exposure_fn = Path(self.root) / self.get_config("exposure.csv.file") if Path(exposure_fn).is_file(): self.logger.debug(f"Reading exposure table {exposure_fn}") self.exposure = ExposureVector( From 454c0c8c9f6712fa9f058bd85d7f651d63455770 Mon Sep 17 00:00:00 2001 From: Frederique Date: Fri, 20 Oct 2023 10:12:25 +0200 Subject: [PATCH 13/14] spelling mistake --- docs/examples/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/examples/index.rst b/docs/examples/index.rst index dbbee426..ad9e3d8b 100644 --- a/docs/examples/index.rst +++ b/docs/examples/index.rst @@ -12,5 +12,5 @@ Offline example access Below you can access some of the main examples and go through them in an off-line manner. More examples will be added soon. 1. `Creating a Delft-FIAT model anywhere in the world from OSM and JRC data <../_examples/global_OSM_JRC.ipynb>`_ -2. `Adding aggregation zones to your Delft-FIAT model <../_examples/aggreagation_zones_example.ipynb>`_ +2. `Adding aggregation zones to your Delft-FIAT model <../_examples/aggregation_zones_example.ipynb>`_ From 5bba56ff2f756007dfc26d13c9d64d9cf4770d31 Mon Sep 17 00:00:00 2001 From: Frederique Date: Fri, 20 Oct 2023 10:13:00 +0200 Subject: [PATCH 14/14] removed docs branch in workflow --- .github/workflows/docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 3257f1ff..c7e01de4 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,7 +3,7 @@ name: Build Documentation on: workflow_dispatch: push: - branches: [ main, docs ] + branches: [ main ] paths: - tests/* - hydromt_fiat/* @@ -11,7 +11,7 @@ on: - examples/* - pyproject.toml pull_request: - branches: [ main, docs ] + branches: [ main ] paths: - tests/* - hydromt_fiat/*