Skip to content

Commit

Permalink
renamed dimension type to wtype for distinction of withdrawal and con…
Browse files Browse the repository at this point in the history
…sumption
  • Loading branch information
FelicitasBeier committed Jun 28, 2024
1 parent 206aa05 commit 7ef5e25
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]", role = c("aut","cre")),
person("Jens", "Heinke", email = "[email protected]", role = "aut"),
person("Kristine", "Karstens", email = "[email protected]", role = "aut"),
Expand Down
2 changes: 1 addition & 1 deletion R/calcMissingWater.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/calcNonrenGroundwatUse.R
Original file line number Diff line number Diff line change
Expand Up @@ -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, ]
Expand Down
6 changes: 3 additions & 3 deletions R/calcPotIrrigAreas.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/calcPotMulticroppingShare.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
10 changes: 5 additions & 5 deletions R/calcPotWater.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions R/calcWaterUseNonAg.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/readISIMIPinputs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"

}

Expand Down
2 changes: 1 addition & 1 deletion R/readWATERGAP.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"

}

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -50,7 +50,7 @@ In case of questions / problems please contact Felicitas Beier <beier@pik-potsda

To cite package **mrwater** in publications use:

Beier F, Heinke J, Karstens K, Bodirsky B, Dietrich J (2024). _mrwater: madrat based MAgPIE water Input Data Library_. R package version 1.13.0, <https://github.com/pik-piam/mrwater>.
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, <https://github.com/pik-piam/mrwater>.

A BibTeX entry for LaTeX users is

Expand All @@ -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},
}
```

0 comments on commit 7ef5e25

Please sign in to comment.