Skip to content

Commit

Permalink
bugfix in calcRiverRoutingInputs for single-cropping case with commit…
Browse files Browse the repository at this point in the history
…ted agriculture.
  • Loading branch information
FelicitasBeier committed Jan 10, 2024
1 parent 95d4054 commit 2ad5f79
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '219254490'
ValidationKey: '219340912'
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.11.15
date-released: '2024-01-04'
version: 1.11.16
date-released: '2024-01-10'
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.11.15
Version: 1.11.16
URL: https://github.com/pik-piam/mrwater,
https: //doi.org/10.5281/zenodo.5801680
License: LGPL-3 | file LICENSE
Date: 2024-01-04
Date: 2024-01-10
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
26 changes: 7 additions & 19 deletions R/calcRiverRoutingInputs.R
Original file line number Diff line number Diff line change
Expand Up @@ -249,24 +249,8 @@ calcRiverRoutingInputs <- function(lpjml, climatetype,
discharge <- collapseNames(previousHumanUse[, , "discharge"])

} else {
# For case of single cropping no special treatment required
# Normal "committed_agricultural" run is conducted where non-ag uses are reserved
# and committed agricultural uses for single cropping conditions are
# being currently requrested
tmp <- calcOutput("RiverRoutingInputs", lpjml = lpjml, climatetype = climatetype,
selectyears = selectyears, iniyear = iniyear,
iteration = "committed_agriculture",
transDist = transDist, efrMethod = efrMethod,
accessibilityrule = accessibilityrule, multicropping = multicropping,
comAg = NULL, rankmethod = NULL, gainthreshold = NULL,
cropmix = NULL, yieldcalib = NULL,
irrigationsystem = NULL, landScen = NULL,
aggregate = FALSE)
discharge <- tmp[, , "discharge"]
prevReservedWW <- tmp[, , "prevReservedWW"]
prevReservedWC <- tmp[, , "presReservedWC"]
currRequestWWlocal <- tmp[, , "currRequestWWlocal"]
currRequestWClocal <- tmp[, , "currRequestWClocal"]
stop("Error in calcRiverRoutingInputs: Under single cropping, `commmitted_agriculture_fullMulticropping`
iteration should not be calculated. Please adjust the settings in the function call accordingly.")
}

} else if (iteration == "potential_irrigation") {
Expand All @@ -275,7 +259,11 @@ calcRiverRoutingInputs <- function(lpjml, climatetype,
# accounting in potentials
comagyear <- iniyear
# previous use
humanuse <- "committed_agriculture_fullMulticropping"
if (as.logical(stringr::str_split(multicropping, ":")[[1]][1])) {
humanuse <- "committed_agriculture_fullMulticropping"
} else {
humanuse <- "committed_agriculture"
}
} else if (comAg == FALSE) {
# committed agriculture not accounted in potentials (full potential)
comagyear <- NULL
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.11.15**
R package **mrwater**, version **1.11.16**

[![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.11.15, <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.11.16, <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.11.15},
note = {R package version 1.11.16},
url = {https://github.com/pik-piam/mrwater},
}
```

0 comments on commit 2ad5f79

Please sign in to comment.