From d94b6f060fa9456de04fd99999b4ffd3c288b279 Mon Sep 17 00:00:00 2001 From: Felicitas Date: Tue, 29 Oct 2024 09:48:09 +0100 Subject: [PATCH] remove filtering rules from calcMulticroppingYieldIncrease and only exclude zeros for numerical reasons --- .buildlibrary | 2 +- .github/workflows/check.yaml | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- R/calcMulticroppingYieldIncrease.R | 27 +++------------------------ README.md | 6 +++--- man/calcMulticroppingYieldIncrease.Rd | 8 +------- 7 files changed, 13 insertions(+), 40 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index d013d3e6..3a443776 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '12833461' +ValidationKey: '12856050' AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' - 'Warning: namespace ''.*'' is not available and has been replaced' diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 23545e6c..d85a3165 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -63,6 +63,6 @@ jobs: shell: Rscript {0} run: | nonDummyTests <- setdiff(list.files("./tests/testthat/"), c("test-dummy.R", "_snaps")) - if(length(nonDummyTests) > 0) covr::codecov(quiet = FALSE) + if(length(nonDummyTests) > 0 && !lucode2:::loadBuildLibraryConfig()[["skipCoverage"]]) covr::codecov(quiet = FALSE) env: NOT_CRAN: "true" diff --git a/CITATION.cff b/CITATION.cff index 6a4fba86..1cb9e858 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: 'mrland: MadRaT land data package' -version: 0.64.1 -date-released: '2024-10-25' +version: 0.64.2 +date-released: '2024-10-29' abstract: The package provides land related data via the madrat framework. authors: - family-names: Dietrich diff --git a/DESCRIPTION b/DESCRIPTION index 5bd8c91e..22fcc6cf 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrland Title: MadRaT land data package -Version: 0.64.1 -Date: 2024-10-25 +Version: 0.64.2 +Date: 2024-10-29 Authors@R: c( person("Jan Philipp", "Dietrich", , "dietrich@pik-potsdam.de", role = c("aut", "cre")), person("Abhijeet", "Mishra", role = "aut"), diff --git a/R/calcMulticroppingYieldIncrease.R b/R/calcMulticroppingYieldIncrease.R index ccf40a4b..18075dbd 100644 --- a/R/calcMulticroppingYieldIncrease.R +++ b/R/calcMulticroppingYieldIncrease.R @@ -14,10 +14,6 @@ #' @param fallowFactor Factor determining yield reduction in off season due to #' fallow period between harvest of first (main) season and #' sowing of second (off) season -#' @param minThreshold Minimum threshold of grass GPP in crop growing period -#' and crop yield to exclude low yielding cells -#' Unit of the threshold is gC/m^2. -#' Default: 100 gC/m^2 #' #' @return magpie object in cellular resolution #' @author Felicitas Beier @@ -32,22 +28,13 @@ #' calcMulticroppingYieldIncrease <- function(selectyears, lpjml, climatetype, - fallowFactor = 0.75, minThreshold = 100) { + fallowFactor = 0.75) { # Function requires lpjml argument in standard format if (length(lpjml) == 1) { lpjml <- c(natveg = "NULL", crop = lpjml) } - #################### - ### Definitions ### - #################### - # Transformation factor gC/m^2 -> tDM/ha - yieldTransform <- 0.01 / 0.45 - - # Minimum threshold in tDM/ha - minThreshold <- minThreshold * yieldTransform - #################### ### Read in data ### #################### @@ -80,21 +67,13 @@ calcMulticroppingYieldIncrease <- function(selectyears, lpjml, climatetype, ### Calculations ### #################### - # Exclude cells with grass yields (in growing period of crop) below minimum threshold - # (Note: for numerical reasons) - rule1 <- grassGPPgrper > minThreshold - - # Exclude low yielding cells (minimum crop yield in main season below minimum threshold) - # (Note: to account for non-matching growing periods) - rule2 <- cropYields > minThreshold - ### Yield Increase Factor ### # Calculate multiple cropping factor based on annual grass GPP and # grass GPP in growing period of crop grassGPPoffseason <- (grassGPPannual[, , cropIrrigList] - grassGPPgrper[, , cropIrrigList]) grassGPPoffseason[grassGPPoffseason < 0] <- 0 - increaseFACTOR <- ifelse(rule1 & rule2, + increaseFACTOR <- ifelse(grassGPPgrper > 0, grassGPPoffseason / grassGPPgrper, 0) * fallowFactor @@ -123,7 +102,7 @@ calcMulticroppingYieldIncrease <- function(selectyears, lpjml, climatetype, ############## ### Return ### ############## - unit <- "unitless" + unit <- "factor" description <- paste0("Factor of yield increase through multiple cropping ", "to be applied on LPJmL crop yield") diff --git a/README.md b/README.md index 7a944661..2d3b729e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MadRaT land data package -R package **mrland**, version **0.64.1** +R package **mrland**, version **0.64.2** [![CRAN status](https://www.r-pkg.org/badges/version/mrland)](https://cran.r-project.org/package=mrland) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3822083.svg)](https://doi.org/10.5281/zenodo.3822083) [![R build status](https://github.com/pik-piam/mrland/workflows/check/badge.svg)](https://github.com/pik-piam/mrland/actions) [![codecov](https://codecov.io/gh/pik-piam/mrland/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mrland) [![r-universe](https://pik-piam.r-universe.dev/badges/mrland)](https://pik-piam.r-universe.dev/builds) @@ -39,7 +39,7 @@ In case of questions / problems please contact Jan Philipp Dietrich , R package version 0.64.1, . +Dietrich J, Mishra A, Weindl I, Bodirsky B, Wang X, Baumstark L, Kreidenweis U, Klein D, Steinmetz N, Chen D, Humpenoeder F, von Jeetze P, Wirth S, Beier F, Hoetten D, Sauer P, Tommey J (2024). _mrland: MadRaT land data package_. doi:10.5281/zenodo.3822083 , R package version 0.64.2, . A BibTeX entry for LaTeX users is @@ -48,7 +48,7 @@ A BibTeX entry for LaTeX users is title = {mrland: MadRaT land data package}, author = {Jan Philipp Dietrich and Abhijeet Mishra and Isabelle Weindl and Benjamin Leon Bodirsky and Xiaoxi Wang and Lavinia Baumstark and Ulrich Kreidenweis and David Klein and Nele Steinmetz and David Chen and Florian Humpenoeder and Patrick {von Jeetze} and Stephen Wirth and Felicitas Beier and David Hoetten and Pascal Sauer and Jake Tommey}, year = {2024}, - note = {R package version 0.64.1}, + note = {R package version 0.64.2}, url = {https://github.com/pik-piam/mrland}, doi = {10.5281/zenodo.3822083}, } diff --git a/man/calcMulticroppingYieldIncrease.Rd b/man/calcMulticroppingYieldIncrease.Rd index bd91a7e7..dbcf0e6a 100644 --- a/man/calcMulticroppingYieldIncrease.Rd +++ b/man/calcMulticroppingYieldIncrease.Rd @@ -8,8 +8,7 @@ calcMulticroppingYieldIncrease( selectyears, lpjml, climatetype, - fallowFactor = 0.75, - minThreshold = 100 + fallowFactor = 0.75 ) } \arguments{ @@ -22,11 +21,6 @@ calcMulticroppingYieldIncrease( \item{fallowFactor}{Factor determining yield reduction in off season due to fallow period between harvest of first (main) season and sowing of second (off) season} - -\item{minThreshold}{Minimum threshold of grass GPP in crop growing period -and crop yield to exclude low yielding cells -Unit of the threshold is gC/m^2. -Default: 100 gC/m^2} } \value{ magpie object in cellular resolution