Commit d1c688b1 authored by Dorchies David's avatar Dorchies David
Browse files

feat: compute flood return periods on Paris

parent 0afd30a2
Pipeline #33625 failed with stages
in 34 minutes and 27 seconds
# Caractérisation des événements de crue à Paris
```{r setup, include=FALSE}
library(seinebasin2)
library(tidyr)
library(ggplot2)
library(InraeThemes)
cfg <- loadConfig()
knitr::opts_chunk$set(
fig.width = 8,
fig.asp = 0.4
)
```
```{r}
id_Paris <- "H5920010"
```
```{r load_Q}
# Débit simulé période historique
Qnat <- readQsim(cfg$Qnat$path, "Qnat-v1", cfg = cfg)
iCol <- which(names(Qnat) == id_Paris)
Qnat <- Qnat[, c(1, iCol)]
# Débit simulé sur les projections climatiques RCP8.5
rcps <- "rcp8.5"
scenarios <- gsub("/", "_", cfg$hydroclim$drias$scenarios)
scenariosX <- rep(scenarios, length(rcps))
rcpsX <- rep(rcps, each = length(scenarios))
loadDriasQsim <- function(rcp_scenario) {
message("Read Qsim for ", rcp_scenario)
Qsim <- readQsim(cfg$Qnat$path, "Drias2020/Qnat-v1", rcp_scenario, cfg = cfg)
iCol <- which(names(Qnat) == id_Paris)
Qsim[, c(1, iCol)]
}
QsimDrias <- lapply(paste(rcps, scenarios, sep="/"), loadDriasQsim)
names(QsimDrias) <- paste(rcps, scenarios, sep = " - ")
QsimAll <- c(list(hist = Qnat), QsimDrias)
```
```{r}
statQJXA <- function(Qsim, period) {
l <- lapply(names(Qsim), function(scenario) {
Q <- Qsim[[scenario]]
Q <- Q[Q$DatesR >= period[1] & Q$DatesR <= period[2], ]
QJXA <- calcQJXA(Q)
QJXA <- sort(QJXA[,1])
p <- 1 - seq(length(QJXA)) / (length(QJXA) + 1)
t <- 1 / p
data.frame(scenario = scenario, p, t, Q = QJXA)
})
do.call(rbind, l)
}
```
```{r}
plotReturnPeriods <- function(QJXA, subtitle) {
ggplot(QJXA, aes(x = t, y = Q)) +
#coord_trans(x = "log2") +
geom_line(aes(color = scenario)) +
ggtitle("Période de retour des débits maximums annuels à Paris", subtitle) +
labs(x = "Période de retour (années)", y ="Débit maximum annuel (m3/s)")
}
```
```{r}
QJXA_ref <- statQJXA(QsimAll, cfg$hydroclim$drias$periods$ref)
plotReturnPeriods(QJXA_ref, "Période 1976-2005")
```
```{r}
QJXA_near <- statQJXA(QsimDrias, cfg$hydroclim$drias$periods$near)
plotReturnPeriods(QJXA_near, "Période 2021-2050")
```
```{r}
QJXA_middle <- statQJXA(QsimDrias, cfg$hydroclim$drias$periods$middle)
plotReturnPeriods(QJXA_middle, "Période 2041-2070")
```
```{r}
QJXA_end <- statQJXA(QsimDrias, cfg$hydroclim$drias$periods$end)
plotReturnPeriods(QJXA_end, "Période 2071-2100")
```
```{r}
period <- c(cfg$hydroclim$drias$periods$ref[1], cfg$hydroclim$drias$periods$end[2])
plotReturnPeriods(statQJXA(QsimDrias, period),
"Période 1976-2100")
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment