From 1f7e028843958bedfc400338d033fa79bd74c54d Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Tue, 16 Jan 2024 15:20:56 +0100 Subject: [PATCH] add new SOC function to fullCELLULAR, fix raster import to new roxygen version --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 6 +++--- R/calcCollectEnvironmentData_new.R | 4 ++-- R/calcCollectSoilCarbonLSU.R | 2 +- R/calcCollectSoilCarbonPastr.R | 2 +- R/calcScaleEnvironmentData_new.R | 2 +- R/calcScaledPastSoilCarbon.R | 2 +- R/calcSoilCharacteristics.R | 2 +- R/fullCELLULARMAGPIE.R | 16 ++++++++++++++++ README.md | 6 +++--- 11 files changed, 32 insertions(+), 16 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 00f3d3a3..1ad64265 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '27545872' +ValidationKey: '27633200' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/CITATION.cff b/CITATION.cff index a6576d9e..e7b36e48 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.39.6 -date-released: '2024-01-10' +version: 1.40.0 +date-released: '2024-01-16' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: - family-names: Karstens diff --git a/DESCRIPTION b/DESCRIPTION index be2b59a3..eaa022c8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.39.6 -Date: 2024-01-10 +Version: 1.40.0 +Date: 2024-01-16 Authors@R: c( person("Kristine", "Karstens", , "karstens@pik-potsdam.de", role = c("aut", "cre")), person("Jan Philipp", "Dietrich", , "dietrich@pik-potsdam.de", role = "aut"), @@ -58,4 +58,4 @@ VignetteBuilder: knitr Encoding: UTF-8 LazyData: no -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.0 diff --git a/R/calcCollectEnvironmentData_new.R b/R/calcCollectEnvironmentData_new.R index 6aeca997..7daebda2 100644 --- a/R/calcCollectEnvironmentData_new.R +++ b/R/calcCollectEnvironmentData_new.R @@ -17,7 +17,7 @@ #' @import mstools #' @importFrom raster rasterFromXYZ #' @importFrom raster area -#' @importFrom raster "crs<-" +#' @importFrom raster crs<- #' @importFrom magpiesets findset #' @@ -63,7 +63,7 @@ calcCollectEnvironmentData_new <- function(subtype = "ISIMIP3b:IPSL-CM6A-LR:ssp1 subtype = paste(x$version, x$scenario, sep = ":"), co2Evolution = "rising")[, (syear - sar / 2):fyear, ] co2 <- toolHoldConstant(co2, seq((max(getYears(co2, as.integer = TRUE)) + 1), 2150, 5)) - soil <- calcOutput("SoilCharacteristics", aggregate = FALSE)[, getYears(co2), ] ### To Do (Alex K., Marcos, Kristine, Feli): adjust to 67k + soil <- calcOutput("SoilCharacteristics", aggregate = FALSE)[, getYears(co2), ] ### To Do (Alex K., Marcos, Kristine, Feli): adjust to 67k constants <- mbind(co2, soil) constants <- constants[, getYears(variables), ] diff --git a/R/calcCollectSoilCarbonLSU.R b/R/calcCollectSoilCarbonLSU.R index 6d2fc5a3..a0b333be 100644 --- a/R/calcCollectSoilCarbonLSU.R +++ b/R/calcCollectSoilCarbonLSU.R @@ -17,7 +17,7 @@ #' @import magclass #' @importFrom raster rasterFromXYZ #' @importFrom raster area -#' @importFrom raster "crs<-" +#' @importFrom raster crs<- #' @importFrom tidyr pivot_longer #' @importFrom dplyr mutate select #' diff --git a/R/calcCollectSoilCarbonPastr.R b/R/calcCollectSoilCarbonPastr.R index f81f9afb..5e9ba8e8 100644 --- a/R/calcCollectSoilCarbonPastr.R +++ b/R/calcCollectSoilCarbonPastr.R @@ -17,7 +17,7 @@ #' @import magclass #' @importFrom raster rasterFromXYZ #' @importFrom raster area -#' @importFrom raster "crs<-" +#' @importFrom raster crs<- #' @importFrom tidyr pivot_longer #' @importFrom dplyr mutate select #' diff --git a/R/calcScaleEnvironmentData_new.R b/R/calcScaleEnvironmentData_new.R index ca7dddd4..ecbbc2cf 100644 --- a/R/calcScaleEnvironmentData_new.R +++ b/R/calcScaleEnvironmentData_new.R @@ -17,7 +17,7 @@ #' @import mstools #' @importFrom raster rasterFromXYZ #' @importFrom raster area -#' @importFrom raster "crs<-" +#' @importFrom raster crs<- #' @importFrom magpiesets findset #' @importFrom stats sd #' diff --git a/R/calcScaledPastSoilCarbon.R b/R/calcScaledPastSoilCarbon.R index ca24bfb8..aa3a522b 100644 --- a/R/calcScaledPastSoilCarbon.R +++ b/R/calcScaledPastSoilCarbon.R @@ -18,7 +18,7 @@ #' @import magclass #' @importFrom raster rasterFromXYZ #' @importFrom raster area -#' @importFrom raster "crs<-" +#' @importFrom raster crs<- #' @importFrom tidyr pivot_longer #' @importFrom dplyr mutate select #' diff --git a/R/calcSoilCharacteristics.R b/R/calcSoilCharacteristics.R index 4cf48ab0..fb4ece53 100644 --- a/R/calcSoilCharacteristics.R +++ b/R/calcSoilCharacteristics.R @@ -13,7 +13,7 @@ #' @importFrom raster rasterFromXYZ #' @importFrom raster area #' @importFrom dplyr left_join -#' @importFrom raster "crs<-" +#' @importFrom raster crs<- #' calcSoilCharacteristics <- function() { diff --git a/R/fullCELLULARMAGPIE.R b/R/fullCELLULARMAGPIE.R index 90066f9d..1e4e2a8e 100755 --- a/R/fullCELLULARMAGPIE.R +++ b/R/fullCELLULARMAGPIE.R @@ -422,6 +422,22 @@ fullCELLULARMAGPIE <- function(rev = 0.1, dev = "", calcOutput("SOCLossShare", aggregate = "cluster", rate = "loss", round = 6, cells = cells, file = paste0("cshare_released_", ctype, ".mz")) + if (dev == "+newSOC") { + + calcOutput("CarbonInputMultiplier", aggregate = "region", + round = 6, file = "f59_cinput_multiplier.cs3") + calcOutput("CarbonLitter", aggregate = "region", years = lpjYears, + lpjmlNatveg = lpjml[["natveg"]], climatetype = climatetype, + mode = "magpieInput", fixFpc = TRUE, + round = 6, file = "f59_litter_recycling.cs3") + calcOutput("DecayFuture", aggregate = "region", years = lpjYears, + lpjmlNatveg = lpjml[["natveg"]], climatetype = climatetype, + round = 6, file = "f59_topsoilc_decay.cs3") + calcOutput("SoilCarbon", aggregate = "region", years = "y1995", + lpjmlNatveg = lpjml[["natveg"]], climatetype = climatetype, + round = 6, file = "f59_topsoilc_actualstate.cs3") + } + ##### AGGREGATION ###### # create info file diff --git a/README.md b/README.md index 3f29947c..c0141b7d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.39.6** +R package **mrmagpie**, version **1.40.0** [![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, 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.40.0, . 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.39.6}, + note = {R package version 1.40.0}, doi = {10.5281/zenodo.4319612}, url = {https://github.com/pik-piam/mrmagpie}, }