# airGRiwrm: an extension of the airGR R-package for handling Integrated Water Resources Management modeling

David Dorchies, Olivier Delaigue, Guillaume Thirel

## ► To cite this version:

David Dorchies, Olivier Delaigue, Guillaume Thirel. airGRiwrm: an extension of the airGR R-package for handling Integrated Water Resources Management modeling. EGU General Assembly 2021 - vEGU21: Gather Online, Apr 2021, Vienna, Austria. pp.EGU21-2190, 10.5194/egusphere-egu21-2190. hal-03330881

HAL Id: hal-03330881

https://hal.inrae.fr/hal-03330881

Submitted on 20 Apr 2023

HAL is a multi-disciplinary open access archive for the deposit and dissemination of scientific research documents, whether they are published or not. The documents may come from teaching and research institutions in France or abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est destinée au dépôt et à la diffusion de documents scientifiques de niveau recherche, publiés ou non, émanant des établissements d'enseignement et de recherche français ou étrangers, des laboratoires publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# airGRiwrm R package
an extension of the airGR R-package for handling
Integrated Water Resources Management
modeling

David Dorchies¹, Olivier Delaigue², and Guillaume Thirel²

1. G-EAU, Univ Montpellier, AgroParisTech, CIRAD, IRD, INRAE, Institut Agro, Montpellier, France

2. Université Paris-Saclay, INRAE, HYCAR research unit, Hydrology Research Group, Antony, France

EGU General Assembly 2021
# The airGR packages constellation

<figure><img src="image_2.png" /></figure>

airGR is an R-package for running GR rainfall-runoff models

The latest version has semi-distributed hydrological modelling capabilities that are exploited by the **airGRiwrm** package.

See EGU21-1371 in the same session

<figure><img src="image_3.png" /></figure>
airGRiwrm package main
features

Handle large network of airGR semi-distributed hydrological models with a
minimum of complexity

Easily integrate withdrawal and release flows in the network

Calibration and simulation with both influenced and naturalised flows

Run user control algorithms for simulating flows with automatic regulation
# Semi-distributed model in airGR

<figure><img src="image_4.png" /></figure>

In airGR, GR hydrological model simulations are routed from upstream basins to downstream basins thanks to a lag model

<figure><img src="image_5.png" /></figure>
# How airGRiwrm works

<figure><img src="image_6.png" /></figure>

It extends **airGR** package functions for handling a network of semi-distributed GR models instead of a single global GR model

```r
library(airGR)
library(airGRiwrm)
```

##

## Attaching package: 'airGRiwrm'

## The following objects are masked from 'package:airGR':

##

## Calibration, CreateCalibOptions, CreateInputsCrit,

## CreateInputsModel, CreateRunOptions, RunModel
# Description of the network

<figure><img src="image_7.png" /></figure>

All required information for running a semi-distributed model network are set in a formated `data.frame` called a `GRiwrm` object which can be displayed as a scheme of the network.

DiagramGRiwrm(griwrm)

<figure><img src="image_8.png" /></figure>

<table><thead><tr><th></th><th>id</th><th>down</th><th>length</th><th>model</th><th>area</th></tr></thead><tbody><tr><td>4</td><td>STDIZ_04</td><td>CHALO_21</td><td>85.570</td><td>RunModel_GR4J</td><td>2347.53</td></tr><tr><td>19</td><td>LOUVE_19</td><td>CHALO_21</td><td>86.165</td><td>RunModel_GR4J</td><td>461.74</td></tr><tr><td>25</td><td>VITRY_25</td><td>CHALO_21</td><td>38.047</td><td>RunModel_GR4J</td><td>2109.14</td></tr><tr><td>21</td><td>CHALO_21</td><td>NA</td><td>NA</td><td>RunModel_GR4J</td><td>6291.55</td></tr></tbody></table>
# Hydroclimatic input data handling

<figure><img src="image_9.png" /></figure>

Inputs are represented by matrices with one named column by sub-basin instead of vectors as in airGR

```
head(P, 10)
```

<table><thead><tr><th>##</th><th></th><th>STDIZ_04</th><th>LOUVE_19</th><th>VITRY_25</th><th>CHALO_21</th></tr></thead><tbody><tr><td>##</td><td>[1,]</td><td>0.7</td><td>0.4</td><td>0.9</td><td>0.6</td></tr><tr><td>##</td><td>[2,]</td><td>0.0</td><td>0.0</td><td>0.0</td><td>0.0</td></tr><tr><td>##</td><td>[3,]</td><td>0.0</td><td>0.0</td><td>0.0</td><td>0.0</td></tr><tr><td>##</td><td>[4,]</td><td>0.0</td><td>0.0</td><td>0.0</td><td>0.0</td></tr><tr><td>##</td><td>[5,]</td><td>0.0</td><td>0.1</td><td>0.0</td><td>0.0</td></tr><tr><td>##</td><td>[6,]</td><td>6.1</td><td>4.7</td><td>1.6</td><td>3.8</td></tr><tr><td>##</td><td>[7,]</td><td>17.1</td><td>23.6</td><td>17.0</td><td>16.4</td></tr><tr><td>##</td><td>[8,]</td><td>2.2</td><td>3.1</td><td>6.1</td><td>3.2</td></tr><tr><td>##</td><td>[9,]</td><td>10.8</td><td>10.8</td><td>6.9</td><td>7.8</td></tr><tr><td>##</td><td>[10,]</td><td>8.6</td><td>9.7</td><td>4.1</td><td>5.5</td></tr></tbody></table>
# Processing with a network of SD models

```r
# Preparation of GRiwrmInputsModel object
IMnat <- CreateInputsModel(
  griwrm,
  DatesR = DatesR,
  Precip = P,
  PotEvap = E,
  Qobs = Q
)
```

We use the classical functions and procedures of **airGR** to build objects embedding the whole network data...

## CreateInputsModel.GRiwrm: Treating sub-basin STDIZ_04...

## CreateInputsModel.GRiwrm: Treating sub-basin LOUVE_19...

## CreateInputsModel.GRiwrm: Treating sub-basin VITRY_25...

## CreateInputsModel.GRiwrm: Treating sub-basin CHALO_21...
# Processing with a network of SD models

```r
# Calibration period selection
I_Run <- 366:length(DatesR)

# Set up GRiwrmRunOptions object
RO <- CreateRunOptions(
  InputsModel = IM,
  IndPeriod_Run = I_Run
)

# Calibration criterion:
# the GRiwrmInputsCrit object
IC <- CreateInputsCrit(
  InputsModel = IM,
  FUN_CRIT = airGR::ErrorCrit_NSE,
  RunOptions = RO,
  Obs = Q[I_Run,]
)
```

```r
# Set up GRiwrmCalibOptions object
CO <- CreateCalibOptions(IM)

# Calibration of the network of
# models from upstream to downstream
OC <- Calibration(
  InputsModel = IM,
  RunOptions = RO,
  InputsCrit = IC,
  CalibOptions = CO,
  useUpstreamQsim = TRUE
)
```

```
Calibration.GRiwrmInputsModel: Treating sub-basin STDIZ_04...
```

```
Grid-Screening in progress (0% 20% 40% 60% 80% 100%)
```

```
Screening completed (81 runs)
```

```
Param = 247.151, -0.020, 83.096, 2.384
```

```
Crit. NSE[Q] = 0.8732
```

```
Steepest-descent local search in progress
```

```
Calibration completed (26 iterations, 273 runs)
```

```
Param = 208.513, -0.130, 74.440, 3.506
```

```
Crit. NSE[Q] = 0.9236
```
# Simulation run and outputs

<figure><img src="image_10.png" /></figure>

```R
# Make a list with sub-basin
# calibrated parameters
Param <- sapply(
  names(OC),
  function(x) {OC[[x]]$Param}
)
```

```R
# Run the network of models
OM <- RunModel(IM,
               RunOptions = RO,
               Param = Param)
```

```R
# Plot downstream sub-basin
# with airGR::plot.OutputsModel
plot(OM[[4]], Q[I_RUN, 4])
```

<figure><img src="image_11.png" /></figure>

<figure><img src="image_12.png" /></figure>

<figure><img src="image_13.png" /><figcaption>30-days rolling mean</figcaption></figure>

<figure><img src="image_14.png" /><figcaption>non-exceedance prob. [-]</figcaption></figure>

<figure><img src="image_15.png" /><figcaption>observed flow [mm/d]</figcaption></figure>
# Flow plotting of all network nodes

<figure><img src="image_16.png" /></figure>

The `GRIwrmOutputsModel` has an attribute `"Qm3s"` containing a `data.frame` with simulated flows for all the nodes in m³/s.

```
Qm3s <- attr(OM, "Qm3s")
```

A dedicated plot function displays simulated flow time series for all the nodes.

```
plot(Qm3s[1:365,])
```

<figure><img src="image_17.png" /></figure>
# Anthropic influence integration

<figure><img src="image_18.png" /></figure>

<figure><img src="image_19.png" /><figcaption>Scheme of the real network</figcaption></figure>

airGRiwrm easily integrates direct flow injections or withdrawals in the network by using the matrix of observed flows instead of an hydrological model in network nodes.

<figure><img src="image_20.png" /><figcaption>Network representation in airGRiwrm →</figcaption></figure>
Naturalised vs influenced flows

<figure><img src="image_21.png" /></figure>

Integrating human withdrawals and releases in the network allow to calibrate the model with influenced observed flows and then to run the model without the influences in order to compute naturalised flows by simulation.

<figure><img src="image_22.png" /></figure>

Regime of observed influenced flows (black) and naturalised
simulated flows (orange)
# Regulation algorithm integration

<figure><img src="image_23.png" /></figure>

A supervisor provides simulation outputs during simulation to controllers that execute a logic of control which apply regulated flows in the network.

The user can write control logic representing withdrawal restriction, reservoir operations... with a complex algorithm

<figure><img src="image_24.png" /><figcaption>Results of the simulation of regulated withdrawal restrictions</figcaption></figure>
<figure><img src="image_25.png" /></figure>

# airGRiwrm: airGR based Integrated Water Resource Management R package

airGRiwrm is an extension of the airGR R package for managing semi-distributive hydrological model on an anthropized catchment.

This package is developed as part of the IN-WOP project (http://www.waterjpi.eu/joint-calls/joint-call-2018-waterworks-2017/booklet/in-wop) by the mixed research unit G-EAU (https://g-eau.fr) and the HYDRO team of the INRAE HYCAR research unit (https://www6.jouy.inrae.fr/hycar/Equipes-de-recherche/HYDRO).

## Installation

We need the package `remotes` to install the package from the Irs tea Gitlab repository:

```r
install.packages("remotes")
```

The package airGRiwrm is under development and is only available on Gitlab:

```r
remotes::install_gitlab("in-wop/airGRiwrm", host = "gitlab.irs tea.fr", dependencies = TRUE, build_...")
```

<figure><img src="image_26.png" /></figure>

<figure><img src="image_27.png" /></figure>

`dependencies = TRUE` and `build_vignettes = TRUE` are optional and respectively trigger the installation of suggested packages used in the vignettes and the compilation and the installation of the vignettes.

## Links

Browse source code at
https://gitlab.irs tea.fr/in-wop/
airGRiwrm

## License

Full license
AGPL-3

## Developers

David Dorchies
Author, maintainer

All authors...

<figure><img src="image_28.png" /></figure>
https://gitlab.irstea.fr/in-wop/airGRiwrm

<figure><img src="image_29.png" /></figure>
# Package installation

<figure><img src="image_30.png" /></figure>

The package will be submitted on CRAN soon.

In the meantime, to install the package*:

```R
install.packages("devtools") ## required
remotes::install.gitlab("in-wop/airgriwrm",
                       host = "gitlab.irstea.fr")
```

<footnote>* It also requires the priori installation of 'Rtools' on windows platforms for compiling airGR Fortran's code</footnote>
<figure><img src="image_31.png" /></figure>

RÉPUBLIQUE
FRANÇAISE

Liberté

Égalité

Fraternité

INRAE®