diff --git a/.buildlibrary b/.buildlibrary index e41653e0..3340adb7 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '27903624' +ValidationKey: '27948800' AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' - 'Warning: namespace ''.*'' is not available and has been replaced' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 243f46a1..62f13da6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ exclude: '^tests/testthat/_snaps/.*$' repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 + rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # frozen: v4.6.0 hooks: - id: check-case-conflict - id: check-json @@ -15,7 +15,7 @@ repos: - id: mixed-line-ending - repo: https://github.com/lorenzwalthert/precommit - rev: v0.4.0 + rev: 7910e0323d7213f34275a7a562b9ef0fde8ce1b9 # frozen: v0.4.2 hooks: - id: parsable-R - id: deps-in-desc diff --git a/CITATION.cff b/CITATION.cff index 8909e040..2e9f8803 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.40.7 -date-released: '2024-04-19' +version: 1.40.8 +date-released: '2024-05-07' 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 61347bb9..8712b4b5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: mrcommons Type: Package Title: MadRat commons Input Data Library -Version: 1.40.7 -Date: 2024-04-19 +Version: 1.40.8 +Date: 2024-05-07 Authors@R: c(person("Benjamin Leon", "Bodirsky", email = "bodirsky@pik-potsdam.de", role = "aut"), person("Kristine", "Karstens", role = "aut"), person("Lavinia", "Baumstark", role = "aut"), diff --git a/NAMESPACE b/NAMESPACE index eb825120..2d82af2d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -93,7 +93,6 @@ importFrom(lpjmlkit,read_io) importFrom(luscale,getAggregationMatrix) importFrom(luscale,groupAggregate) importFrom(luscale,rename_dimnames) -importFrom(luscale,speed_aggregate) importFrom(madrat,calcOutput) importFrom(madrat,getISOlist) importFrom(madrat,metadataGFZ) diff --git a/R/calcBodyHeight.R b/R/calcBodyHeight.R index 92424048..95d1f47c 100644 --- a/R/calcBodyHeight.R +++ b/R/calcBodyHeight.R @@ -8,8 +8,6 @@ #' Also,the year 1965 is extrapolatedusing the worldbank population #' data and sex, age, and education structure of 1970. #' @export -#' @importFrom luscale speed_aggregate - calcBodyHeight <- function(convert = TRUE) { demo <- calcOutput("Demography", education = FALSE, aggregate = FALSE) diff --git a/R/calcDemography.R b/R/calcDemography.R index 97886f0b..ef06b669 100644 --- a/R/calcDemography.R +++ b/R/calcDemography.R @@ -16,8 +16,8 @@ calcDemography <- function(convert = TRUE, education = TRUE) { lutz <- readSource("Lutz2014", convert = convert) mapping2 <- toolGetMapping(type = "sectoral", name = "lutz2hic2.csv", - where = "mappingfolder") - demo <- luscale::speed_aggregate(x = lutz, rel = mapping2, from = "lutz", to = "hic", dim = 3.2) + where = "mappingfolder") + demo <- toolAggregate(x = lutz, rel = mapping2, from = "lutz", to = "hic", dim = 3.2) demo <- demo[, , "B", invert = TRUE] demo <- demo[, , "All", invert = TRUE] @@ -39,8 +39,7 @@ calcDemography <- function(convert = TRUE, education = TRUE) { naming = "scenario", years = magpiesets::findset("time"), aggregate = FALSE) - diff <- dimSums(demo, dim = c("sex", "age", "education")) - population[, getYears(demo), - getNames(demo, dim = 1)] + diff <- dimSums(demo, dim = c("sex", "age", "education")) - population[, getYears(demo), getNames(demo, dim = 1)] diff[] <- abs(diff) if (sum(diff) > 100) { vcat(2, paste0( @@ -59,13 +58,13 @@ calcDemography <- function(convert = TRUE, education = TRUE) { } # recalibration to SSP population scenarios - # create SSP2EU and SDP scenarios columns based on SSP2 and SSP1 - if (any(c("SDP", "SDP_EI", "SDP_MC", "SDP_RC", "SSP2EU") %in% getNames(population))) { - demo <- add_columns(demo, addnm = c("SDP", "SDP_EI", "SDP_MC", "SDP_RC", "SSP2EU"), - dim = 3.1, fill = NA) - demo[, , "SSP2EU"] <- demo[, , "SSP2"] - demo[, , "SDP", pmatch = TRUE] <- demo[, , "SSP1"] - } + # create SSP2EU and SDP scenarios columns based on SSP2 and SSP1 + if (any(c("SDP", "SDP_EI", "SDP_MC", "SDP_RC", "SSP2EU") %in% getNames(population))) { + demo <- add_columns(demo, addnm = c("SDP", "SDP_EI", "SDP_MC", "SDP_RC", "SSP2EU"), + dim = 3.1, fill = NA) + demo[, , "SSP2EU"] <- demo[, , "SSP2"] + demo[, , "SDP", pmatch = TRUE] <- demo[, , "SSP1"] + } demoShr <- demo / dimSums(demo, dim = c("sex", "age", "education")) vcat(verbosity = 2, paste0("Year 1965 in demography data missing. Used values of 1970 instead")) diff --git a/R/calcIntakeBodyweight.R b/R/calcIntakeBodyweight.R index d35d6dc4..acbeae32 100644 --- a/R/calcIntakeBodyweight.R +++ b/R/calcIntakeBodyweight.R @@ -37,8 +37,8 @@ calcIntakeBodyweight <- function(bodyweight, bodyheight = NULL, inactivity, tmea requirement <- readSource("HHS_USDA", convert = FALSE) weight <- requirement * 0 + 1 mapping <- toolGetMapping(type = "sectoral", name = "HHS_USDA2hic.csv", where = "mappingfolder") - requirement <- speed_aggregate(x = requirement, rel = mapping, weight = weight, - from = "HHS_USDA", to = "hic", dim = 3.2) + requirement <- toolAggregate(x = requirement, rel = mapping, weight = weight, + from = "HHS_USDA", to = "hic", dim = 3.2) standardizedRequirement <- (collapseNames(requirement[, , "Sedentary"]) * inactivity + collapseNames(requirement[, , "Active"]) * (1 - inactivity)) diff --git a/R/convertLutz2014.R b/R/convertLutz2014.R index d7ec36c0..88695ca1 100644 --- a/R/convertLutz2014.R +++ b/R/convertLutz2014.R @@ -22,7 +22,7 @@ convertLutz2014 <- function(x) { x <- toolCountryFill(x, fill = NA, no_remove_warning = "ANT") - # BB: use of speed_aggregate with an external mapping could replace the following function and speed it up + # BB: use of toolAggregate with an external mapping could replace the following function and speed it up fillCountryByAverageOfRegion <- function(x, country, region) { vcat(2, paste0("interpolating country: ", country)) values <- x[region, , ] diff --git a/README.md b/README.md index 0a7552bf..4cb1d2a6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MadRat commons Input Data Library -R package **mrcommons**, version **1.40.7** +R package **mrcommons**, version **1.40.8** [![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 , R package version 1.40.8, . A BibTeX entry for LaTeX users is @@ -48,8 +48,8 @@ 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.40.7}, - doi = {10.5281/zenodo.3822009}, + note = {R package version 1.40.8}, url = {https://github.com/pik-piam/mrcommons}, + doi = {10.5281/zenodo.3822009}, } ```