diff --git a/NAMESPACE b/NAMESPACE index 3c6efd3b353bd606095c2be682edfe2b4311e84a..5df705b85011754c0d032509f2327c86d27f4a55 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -18,6 +18,10 @@ S3method(calcQMNAn,data.frame) S3method(calcVCN,matrix) S3method(calcVCN,numeric) S3method(calcVCNn,data.frame) +S3method(convertMeteoBVI2BV,GRiwrm) +S3method(convertMeteoBVI2BV,character) +S3method(convertMeteoBVI2BV,data.frame) +S3method(convertMeteoBVI2BV,matrix) S3method(convertUnitQ,data.frame) export(addReservoirsGRiwrm) export(addReservoirsQ) @@ -46,6 +50,7 @@ export(calcVCN30_10) export(calcVCN30_2) export(calcVCN30_5) export(calcVCNn) +export(convertMeteoBVI2BV) export(convertUnitQ) export(createBasinsObs) export(getAprioriIds) @@ -62,12 +67,15 @@ export(max_na_rm) export(mean_na_rm) export(min_na_rm) export(not_na_count) +export(plot_monthly_mean) export(plot_seine_map) export(pmedian) export(readDrias2020) export(readQsim) export(saveFlowDB) +export(selectDriasPeriod) import(airGRiwrm) +import(ggplot2) import(magrittr) import(stats) import(utils) diff --git a/R/convertMeteoBVI2BV.R b/R/convertMeteoBVI2BV.R new file mode 100644 index 0000000000000000000000000000000000000000..2819ed56ca50d3d0e33105d51e0094e45845d035 --- /dev/null +++ b/R/convertMeteoBVI2BV.R @@ -0,0 +1,82 @@ +#' Conversion of meteorological data from sub-basin scale to basin scale +#' +#' @details +#' If `x` is a [data.frame], the first column should a [POSIXct] containing the date and the other columns the time series data. +#' +#' @param x either a `GRiwrm` network description (See [CreateGRiwrm]), a [character] id of a node, or a [matrix] or a [data.frame] containing meteorological data (See details) +#' @param ... Parameters passed to the methods +#' +#' @return [matrix] a matrix containing the converted meteorological data or a [data.frame] if `x` is a [data.frame]. +#' @export +#' @rdname convertMeteoBVI2BV +#' +convertMeteoBVI2BV <- function(x, ...) { + UseMethod("convertMeteoBVI2BV", x) +} + +#' @export +#' @rdname convertMeteoBVI2BV +convertMeteoBVI2BV.data.frame <- function(x, griwrm, ...) { + if (!inherits(x[[1L]], "POSIXt")) { + stop("'x' first column must be a vector of class 'POSIXlt' or 'POSIXct'") + } + DatesR <- x[[1L]] + m <- convertMeteoBVI2BV(griwrm, as.matrix(x[, -1])) + df <- cbind(DatesR, as.data.frame(m)) + names(df) <- names(x) + return(df) +} + +#' @param meteo [matrix] or [data.frame] containing meteorological data. Its [colnames] should be equal to the ID of the basins +#' @export +#' @rdname convertMeteoBVI2BV +convertMeteoBVI2BV.GRiwrm <- function(x, meteo, ...) { + meteo <- as.matrix(meteo) + output <- lapply(colnames(meteo), convertMeteoBVI2BV , griwrm = x, meteo = meteo) + meteoOut <- do.call(cbind,output) + dimnames(meteoOut)[[2]] <- colnames(meteo) + return(meteoOut) +} + +#' @param griwrm `GRiwrm` object describing the semi-distributed network (See [CreateGRiwrm]) +#' @export +#' @rdname convertMeteoBVI2BV +convertMeteoBVI2BV.character <- function(x, griwrm, meteo, ...) { + upperBasins <- !is.na(griwrm$down) & griwrm$down == x + if(all(!upperBasins)) { + return(meteo[,x]) + } + upperIDs <- griwrm$id[upperBasins] + areas <- griwrm$area[match(c(x, upperIDs), griwrm$id)] + output <- convertMeteoBVI2BV( + meteo[,c(x, upperIDs), drop = FALSE], + areas = areas + ) + return(output) +} + +#' @param areas [numeric] vector with the total area of the basin followed by the areas of the upstream basins in km2 +#' @param temperature [logical] `TRUE` if the meteorological data contain air temperature. If `FALSE` minimum output values are bounded to zero +#' @export +#' @rdname convertMeteoBVI2BV +convertMeteoBVI2BV.matrix <- function(x, areas, temperature = FALSE, ...) { + # Check arguments + if(nrow(x) < 2) { + stop("Meteorological data matrix should contain more than one row") + } + if(length(areas) != ncol(x)) { + stop("'areas' length and meteo data matrix number of columns should be equal") + } + if(areas[1] <= sum(areas[-1])) { + stop("Basin area 'areas[1]' should be greater than the sum of the upstream sub-basin areas") + } + if(ncol(x) == 1) { + return(x) + } + # Convert mm to 1E3 m3 and weighted temperatures + V <- x * rep(areas, each = nrow(x)) + # Sum all weighted data and convert back to mm or °C + meteoBV <- rowSums(V) / sum(areas) + return(as.matrix(meteoBV, ncol = 1)) +} + diff --git a/R/plot_monthly_mean.R b/R/plot_monthly_mean.R new file mode 100644 index 0000000000000000000000000000000000000000..3ce56412be024712d8ce8509b39879a2545eb37e --- /dev/null +++ b/R/plot_monthly_mean.R @@ -0,0 +1,45 @@ +#' Plot monthly mean at one gauging station +#' +#' Used for simulated flows and climatic inputs. +#' +#' @details +#' Select time steps corresponding to one of the DRIAS 2020 periods: +#' "ref" for reference (1976-2005), "near" for near future (2021-2050), +#' "middle" for middle of the century (2041-2070), "end" for end of the century (2071-2100). +#' +#' @param rcp [character], "rcp4.5" or "rcp8.5" +#' @param period [character], see details +#' @param station [character], id of gauging station +#' @param drias [list], monthly data of each GCM/RCM projection and each period +#' @param hist [list], monthly data coming from observations +#' @param y_label [character], argument passed to [ggplot2::ylab] +#' +#' @return A ggplot object. +#' @import ggplot2 +#' @export +#' +plot_monthly_mean <- function(rcp, period, station, drias, hist, y_label = "Flow (m³/s)") { + scenarios <- names(drias) + names(scenarios) <- scenarios + drias <- lapply(scenarios, function(x) { + if (grepl(rcp, x, fixed = TRUE)) { + + drias[[x]][[period]][station, ] + } else { + NULL + } + }) + drias <- drias[!sapply(drias,is.null)] + df <- as.data.frame(do.call(cbind, drias)) + df$Mois <- seq.int(12) + dfHist <- as.data.frame(do.call(cbind, lapply(hist, function(x) x[station, ]))) + dfHist$Mois <- seq.int(12) + ggplot(tidyr::gather(df, key = "scenario", value = "Q", -Mois)) + + geom_line(aes(x = Mois, y = Q, color = scenario), size = 1) + + geom_line(data = tidyr::gather(dfHist, key = "historique", value = "Q", -Mois), + aes(x = Mois, y = Q, linetype = historique), + size = 1) + + scale_x_continuous(breaks = seq.int(12), + labels = strsplit("JFMAMJJASOND", "")[[1]]) + + ylab(y_label) + xlab("") +} diff --git a/R/selectDriasPeriod.R b/R/selectDriasPeriod.R new file mode 100644 index 0000000000000000000000000000000000000000..9b40bc589c41de02f2499b61e810038664543665 --- /dev/null +++ b/R/selectDriasPeriod.R @@ -0,0 +1,24 @@ +#' Select a period in a time series +#' +#' @details +#' Select time steps corresponding to one of the DRIAS 2020 periods: +#' "ref" for reference (1976-2005), "near" for near future (2021-2050), +#' "middle" for middle of the century (2041-2070), "end" for end of the century (2071-2100). +#' +#' @param df [data.frame] with a first column of [POSIXt] dates and [numeric] in the other columns +#' @param period [character], see details +#' @template param_cfg +#' +#' @return [data.frame] with a first column of [POSIXt] dates and [numeric] in the other columns with selected rows according to the chosen period +#' @export +#' +selectDriasPeriod <- function(df, period, cfg = loadConfig()) { + periods <- lapply(cfg$hydroclim$drias$periods, as.POSIXct, tz = "UTC") + if (!period %in% names(periods)) { + stop("`period`should be in ", + paste(sprintf("\"%s\"", names(periods)), collapse = ", ")) + } + selectDates <- df$DatesR >= periods[[period]][1] & + df$DatesR <= periods[[period]][2] + return(df[selectDates, ]) +} diff --git a/bookdown/04-scenarios_climatiques.Rmd b/bookdown/04-scenarios_climatiques.Rmd index d11561d543aaed6db6f59abd83f78809316ee591..eb999b2e43e1958526a82de520c24e94c4077b62 100644 --- a/bookdown/04-scenarios_climatiques.Rmd +++ b/bookdown/04-scenarios_climatiques.Rmd @@ -28,13 +28,16 @@ plot_safran_bvi <- function(gis_safran, gis_bvi) { prettymapr::addscalebar() prettymapr::addnortharrow(pos = "topleft", scale = 0.5) } +``` + +```{r, fig.cap = "Carte de superposition des mailles SAFRAN avec le contour du bassin versant de la Seine à Vernon"} plot_safran_bvi(gis_safran = gis_safran, gis_bvi = gis_bvi) title("Superposition des mailles SAFRAN avec le contour du BV") ``` ## Calcul de l'intersection entre les couches mailles SAFRAN et BVI -```{r} +```{r, fig.cap="Fusion de la couche SAFRAN avec celle des bassins versant intermédiaire du bassin versant de la Seine à Vernon"} spMailles <- raster::intersect(gis_safran, gis_bvi) plot(gis_bvi, col = "#33333330") plot(spMailles, add = TRUE) @@ -77,7 +80,7 @@ La liste des scénarios sélectionnés pour l'étude est la suivante : `r paste( ### Aggrégation des données DRIAS 2020 -```{r, eval=!cfg$data$cloud} +```{r, eval=!cfg$data$write_results} driasPath <- getDataPath(cfg$hydroclim$path) saveBasinsObs <- function(rcp, scenario) { @@ -99,3 +102,113 @@ mapply(saveBasinsObs, rcp = cfg$hydroclim$drias$rcp[-1], scenario = rep(colnames(scenarioDriasFiles), 2)) ``` + +## Analyse des données climatiques des GCM/RCM + +```{r} +rcps <- cfg$hydroclim$drias$rcp[-1] +scenarios <- gsub("/", "_", cfg$hydroclim$drias$scenarios) +scenariosX <- rep(scenarios, length(rcps)) +rcpsX <- rep(rcps, each = length(scenarios)) +``` + +## Lecture des données climatiques + +```{r} +# Load all climatic data scenarios +loadAllBasinsObs <- function(rcp, scenario) { + message("Processing ", rcp, " scenario ", scenario, "...") + file <- paste0(paste("BasinObs", rcp, scenario, sep = "_"), ".RDS") + loadBasinsObs(file, cfg = cfg) +} +AllBasinsObs <- mapply(loadAllBasinsObs, + rcp = rcpsX, + scenario = scenariosX, + SIMPLIFY = FALSE) +names(AllBasinsObs) <- paste(rcpsX, scenariosX, sep = " - ") +``` + +```{r} +# arrange data by climat variable +formatObs <- function(BasinsObs, item) { + cbind(DatesR = BasinsObs$DatesR, as.data.frame(BasinsObs[[item]])) +} + +P_drias_BVI <- lapply(AllBasinsObs, formatObs, item = "P") +E_drias_BVI <- lapply(AllBasinsObs, formatObs, item = "E") +T_drias_BVI <- lapply(AllBasinsObs, formatObs, item = "Temp") +rm(AllBasinsObs) + +``` + +```{r} +# Convert BVI to BV +data("griwrm") + +P_drias <- lapply(P_drias_BVI, convertMeteoBVI2BV, griwrm = griwrm) +E_drias <- lapply(E_drias_BVI, convertMeteoBVI2BV, griwrm = griwrm) +T_drias <- lapply(T_drias_BVI, convertMeteoBVI2BV, griwrm = griwrm) + +# Calcul pour tous les scénarios et périodes +calcPeriod <- function(period, df, calcFUN) { + ind <- calcFUN(selectDriasPeriod(df, period)) + t(ind) +} +calcAll <- function(data, calcFUN, periods = names(cfg$hydroclim$drias$periods)) { + names(periods) <- periods + lapply(data, function(df) { + lapply(as.list(periods), calcPeriod, df = df, calcFUN = calcFUN) + }) +} +P_drias_month <- calcAll(P_drias, calcMonthlyInterannualSum) +T_drias_month <- calcAll(T_drias, calcMonthlyInterannualMean) +E_drias_month <- calcAll(E_drias, calcMonthlyInterannualSum) +``` + +```{r} +# Calculs pour les données observées sur la période de référence +BasinsObs <- loadBasinsObs("BasinsObs_observations_day_1958-2019.RDS", cfg = cfg) +P_obs <- formatObs(BasinsObs, item = "P") +T_obs <- formatObs(BasinsObs, item = "Temp") +E_obs <- formatObs(BasinsObs, item = "E") +P_obs_month <- t(calcMonthlyInterannualSum(P_obs)) +T_obs_month <- t(calcMonthlyInterannualMean(T_obs)) +E_obs_month <- t(calcMonthlyInterannualSum(E_obs)) +``` + +```{r, fig.cap="Précipitation moyenne mensuelle du bassin versant à Paris Austerlitz (H5920010) entre 1976 et 2005 pour le climat observé et 5 couples GCM/RCM (DRIAS 2020)"} +plot_monthly_mean("rcp4.5", "ref", "H5920010", P_drias_month, list(obs = P_obs_month), "Precipitation (mm)") +``` + +```{r, fig.cap="Température moyenne mensuelle du bassin versant à Paris Austerlitz (H5920010) entre 1976 et 2005 pour le climat observé et 5 couples GCM/RCM (DRIAS 2020)"} +plot_monthly_mean("rcp4.5", "ref", "H5920010", T_drias_month, list(obs = T_obs_month), "Temperature (°C)") +``` + +```{r, fig.cap="ETP moyenne mensuelle du bassin versant à Paris Austerlitz (H5920010) entre 1976 et 2005 pour le climat observé et 5 couples GCM/RCM (DRIAS 2020)"} +plot_monthly_mean("rcp4.5", "ref", "H5920010", E_drias_month, list(obs = E_obs_month), "PE (mm)") +``` + +```{r, eval=cfg$data$write_results} +# Sauvegarde des données mensuelles dans le cloud +saveClimaticData <- function(obs, drias, path, name) { + drias$obs <- list(ref = obs) + lapply(names(drias), function(scenario) { + lapply(names(drias[[scenario]]), function(period) { + file <- paste0(name, "_monthly_", + gsub(" ", "", scenario),"_", + paste(lubridate::year(cfg$hydroclim$drias$periods[[period]]), collapse = "-"), + ".tsv") + m <- drias[[scenario]][[period]] + df <- cbind(Id = rownames(m), m) + readr::write_tsv(as.data.frame(df), + file.path(path, file)) + }) + }) +} + +path <- getDataPath(cfg$hydroclim$path, "Analyses") +saveClimaticData(P_obs_month, P_drias_month, path, "P") +saveClimaticData(T_obs_month, T_drias_month, path, "T") +saveClimaticData(E_obs_month, E_drias_month, path, "E") +``` + diff --git a/bookdown/06-evolution_indicateurs_hydrologiques.Rmd b/bookdown/06-evolution_indicateurs_hydrologiques.Rmd index 608a3b2efddc4327b5395706d6abf88d6f178de0..9745bd715c0d48c17f08888868d5421152cf1e92 100644 --- a/bookdown/06-evolution_indicateurs_hydrologiques.Rmd +++ b/bookdown/06-evolution_indicateurs_hydrologiques.Rmd @@ -13,20 +13,6 @@ L'évolution est représentée sous la forme du rapport entre l'indicateur calcu La période de référence correspond à la période 1976-2005 et la période future choisie ici correspond à la période "fin de siècle" 2071-2100. -```{r} -selectPeriod <- function(df, period) { - periods <- lapply(cfg$hydroclim$drias$periods, as.POSIXct, tz = "UTC") - if (!period %in% names(periods)) { - stop("`period`should be in ", - paste(sprintf("\"%s\"", names(periods)), collapse = ", ")) - } - selectDates <- df$DatesR >= periods[[period]][1] & - df$DatesR <= periods[[period]][2] - return(df[selectDates, ]) -} -``` - - Les indicateurs sont calculés séparément pour les deux scénarios d'émission RCP 4.5 et RCP 8.5 et une synthèse des différents couples GCM/RCM est réalisée. ```{r} @@ -36,45 +22,6 @@ scenariosX <- rep(scenarios, length(rcps)) rcpsX <- rep(rcps, each = length(scenarios)) ``` -## Lecture des données climatiques - -Les données climatiques sont stockées dans les objets `BasinsObs` (Voir `?loadBasinsObs` pour le chargement). Le nom des fichiers contenant ces données est formé comme suit : `BasinObs_[RCP]_[GCM_RCM].RDS`. Ce qui se traduit en R par : - -```r -file <- paste0(paste("BasinObs", rcp, scenario, sep = "_"), ".RDS") -BasinsObs <- loadBasinsObs(file, cfg = cfg) -``` - -On peut charger toutes les données climatiques de tous les scénarios GCM/RCM dans une liste avec le script suivant : - -```{r} -loadAllBasinsObs <- function(rcp, scenario) { - message("Processing ", rcp, " scenario ", scenario, "...") - file <- paste0(paste("BasinObs", rcp, scenario, sep = "_"), ".RDS") - loadBasinsObs(file, cfg = cfg) -} -AllBasinsObs <- mapply(loadAllBasinsObs, - rcp = rcpsX, - scenario = scenariosX, - SIMPLIFY = FALSE) -names(AllBasinsObs) <- paste(rcpsX, scenariosX, sep = " - ") -``` - -On réarrange les données pour avoir une liste de data.frame pour chaque variable étudiée: - -```{r} -formatObs <- function(BasinObs, item) { - cbind(DatesR = BasinObs$DatesR, as.data.frame(BasinObs[[item]])) -} - -P_drias <- lapply(AllBasinsObs, formatObs, item = "P") -E_drias <- lapply(AllBasinsObs, formatObs, item = "E") -T_drias <- lapply(AllBasinsObs, formatObs, item = "Temp") -rm(AllBasinsObs) -``` -Chaque élément de la liste `AllBasinsObs` est une liste structurée de classe *BasinsObs* (Voir `?createBasinsObs`). - - ## Listes des indicateurs ### Indicateurs mensuels @@ -86,24 +33,13 @@ Pour les données climatiques : - Cumul ETP (mm) ```{r} -# Précipitation moyenne mensuelle pour la période de référence -calcMonthlyInterannualSum(selectPeriod(P_drias[[1]][, 1:3], "ref")) - -# Température moyenne mensuelle pour l'horizon fin de siècle -calcMonthlyInterannualMean(selectPeriod(T_drias[[1]][, 1:3], "end")) - -# Calcul pour tous les scénarios et périodes -calcPeriod <- function(period, df, calcFUN) { - ind <- calcFUN(selectPeriod(df, period)) - t(ind) -} -calcAll <- function(data, calcFUN) { - lapply(data, function(df) { - periods <- names(cfg$hydroclim$drias$periods) - names(periods) <- periods - lapply(as.list(periods), calcPeriod, df = df, calcFUN = calcFUN) - }) +readTsvMatrix <- function(path) { + df <- read.csv(path, sep = "\t") + m <- as.matrix(df[,-1]) + rownames(m) <- df[, 1] + m } + P_month <- calcAll(P_drias, calcMonthlyInterannualSum) T_month <- calcAll(T_drias, calcMonthlyInterannualMean) E_month <- calcAll(E_drias, calcMonthlyInterannualSum) @@ -117,12 +53,6 @@ Pour les débits : Ces données ont été calculées et enregistrées lors de la simulation des débits. ```{r} -readTsvMatrix <- function(path) { - df <- read.csv(path, sep = "\t") - m <- as.matrix(df[,-1]) - rownames(m) <- df[, 1] - m -} loadIndicators <- function(rcp, scenario, indicator) { periods <- names(cfg$hydroclim$drias$periods) names(periods) <- periods @@ -204,45 +134,16 @@ Qhist_month5 <- lapply(historiQ, loadHistoriQ, indicator = "Q_monthly_5years") Qhist_indicators <- lapply(historiQ, loadHistoriQ, indicator = "Q_indicators") ``` -```{r} -plotDataMonth <- function(rcp, period, station, drias, hist) { - scenarios <- names(drias) - names(scenarios) <- scenarios - drias <- lapply(scenarios, function(x) { - if (grepl(rcp, x, fixed = TRUE)) { - - drias[[x]][[period]][station, ] - } else { - NULL - } - }) - drias <- drias[!sapply(drias,is.null)] - df <- as.data.frame(do.call(cbind, drias)) - df$Mois <- seq.int(12) - dfHist <- as.data.frame(do.call(cbind, lapply(hist, function(x) x[station, ]))) - dfHist$Mois <- seq.int(12) - library(ggplot2) - ggplot(tidyr::gather(df, key = "scenario", value = "Q", -Mois)) + - geom_line(aes(x = Mois, y = Q, color = scenario), size = 1) + - geom_line(data = tidyr::gather(dfHist, key = "historique", value = "Q", -Mois), - aes(x = Mois, y = Q, linetype = historique), - size = 1) + - scale_x_continuous(breaks = seq.int(12), - labels = strsplit("JFMAMJJASOND", "")[[1]]) - -} -``` - Débits moyens mensuels à Paris sur la période de référence: -```{r} -plotDataMonth("rcp4.5", "ref", "H5920010", Q_month, Qhist_month) +```{r, fig.asp = 0.7} +plot_monthly_mean("rcp4.5", "ref", "H5920010", Q_month, Qhist_month) ``` Débits moyens à Paris sur la période 2071-2100 avec le scénario d'émission RCP4.5: -```{r} -plotDataMonth("rcp4.5", "end", "H5920010", Q_month, Qhist_month) +```{r, fig.asp = 0.7} +plot_monthly_mean("rcp4.5", "end", "H5920010", Q_month, Qhist_month) ``` diff --git a/bookdown/book.bib b/bookdown/book.bib index 4b87c94b581f77da930bee8ba5e8fff28ce7b21b..922930cc50c8b09ceff224832f6a225fc84ad307 100644 --- a/bookdown/book.bib +++ b/bookdown/book.bib @@ -85,6 +85,17 @@ file = {C\:\\Users\\david.dorchies\\Zotero\\storage\\9ENK4C92\\Oudin et al. - 2005 - Which potential evapotranspiration input for a lum.pdf} } +@report{soubeyrouxNouvellesProjectionsClimatiques2020, + title = {Les nouvelles projections climatiques de référence DRIAS 2020 pour la métropole}, + author = {Soubeyroux, Jean-Michel and Bernus, Sébastien and Corre, Lola and Drouin, Agathe and Dubuisson, Brigitte and Etchevers, Pierre and Gouget, Viviane and Josse, Patrick and Kerdoncuff, Maryvonne and Samacoits, Raphaëlle and Tocquer, Flore}, + date = {2020}, + pages = {98}, + institution = {{Météo France}}, + url = {http://www.drias-climat.fr/document/rapport-DRIAS-2020-red3-2.pdf}, + langid = {french}, + file = {C\:\\Users\\david.dorchies\\Zotero\\storage\\D7FZ2YZ4\\Soubeyroux et al. - 2020 - Les nouvelles projections climatiques de référence.pdf} +} + @article{terrierStreamflowNaturalizationMethods2020, title = {Streamflow Naturalization Methods: A Review}, shorttitle = {Streamflow Naturalization Methods}, diff --git a/man/convertMeteoBVI2BV.Rd b/man/convertMeteoBVI2BV.Rd new file mode 100644 index 0000000000000000000000000000000000000000..c01868b8eb85bec5b015ec72d6eba212626ae78b --- /dev/null +++ b/man/convertMeteoBVI2BV.Rd @@ -0,0 +1,42 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/convertMeteoBVI2BV.R +\name{convertMeteoBVI2BV} +\alias{convertMeteoBVI2BV} +\alias{convertMeteoBVI2BV.data.frame} +\alias{convertMeteoBVI2BV.GRiwrm} +\alias{convertMeteoBVI2BV.character} +\alias{convertMeteoBVI2BV.matrix} +\title{Conversion of meteorological data from sub-basin scale to basin scale} +\usage{ +convertMeteoBVI2BV(x, ...) + +\method{convertMeteoBVI2BV}{data.frame}(x, griwrm, ...) + +\method{convertMeteoBVI2BV}{GRiwrm}(x, meteo, ...) + +\method{convertMeteoBVI2BV}{character}(x, griwrm, meteo, ...) + +\method{convertMeteoBVI2BV}{matrix}(x, areas, temperature = FALSE, ...) +} +\arguments{ +\item{x}{either a \code{GRiwrm} network description (See \link{CreateGRiwrm}), a \link{character} id of a node, or a \link{matrix} or a \link{data.frame} containing meteorological data (See details)} + +\item{...}{Parameters passed to the methods} + +\item{griwrm}{\code{GRiwrm} object describing the semi-distributed network (See \link{CreateGRiwrm})} + +\item{meteo}{\link{matrix} or \link{data.frame} containing meteorological data. Its \link{colnames} should be equal to the ID of the basins} + +\item{areas}{\link{numeric} vector with the total area of the basin followed by the areas of the upstream basins in km2} + +\item{temperature}{\link{logical} \code{TRUE} if the meteorological data contain air temperature. If \code{FALSE} minimum output values are bounded to zero} +} +\value{ +\link{matrix} a matrix containing the converted meteorological data or a \link{data.frame} if \code{x} is a \link{data.frame}. +} +\description{ +Conversion of meteorological data from sub-basin scale to basin scale +} +\details{ +If \code{x} is a \link{data.frame}, the first column should a \link{POSIXct} containing the date and the other columns the time series data. +} diff --git a/man/plot_monthly_mean.Rd b/man/plot_monthly_mean.Rd new file mode 100644 index 0000000000000000000000000000000000000000..f469a0f2ea5e2b8b853ff85964ab6f4b22aafb5c --- /dev/null +++ b/man/plot_monthly_mean.Rd @@ -0,0 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot_monthly_mean.R +\name{plot_monthly_mean} +\alias{plot_monthly_mean} +\title{Plot monthly mean at one gauging station} +\usage{ +plot_monthly_mean(rcp, period, station, drias, hist, y_label = "Flow (m³/s)") +} +\arguments{ +\item{rcp}{\link{character}, "rcp4.5" or "rcp8.5"} + +\item{period}{\link{character}, see details} + +\item{station}{\link{character}, id of gauging station} + +\item{drias}{\link{list}, monthly data of each GCM/RCM projection and each period} + +\item{hist}{\link{list}, monthly data coming from observations} + +\item{y_label}{\link{character}, argument passed to \link[ggplot2:labs]{ggplot2::ylab}} +} +\value{ +A ggplot object. +} +\description{ +Used for simulated flows and climatic inputs. +} +\details{ +Select time steps corresponding to one of the DRIAS 2020 periods: +"ref" for reference (1976-2005), "near" for near future (2021-2050), +"middle" for middle of the century (2041-2070), "end" for end of the century (2071-2100). +} diff --git a/man/selectDriasPeriod.Rd b/man/selectDriasPeriod.Rd new file mode 100644 index 0000000000000000000000000000000000000000..f4b465142f1aac16a0e1e1c86649d5c2b6d64905 --- /dev/null +++ b/man/selectDriasPeriod.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/selectDriasPeriod.R +\name{selectDriasPeriod} +\alias{selectDriasPeriod} +\title{Select a period in a time series} +\usage{ +selectDriasPeriod(df, period, cfg = loadConfig()) +} +\arguments{ +\item{df}{\link{data.frame} with a first column of \link{POSIXt} dates and \link{numeric} in the other columns} + +\item{period}{\link{character}, see details} + +\item{cfg}{a config object. Configuration to use. See \link{loadConfig} for details} +} +\value{ +\link{data.frame} with a first column of \link{POSIXt} dates and \link{numeric} in the other columns with selected rows according to the chosen period +} +\description{ +Select a period in a time series +} +\details{ +Select time steps corresponding to one of the DRIAS 2020 periods: +"ref" for reference (1976-2005), "near" for near future (2021-2050), +"middle" for middle of the century (2041-2070), "end" for end of the century (2071-2100). +}