diff --git a/.buildlibrary b/.buildlibrary index 7dfe624b..f596f340 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '28117287' +ValidationKey: '28269360' 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 da3051a2..c134cbd5 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: 'mrcommons: MadRat commons Input Data Library' -version: 1.41.3 -date-released: '2024-06-25' +version: 1.42.0 +date-released: '2024-07-04' abstract: Provides useful functions and a common structure to all the input data required to run models like MAgPIE and REMIND of model input data. authors: diff --git a/DESCRIPTION b/DESCRIPTION index 6eee8811..96b8b17f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: mrcommons Type: Package Title: MadRat commons Input Data Library -Version: 1.41.3 -Date: 2024-06-25 +Version: 1.42.0 +Date: 2024-07-04 Authors@R: c(person("Benjamin Leon", "Bodirsky", email = "bodirsky@pik-potsdam.de", role = "aut"), person("Kristine", "Karstens", role = "aut"), person("Lavinia", "Baumstark", role = "aut"), @@ -84,6 +84,6 @@ URL: BugReports: https://github.com/pik-piam/mrcommons/issues LazyData: no Encoding: UTF-8 -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 VignetteBuilder: knitr Roxygen: list(markdown = TRUE) diff --git a/R/calcAtmosphericDeposition.R b/R/calcAtmosphericDeposition.R index 13ececb9..69b0de25 100644 --- a/R/calcAtmosphericDeposition.R +++ b/R/calcAtmosphericDeposition.R @@ -71,16 +71,16 @@ calcAtmosphericDeposition <- function(datasource = "ACCMIP", glo_incl_oceans = F out <- dimOrder(out, perm = c(2, 1)) if (cellular) { weight <- collapseNames(calcOutput("AtmosphericDeposition", datasource = "ACCMIP", glo = FALSE, cellular = TRUE, - cells = "lpjcell", emission = FALSE, scenario = NULL, aggregate = FALSE)) + cells = "lpjcell", emission = FALSE, scenario = NULL, aggregate = FALSE)) commonCtries <- intersect(getItems(weight, dim = "iso"), getItems(out, dim = 1)) out <- out[commonCtries, , ] getSets(out) <- c("iso", "year", "landuse", "data1") weight <- weight[, getItems(out, dim = 2), ] weight <- weight[, , getItems(out, dim = 3)] coordMapping <- toolGetMappingCoord2Country() - out <- toolAggregate(out, weight = weight, - rel = coordMapping, from = "iso", to = "coords", - partrel = FALSE) + out <- toolAggregate(out, weight = weight + 10^-10, + rel = coordMapping, from = "iso", to = "coords", + partrel = FALSE) out <- toolCoord2Isocoord(out) } } @@ -106,5 +106,5 @@ calcAtmosphericDeposition <- function(datasource = "ACCMIP", glo_incl_oceans = F min = 0, max = 200, description = paste0("Atmospheric deposition, natural (1870 levels) and anthropogenic in the ", - "year 1995 (actually 1993) for different landuse classes."))) + "year 1995 (actually 1993) for different landuse classes."))) } diff --git a/R/calcGrowingStockpha.R b/R/calcGrowingStockpha.R index 3cb13ded..d57072bd 100644 --- a/R/calcGrowingStockpha.R +++ b/R/calcGrowingStockpha.R @@ -22,7 +22,7 @@ calcGrowingStockpha <- function() { getNames(area) <- FRAnames(getNames(area)) vars <- intersect(getNames(area), getNames(x)) x <- x[, , vars] - weight <- area[, , vars] + weight <- area[, , vars] + 10^-10 x <- setYears(collapseNames(x[, "y2000", "Plantations"]), NULL) weight <- setYears(collapseNames(weight[, "y2000", "Plantations"]), NULL) diff --git a/R/calcNitrogenFixationRateNatural.R b/R/calcNitrogenFixationRateNatural.R index 48f5a005..51464660 100644 --- a/R/calcNitrogenFixationRateNatural.R +++ b/R/calcNitrogenFixationRateNatural.R @@ -21,8 +21,8 @@ calcNitrogenFixationRateNatural <- function(cells = "lpjcell") { # evapotranspiration (in m^3 per ha) etRate <- collapseNames(calcOutput("LPJmL_new", version = "LPJmL4_for_MAgPIE_44ac93de", - climatetype = "GSWP3-W5E5:historical", subtype = "aet", - stage = "smoothed", aggregate = FALSE)[, years, ]) + climatetype = "GSWP3-W5E5:historical", subtype = "aet", + stage = "smoothed", aggregate = FALSE)[, years, ]) startYear <- "y1965" @@ -48,7 +48,7 @@ calcNitrogenFixationRateNatural <- function(cells = "lpjcell") { } return(list(x = bnfRate, - weight = dimSums(land, dim = 3), + weight = dimSums(land, dim = 3) + 10^-10, unit = "Mt Nr / Mha", description = "Nitrogen fixation freeliving bacteria", isocountries = FALSE)) diff --git a/R/calcPriceAgriculture.R b/R/calcPriceAgriculture.R index fe49f4da..4f55118d 100644 --- a/R/calcPriceAgriculture.R +++ b/R/calcPriceAgriculture.R @@ -62,9 +62,9 @@ calcPriceAgriculture <- function(datasource = "IMPACT3.2.2World_Price", unit = " names(dimnames(out))[3] <- "scenario.model.variable" description <- paste0("Prices from the IMPACT model projections. There are ", - length(ktradeSet) - length(commodities), - " missing MAgPIE commodities: ", - paste(ktradeSet[!ktradeSet %in% commodities], collapse = " ")) + length(ktradeSet) - length(commodities), + " missing MAgPIE commodities: ", + paste(ktradeSet[!ktradeSet %in% commodities], collapse = " ")) weight <- NULL isocountries <- FALSE @@ -165,7 +165,7 @@ calcPriceAgriculture <- function(datasource = "IMPACT3.2.2World_Price", unit = " qprod[out == 0] <- 0 # weighted aggregation of fao prices to magpie commodities - out <- toolAggregate(out, rel = aggregation, weight = qprod, from = "ProductionItem", + out <- toolAggregate(out, rel = aggregation, weight = qprod + 10^-10, from = "ProductionItem", to = "k", dim = 3, partrel = TRUE, verbosity = 2) out <- out[, , -which(getNames(out) %in% c("remaining", "not_clear"), arr.ind = TRUE)] @@ -193,7 +193,7 @@ calcPriceAgriculture <- function(datasource = "IMPACT3.2.2World_Price", unit = " } return(list(x = out, - weight = weight, + weight = weight + 10^-10, unit = unit, description = description, isocountries = isocountries)) diff --git a/R/calcSOCLossShare.R b/R/calcSOCLossShare.R index 9e88cc55..d616ab02 100644 --- a/R/calcSOCLossShare.R +++ b/R/calcSOCLossShare.R @@ -20,7 +20,7 @@ calcSOCLossShare <- function(subsystems = FALSE, rate = "change", factor = "ipcc cells = "lpjcell") { ipccClimate <- calcOutput("ClimateClass", aggregate = FALSE, - datasource = factor, cells = cells) + datasource = factor, cells = cells) factor2SCF <- c(ipccReduced = "SCF_sub", ipccReduced2019 = "SCF_sub2019") @@ -52,12 +52,11 @@ calcSOCLossShare <- function(subsystems = FALSE, rate = "change", factor = "ipcc } weight <- dimSums(calcOutput("LanduseInitialisation", aggregate = FALSE, cellular = TRUE, - cells = cells, years = "y1995", round = 6), dim = 3) - - return(list( - x = socLossShare, - weight = weight, - unit = "tC/tC", - description = "Soil organic carbon loss share per crop type", - isocountries = FALSE)) + cells = cells, years = "y1995", round = 6), dim = 3) + 10^-10 + + return(list(x = socLossShare, + weight = weight, + unit = "tC/tC", + description = "Soil organic carbon loss share per crop type", + isocountries = FALSE)) } diff --git a/R/convertGTAPv8v9.R b/R/convertGTAPv8v9.R index 4669d59e..4d8f0795 100644 --- a/R/convertGTAPv8v9.R +++ b/R/convertGTAPv8v9.R @@ -45,11 +45,11 @@ convertGTAPv8v9 <- function(x, subtype) { dim = 3, partrel = TRUE) if (split$header %in% c("VIWS", "VIMS")) { - w1 <- faoI - w2 <- faoX + w1 <- faoI + 10^-10 + w2 <- faoX + 10^-10 } else { - w1 <- faoX - w2 <- faoI + w1 <- faoX + 10^-10 + w2 <- faoI + 10^-10 } diff --git a/README.md b/README.md index ef48e0ea..0a2f55ad 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MadRat commons Input Data Library -R package **mrcommons**, version **1.41.3** +R package **mrcommons**, version **1.42.0** [![CRAN status](https://www.r-pkg.org/badges/version/mrcommons)](https://cran.r-project.org/package=mrcommons) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3822009.svg)](https://doi.org/10.5281/zenodo.3822009) [![R build status](https://github.com/pik-piam/mrcommons/workflows/check/badge.svg)](https://github.com/pik-piam/mrcommons/actions) [![codecov](https://codecov.io/gh/pik-piam/mrcommons/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mrcommons) [![r-universe](https://pik-piam.r-universe.dev/badges/mrcommons)](https://pik-piam.r-universe.dev/builds) @@ -39,7 +39,7 @@ In case of questions / problems please contact Jan Philipp Dietrich . +Bodirsky B, Karstens K, Baumstark L, Weindl I, Wang X, Mishra A, Wirth S, Stevanovic M, Steinmetz N, Kreidenweis U, Rodrigues R, Popov R, Humpenoeder F, Giannousakis A, Levesque A, Klein D, Araujo E, Beier F, Oeser J, Pehl M, Leip D, Crawford M, Molina Bacca E, von Jeetze P, Martinelli E, Schreyer F, Soergel B, Sauer P, Hötten D, Hasse R, Abrahão G, Weigmann P, Dietrich J (2024). _mrcommons: MadRat commons Input Data Library_. doi: 10.5281/zenodo.3822009 (URL: https://doi.org/10.5281/zenodo.3822009), R package version 1.42.0, . A BibTeX entry for LaTeX users is @@ -48,7 +48,7 @@ A BibTeX entry for LaTeX users is title = {mrcommons: MadRat commons Input Data Library}, author = {Benjamin Leon Bodirsky and Kristine Karstens and Lavinia Baumstark and Isabelle Weindl and Xiaoxi Wang and Abhijeet Mishra and Stephen Wirth and Mishko Stevanovic and Nele Steinmetz and Ulrich Kreidenweis and Renato Rodrigues and Roman Popov and Florian Humpenoeder and Anastasis Giannousakis and Antoine Levesque and David Klein and Ewerton Araujo and Felicitas Beier and Julian Oeser and Michaja Pehl and Debbora Leip and Michael Crawford and Edna {Molina Bacca} and Patrick {von Jeetze} and Eleonora Martinelli and Felix Schreyer and Bjoern Soergel and Pascal Sauer and David Hötten and Robin Hasse and Gabriel Abrahão and Pascal Weigmann and Jan Philipp Dietrich}, year = {2024}, - note = {R package version 1.41.3}, + note = {R package version 1.42.0}, doi = {10.5281/zenodo.3822009}, url = {https://github.com/pik-piam/mrcommons}, }