diff --git a/.buildlibrary b/.buildlibrary index 9886e74d8..8f420aaa3 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '57667642' +ValidationKey: '57688304' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 6c9a1ac67..0b6cf0c36 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,7 +2,7 @@ cff-version: 1.2.0 message: If you use this software, please cite it using the metadata from this file. type: software title: 'magpie4: MAgPIE outputs R package for MAgPIE version 4.x' -version: 2.79.1 +version: 2.79.2 date-released: '2026-07-28' abstract: Common output routines for extracting results from the MAgPIE framework (versions 4.x). diff --git a/DESCRIPTION b/DESCRIPTION index f12d80d8d..2933b3b74 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: magpie4 Title: MAgPIE outputs R package for MAgPIE version 4.x -Version: 2.79.1 +Version: 2.79.2 Date: 2026-07-28 Authors@R: c( person("Benjamin Leon", "Bodirsky", , "bodirsky@pik-potsdam.de", role = c("aut", "cre")), diff --git a/R/reportFeedConversion.R b/R/reportFeedConversion.R index 78c16bbb2..28bf8609b 100644 --- a/R/reportFeedConversion.R +++ b/R/reportFeedConversion.R @@ -181,19 +181,11 @@ reportFeedConversion <- function(gdx, livestockSystem = TRUE, balanceflow = FALS livestockProdReg <- production(gdx, products = "kli", attributes = "dm", level = "reg") livestockProd <- superAggregateX(livestockProdReg, aggr_type = "sum", level = level) livestockYield <- livestockYield[, getYears(livestockProd), ] - # Any level beyond 'reg' has to be aggregated here. Note that the aggregated - # rows are sum(yield * production) rather than a production-weighted mean; - # this reproduces the behaviour of the removed colSums() call and is kept - # deliberately. + # A yield is an intensive quantity, so it aggregates as the production-weighted + # mean of the regional yields, not as their sum. livestockProdReg <- livestockProdReg[getItems(livestockYield, 1.1), , ] - if (level == "regglo") { - livestockYield <- mbind(livestockYield, - superAggregateX(livestockYield * livestockProdReg, - aggr_type = "sum", level = "glo")) - } else if (level != "reg") { - livestockYield <- superAggregateX(livestockYield * livestockProdReg, - aggr_type = "sum", level = level) - } + livestockYield <- superAggregateX(livestockYield, aggr_type = "weighted_mean", + weight = livestockProdReg, level = level) prefix <- "Productivity|Livestock system yield|" nameIndicator <- paste0(prefix, getNames(livestockYield, dim = 1), " (", "DM per live animal", ")") x <- mbind(x, setNames(livestockYield, nameIndicator)) diff --git a/README.md b/README.md index 9a4625b69..4eaff6eb8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MAgPIE outputs R package for MAgPIE version 4.x -R package **magpie4**, version **2.79.1** +R package **magpie4**, version **2.79.2** [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1158582.svg)](https://doi.org/10.5281/zenodo.1158582) [![R build status](https://github.com/pik-piam/magpie4/workflows/check/badge.svg)](https://github.com/pik-piam/magpie4/actions) [![codecov](https://codecov.io/gh/pik-piam/magpie4/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/magpie4) [![r-universe](https://pik-piam.r-universe.dev/badges/magpie4)](https://pik-piam.r-universe.dev/builds) @@ -39,7 +39,7 @@ In case of questions / problems please contact Benjamin Leon Bodirsky , Version: 2.79.1, . +Bodirsky B, Humpenoeder F, Dietrich J, Stevanovic M, Weindl I, Karstens K, Wang X, Mishra A, Beier F, Breier J, Yalew A, Chen D, Biewald A, Wirth S, von Jeetze P, Leip D, Crawford M, Alves M, Sauer P, Bonsch M, Vartika S, Rein P (2026). "magpie4: MAgPIE outputs R package for MAgPIE version 4.x." doi:10.5281/zenodo.1158582 , Version: 2.79.2, . A BibTeX entry for LaTeX users is @@ -51,6 +51,6 @@ A BibTeX entry for LaTeX users is date = {2026-07-28}, year = {2026}, url = {https://github.com/pik-piam/magpie4}, - note = {Version: 2.79.1}, + note = {Version: 2.79.2}, } ```