diff --git a/.buildlibrary b/.buildlibrary index 9c6e3bbe..f8ba55c0 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '30453908' +ValidationKey: '30512004' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package .* was built under R version' @@ -8,3 +8,4 @@ AcceptedNotes: - includes the non-default packages allowLinterWarnings: no enforceVersionUpdate: no +skipCoverage: no diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index f6ea5d40..d85a3165 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -23,14 +23,14 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: extra-packages: | - any::lucode2 - any::covr - any::madrat - any::magclass - any::citation - any::gms - any::goxygen - any::GDPuc + lucode2 + covr + madrat + magclass + citation + gms + goxygen + GDPuc # piam packages also available on CRAN (madrat, magclass, citation, # gms, goxygen, GDPuc) will usually have an outdated binary version # available; by using extra-packages we get the newest version @@ -63,6 +63,6 @@ jobs: shell: Rscript {0} run: | nonDummyTests <- setdiff(list.files("./tests/testthat/"), c("test-dummy.R", "_snaps")) - if(length(nonDummyTests) > 0) covr::codecov(quiet = FALSE) + if(length(nonDummyTests) > 0 && !lucode2:::loadBuildLibraryConfig()[["skipCoverage"]]) covr::codecov(quiet = FALSE) env: NOT_CRAN: "true" diff --git a/CITATION.cff b/CITATION.cff index 0279ce00..d375d1be 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.52.3 -date-released: '2024-09-30' +version: 1.52.4 +date-released: '2024-10-25' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: - family-names: Karstens diff --git a/DESCRIPTION b/DESCRIPTION index e2c64e36..da3a4415 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.52.3 -Date: 2024-09-30 +Version: 1.52.4 +Date: 2024-10-25 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/calcAgeClassDistribution.R b/R/calcAgeClassDistribution.R index fe1c6991..f153d23c 100644 --- a/R/calcAgeClassDistribution.R +++ b/R/calcAgeClassDistribution.R @@ -1,10 +1,10 @@ #' @title calcAgeClassDistribution -#' @description This function calculates the share of each age class in secondary forests in each -#' MAgPIE simulation cluster based on Global Forest Age Dataset from Poulter et al. 2019 +#' @description This function calculates forest area in 15 age classes based on the +#' Global Forest Age Dataset (GFAD) from Poulter et al. 2019 #' @param cells lpjcell for 67420 cells or magpiecell for 59199 cells #' #' @return magpie object in cluster resolution -#' @author Abhijeet Mishra, Felicitas Beier +#' @author Abhijeet Mishra, Felicitas Beier, Florian Humpenoeder #' #' @examples #' \dontrun{ @@ -23,26 +23,18 @@ calcAgeClassDistribution <- function(cells = "lpjcell") { cb <- toolGetMapping("LPJ_CellBelongingsToCountries.csv", type = "cell", where = "mrcommons") cellArea <- (111e3 * 0.5) * (111e3 * 0.5) * cos(cb$lat / 180 * pi) - cellArea <- as.magpie(cellArea, spatial = 1) + cellArea <- as.magpie(cellArea, spatial = 1) / 1e10 # convert to Mha getItems(cellArea, dim = 1, raw = TRUE) <- paste(mapping$coords, mapping$iso, sep = ".") getSets(cellArea) <- c("x", "y", "iso", "year", "data") ###################### - forestArea <- poulterDataset * cellArea + out <- poulterDataset * cellArea - forestArea <- dimSums(forestArea, dim = 3.1) + out <- dimSums(out, dim = 3.1) - getNames(forestArea) <- gsub(pattern = "X", - replacement = "class", - x = getNames(forestArea)) - - ## Set age classes to 0 where forest does not exist - ## Only checking where zero forest area exists - zeroForestArea <- dimSums(forestArea, dim = 3) - acDistribution <- forestArea / zeroForestArea - acDistribution[magclass::where((setYears(zeroForestArea, "y2000")) == 0)$true$regions, , ] <- 0 - - out <- acDistribution + getNames(out) <- gsub(pattern = "X", + replacement = "class", + x = getNames(out)) if (cells == "magpiecell") { out <- toolCoord2Isocell(out, cells = cells) @@ -51,8 +43,8 @@ calcAgeClassDistribution <- function(cells = "lpjcell") { return(list(x = out, weight = cellArea, - unit = "1", - description = "Fraction of each age class in secondary forest from each spatially - explicit cell as described in Poulter age classes", + unit = "Mha", + description = "Forest area in 15 age classes based the Global Forest Age + Dataset (GFAD) from Poulter et al. 2019", isocountries = FALSE)) } diff --git a/README.md b/README.md index b04b6c9b..b9889199 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.52.3** +R package **mrmagpie**, version **1.52.4** [![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 , R package version 1.52.3, . +Karstens K, Dietrich J, Chen D, Windisch M, Alves M, Beier F, Köberle A, v. Jeetze P, Mishra A, Humpenoeder F, Sauer P (2024). _mrmagpie: madrat based MAgPIE Input Data Library_. doi:10.5281/zenodo.4319612 , R package version 1.52.4, . 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 Alexandre Köberle and Patrick {v. Jeetze} and Abhijeet Mishra and Florian Humpenoeder and Pascal Sauer}, year = {2024}, - note = {R package version 1.52.3}, + note = {R package version 1.52.4}, url = {https://github.com/pik-piam/mrmagpie}, doi = {10.5281/zenodo.4319612}, } diff --git a/man/calcAgeClassDistribution.Rd b/man/calcAgeClassDistribution.Rd index f5baee37..957ff3d6 100644 --- a/man/calcAgeClassDistribution.Rd +++ b/man/calcAgeClassDistribution.Rd @@ -13,8 +13,8 @@ calcAgeClassDistribution(cells = "lpjcell") magpie object in cluster resolution } \description{ -This function calculates the share of each age class in secondary forests in each - MAgPIE simulation cluster based on Global Forest Age Dataset from Poulter et al. 2019 +This function calculates forest area in 15 age classes based on the +Global Forest Age Dataset (GFAD) from Poulter et al. 2019 } \examples{ \dontrun{ @@ -23,5 +23,5 @@ calcOutput("AgeClassDistribution", aggregate = FALSE) } \author{ -Abhijeet Mishra, Felicitas Beier +Abhijeet Mishra, Felicitas Beier, Florian Humpenoeder }