Skip to content

Commit

Permalink
Merge pull request #42 from Deltares/results
Browse files Browse the repository at this point in the history
Results
  • Loading branch information
hboisgon committed Aug 24, 2021
2 parents 4d69a7a + b7013eb commit 1efb9d3
Show file tree
Hide file tree
Showing 19 changed files with 1,028 additions and 30 deletions.
7 changes: 7 additions & 0 deletions docs/changelog.rst
Expand Up @@ -11,6 +11,7 @@ The format is based on `Keep a Changelog`_, and this project adheres to
Added
^^^^^

- Add results attributes for wflow and read_results method (including test+example).
- Add f_ parameter in soilgrids
- Support soilgrids version 2020
- Setup_areamap component to prepare maps of areas of interest to save wflow outputs at.
Expand All @@ -29,6 +30,12 @@ Fixed

- Fix f parameter in soilgrids

Documentation
^^^^^^^^^^^^^

- Added wflow_plot_results example.
- Fixed staticmaps_to_mapstack example.

v0.1.1 (21 May 2021)
--------------------
This release adds more functionnality for saving forcing data for wflow and fixes several bugs for some parameter values and soilgrids workflow.
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/index.rst
Expand Up @@ -32,7 +32,8 @@ Examples
.. toctree::
:maxdepth: 1

Convert wflow staticmaps netcdf to raster files <examples/convert_staticmaps_to_gtiff>
Convert wflow staticmaps netcdf to raster files <examples/convert_staticmaps_to_mapstack>
Plot Wflow static maps <examples/plot_wflow_staticmaps>
Plot Wflow forcing data <examples/plot_wflow_forcing>
Plot Wflow results data <examples/plot_wflow_results>

2 changes: 1 addition & 1 deletion envs/hydromt-wflow.yml
Expand Up @@ -11,7 +11,7 @@ dependencies:
- black
- bottleneck
- cartopy # to run examples
- dask=2021.06.1
- dask
- descartes # to run examples
- entrypoints
- flit>=3.2
Expand Down
Expand Up @@ -177,7 +177,8 @@
"metadata": {},
"outputs": [],
"source": [
"# update the model staticmaps\n",
"# Reinitialize and update the new model staticmaps\n",
"mod._staticmaps = xr.Dataset()\n",
"mod.set_staticmaps(ds_updated)"
]
},
Expand All @@ -191,6 +192,122 @@
"# write the model to the new directory\n",
"mod.write()"
]
},
{
"cell_type": "markdown",
"id": "7fdabc58",
"metadata": {},
"source": [
"### Update wflow staticmaps manually using hydroMT"
]
},
{
"cell_type": "markdown",
"id": "e1567262",
"metadata": {},
"source": [
"The previous steps show you how you can easily save a model staticmaps to a GeoTIFF mapstacks and read it again using hydroMT functions **to_mapstack** and **open_mfraster**.\n",
"\n",
"However in order to have a fully ready-to-run wflow model, the mapstacks that we create needs to be processed a little more:\n",
"\n",
"* The LAI maps have a third *time* dimension (other than x and y coordinates)\n",
"* The c maps have a third soil *layer* dimension\n",
"\n",
"To update manually a wflow model that is then ready to run, we advise to use the following workflow and functions:\n",
"\n",
"* read the original model\n",
"* save the original model staticmaps to formatted PCRaster mapstacks using the **write_staticmaps_pcr** function (based on to_mapstack with c and LAI pre-processing)\n",
"* manually update the PCRaster maps (eg using QGIS)\n",
"* read the updated staticmaps using the **read_staticmaps_pcr** function (based on open_mfraster with c and LAI post-processing)\n",
"* Change the model root to write the updated model to a new directory\n",
"* Write the model\n",
"\n",
"NOTE: We do not read the forcing as it is probably faster to just copy the file instead of loading it into python and writing it back to netcdf.\n",
"\n",
"NOTE: The staticgeoms might be changed because of manual changes in the wflow_river, lakes, reservoir or glacier staticmaps and are therefore not read here. To change these maps we recommend using the hydromt update method to keep the staticgeoms and maps aligned."
]
},
{
"cell_type": "markdown",
"id": "3464a5c3",
"metadata": {},
"source": [
"#### Save the staticmaps as a PCRaster mapstack"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b06f0f2b",
"metadata": {},
"outputs": [],
"source": [
"# read the original model\n",
"root = 'wflow_piave_subbasin' \n",
"mod = hydromt.WflowModel(root, mode='r+')\n",
"mod.read_staticmaps()\n",
"mod.read_config()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "330cfb52",
"metadata": {},
"outputs": [],
"source": [
"# save the staticmaps to PCRaster mapstacks and update them manually where needed\n",
"mod.write_staticmaps_pcr()"
]
},
{
"cell_type": "markdown",
"id": "7474fc4e",
"metadata": {},
"source": [
"#### Create a new wflow model based on the updated PCRaster mapstack"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ca8c57cc",
"metadata": {},
"outputs": [],
"source": [
"# read the updated staticmaps\n",
"root = 'wflow_piave_subbasin' \n",
"mod = hydromt.WflowModel(root, mode='r')\n",
"mod.read_staticmaps_pcr()\n",
"mod.read_config()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c84202b5",
"metadata": {},
"outputs": [],
"source": [
"# change root to a new directory\n",
"root_updated = 'wflow_piave_subbasin_updated'\n",
"mod.set_root(root_updated, mode='w')\n",
"# re-generate the basins and rivers staticgeoms, for others (gauges, lakes, reservoirs, glaicers) use the hydromt update method\n",
"mod.basins\n",
"mod.rivers\n",
"print(\"Creating a new directory for the updated model\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "04df13a5",
"metadata": {},
"outputs": [],
"source": [
"# write the model to the new directory\n",
"mod.write()"
]
}
],
"metadata": {
Expand All @@ -209,7 +326,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.2"
"version": "3.9.4"
}
},
"nbformat": 4,
Expand Down
10 changes: 10 additions & 0 deletions examples/gauges_observed_flow.csv
@@ -0,0 +1,10 @@
time;Q_6349410;Q_6349400;Q_6349411
2010-02-02T00:00:00;14.21117463;23.14968045;4.657260644
2010-02-03T00:00:00;20.63727294;40.4367125;9.237468864
2010-02-04T00:00:00;26.21875575;54.46918112;11.94857033
2010-02-05T00:00:00;29.66606831;59.2240498;12.4642965
2010-02-06T00:00:00;32.1589512;59.21861451;11.93064957
2010-02-07T00:00:00;32.26008825;57.43010672;11.23056571
2010-02-08T00:00:00;31.09006663;54.0491823;10.51420303
2010-02-09T00:00:00;29.99882382;50.84542554;9.88308009
2010-02-10T00:00:00;29.10063939;48.09354881;9.312256295

0 comments on commit 1efb9d3

Please sign in to comment.