From 7ef5e25281f68be8ab47673463bcae8a9d4f57ff Mon Sep 17 00:00:00 2001 From: Felicitas Date: Fri, 28 Jun 2024 10:43:20 +0200 Subject: [PATCH] renamed dimension type to wtype for distinction of withdrawal and consumption --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- R/calcMissingWater.R | 2 +- R/calcNonrenGroundwatUse.R | 2 +- R/calcPotIrrigAreas.R | 6 +++--- R/calcPotMulticroppingShare.R | 2 +- R/calcPotWater.R | 10 +++++----- R/calcWaterUseNonAg.R | 6 +++--- R/readISIMIPinputs.R | 2 +- R/readWATERGAP.R | 2 +- README.md | 6 +++--- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index e7ff002f..b34f73a6 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '22437280' +ValidationKey: '22509162' AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' - 'Warning: namespace ''.*'' is not available and has been replaced' diff --git a/CITATION.cff b/CITATION.cff index 2695d0a1..fcecc44b 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,8 +2,8 @@ cff-version: 1.2.0 message: If you use this software, please cite it using the metadata from this file. type: software title: 'mrwater: madrat based MAgPIE water Input Data Library' -version: 1.13.0 -date-released: '2024-05-13' +version: 1.13.1 +date-released: '2024-06-28' abstract: Provides functions for MAgPIE cellular input data generation and stand-alone water calculations. authors: diff --git a/DESCRIPTION b/DESCRIPTION index 9b5fd0ac..16073f70 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,11 +1,11 @@ Type: Package Package: mrwater Title: madrat based MAgPIE water Input Data Library -Version: 1.13.0 +Version: 1.13.1 URL: https://github.com/pik-piam/mrwater, https: //doi.org/10.5281/zenodo.5801680 License: LGPL-3 | file LICENSE -Date: 2024-05-13 +Date: 2024-06-28 Authors@R: c(person("Felicitas", "Beier", email = "beier@pik-potsdam.de", role = c("aut","cre")), person("Jens", "Heinke", email = "heinke@pik-potsdam.de", role = "aut"), person("Kristine", "Karstens", email = "karstens@pik-potsdam.de", role = "aut"), diff --git a/R/calcMissingWater.R b/R/calcMissingWater.R index aa781b05..243b8b2d 100644 --- a/R/calcMissingWater.R +++ b/R/calcMissingWater.R @@ -125,7 +125,7 @@ calcMissingWater <- function(output, lpjml, climatetype, years = years, names = names, fill = 0, - sets = c("x.y.iso", "year", "EFP.scen.type")) + sets = c("x.y.iso", "year", "EFP.scen.wtype")) # bring object x to dimension of object0 out <- object0 + x return(out) diff --git a/R/calcNonrenGroundwatUse.R b/R/calcNonrenGroundwatUse.R index 6cec0233..d94b366d 100644 --- a/R/calcNonrenGroundwatUse.R +++ b/R/calcNonrenGroundwatUse.R @@ -101,7 +101,7 @@ calcNonrenGroundwatUse <- function(output, lpjml, climatetype, cells_and_regions = getItems(missingWat, dim = 1), years = selectyears, names = c("withdrawal", "consumption")) - getSets(out) <- c("x", "y", "iso", "year", "type") + getSets(out) <- c("x", "y", "iso", "year", "wtype") # In past time steps, missing water is accounted as fossil groundwater out[, pstYrs, ] <- missingWat[, pstYrs, ] diff --git a/R/calcPotIrrigAreas.R b/R/calcPotIrrigAreas.R index 796bed1d..6d93376f 100644 --- a/R/calcPotIrrigAreas.R +++ b/R/calcPotIrrigAreas.R @@ -232,17 +232,17 @@ calcPotIrrigAreas <- function(cropAggregation, irrigareaWW <- pmin(avlWatWW / watReqWW, 1) * areaPotIrrig # cells with no water requirements also get no irrigated area assigned irrigareaWW[watReqWW == 0] <- 0 - irrigareaWW <- add_dimension(irrigareaWW, dim = 3.4, add = "type", + irrigareaWW <- add_dimension(irrigareaWW, dim = 3.4, add = "wtype", nm = "irrigatable_ww") irrigareaWC <- pmin(avlWatWC / watReqWC, 1) * areaPotIrrig # cells with no water requirements also get no irrigated area assigned irrigareaWC[watReqWC == 0] <- 0 - irrigareaWC <- add_dimension(irrigareaWC, dim = 3.4, add = "type", + irrigareaWC <- add_dimension(irrigareaWC, dim = 3.4, add = "wtype", nm = "irrigatable_wc") irrigatableArea <- pmin(collapseNames(irrigareaWW), collapseNames(irrigareaWC)) - irrigatableArea <- add_dimension(irrigatableArea, dim = 3.4, add = "type", + irrigatableArea <- add_dimension(irrigatableArea, dim = 3.4, add = "wtype", nm = "irrigatable") # share of crop area by crop type given chosen cropmix diff --git a/R/calcPotMulticroppingShare.R b/R/calcPotMulticroppingShare.R index 61d832e5..d37f8c5b 100644 --- a/R/calcPotMulticroppingShare.R +++ b/R/calcPotMulticroppingShare.R @@ -246,7 +246,7 @@ calcPotMulticroppingShare <- function(scenario, lpjml, climatetype, potShr <- potShr + shrMC # Ensure that not too much water has been allocated - if ((remainingWatWW - dimSums(comAgWatSecondWW[, , crops] * potShr[, , crops], dim = "crop")) < 0) { + if (any(remainingWatWW - dimSums(comAgWatSecondWW[, , crops] * potShr[, , crops], dim = "crop") < 0)) { stop("There is a problem in calcPotMulticroppingShare: Too much multiple cropping expansion on currently irrigated area. Water is not sufficient.") diff --git a/R/calcPotWater.R b/R/calcPotWater.R index 58df8ee7..920a6912 100644 --- a/R/calcPotWater.R +++ b/R/calcPotWater.R @@ -238,13 +238,13 @@ calcPotWater <- function(lpjml, selectyears, climatetype, efrMethod, watTotWW <- watNonAgWW + watAgWW watTotWC <- watNonAgWC + watAgWC - watAgWW <- add_dimension(watAgWW, dim = 3.4, add = "type", nm = "wat_ag_ww") - watAgWC <- add_dimension(watAgWC, dim = 3.4, add = "type", nm = "wat_ag_wc") - watTotWW <- add_dimension(watTotWW, dim = 3.4, add = "type", nm = "wat_tot_ww") - watTotWC <- add_dimension(watTotWC, dim = 3.4, add = "type", nm = "wat_tot_wc") + watAgWW <- add_dimension(watAgWW, dim = 3.4, add = "wtype", nm = "wat_ag_ww") + watAgWC <- add_dimension(watAgWC, dim = 3.4, add = "wtype", nm = "wat_ag_wc") + watTotWW <- add_dimension(watTotWW, dim = 3.4, add = "wtype", nm = "wat_tot_ww") + watTotWC <- add_dimension(watTotWC, dim = 3.4, add = "wtype", nm = "wat_tot_wc") out <- mbind(watAgWW, watAgWC, watTotWW, watTotWC) - getSets(out) <- c("x", "y", "iso", "year", "EFP", "scen", "type") + getSets(out) <- c("x", "y", "iso", "year", "EFP", "scen", "wtype") return(list(x = out, weight = NULL, diff --git a/R/calcWaterUseNonAg.R b/R/calcWaterUseNonAg.R index b2889b7c..1d42e9cf 100644 --- a/R/calcWaterUseNonAg.R +++ b/R/calcWaterUseNonAg.R @@ -161,7 +161,7 @@ calcWaterUseNonAg <- function(selectyears = seq(1995, 2100, by = 5), cells = "lp tmpWATERGAP <- new.magpie(cells_and_regions = getCells(watdemWATERGAP), years = yearsWATERGAP, names = getNames(watdemISIMIP)) - getSets(tmpWATERGAP) <- c("x", "y", "iso", "year", "use", "type") + getSets(tmpWATERGAP) <- c("x", "y", "iso", "year", "use", "wtype") scenarios <- getNames(watdemWATERGAP, dim = "scenario") listMAgPIE <- vector(mode = "list", length = length(scenarios)) @@ -175,7 +175,7 @@ calcWaterUseNonAg <- function(selectyears = seq(1995, 2100, by = 5), cells = "lp harmonizedWATERGAP <- toolHarmonize2Baseline(x = tmpWATERGAP, base = watdemISIMIP, ref_year = baseyear, method = "additive", hard_cut = FALSE) harmonizedWATERGAP <- setNames(harmonizedWATERGAP, nm = paste(scenario, getNames(harmonizedWATERGAP), sep = ".")) - getSets(harmonizedWATERGAP) <- c("x", "y", "iso", "year", "scenario", "use", "type") + getSets(harmonizedWATERGAP) <- c("x", "y", "iso", "year", "scenario", "use", "wtype") # Store harmonized data in final object tmp <- vector(mode = "list", length = 3) @@ -211,7 +211,7 @@ calcWaterUseNonAg <- function(selectyears = seq(1995, 2100, by = 5), cells = "lp method = "additive", hard_cut = FALSE) getNames(tmp[[i]]) <- paste(scenario, getNames(tmp[[i]]), sep = ".") - getSets(tmp[[i]]) <- c("x", "y", "iso", "year", "scenario", "use", "type") + getSets(tmp[[i]]) <- c("x", "y", "iso", "year", "scenario", "use", "wtype") } watFUTURE <- mbind(tmp) diff --git a/R/readISIMIPinputs.R b/R/readISIMIPinputs.R index 9ebaaaaa..84d1bc65 100644 --- a/R/readISIMIPinputs.R +++ b/R/readISIMIPinputs.R @@ -68,7 +68,7 @@ readISIMIPinputs <- function(subtype = "ISIMIP3b:water:histsoc.waterabstraction" getNames(x) <- gsub("industrial water ", "industry.", getNames(x)) getNames(x) <- gsub("domestic water ", "domestic.", getNames(x)) getSets(x)["d3.1"] <- "use" - getSets(x)["d3.2"] <- "type" + getSets(x)["d3.2"] <- "wtype" } diff --git a/R/readWATERGAP.R b/R/readWATERGAP.R index 41e67a98..acd1194a 100644 --- a/R/readWATERGAP.R +++ b/R/readWATERGAP.R @@ -79,7 +79,7 @@ readWATERGAP <- function(subtype = "WATCH_ISIMIP_WATERGAP") { getNames(x) <- gsub("Domestic water ", "domestic.", getNames(x)) getSets(x)["d3.1"] <- "scenario" getSets(x)["d3.2"] <- "use" - getSets(x)["d3.3"] <- "type" + getSets(x)["d3.3"] <- "wtype" } diff --git a/README.md b/README.md index fd6cd643..d7eea414 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE water Input Data Library -R package **mrwater**, version **1.13.0** +R package **mrwater**, version **1.13.1** [![CRAN status](https://www.r-pkg.org/badges/version/mrwater)](https://cran.r-project.org/package=mrwater) [![R build status](https://github.com/pik-piam/mrwater/workflows/check/badge.svg)](https://github.com/pik-piam/mrwater/actions) [![codecov](https://codecov.io/gh/pik-piam/mrwater/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mrwater) [![r-universe](https://pik-piam.r-universe.dev/badges/mrwater)](https://pik-piam.r-universe.dev/builds) @@ -50,7 +50,7 @@ In case of questions / problems please contact Felicitas Beier . +Beier F, Heinke J, Karstens K, Bodirsky B, Dietrich J (2024). _mrwater: madrat based MAgPIE water Input Data Library_. R package version 1.13.1, . A BibTeX entry for LaTeX users is @@ -59,7 +59,7 @@ A BibTeX entry for LaTeX users is title = {mrwater: madrat based MAgPIE water Input Data Library}, author = {Felicitas Beier and Jens Heinke and Kristine Karstens and Benjamin Leon Bodirsky and Jan Philipp Dietrich}, year = {2024}, - note = {R package version 1.13.0}, + note = {R package version 1.13.1}, url = {https://github.com/pik-piam/mrwater}, } ```