diff --git a/.buildlibrary b/.buildlibrary index 0bb3655e..d1e2ed04 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '10288620' +ValidationKey: '10308853' 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 f1f2ea33..3976de55 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: 'mrland: MadRaT land data package' -version: 0.52.2 -date-released: '2023-12-19' +version: 0.52.3 +date-released: '2023-12-20' abstract: The package provides land related data via the madrat framework. authors: - family-names: Dietrich diff --git a/DESCRIPTION b/DESCRIPTION index 2f04ec16..3f2d2181 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrland Title: MadRaT land data package -Version: 0.52.2 -Date: 2023-12-19 +Version: 0.52.3 +Date: 2023-12-20 Authors@R: c( person("Jan Philipp", "Dietrich", , "dietrich@pik-potsdam.de", role = c("aut", "cre")), person("Abhijeet", "Mishra", role = "aut"), diff --git a/R/calcEATFruitvegRatio.R b/R/calcEATFruitvegRatio.R index 4b072278..df6ef262 100644 --- a/R/calcEATFruitvegRatio.R +++ b/R/calcEATFruitvegRatio.R @@ -85,18 +85,21 @@ calcEATFruitvegRatio <- function(populationweight = "PopulationPast") { kcalBananas <- dimSums(cbsFAO[, , bananas], dim = 3) ratioFruit2Cassava <- kcalBananas / kcalCassava - ratioFruit2Cassava <- toolFillWithRegionAvg(ratioFruit2Cassava, weight = weight, verbose = FALSE) # Correct NA's in the past by extending values from years that have values if (any(is.na(ratioFruit2Cassava))) { noCassavaRegions <- where(is.na(ratioFruit2Cassava))$true$regions for (i in noCassavaRegions) { yrsNoNA <- where(!is.na(ratioFruit2Cassava[i, , ]))$true$years - tmp <- new.magpie(cells_and_regions = i, - years = yrsNoNA) - tmp[, , ] <- ratioFruit2Cassava[i, , ][!is.na(ratioFruit2Cassava[i, , ])] - ratioFruit2Cassava[i, , ] <- toolHoldConstant(tmp, pastYrs) + if (!identical(yrsNoNA, character(0))) { + tmp <- new.magpie(cells_and_regions = i, + years = yrsNoNA) + tmp[, , ] <- ratioFruit2Cassava[i, , ][!is.na(ratioFruit2Cassava[i, , ])] + ratioFruit2Cassava[i, , ] <- toolHoldConstant(tmp, pastYrs) + } } } + # Fill missing countries with regional average + ratioFruit2Cassava <- toolFillWithRegionAvg(ratioFruit2Cassava, weight = weight, verbose = FALSE) ratioFruit2Cassava <- add_dimension(ratioFruit2Cassava, add = "EAT_special", nm = "cassav_sp") out <- mbind(ratioFruitveg2Others, ratioFruit2Cassava) diff --git a/README.md b/README.md index 54548ad6..b5b993a7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MadRaT land data package -R package **mrland**, version **0.52.2** +R package **mrland**, version **0.52.3** [![CRAN status](https://www.r-pkg.org/badges/version/mrland)](https://cran.r-project.org/package=mrland) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3822083.svg)](https://doi.org/10.5281/zenodo.3822083) [![R build status](https://github.com/pik-piam/mrland/workflows/check/badge.svg)](https://github.com/pik-piam/mrland/actions) [![codecov](https://codecov.io/gh/pik-piam/mrland/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mrland) [![r-universe](https://pik-piam.r-universe.dev/badges/mrland)](https://pik-piam.r-universe.dev/builds) @@ -39,7 +39,7 @@ In case of questions / problems please contact Jan Philipp Dietrich . +Dietrich J, Mishra A, Weindl I, Bodirsky B, Wang X, Baumstark L, Kreidenweis U, Klein D, Steinmetz N, Chen D, Humpenoeder F, von Jeetze P, Wirth S, Beier F, Hoetten D (2023). _mrland: MadRaT land data package_. doi:10.5281/zenodo.3822083 , R package version 0.52.3, . A BibTeX entry for LaTeX users is @@ -48,7 +48,7 @@ A BibTeX entry for LaTeX users is title = {mrland: MadRaT land data package}, author = {Jan Philipp Dietrich and Abhijeet Mishra and Isabelle Weindl and Benjamin Leon Bodirsky and Xiaoxi Wang and Lavinia Baumstark and Ulrich Kreidenweis and David Klein and Nele Steinmetz and David Chen and Florian Humpenoeder and Patrick {von Jeetze} and Stephen Wirth and Felicitas Beier and David Hoetten}, year = {2023}, - note = {R package version 0.52.2}, + note = {R package version 0.52.3}, doi = {10.5281/zenodo.3822083}, url = {https://github.com/pik-piam/mrland}, }