Skip to content
Snippets Groups Projects

Resimuler les événements de crue à Paris pour le couplage avec le modèle Artelia

8 files
+ 391
75
Compare changes
  • Side-by-side
  • Inline
Files
8
+ 15
10
@@ -13,9 +13,9 @@
#'
convert_flood <- function(couplage, cfg, rcp, scenario, dates, fname) {
# Read data
Qsim <- readQsim(cfg$Qnat$path, rcp, "data", scenario, cfg = cfg)
Qsim <- readQsim(cfg$Qnat$path, cfg$hydroclim$drias$version, rcp, "data", scenario, cfg = cfg)
Qsim <- Qsim[Qsim$DatesR %in% dates, ]
Qdown <- readQsim(cfg$Qnat$path, rcp, "data", scenario, filename = "ts_Qcontrib.tsv", cfg = cfg)
Qdown <- readQsim(cfg$Qnat$path,cfg$hydroclim$drias$version, rcp, "data", scenario, filename = "ts_Qcontrib.tsv", cfg = cfg)
Qdown <- Qdown[Qdown$DatesR %in% dates, ]
# Compute arteseine flows
@@ -48,18 +48,23 @@ convert_flood <- function(couplage, cfg, rcp, scenario, dates, fname) {
t <- dates - dates[1]
l <- list(CL = list(name = "CL", ncol = 76, cond = arteseine.ids < 0),
Apports = list(name = "Apports", ncol = 29, cond = arteseine.ids > 0))
path <- file.path(cfg$couplage$path, seinebasin2::iconv_filename(fname))
dir.create(path, showWarnings = FALSE)
if (cfg$couplage$write_results) {
path <- file.path(cfg$couplage$path,
seinebasin2::iconv_filename(sub("\n", "", fname)))
dir.create(path, showWarnings = FALSE)
}
lapply(l, function(x) {
m <- matrix(0, nrow = nrow(Q), ncol = x$ncol)
m[, 1] <- t
m[, 1 + abs(arteseine.ids[x$cond])] <- Q[, x$cond]
filename <- file.path(path, paste0("Tab_", x$name, ".tsv"))
file.copy(paste0("data/header_Tab_", x$name, ".tsv"),
filename,
overwrite = TRUE)
write.table(m, file = filename, append = TRUE, sep ="\t",
row.names = FALSE, col.names = FALSE)
if (cfg$couplage$write_results) {
filename <- file.path(path, paste0("Tab_", x$name, ".tsv"))
file.copy(paste0("data/header_Tab_", x$name, ".tsv"),
filename,
overwrite = TRUE)
write.table(m, file = filename, append = TRUE, sep ="\t",
row.names = FALSE, col.names = FALSE)
}
m
})
}
Loading