diff --git a/.buildlibrary b/.buildlibrary index a9067f9e..ea1f3289 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '27163210' +ValidationKey: '27184248' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/CITATION.cff b/CITATION.cff index b4643227..81ac0c1f 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: 'mrmagpie: madrat based MAgPIE Input Data Library' -version: 1.38.2 -date-released: '2023-10-25' +version: 1.38.3 +date-released: '2023-10-26' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: - family-names: Karstens diff --git a/DESCRIPTION b/DESCRIPTION index 265d42b2..d2c01ef4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.38.2 -Date: 2023-10-25 +Version: 1.38.3 +Date: 2023-10-26 Authors@R: c( person("Kristine", "Karstens", , "karstens@pik-potsdam.de", role = c("aut", "cre")), person("Jan Philipp", "Dietrich", , "dietrich@pik-potsdam.de", role = "aut"), diff --git a/R/calcFoodDemandGridded.R b/R/calcFoodDemandGridded.R index 227276cd..0479041e 100644 --- a/R/calcFoodDemandGridded.R +++ b/R/calcFoodDemandGridded.R @@ -3,13 +3,16 @@ #' @return Gridded magpie object of food demand disaggregated by rural urban pop #' @param attribute dm or calories ("ge") or other massbalance attribute #' @param feed whether to include feed demand in the gridded demand +#' @param prod for memory reasons #' @author David M Chen +#' @importFrom withr local_options +#' @importFrom magpiesets findset #' @examples #' \dontrun{ #' calcOutput("FoodDemandGridded") #' } #' -calcFoodDemandGridded <- function(attribute = "dm", feed = TRUE) { +calcFoodDemandGridded <- function(attribute = "dm", prod = "k", feed = TRUE) { foodDemand <- calcOutput("FAOmassbalance", aggregate = FALSE) if (feed) { @@ -18,7 +21,7 @@ calcFoodDemandGridded <- function(attribute = "dm", feed = TRUE) { prods <- c("food", "flour1") } - foodDemand <- foodDemand[, , prods][, , attribute] + foodDemand <- collapseNames(foodDemand[, , prods][, , attribute]) hist <- getYears(foodDemand) @@ -42,6 +45,12 @@ calcFoodDemandGridded <- function(attribute = "dm", feed = TRUE) { foodDisaggUrb[, , "urban"][, , "feed"] foodDisaggUrb[, , "urban"][, , "feed"] <- 0 + local_options(magclass_sizeLimit = 1e+12) + + prods <- findset(prod) + #sum up demand dimension + foodDisaggUrb <- dimSums(foodDisaggUrb[, , prods], dim = 3.2) + return(list(x = foodDisaggUrb, weight = NULL, unit = "Mt", diff --git a/README.md b/README.md index 96c52d08..49da3bf0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.38.2** +R package **mrmagpie**, version **1.38.3** [![CRAN status](https://www.r-pkg.org/badges/version/mrmagpie)](https://cran.r-project.org/package=mrmagpie) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4319612.svg)](https://doi.org/10.5281/zenodo.4319612) [![R build status](https://github.com/pik-piam/mrmagpie/workflows/check/badge.svg)](https://github.com/pik-piam/mrmagpie/actions) [![codecov](https://codecov.io/gh/pik-piam/mrmagpie/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mrmagpie) [![r-universe](https://pik-piam.r-universe.dev/badges/mrmagpie)](https://pik-piam.r-universe.dev/builds) @@ -39,7 +39,7 @@ In case of questions / problems please contact Kristine Karstens . +Karstens K, Dietrich J, Chen D, Windisch M, Alves M, Beier F, v. Jeetze P, Mishra A, Humpenoeder F, Führlich P (2023). _mrmagpie: madrat based MAgPIE Input Data Library_. doi: 10.5281/zenodo.4319612 (URL: https://doi.org/10.5281/zenodo.4319612), R package version 1.38.3, . A BibTeX entry for LaTeX users is @@ -48,7 +48,7 @@ A BibTeX entry for LaTeX users is title = {mrmagpie: madrat based MAgPIE Input Data Library}, author = {Kristine Karstens and Jan Philipp Dietrich and David Chen and Michael Windisch and Marcos Alves and Felicitas Beier and Patrick {v. Jeetze} and Abhijeet Mishra and Florian Humpenoeder and Pascal Führlich}, year = {2023}, - note = {R package version 1.38.2}, + note = {R package version 1.38.3}, doi = {10.5281/zenodo.4319612}, url = {https://github.com/pik-piam/mrmagpie}, } diff --git a/man/calcFoodDemandGridded.Rd b/man/calcFoodDemandGridded.Rd index 5685559d..fa66da4b 100644 --- a/man/calcFoodDemandGridded.Rd +++ b/man/calcFoodDemandGridded.Rd @@ -4,11 +4,13 @@ \alias{calcFoodDemandGridded} \title{calcFoodDemandGridded} \usage{ -calcFoodDemandGridded(attribute = "dm", feed = TRUE) +calcFoodDemandGridded(attribute = "dm", prod = "k", feed = TRUE) } \arguments{ \item{attribute}{dm or calories ("ge") or other massbalance attribute} +\item{prod}{for memory reasons} + \item{feed}{whether to include feed demand in the gridded demand} } \value{