From bb56378bacb313ff68de8b7619ca6900e79b603a Mon Sep 17 00:00:00 2001 From: bodirsky Date: Thu, 9 Apr 2026 15:42:07 +0200 Subject: [PATCH 01/15] .. --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- R/calcValidCroparea.R | 2 +- R/calcValidCropareaDiversity.R | 2 +- README.md | 8 ++++---- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 3f5f1a58..d7d2c2db 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '54847140' +ValidationKey: '54894392' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package .* was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 6518e0f6..6ae1c636 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: 'mrvalidation: madrat data preparation for validation purposes' -version: 2.67.0 -date-released: '2026-03-30' +version: 2.67.1 +date-released: '2026-04-09' abstract: Package contains routines to prepare data for validation exercises. authors: - family-names: Bodirsky diff --git a/DESCRIPTION b/DESCRIPTION index 1a922b4e..88753788 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrvalidation Title: madrat data preparation for validation purposes -Version: 2.67.0 -Date: 2026-03-30 +Version: 2.67.1 +Date: 2026-04-09 Authors@R: c( person("Benjamin Leon", "Bodirsky", , "bodirsky@pik-potsdam.de", role = c("aut", "cre")), person("Stephen", "Wirth", role = "aut"), diff --git a/R/calcValidCroparea.R b/R/calcValidCroparea.R index 43a89902..e2e803e3 100644 --- a/R/calcValidCroparea.R +++ b/R/calcValidCroparea.R @@ -31,7 +31,7 @@ calcValidCroparea <- function(datasource = "FAO", detail = FALSE) { level_zero_name = "Resources|Land Cover|Cropland|Croparea", detail = detail) croparea <- summationhelper(croparea, sep = "+") - fallow <- setNames(calcOutput("FallowLand", + fallow <- setNames(calcOutput("Fallow", aggregate = FALSE, cellular = FALSE), paste("Resources|Land Cover|Cropland|+|", reportingnames("crop_fallow"), sep = "")) diff --git a/R/calcValidCropareaDiversity.R b/R/calcValidCropareaDiversity.R index 5953d219..05ffe26e 100644 --- a/R/calcValidCropareaDiversity.R +++ b/R/calcValidCropareaDiversity.R @@ -19,7 +19,7 @@ calcValidCropareaDiversity <- function(index = "shannon", groupdiv = "agg1") { area <- readSource("LandInG", subtype = "harvestedArea") area <- area[, , c("pasture"), invert = TRUE] area <- collapseNames(area[, , "irrigated"]) + collapseNames(area[, , "rainfed"]) - fallow <- calcOutput("FallowLand", aggregate = FALSE, cellular = TRUE) + fallow <- calcOutput("Fallow", aggregate = FALSE, cellular = TRUE) fallow <- setNames(fallow, "fallow") area <- mbind(area, fallow) diff --git a/README.md b/README.md index 6b64c294..326589e1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat data preparation for validation purposes -R package **mrvalidation**, version **2.67.0** +R package **mrvalidation**, version **2.67.1** [![CRAN status](https://www.r-pkg.org/badges/version/mrvalidation)](https://cran.r-project.org/package=mrvalidation) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4317826.svg)](https://doi.org/10.5281/zenodo.4317826) [![R build status](https://github.com/pik-piam/mrvalidation/workflows/check/badge.svg)](https://github.com/pik-piam/mrvalidation/actions) [![codecov](https://codecov.io/gh/pik-piam/mrvalidation/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mrvalidation) [![r-universe](https://pik-piam.r-universe.dev/badges/mrvalidation)](https://pik-piam.r-universe.dev/builds) @@ -39,7 +39,7 @@ In case of questions / problems please contact Benjamin Leon Bodirsky , Version: 2.67.0, . +Bodirsky B, Wirth S, Karstens K, Humpenoeder F, Stevanovic M, Mishra A, Biewald A, Weindl I, Beier F, Chen D, Crawford M, Leip D, Molina Bacca E, Kreidenweis U, W. Yalew A, von Jeetze P, Wang X, Dietrich J, Alves M (2026). "mrvalidation: madrat data preparation for validation purposes." doi:10.5281/zenodo.4317826 , Version: 2.67.1, . A BibTeX entry for LaTeX users is @@ -48,9 +48,9 @@ A BibTeX entry for LaTeX users is title = {mrvalidation: madrat data preparation for validation purposes}, author = {Benjamin Leon Bodirsky and Stephen Wirth and Kristine Karstens and Florian Humpenoeder and Mishko Stevanovic and Abhijeet Mishra and Anne Biewald and Isabelle Weindl and Felicitas Beier and David Chen and Michael Crawford and Debbora Leip and Edna {Molina Bacca} and Ulrich Kreidenweis and Amsalu {W. Yalew} and Patrick {von Jeetze} and Xiaoxi Wang and Jan Philipp Dietrich and Marcos Alves}, doi = {10.5281/zenodo.4317826}, - date = {2026-03-30}, + date = {2026-04-09}, year = {2026}, url = {https://github.com/pik-piam/mrvalidation}, - note = {Version: 2.67.0}, + note = {Version: 2.67.1}, } ``` From 155508ff9a170c8b3f91b105f4beffdf18a6839d Mon Sep 17 00:00:00 2001 From: bodirsky Date: Wed, 6 May 2026 14:39:18 +0200 Subject: [PATCH 02/15] .. --- R/calcValidCropareaDiversity.R | 35 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/R/calcValidCropareaDiversity.R b/R/calcValidCropareaDiversity.R index 05ffe26e..5917a8dc 100644 --- a/R/calcValidCropareaDiversity.R +++ b/R/calcValidCropareaDiversity.R @@ -21,7 +21,8 @@ calcValidCropareaDiversity <- function(index = "shannon", groupdiv = "agg1") { area <- collapseNames(area[, , "irrigated"]) + collapseNames(area[, , "rainfed"]) fallow <- calcOutput("Fallow", aggregate = FALSE, cellular = TRUE) fallow <- setNames(fallow, "fallow") - area <- mbind(area, fallow) + combined_years <- intersect(getYears(fallow), getYears(area)) + area <- mbind(area[, combined_years, ], fallow[, combined_years, ]) land <- dimSums(area, dim = 3) @@ -89,26 +90,26 @@ calcValidCropareaDiversity <- function(index = "shannon", groupdiv = "agg1") { ) } else if (groupdiv == "agg2") { mix <- c( - cellvalue["tece"], #c3 - cellvalue["maiz"] + cellvalue["trce"], #c4 - cellvalue["rice_pro"], #rice - cellvalue["puls_pro"] + cellvalue["soybean"] + cellvalue["groundnut"], #legumes - cellvalue["begr"] + cellvalue["sugr_cane"] + cellvalue["betr"] + cellvalue["oilpalm"], #plantations - cellvalue["potato"] + cellvalue["cassav_sp"] + cellvalue["sugr_beet"], #roots - cellvalue["rapeseed"] + cellvalue["sunflower"] + cellvalue["cottn_pro"], #non-legume oil crops - rep(cellvalue["fallow"] / 2, 2), #fallow - rep(cellvalue["foddr"] / 2, 2), #foddr - rep(cellvalue["others"] / 5, 5) #fruits vegetables nuts + cellvalue["tece"], # c3 + cellvalue["maiz"] + cellvalue["trce"], # c4 + cellvalue["rice_pro"], # rice + cellvalue["puls_pro"] + cellvalue["soybean"] + cellvalue["groundnut"], # legumes + cellvalue["begr"] + cellvalue["sugr_cane"] + cellvalue["betr"] + cellvalue["oilpalm"], # plantations + cellvalue["potato"] + cellvalue["cassav_sp"] + cellvalue["sugr_beet"], # roots + cellvalue["rapeseed"] + cellvalue["sunflower"] + cellvalue["cottn_pro"], # non-legume oil crops + rep(cellvalue["fallow"] / 2, 2), # fallow + rep(cellvalue["foddr"] / 2, 2), # foddr + rep(cellvalue["others"] / 5, 5) # fruits vegetables nuts ) } else if (groupdiv == "agg3") { mix <- c( - cellvalue["tece"] + cellvalue["maiz"] + cellvalue["trce"] + cellvalue["rice_pro"], #rice - cellvalue["puls_pro"] + cellvalue["soybean"] + cellvalue["groundnut"], #legumes - cellvalue["begr"] + cellvalue["sugr_cane"] + cellvalue["betr"] + cellvalue["oilpalm"], #plantations + cellvalue["tece"] + cellvalue["maiz"] + cellvalue["trce"] + cellvalue["rice_pro"], # rice + cellvalue["puls_pro"] + cellvalue["soybean"] + cellvalue["groundnut"], # legumes + cellvalue["begr"] + cellvalue["sugr_cane"] + cellvalue["betr"] + cellvalue["oilpalm"], # plantations cellvalue["potato"] + cellvalue["cassav_sp"] + cellvalue["sugr_beet"] + - cellvalue["rapeseed"] + cellvalue["sunflower"] + cellvalue["cottn_pro"] + cellvalue["foddr"], #other - cellvalue["others"], #fruits vegetables nuts - cellvalue["fallow"] #fallow + cellvalue["rapeseed"] + cellvalue["sunflower"] + cellvalue["cottn_pro"] + cellvalue["foddr"], # other + cellvalue["others"], # fruits vegetables nuts + cellvalue["fallow"] # fallow ) } else { mix <- cellvalue From 4e8bf8ab769ad9e8e1438c9fc604f49d6d0993db Mon Sep 17 00:00:00 2001 From: Patrick Rein Date: Wed, 15 Jul 2026 15:22:56 +0200 Subject: [PATCH 03/15] Changes area weight of calcValidCarbon to LanduseInitialisation --- R/calcValidCarbon.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/calcValidCarbon.R b/R/calcValidCarbon.R index dcbf7f3d..7d0c5ce8 100644 --- a/R/calcValidCarbon.R +++ b/R/calcValidCarbon.R @@ -45,7 +45,7 @@ calcValidCarbon <- function(datasource = "LPJmL4_for_MAgPIE_44ac93de:GSWP3-W5E5: stock <- mbind(setNames(soilc, "soilc"), setNames(litc, "litc"), setNames(vegc, "vegc")) rm(soilc, litc, vegc) - area <- dimSums(calcOutput("LUH3", landuseTypes = "LUH3", irrigation = FALSE, + area <- dimSums(calcOutput("LanduseInitialisation", cellular = TRUE, years = "y1995", aggregate = FALSE), dim = 3) From 1b8220d7246c2f8538e2c59b0e8341d0babb8bc5 Mon Sep 17 00:00:00 2001 From: Patrick Rein Date: Wed, 15 Jul 2026 15:23:26 +0200 Subject: [PATCH 04/15] Removes calcValidTauPastr as there are no remaining calls for it or the corresponding PastrTauHist --- R/calcValidTauPastr.R | 86 ------------------------------------------- 1 file changed, 86 deletions(-) delete mode 100644 R/calcValidTauPastr.R diff --git a/R/calcValidTauPastr.R b/R/calcValidTauPastr.R deleted file mode 100644 index d840f33e..00000000 --- a/R/calcValidTauPastr.R +++ /dev/null @@ -1,86 +0,0 @@ -#' @title ValidTauPastr -#' @description Calculates managed pastures Tau based on FAO yield trends for 1995. -#' -#' @return List of magpie objects with results on country level, weight on country level, unit and description. -#' @author Marcos Alves -#' @examples -#' \dontrun{ -#' calcOutput("ValidTauPastr") -#' } -#' -calcValidTauPastr <- function() { - past <- findset("past") - # Production - prod <- calcOutput("GrasslandBiomass", aggregate = FALSE)[, past, "pastr"] - prod <- toolCountryFill(prod, fill = 0) - - # pasture areas - luh <- calcOutput("LUH3", landuseTypes = "LUH3", cellular = FALSE, aggregate = FALSE) - area <- luh[, past, "pastr"] - area <- toolCountryFill(area, fill = 0) - - # Adding 'otherland' as an extra source of grass biomass comparable - # to managed pastures in India, Pakistan and Bangladesh. - otherland <- luh[, past, c("secdn", "primn")] - area["IND", , "pastr"] <- - area["IND", , "pastr"] + - setNames(dimSums(otherland["IND", , ], dim = 3), "pastr") - area["BGD", , "pastr"] <- - area["BGD", , "pastr"] + - setNames(dimSums(otherland["BGD", , ], dim = 3), "pastr") - area["PAK", , "pastr"] <- - area["PAK", , "pastr"] + - setNames(dimSums(otherland["PAK", , ], dim = 3), "pastr") - - # Actual yields - yact <- prod[, past, ] / area[, past, ] - yact[is.nan(yact) | is.infinite(yact)] <- 0 - - # reference yields - yref <- calcOutput("GrasslandsYields", - lpjml = "lpjml5p2_pasture", - climatetype = "MRI-ESM2-0:ssp245", - subtype = "/co2/Nreturn0p5", # nolint: absolute_path_linter. - lsu_levels = c(seq(0, 2.2, 0.2), 2.5), past_mngmt = "mdef", - aggregate = FALSE)[, past, "pastr.rainfed"] - - yrefWeights <- calcOutput("LUH3", landuseTypes = "LUH3", cellular = TRUE, - aggregate = FALSE)[, past, "pastr"] - cell2iso <- data.frame(cell = getItems(yref, 1, full = TRUE), - iso = getItems(yref, if (dimExists("iso", yref)) "iso" else 1.1, full = TRUE)) - yref <- toolAggregate(yref, rel = cell2iso, from = "cell", to = "iso", weight = yrefWeights + 10^(-10)) - yref <- toolCountryFill(yref, fill = 0) - - # tau calculation - t <- yact[, past, ] / yref[, past, ] - t[is.nan(t) | is.infinite(t)] <- 0 - t <- collapseNames(t) - - # replacing unrealistic high tau values by regional averages - regMap <- toolGetMapping("regionmappingH12.csv", type = "regional", where = "madrat") - tReg <- toolAggregate(t, rel = regMap, weight = area, from = "CountryCode", to = "RegionCode") - regions <- regMap$RegionCode - names(regions) <- regMap[, "CountryCode"] - - largeTC <- where(t >= 10)$true$individual # tau threshold - colnames(largeTC)[1] <- "country" - largeTC <- as.data.frame(largeTC) - - for (i in as.vector(largeTC[, "country"])) { - for (j in as.vector(largeTC[largeTC$country == i, "year"])) { - t[i, j, ] <- tReg[regions[i], j, ] - } - } - - names(dimnames(t))[3] <- "scenario.model.variable" - getNames(t) <- - "historical.MAgPIEOwn.Productivity|Landuse Intensity Indicator Tau managed pastures (Index)" # nolint - - return(list( - x = t, - weight = yref * area, # Xref - unit = "-", - description = - "Historic Trends in managed pastures Land Use Intensity Tau based on FAO yield trends" # nolint - )) -} From 52e3852a46eb2b4a681181aab2a86129a4f39e77 Mon Sep 17 00:00:00 2001 From: FelicitasBeier Date: Thu, 6 Aug 2026 16:08:09 +0200 Subject: [PATCH 05/15] removed calcValidTauPastr call since function has been deleted and shall no longer be used --- .buildlibrary | 2 +- CITATION.cff | 2 +- DESCRIPTION | 2 +- R/fullVALIDATION.R | 1 - README.md | 2 +- man/calcValidTauPastr.Rd | 23 ----------------------- 6 files changed, 4 insertions(+), 28 deletions(-) delete mode 100644 man/calcValidTauPastr.Rd diff --git a/.buildlibrary b/.buildlibrary index 9e0c4ee0..ed2042cd 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '55784700' +ValidationKey: '55811700' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package .* was built under R version' diff --git a/CITATION.cff b/CITATION.cff index e6daad0e..aac01336 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -3,7 +3,7 @@ message: If you use this software, please cite it using the metadata from this f type: software title: 'mrvalidation: madrat data preparation for validation purposes' version: 2.70.0 -date-released: '2026-07-27' +date-released: '2026-08-06' abstract: Package contains routines to prepare data for validation exercises. authors: - family-names: Bodirsky diff --git a/DESCRIPTION b/DESCRIPTION index fd286ccc..a7ca64fb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Type: Package Package: mrvalidation Title: madrat data preparation for validation purposes Version: 2.70.0 -Date: 2026-07-27 +Date: 2026-08-06 Authors@R: c( person("Benjamin Leon", "Bodirsky", , "bodirsky@pik-potsdam.de", role = c("aut", "cre")), person("Stephen", "Wirth", role = "aut"), diff --git a/R/fullVALIDATION.R b/R/fullVALIDATION.R index 709df1fc..15250038 100644 --- a/R/fullVALIDATION.R +++ b/R/fullVALIDATION.R @@ -317,7 +317,6 @@ fullVALIDATION <- function(rev = 0.1, aggregate = "region+global") { # Productivity calcOutput(type = "ValidTau", aggregate = aggregate, file = valfile, append = TRUE, try = TRUE) - calcOutput(type = "ValidTauPastr", aggregate = aggregate, file = valfile, append = TRUE, try = TRUE) calcOutput(type = "ValidLSUdensity", aggregate = aggregate, file = valfile, append = TRUE, try = TRUE) calcOutput(type = "ValidAgriResearchIntensity", aggregate = aggregate, datasource = "Pardey", file = valfile, append = TRUE, try = TRUE) diff --git a/README.md b/README.md index 2879d966..cf738182 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ A BibTeX entry for LaTeX users is title = {mrvalidation: madrat data preparation for validation purposes}, author = {Benjamin Leon Bodirsky and Stephen Wirth and Kristine Karstens and Florian Humpenoeder and Mishko Stevanovic and Abhijeet Mishra and Anne Biewald and Isabelle Weindl and Felicitas Beier and David Chen and Michael Crawford and Debbora Leip and Edna {Molina Bacca} and Ulrich Kreidenweis and Amsalu {W. Yalew} and Patrick {von Jeetze} and Xiaoxi Wang and Jan Philipp Dietrich and Marcos Alves}, doi = {10.5281/zenodo.4317826}, - date = {2026-07-27}, + date = {2026-08-06}, year = {2026}, url = {https://github.com/pik-piam/mrvalidation}, note = {Version: 2.70.0}, diff --git a/man/calcValidTauPastr.Rd b/man/calcValidTauPastr.Rd deleted file mode 100644 index a146f622..00000000 --- a/man/calcValidTauPastr.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/calcValidTauPastr.R -\name{calcValidTauPastr} -\alias{calcValidTauPastr} -\title{ValidTauPastr} -\usage{ -calcValidTauPastr() -} -\value{ -List of magpie objects with results on country level, weight on country level, unit and description. -} -\description{ -Calculates managed pastures Tau based on FAO yield trends for 1995. -} -\examples{ -\dontrun{ -calcOutput("ValidTauPastr") -} - -} -\author{ -Marcos Alves -} From 70f011d0d28812580b781568db27d9c85a1212af Mon Sep 17 00:00:00 2001 From: FelicitasBeier Date: Fri, 7 Aug 2026 11:31:52 +0200 Subject: [PATCH 06/15] removed redundant datasource Ostberg part in calcValidYield, --- .buildlibrary | 2 +- CITATION.cff | 2 +- DESCRIPTION | 2 +- R/calcValidCroparea.R | 2 + R/calcValidGridCroparea.R | 3 +- R/calcValidYield.R | 86 +-------------------------------------- README.md | 2 +- 7 files changed, 10 insertions(+), 89 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index ed2042cd..932779f5 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '55811700' +ValidationKey: '55814400' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package .* was built under R version' diff --git a/CITATION.cff b/CITATION.cff index aac01336..f5c8f6b9 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -3,7 +3,7 @@ message: If you use this software, please cite it using the metadata from this f type: software title: 'mrvalidation: madrat data preparation for validation purposes' version: 2.70.0 -date-released: '2026-08-06' +date-released: '2026-08-07' abstract: Package contains routines to prepare data for validation exercises. authors: - family-names: Bodirsky diff --git a/DESCRIPTION b/DESCRIPTION index a7ca64fb..5b304379 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Type: Package Package: mrvalidation Title: madrat data preparation for validation purposes Version: 2.70.0 -Date: 2026-08-06 +Date: 2026-08-07 Authors@R: c( person("Benjamin Leon", "Bodirsky", , "bodirsky@pik-potsdam.de", role = c("aut", "cre")), person("Stephen", "Wirth", role = "aut"), diff --git a/R/calcValidCroparea.R b/R/calcValidCroparea.R index aee87c0a..acb33984 100644 --- a/R/calcValidCroparea.R +++ b/R/calcValidCroparea.R @@ -32,6 +32,8 @@ calcValidCroparea <- function(datasource = "FAO", detail = FALSE) { out <- add_dimension(out, dim = 3.2, add = "model", nm = datasource) } else if (datasource == "ostberg2023") { + # read in uncorrected/raw data from LandInG toolbox by Sebastian Ostberg + # based on FAO-LUH2v2 data <- calcOutput("CropareaLandInG", aggregate = FALSE) croparea <- reporthelper(x = data, dim = 3.1, level_zero_name = "Resources|Land Cover|Cropland|Croparea", diff --git a/R/calcValidGridCroparea.R b/R/calcValidGridCroparea.R index d320e2b6..db31f90f 100644 --- a/R/calcValidGridCroparea.R +++ b/R/calcValidGridCroparea.R @@ -23,7 +23,8 @@ calcValidGridCroparea <- function(physical = TRUE) { descName <- "harvested area" } - out <- calcOutput("Croparea", cellular = TRUE, aggregate = FALSE, physical = physical, irrigation = TRUE) + out <- calcOutput("Croparea", cellular = TRUE, aggregate = FALSE, + physical = physical, irrigation = TRUE) getNames(out, dim = 1) <- reportingnames(getNames(out, dim = 1)) getNames(out, dim = 2) <- reportingnames(getNames(out, dim = 2)) out <- clean_magpie(out) diff --git a/R/calcValidYield.R b/R/calcValidYield.R index 23df947d..0269597a 100644 --- a/R/calcValidYield.R +++ b/R/calcValidYield.R @@ -28,7 +28,8 @@ #' @importFrom magclass getNames<- as.magpie #' @importFrom magpiesets reporthelper summationhelper findset -calcValidYield <- function(datasource = "FAO", faoVersion = "join2010", future = NULL, physical = TRUE) { +calcValidYield <- function(datasource = "FAO", faoVersion = "join2010", + future = NULL, physical = TRUE) { if (physical) { indicatorName <- "Productivity|Yield" @@ -121,89 +122,6 @@ calcValidYield <- function(datasource = "FAO", faoVersion = "join2010", future scenario <- "historical" description <- paste("FAO massbalance production divided by", descName, " from FAO.") - } else if (datasource == "Ostberg2023_FAO_LUH2v2") { - - if (!is.null(future)) stop("Future options is not available for source type 'FAO'.") - - # Calculate areas of individual crops and pasture - croparea <- calcOutput("CropareaLandInG", aggregate = FALSE, physical = physical) - pastarea <- setNames(calcOutput("LanduseInitialisation", aggregate = FALSE)[, , "past"], - "pasture") - - cyears <- intersect(getYears(croparea), getYears(pastarea)) - area <- mbind(croparea[, cyears, ], pastarea[, cyears, ]) - area <- summationhelper(reporthelper(area, - level_zero_name = indicatorName), - sep = NULL) - - # Calculate production - if (faoVersion == "join2010") { - histproduction <- collapseNames(calcOutput("FAOmassbalance", aggregate = FALSE)) - } else if (faoVersion == "FAOpre2010") { - histproduction <- collapseNames(calcOutput("FAOmassbalance", version = "pre2010", aggregate = FALSE)) - } else if (faoVersion == "FAOpost2010") { - histproduction <- collapseNames(calcOutput("FAOmassbalance", version = "post2010", aggregate = FALSE)) - } - - # extract DryMatter(dm) from production data - # Extract Production from subsetted production data containing only DryMatter(dm) - histproduction <- collapseNames(histproduction[, , "dm"][, , "production"]) - - # Figure out which commodities are common and make sure that production and area has same commodity names - kcr <- findset("kcr") - cropproduction <- histproduction[, , kcr] - pastproduction <- histproduction[, , "pasture"] - production <- mbind(cropproduction, pastproduction) - - # Calculate Yields - production <- summationhelper(reporthelper(production, - level_zero_name = indicatorName), - sep = NULL) - cyears <- intersect(getYears(production), getYears(area)) - yield <- production[, cyears, ] / area[, cyears, ] - - # Check for NaN values - indexNaN <- which(is.nan(yield)) - # Change NaN to 0 - yield[is.nan(yield)] <- 0 - if (length(indexNaN) > 0) { - vcat(verbosity = 2, "NaN values were found in the calculated yields ---> NaN values set to 0") - } else if (length(indexNaN) == 0) { - vcat(verbosity = 2, paste0("No NaN values detected in calculated yields. ", - "Yields for area reported as 0 are converted to 0.")) - } - - # Check for infinite values - Production reported but on 0 area - infindex <- which(is.infinite(yield)) # Lots of inf values. Being too diplomatic FAO aren't we!! - # Change inf to 0 - yield[is.infinite(yield)] <- 0 - if (length(infindex) > 0) { - vcat(verbosity = 2, "inf values were found in the calculated yields ---> inf values set to 0") - } else if (length(infindex) == 0) { - vcat(verbosity = 2, "No inf values found in the calculated yields") - } - - ## Additional checks required because we are reporting insanely high yields - ## Check which(yield>200,arr.ind = TRUE) - ## looks like Vatican are the best producers of oil - - ## We decided to set these outliers to 0 - # look for the Region names which are outliers - region <- rownames(which(yield > 200, arr.ind = TRUE)) - # look for the Years where reporting is flawed - year <- which(yield > 200, arr.ind = TRUE)[, 2] - # look for the scenario.model.Variable where reporting is flawed - variable <- which(yield > 200, arr.ind = TRUE)[, 3] - - ## Now do the operation of our magpie object - yield[region, year, variable] <- 0 - vcat(verbosity = 2, paste0("Yields>200 ton/ha were converted to 0 ", - "when area and production values were ambiguous")) - - scenario <- "historical" - description <- paste("FAO massbalance production divided by", descName, - " from Ostberg et al 2023 (excluding fallow land)") - } else if (datasource == "calibratedLPJmL") { irrigation <- FALSE # can be made function argument if needed diff --git a/README.md b/README.md index cf738182..a3da00d7 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ A BibTeX entry for LaTeX users is title = {mrvalidation: madrat data preparation for validation purposes}, author = {Benjamin Leon Bodirsky and Stephen Wirth and Kristine Karstens and Florian Humpenoeder and Mishko Stevanovic and Abhijeet Mishra and Anne Biewald and Isabelle Weindl and Felicitas Beier and David Chen and Michael Crawford and Debbora Leip and Edna {Molina Bacca} and Ulrich Kreidenweis and Amsalu {W. Yalew} and Patrick {von Jeetze} and Xiaoxi Wang and Jan Philipp Dietrich and Marcos Alves}, doi = {10.5281/zenodo.4317826}, - date = {2026-08-06}, + date = {2026-08-07}, year = {2026}, url = {https://github.com/pik-piam/mrvalidation}, note = {Version: 2.70.0}, From 82d6346ba65686315ec1e9206fe1e015f0f475d1 Mon Sep 17 00:00:00 2001 From: FelicitasBeier Date: Fri, 7 Aug 2026 11:41:23 +0200 Subject: [PATCH 07/15] changed cells argument in calcYieldsCalibrated to new default lpjcell --- R/calcValidGridYields.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/calcValidGridYields.R b/R/calcValidGridYields.R index 2363a886..8bb24184 100644 --- a/R/calcValidGridYields.R +++ b/R/calcValidGridYields.R @@ -74,8 +74,8 @@ calcValidGridYields <- function(datasource = "downscaledFAO", future = NULL, phy refYear <- "y2010" out <- calcOutput("YieldsCalibrated", source = c(lpjml = lpjml, isimip = isimip), - climatetype = climatetype, refYear = refYear, cells = "magpiecell", - multicropping = physical, aggregate = FALSE)[, , findset("kcr")] + climatetype = climatetype, refYear = refYear, cells = "lpjcell", + multicropping = FALSE, aggregate = FALSE)[, , findset("kcr")] getNames(out, dim = 1) <- reportingnames(getNames(out, dim = 1)) getNames(out, dim = 2) <- reportingnames(getNames(out, dim = 2)) From eeaba126f7374d57b231d7a5a1ddadabe52382f9 Mon Sep 17 00:00:00 2001 From: bodirsky Date: Fri, 7 Aug 2026 12:10:33 +0200 Subject: [PATCH 08/15] calcValidCropareaDiversity: rename combined_years to combinedYears lintr object_name_linter requires camelCase. Local variable in one function, both occurrences renamed; grep confirms none left and the name is not used across file boundaries. Addresses review finding m9. --- R/calcValidCropareaDiversity.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/calcValidCropareaDiversity.R b/R/calcValidCropareaDiversity.R index 5917a8dc..0bfbb01a 100644 --- a/R/calcValidCropareaDiversity.R +++ b/R/calcValidCropareaDiversity.R @@ -21,8 +21,8 @@ calcValidCropareaDiversity <- function(index = "shannon", groupdiv = "agg1") { area <- collapseNames(area[, , "irrigated"]) + collapseNames(area[, , "rainfed"]) fallow <- calcOutput("Fallow", aggregate = FALSE, cellular = TRUE) fallow <- setNames(fallow, "fallow") - combined_years <- intersect(getYears(fallow), getYears(area)) - area <- mbind(area[, combined_years, ], fallow[, combined_years, ]) + combinedYears <- intersect(getYears(fallow), getYears(area)) + area <- mbind(area[, combinedYears, ], fallow[, combinedYears, ]) land <- dimSums(area, dim = 3) From 3807c16265dfdb774e79301e621e99f95cf401a9 Mon Sep 17 00:00:00 2001 From: bodirsky Date: Mon, 10 Aug 2026 14:04:12 +0200 Subject: [PATCH 09/15] .. --- R/calcValidCroparea.R | 2 +- R/fullVALIDATION.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/calcValidCroparea.R b/R/calcValidCroparea.R index acb33984..6c146db4 100644 --- a/R/calcValidCroparea.R +++ b/R/calcValidCroparea.R @@ -20,7 +20,7 @@ calcValidCroparea <- function(datasource = "FAO", detail = FALSE) { - if (datasource == "FAO") { + if (datasource == "MadratLandingLUH") { data <- calcOutput("Croparea", sectoral = "kcr", physical = TRUE, aggregate = FALSE) out <- reporthelper(x = data, dim = 3.1, level_zero_name = "Resources|Land Cover|Cropland|Croparea", diff --git a/R/fullVALIDATION.R b/R/fullVALIDATION.R index 15250038..c6314dcc 100644 --- a/R/fullVALIDATION.R +++ b/R/fullVALIDATION.R @@ -150,7 +150,7 @@ fullVALIDATION <- function(rev = 0.1, aggregate = "region+global") { # Resources: # Croparea - calcOutput(type = "ValidCroparea", datasource = "FAO", aggregate = aggregate, + calcOutput(type = "ValidCroparea", datasource = "MadratLandingLUH", aggregate = aggregate, file = valfile, append = TRUE, detail = TRUE, try = TRUE) # ready calcOutput(type = "ValidCroparea", datasource = "ostberg2023", aggregate = aggregate, file = valfile, append = TRUE, detail = TRUE, try = TRUE) # ready From 7798cb65bed20971286a2a6d7f6174f66e62b40e Mon Sep 17 00:00:00 2001 From: bodirsky Date: Mon, 10 Aug 2026 14:08:06 +0200 Subject: [PATCH 10/15] .. --- R/calcValidCroparea.R | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/R/calcValidCroparea.R b/R/calcValidCroparea.R index 6c146db4..3803c54c 100644 --- a/R/calcValidCroparea.R +++ b/R/calcValidCroparea.R @@ -1,15 +1,18 @@ #' @title calcValidCroparea #' -#' @description Returns historical areas of individual crops. These are derived by -#' correcting harvested areas to match to physical cropland areas. Both these -#' datasets are from FAO. Output is meant to be used for model validation. +#' @description Returns historical areas of individual crops, meant to be used for +#' model validation. The default source is the madrat croparea preprocessing, which +#' harmonises LandInG against LUH and calibrates it to LanduseInitialisation cropland; +#' it is no longer FAOSTAT, so the series is labelled accordingly rather than as "FAO". #' Ostberg2023 is a slightly modified version of #' https://gmd.copernicus.org/articles/16/3375/2023/gmd-16-3375-2023-assets.html #' -#' @param datasource "FAO": croparea according to FAOSTAT, +#' @param datasource "MadratLandingLUH": croparea as returned by calcCroparea, i.e. +#' LandInG harmonised against LUH and calibrated +#' to LanduseInitialisation cropland #' "ostberg2023": croparea according to LandInG data harmonization -#' by Ostberg et al. (2023) -#' "FAOfallow": fallow land according to FAOSTAT +#' by Ostberg et al. (2023), uncorrected +#' "FAOfallow": fallow land according to FAOSTAT #' @param detail TRUE: data provided for different crop types, FALSE: aggregated data #' #' @return magpie object From 22f074f215d984ca2de841d412ca00f5aae026e7 Mon Sep 17 00:00:00 2001 From: bodirsky Date: Mon, 10 Aug 2026 14:18:49 +0200 Subject: [PATCH 11/15] .. --- R/calcValidCroparea.R | 2 +- R/calcValidYield.R | 4 ++-- R/fullVALIDATION.R | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/R/calcValidCroparea.R b/R/calcValidCroparea.R index 3803c54c..dba5b488 100644 --- a/R/calcValidCroparea.R +++ b/R/calcValidCroparea.R @@ -21,7 +21,7 @@ #' @importFrom magclass getNames #' -calcValidCroparea <- function(datasource = "FAO", detail = FALSE) { +calcValidCroparea <- function(datasource = "MadratLandingLUH", detail = FALSE) { if (datasource == "MadratLandingLUH") { data <- calcOutput("Croparea", sectoral = "kcr", physical = TRUE, aggregate = FALSE) diff --git a/R/calcValidYield.R b/R/calcValidYield.R index 0269597a..ab231e63 100644 --- a/R/calcValidYield.R +++ b/R/calcValidYield.R @@ -7,7 +7,7 @@ #' Returns yield as calculated from area area and production. #' #' @param datasource Specify which datasource needs to be used. -#' Currently only "FAO" and "calibratedLPJmL" is available. +#' Currently only "MadratLandingFAOLUH" and "calibratedLPJmL" is available. #' @param future if NULL no future values are returned (default). #' specify climate scenario (gcm:rcp), if future is needed #' @param physical if true (default) physical area (croparea) used for yield calculation; @@ -39,7 +39,7 @@ calcValidYield <- function(datasource = "FAO", faoVersion = "join2010", descName <- "harvested area" } - if (datasource == "FAO") { + if (datasource == "MadratLandingFAOLUH") { if (!is.null(future)) stop("Future options is not available for source type 'FAO'.") diff --git a/R/fullVALIDATION.R b/R/fullVALIDATION.R index c6314dcc..c1516175 100644 --- a/R/fullVALIDATION.R +++ b/R/fullVALIDATION.R @@ -304,7 +304,7 @@ fullVALIDATION <- function(rev = 0.1, aggregate = "region+global") { file = valfile, append = TRUE, try = TRUE) # ready # Yield - for (datasource in c("FAO", "Ostberg2023_FAO_LUH2v2")) { + for (datasource in c("MadratLandingFAOLUH")) { for (faoVersion in c("join2010", "FAOpre2010", "FAOpost2010")) { for (physical in c(TRUE, FALSE)) { calcOutput(type = "ValidYield", datasource = datasource, physical = physical, From 5a6b14926e7b6394ef751d22ae34f75900b190f4 Mon Sep 17 00:00:00 2001 From: bodirsky Date: Mon, 10 Aug 2026 14:21:15 +0200 Subject: [PATCH 12/15] .. --- R/calcValidCroparea.R | 6 +++--- R/calcValidYield.R | 6 +++--- R/fullVALIDATION.R | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/R/calcValidCroparea.R b/R/calcValidCroparea.R index dba5b488..f55db5d4 100644 --- a/R/calcValidCroparea.R +++ b/R/calcValidCroparea.R @@ -7,7 +7,7 @@ #' Ostberg2023 is a slightly modified version of #' https://gmd.copernicus.org/articles/16/3375/2023/gmd-16-3375-2023-assets.html #' -#' @param datasource "MadratLandingLUH": croparea as returned by calcCroparea, i.e. +#' @param datasource "MadratLandIngLUH": croparea as returned by calcCroparea, i.e. #' LandInG harmonised against LUH and calibrated #' to LanduseInitialisation cropland #' "ostberg2023": croparea according to LandInG data harmonization @@ -21,9 +21,9 @@ #' @importFrom magclass getNames #' -calcValidCroparea <- function(datasource = "MadratLandingLUH", detail = FALSE) { +calcValidCroparea <- function(datasource = "MadratLandIngLUH", detail = FALSE) { - if (datasource == "MadratLandingLUH") { + if (datasource == "MadratLandIngLUH") { data <- calcOutput("Croparea", sectoral = "kcr", physical = TRUE, aggregate = FALSE) out <- reporthelper(x = data, dim = 3.1, level_zero_name = "Resources|Land Cover|Cropland|Croparea", diff --git a/R/calcValidYield.R b/R/calcValidYield.R index ab231e63..1946394a 100644 --- a/R/calcValidYield.R +++ b/R/calcValidYield.R @@ -7,7 +7,7 @@ #' Returns yield as calculated from area area and production. #' #' @param datasource Specify which datasource needs to be used. -#' Currently only "MadratLandingFAOLUH" and "calibratedLPJmL" is available. +#' Currently only "MadratLandIngFAOLUH" and "calibratedLPJmL" is available. #' @param future if NULL no future values are returned (default). #' specify climate scenario (gcm:rcp), if future is needed #' @param physical if true (default) physical area (croparea) used for yield calculation; @@ -28,7 +28,7 @@ #' @importFrom magclass getNames<- as.magpie #' @importFrom magpiesets reporthelper summationhelper findset -calcValidYield <- function(datasource = "FAO", faoVersion = "join2010", +calcValidYield <- function(datasource = "MadratLandIngFAOLUH", faoVersion = "join2010", future = NULL, physical = TRUE) { if (physical) { @@ -39,7 +39,7 @@ calcValidYield <- function(datasource = "FAO", faoVersion = "join2010", descName <- "harvested area" } - if (datasource == "MadratLandingFAOLUH") { + if (datasource == "MadratLandIngFAOLUH") { if (!is.null(future)) stop("Future options is not available for source type 'FAO'.") diff --git a/R/fullVALIDATION.R b/R/fullVALIDATION.R index c1516175..bba6e4ec 100644 --- a/R/fullVALIDATION.R +++ b/R/fullVALIDATION.R @@ -150,7 +150,7 @@ fullVALIDATION <- function(rev = 0.1, aggregate = "region+global") { # Resources: # Croparea - calcOutput(type = "ValidCroparea", datasource = "MadratLandingLUH", aggregate = aggregate, + calcOutput(type = "ValidCroparea", datasource = "MadratLandIngLUH", aggregate = aggregate, file = valfile, append = TRUE, detail = TRUE, try = TRUE) # ready calcOutput(type = "ValidCroparea", datasource = "ostberg2023", aggregate = aggregate, file = valfile, append = TRUE, detail = TRUE, try = TRUE) # ready @@ -304,7 +304,7 @@ fullVALIDATION <- function(rev = 0.1, aggregate = "region+global") { file = valfile, append = TRUE, try = TRUE) # ready # Yield - for (datasource in c("MadratLandingFAOLUH")) { + for (datasource in c("MadratLandIngFAOLUH")) { for (faoVersion in c("join2010", "FAOpre2010", "FAOpost2010")) { for (physical in c(TRUE, FALSE)) { calcOutput(type = "ValidYield", datasource = datasource, physical = physical, From 4829d676a73c9621ab830eb0affbc827d91d7d46 Mon Sep 17 00:00:00 2001 From: bodirsky Date: Mon, 10 Aug 2026 14:30:59 +0200 Subject: [PATCH 13/15] .. --- R/calcValidCroparea.R | 6 +++--- R/calcValidTau.R | 7 ++++++- R/calcValidYield.R | 8 ++++---- R/fullENGAGE.R | 2 +- R/fullVALIDATION.R | 4 ++-- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/R/calcValidCroparea.R b/R/calcValidCroparea.R index f55db5d4..1bc7f7b6 100644 --- a/R/calcValidCroparea.R +++ b/R/calcValidCroparea.R @@ -7,7 +7,7 @@ #' Ostberg2023 is a slightly modified version of #' https://gmd.copernicus.org/articles/16/3375/2023/gmd-16-3375-2023-assets.html #' -#' @param datasource "MadratLandIngLUH": croparea as returned by calcCroparea, i.e. +#' @param datasource "MadratLandInGLUH": croparea as returned by calcCroparea, i.e. #' LandInG harmonised against LUH and calibrated #' to LanduseInitialisation cropland #' "ostberg2023": croparea according to LandInG data harmonization @@ -21,9 +21,9 @@ #' @importFrom magclass getNames #' -calcValidCroparea <- function(datasource = "MadratLandIngLUH", detail = FALSE) { +calcValidCroparea <- function(datasource = "MadratLandInGLUH", detail = FALSE) { - if (datasource == "MadratLandIngLUH") { + if (datasource == "MadratLandInGLUH") { data <- calcOutput("Croparea", sectoral = "kcr", physical = TRUE, aggregate = FALSE) out <- reporthelper(x = data, dim = 3.1, level_zero_name = "Resources|Land Cover|Cropland|Croparea", diff --git a/R/calcValidTau.R b/R/calcValidTau.R index 5dc34a49..df127eca 100644 --- a/R/calcValidTau.R +++ b/R/calcValidTau.R @@ -45,7 +45,12 @@ calcValidTau <- function(datasource = "FAO2012") { description <- "Historic Trends in Agricultural Land Use Intensity Tau based on FAO yield trends (updated)" sourceName <- "dietrich_et_al_2012_updated" } else if (datasource == "FAOValidYields") { - cropYields <- calcOutput("ValidYield", aggregate = FALSE)[, , "historical.FAO.Productivity|Yield|+|Crops (t DM/ha)"] + # the model name is stamped onto the series by calcValidYield, so ask for the + # datasource explicitly and build the subscript from the same string + yieldSource <- "MadratLandInGFAOLUH" + cropYields <- calcOutput("ValidYield", datasource = yieldSource, aggregate = FALSE) + cropYields <- cropYields[, , paste0("historical.", yieldSource, + ".Productivity|Yield|+|Crops (t DM/ha)")] yieldIndex <- collapseDim(cropYields / cropYields[, 1995, ]) # average growth rates of more than 20% per year are assumed to be incorrect diff --git a/R/calcValidYield.R b/R/calcValidYield.R index 1946394a..1fb3a3f8 100644 --- a/R/calcValidYield.R +++ b/R/calcValidYield.R @@ -7,7 +7,7 @@ #' Returns yield as calculated from area area and production. #' #' @param datasource Specify which datasource needs to be used. -#' Currently only "MadratLandIngFAOLUH" and "calibratedLPJmL" is available. +#' Currently only "MadratLandInGFAOLUH" and "calibratedLPJmL" is available. #' @param future if NULL no future values are returned (default). #' specify climate scenario (gcm:rcp), if future is needed #' @param physical if true (default) physical area (croparea) used for yield calculation; @@ -28,7 +28,7 @@ #' @importFrom magclass getNames<- as.magpie #' @importFrom magpiesets reporthelper summationhelper findset -calcValidYield <- function(datasource = "MadratLandIngFAOLUH", faoVersion = "join2010", +calcValidYield <- function(datasource = "MadratLandInGFAOLUH", faoVersion = "join2010", future = NULL, physical = TRUE) { if (physical) { @@ -39,9 +39,9 @@ calcValidYield <- function(datasource = "MadratLandIngFAOLUH", faoVersion = "j descName <- "harvested area" } - if (datasource == "MadratLandIngFAOLUH") { + if (datasource == "MadratLandInGFAOLUH") { - if (!is.null(future)) stop("Future options is not available for source type 'FAO'.") + if (!is.null(future)) stop("Future options are not available for source type 'MadratLandInGFAOLUH'.") # Calculate areas of individual crops and pasture croparea <- collapseNames(calcOutput("Croparea", sectoral = "kcr", diff --git a/R/fullENGAGE.R b/R/fullENGAGE.R index 2b680bdd..ef371746 100644 --- a/R/fullENGAGE.R +++ b/R/fullENGAGE.R @@ -29,7 +29,7 @@ fullENGAGE <- function() { x <- convertENGAGE(x) out <- mbind(out, x) - x <- calcOutput(type = "ValidYield", datasource = "FAO", aggregate = "REG+GLO") + x <- calcOutput(type = "ValidYield", datasource = "MadratLandInGFAOLUH", aggregate = "REG+GLO") x <- convertENGAGE(x) out <- mbind(out, x) diff --git a/R/fullVALIDATION.R b/R/fullVALIDATION.R index bba6e4ec..d1d7bbd0 100644 --- a/R/fullVALIDATION.R +++ b/R/fullVALIDATION.R @@ -150,7 +150,7 @@ fullVALIDATION <- function(rev = 0.1, aggregate = "region+global") { # Resources: # Croparea - calcOutput(type = "ValidCroparea", datasource = "MadratLandIngLUH", aggregate = aggregate, + calcOutput(type = "ValidCroparea", datasource = "MadratLandInGLUH", aggregate = aggregate, file = valfile, append = TRUE, detail = TRUE, try = TRUE) # ready calcOutput(type = "ValidCroparea", datasource = "ostberg2023", aggregate = aggregate, file = valfile, append = TRUE, detail = TRUE, try = TRUE) # ready @@ -304,7 +304,7 @@ fullVALIDATION <- function(rev = 0.1, aggregate = "region+global") { file = valfile, append = TRUE, try = TRUE) # ready # Yield - for (datasource in c("MadratLandIngFAOLUH")) { + for (datasource in c("MadratLandInGFAOLUH")) { for (faoVersion in c("join2010", "FAOpre2010", "FAOpost2010")) { for (physical in c(TRUE, FALSE)) { calcOutput(type = "ValidYield", datasource = datasource, physical = physical, From a73fcdac69fc3d45b2ad61674e54d4687b1a3ac5 Mon Sep 17 00:00:00 2001 From: bodirsky Date: Mon, 10 Aug 2026 14:38:00 +0200 Subject: [PATCH 14/15] calcValidTau: document the renamed datasource, and drop stale FAO labels The FAOValidYields branch was renamed to MadratLandInGFAOLUH, but three strings still said FAO: - the roxygen @param, which had never documented this branch at all and then briefly named the intermediate spelling - sourceName, which line 76 stamps into the output as the model name, so the published Tau series still claimed FAO provenance - the description, which said "based on FAO yield trends" although the yields are FAO production over LandInG croparea Also passes the datasource explicitly to calcValidYield and builds the subscript from the same string, instead of hardcoding the model name in a subscript that silently depended on a default in another file. That coupling is what broke when the datasource was renamed. --- R/calcValidTau.R | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/R/calcValidTau.R b/R/calcValidTau.R index df127eca..447ef4a9 100644 --- a/R/calcValidTau.R +++ b/R/calcValidTau.R @@ -2,9 +2,10 @@ #' #' @description Returns historical land use intensity estimates (tau). #' -#' @param datasource Currently available: \code{"FAO2012"} (original data set) -#' and \code{"FAOonline"} (projection of tau values from 1995 based on recent FAO yield -#' projections.) +#' @param datasource Currently available: \code{"FAO2012"} (original data set), +#' \code{"FAOonline"} (projection of tau values from 1995 based on recent FAO yield +#' projections) and \code{"MadratLandInGFAOLUH"} (projection from 1995 based on the +#' calcValidYield series, i.e. FAO production over LandInG croparea). #' @return tau time series #' @author Jan Philipp Dietrich @@ -44,7 +45,7 @@ calcValidTau <- function(datasource = "FAO2012") { out <- tauHist description <- "Historic Trends in Agricultural Land Use Intensity Tau based on FAO yield trends (updated)" sourceName <- "dietrich_et_al_2012_updated" - } else if (datasource == "FAOValidYields") { + } else if (datasource == "MadratLandInGFAOLUH") { # the model name is stamped onto the series by calcValidYield, so ask for the # datasource explicitly and build the subscript from the same string yieldSource <- "MadratLandInGFAOLUH" @@ -63,8 +64,9 @@ calcValidTau <- function(datasource = "FAO2012") { weight[is.na(tauHist)] <- 0 tauHist[is.na(tauHist)] <- 0 out <- tauHist - description <- "Trends in Agricultural Land Use Intensity Tau based on FAO yield trends from calcValidYield" - sourceName <- "yield validation FAO" + description <- paste("Trends in Agricultural Land Use Intensity Tau based on the", + "calcValidYield series, i.e. FAO production over LandInG croparea") + sourceName <- "yield validation MadratLandInGFAOLUH" } else { stop("Unknown datasource chosen in calcValidTau!") } From 756569c9debae90dc02367900b6ff639644170fb Mon Sep 17 00:00:00 2001 From: bodirsky Date: Mon, 10 Aug 2026 15:43:27 +0200 Subject: [PATCH 15/15] .. --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- README.md | 8 ++++---- man/calcValidCroparea.Rd | 17 ++++++++++------- man/calcValidTau.Rd | 7 ++++--- man/calcValidYield.Rd | 4 ++-- 7 files changed, 25 insertions(+), 21 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 932779f5..1186b0be 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '55814400' +ValidationKey: '56029250' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package .* was built under R version' diff --git a/CITATION.cff b/CITATION.cff index f5c8f6b9..2a6254b1 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: 'mrvalidation: madrat data preparation for validation purposes' -version: 2.70.0 -date-released: '2026-08-07' +version: 2.71.0 +date-released: '2026-08-10' abstract: Package contains routines to prepare data for validation exercises. authors: - family-names: Bodirsky diff --git a/DESCRIPTION b/DESCRIPTION index 5b304379..f026ad5c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrvalidation Title: madrat data preparation for validation purposes -Version: 2.70.0 -Date: 2026-08-07 +Version: 2.71.0 +Date: 2026-08-10 Authors@R: c( person("Benjamin Leon", "Bodirsky", , "bodirsky@pik-potsdam.de", role = c("aut", "cre")), person("Stephen", "Wirth", role = "aut"), diff --git a/README.md b/README.md index a3da00d7..47fa6f19 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat data preparation for validation purposes -R package **mrvalidation**, version **2.70.0** +R package **mrvalidation**, version **2.71.0** [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4317826.svg)](https://doi.org/10.5281/zenodo.4317826) [![R build status](https://github.com/pik-piam/mrvalidation/workflows/check/badge.svg)](https://github.com/pik-piam/mrvalidation/actions) [![codecov](https://codecov.io/gh/pik-piam/mrvalidation/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mrvalidation) [![r-universe](https://pik-piam.r-universe.dev/badges/mrvalidation)](https://pik-piam.r-universe.dev/builds) @@ -39,7 +39,7 @@ In case of questions / problems please contact Benjamin Leon Bodirsky , Version: 2.70.0, . +Bodirsky B, Wirth S, Karstens K, Humpenoeder F, Stevanovic M, Mishra A, Biewald A, Weindl I, Beier F, Chen D, Crawford M, Leip D, Molina Bacca E, Kreidenweis U, W. Yalew A, von Jeetze P, Wang X, Dietrich J, Alves M (2026). "mrvalidation: madrat data preparation for validation purposes." doi:10.5281/zenodo.4317826 , Version: 2.71.0, . A BibTeX entry for LaTeX users is @@ -48,9 +48,9 @@ A BibTeX entry for LaTeX users is title = {mrvalidation: madrat data preparation for validation purposes}, author = {Benjamin Leon Bodirsky and Stephen Wirth and Kristine Karstens and Florian Humpenoeder and Mishko Stevanovic and Abhijeet Mishra and Anne Biewald and Isabelle Weindl and Felicitas Beier and David Chen and Michael Crawford and Debbora Leip and Edna {Molina Bacca} and Ulrich Kreidenweis and Amsalu {W. Yalew} and Patrick {von Jeetze} and Xiaoxi Wang and Jan Philipp Dietrich and Marcos Alves}, doi = {10.5281/zenodo.4317826}, - date = {2026-08-07}, + date = {2026-08-10}, year = {2026}, url = {https://github.com/pik-piam/mrvalidation}, - note = {Version: 2.70.0}, + note = {Version: 2.71.0}, } ``` diff --git a/man/calcValidCroparea.Rd b/man/calcValidCroparea.Rd index 3d57d2f6..af52f7ae 100644 --- a/man/calcValidCroparea.Rd +++ b/man/calcValidCroparea.Rd @@ -4,13 +4,15 @@ \alias{calcValidCroparea} \title{calcValidCroparea} \usage{ -calcValidCroparea(datasource = "FAO", detail = FALSE) +calcValidCroparea(datasource = "MadratLandInGLUH", detail = FALSE) } \arguments{ -\item{datasource}{"FAO": croparea according to FAOSTAT, +\item{datasource}{"MadratLandInGLUH": croparea as returned by calcCroparea, i.e. + LandInG harmonised against LUH and calibrated + to LanduseInitialisation cropland "ostberg2023": croparea according to LandInG data harmonization - by Ostberg et al. (2023) - "FAOfallow": fallow land according to FAOSTAT} + by Ostberg et al. (2023), uncorrected +"FAOfallow": fallow land according to FAOSTAT} \item{detail}{TRUE: data provided for different crop types, FALSE: aggregated data} } @@ -18,9 +20,10 @@ calcValidCroparea(datasource = "FAO", detail = FALSE) magpie object } \description{ -Returns historical areas of individual crops. These are derived by -correcting harvested areas to match to physical cropland areas. Both these -datasets are from FAO. Output is meant to be used for model validation. +Returns historical areas of individual crops, meant to be used for +model validation. The default source is the madrat croparea preprocessing, which +harmonises LandInG against LUH and calibrates it to LanduseInitialisation cropland; +it is no longer FAOSTAT, so the series is labelled accordingly rather than as "FAO". Ostberg2023 is a slightly modified version of https://gmd.copernicus.org/articles/16/3375/2023/gmd-16-3375-2023-assets.html } diff --git a/man/calcValidTau.Rd b/man/calcValidTau.Rd index fde4ae0c..5258c218 100644 --- a/man/calcValidTau.Rd +++ b/man/calcValidTau.Rd @@ -7,9 +7,10 @@ calcValidTau(datasource = "FAO2012") } \arguments{ -\item{datasource}{Currently available: \code{"FAO2012"} (original data set) -and \code{"FAOonline"} (projection of tau values from 1995 based on recent FAO yield -projections.)} +\item{datasource}{Currently available: \code{"FAO2012"} (original data set), +\code{"FAOonline"} (projection of tau values from 1995 based on recent FAO yield +projections) and \code{"MadratLandInGFAOLUH"} (projection from 1995 based on the +calcValidYield series, i.e. FAO production over LandInG croparea).} } \value{ tau time series diff --git a/man/calcValidYield.Rd b/man/calcValidYield.Rd index 04df5fd9..317fd8c5 100644 --- a/man/calcValidYield.Rd +++ b/man/calcValidYield.Rd @@ -5,7 +5,7 @@ \title{calcValidYield} \usage{ calcValidYield( - datasource = "FAO", + datasource = "MadratLandInGFAOLUH", faoVersion = "join2010", future = NULL, physical = TRUE @@ -13,7 +13,7 @@ calcValidYield( } \arguments{ \item{datasource}{Specify which datasource needs to be used. -Currently only "FAO" and "calibratedLPJmL" is available.} +Currently only "MadratLandInGFAOLUH" and "calibratedLPJmL" is available.} \item{faoVersion}{which FAO version to use (pre, post or joined 2010 data)}