From b97411102894e6d849838044bb9f8d3bc523bb34 Mon Sep 17 00:00:00 2001 From: mppalves Date: Tue, 5 Sep 2023 19:45:03 +0200 Subject: [PATCH 01/23] test --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- R/fullCELLULARMAGPIE.R | 4 ++-- README.md | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 9a9b8107..772f5bce 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '27036960' +ValidationKey: '270725464605' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 5cf4ad32..470bd522 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.0 -date-released: '2023-08-23' +version: 1.38.0.9001 +date-released: '2023-09-05' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: - family-names: Karstens diff --git a/DESCRIPTION b/DESCRIPTION index 34e2f011..8dd9a03c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.38.0 -Date: 2023-08-23 +Version: 1.38.0.9001 +Date: 2023-09-05 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/fullCELLULARMAGPIE.R b/R/fullCELLULARMAGPIE.R index 15c44295..a3576ce1 100644 --- a/R/fullCELLULARMAGPIE.R +++ b/R/fullCELLULARMAGPIE.R @@ -179,8 +179,8 @@ fullCELLULARMAGPIE <- function(rev = 0.1, dev = "", aggregate = "cluster", round = 6, file = paste0("consv_prio_areas_", ctype, ".mz")) } - calcOutput("ProtectArea", bhifl = ifelse(rev > 4.66, TRUE, FALSE), aggregate = "cluster", round = 6, - file = paste0("protect_area_", ctype, ".mz")) +# calcOutput("ProtectArea", bhifl = ifelse(rev > 4.66, TRUE, FALSE), aggregate = "cluster", round = 6, +# file = paste0("protect_area_", ctype, ".mz")) # 30 crop calcOutput("Croparea", sectoral = "kcr", physical = TRUE, cellular = TRUE, irrigation = FALSE, diff --git a/README.md b/README.md index 581ae19d..e169eaa1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.38.0** +R package **mrmagpie**, version **1.38.0.9001** [![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.0.9001, . 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.0}, + note = {R package version 1.38.0.9001}, doi = {10.5281/zenodo.4319612}, url = {https://github.com/pik-piam/mrmagpie}, } From d31d60b4ceb996205ea1526314e7fb03b8eccfc0 Mon Sep 17 00:00:00 2001 From: mppalves Date: Mon, 4 Dec 2023 21:26:30 +0100 Subject: [PATCH 02/23] new past calc suit --- R/calcPastureSuit.R | 125 +++++++++++++++++++++++--------------------- 1 file changed, 64 insertions(+), 61 deletions(-) diff --git a/R/calcPastureSuit.R b/R/calcPastureSuit.R index 29f45294..f29ebd9c 100644 --- a/R/calcPastureSuit.R +++ b/R/calcPastureSuit.R @@ -15,10 +15,10 @@ #' } #' @importFrom raster area rasterFromXYZ -calcPastureSuit <- function(climatetype = "MRI-ESM2-0:ssp126", - lpjml = "LPJmL4_for_MAgPIE_44ac93de", - cells = "lpjcell") { +calcPastureSuit <- function(climatetype = "MRI-ESM2-0:ssp126", + lpjml = "LPJmL4_for_MAgPIE_44ac93de", + cells = "lpjcell") { x <- toolSplitSubtype(climatetype, list(climatemodel = NULL, scenario = NULL)) # Extract stage argument information @@ -29,30 +29,53 @@ calcPastureSuit <- function(climatetype = "MRI-ESM2-0:ssp126", } # Drivers of managed pastures - population <- calcOutput("GridPop", subtype = "all", cellular = TRUE, FiveYear = TRUE, harmonize_until = 2015, - aggregate = FALSE)[, , toupper(substring(x$scenario, first = 0, last = 4))] + population <- calcOutput("GridPop", + subtype = "all", cellular = TRUE, FiveYear = TRUE, harmonize_until = 2015, + aggregate = FALSE + )[, , toupper(substring(x$scenario, first = 0, last = 4))] + + cellPrep <- calcOutput("LPJmLClimateInput", + climatetype = climatetype, + variable = "precipitation:monthlySum", + stage = stage, + lpjmlVersion = lpjml, + aggregate = FALSE + ) + + + cellPet <- calcOutput( + type = "LPJmL_new", climatetype = climatetype, + subtype = "mpet", + stage = stage, + version = lpjml, + aggregate = FALSE + ) + + + yearsCellPet <- intersect(getYears(cellPet), findset("time")) + yearsCellPrep <- intersect(findset("time"), getYears(cellPrep)) + years <- intersect(yearsCellPet, yearsCellPrep) + cellPrep <- dimSums(cellPrep[, years, ], dim = 3) + cellPet <- dimSums(cellPet[, years, ], dim = 3) - cellPrep <- calcOutput("LPJmLClimateInput", climatetype = climatetype, - variable = "precipitation:monthlySum", - stage = stage, - lpjmlVersion = lpjml, - aggregate = FALSE) + # Cell area calculation + landcoords <- cellPet[, 1, 1] + landcoords[] <- 1 + landcoords <- as.RasterBrick(landcoords) - cellPet <- calcOutput(type = "LPJmL_new", climatetype = climatetype, - subtype = "mpet", - stage = stage, - version = lpjml, - aggregate = FALSE) + cellSize <- raster::area(landcoords) + cellSize <- cellSize * landcoords + cellSize <- as.magpie(cellSize) + landArea <- cellSize - yearsCellPet <- intersect(getYears(cellPet), findset("time")) - yearsCellPrep <- intersect(findset("time"), getYears(cellPrep)) - years <- intersect(yearsCellPet, yearsCellPrep) - cellPrep <- dimSums(cellPrep[, years, ], dim = 3) - cellPet <- dimSums(cellPet[, years, ], dim = 3) + cellorder <- population + dimnames(cellorder)$x.y.iso <- gsub("\\.\\w+$", "", dimnames(cellorder)$x.y.iso) + cellorder <- match(dimnames(cellorder)$x.y.iso, dimnames(landArea)$x.y) - # Cell area calculation - landArea <- calcOutput("LandArea", aggregate = FALSE) / 100 # transformed to km^2 + # Reorder the dimensions of landArea to match Population + landArea <- landArea[cellorder, , ] + getCells(landArea) <- getCells(population) # population density popDensity <- (population * 1e6) / landArea # population density in number of people per km2 @@ -70,48 +93,28 @@ calcPastureSuit <- function(climatetype = "MRI-ESM2-0:ssp126", # pasture suitability check pastureSuit <- aridity popDensity <- popDensity[, getYears(pastureSuit), ] + + cellorder <- match(dimnames(pastureSuit)$x.y.iso, dimnames(popDensity)$x.y.iso) + popDensity <- popDensity[cellorder] pastureSuit[popDensity < 5] <- 0 # 5 hab km2 population threshold for managed pastures. Same from HYDE 3.2. pastureSuitArea <- (pastureSuit * landArea * 100) / 1e6 # (from km2 (x100) to mha (/1e6)) - pastureSuitArea <- collapseDim(pastureSuitArea) - pastureSuitArea <- toolHoldConstantBeyondEnd(pastureSuitArea) - # calibration to historical values - histPastr <- setNames(calcOutput("LanduseInitialisation", cellular = TRUE, - nclasses = "nine", aggregate = FALSE)[, , c("past")], "pastr") - pastAll <- intersect(getYears(histPastr), getYears(pastureSuitArea)) - - pastLy <- findset("past") - pastLy <- pastLy[length(pastLy)] # past last year - future <- setdiff(getYears(pastureSuitArea), pastAll) - - pastureSuitAreaReg <- dimSums(pastureSuitArea, dim = c("x", "y")) - histPastrReg <- dimSums(histPastr, dim = c("x", "y")) - calibReg <- histPastrReg[, pastLy, ] / pastureSuitAreaReg[, pastLy, ] - calibReg[is.infinite(calibReg)] <- 1 - calibReg[is.nan(calibReg)] <- 0 - pastureSuitArea[, future, ] <- calibReg * pastureSuitArea[, future, ] - - pastureSuitArea[is.infinite(pastureSuitArea) | is.nan(pastureSuitArea) | is.na(pastureSuitArea)] <- 0 - pastureSuitArea[pastureSuitArea < 0] <- 0 - pastureSuitArea[, pastAll, ] <- histPastr[, pastAll, ] - - y <- intersect(pastAll, getYears(pastureSuitArea)) - pastureSuitArea[, y, ] <- histPastr[, intersect(pastAll, getYears(pastureSuitArea)), ] - pastureSuitArea <- toolHoldConstant(pastureSuitArea, findset("time")) - pastureSuitArea <- collapseNames(pastureSuitArea) - pastureSuitArea[, pastAll, ] <- histPastr[, pastAll, ] - #maybe change to: pastureSuitArea[, pastAll, ] <- max(histPastr[, pastAll, ], pastureSuitArea[, pastAll, ]) #nolint - pastureSuitArea <- setNames(pastureSuitArea, "yields") - - # Reduce number of grid cells to 59199 - if (cells == "magpiecell") { - pastureSuitArea <- toolCoord2Isocell(pastureSuitArea, cells = cells) - } + # New part: Calculating changing year after year + + #pastureSuitAreaChanges <- pastureSuitArea + #for (i in 1:(length(getYears(pastureSuitArea)) - 1)) { + # pastureSuitAreaChanges[, i + 1, ] <- (pastureSuitArea[, i + 1, ] - pastureSuitArea[, i, ]) + #} + + #pastureSuitAreaChanges[, 1, ] <- 0 + pastureSuitArea <- toolHoldConstantBeyondEnd(pastureSuitArea) - return(list(x = pastureSuitArea, - weight = NULL, - unit = "Mha", - description = "Area suitable for pasture management in mha", - isocountries = FALSE)) + return(list( + x = pastureSuitArea, + weight = NULL, + unit = "Mha", + description = "Area suitable for pasture management in mha", + isocountries = FALSE + )) } From 499423d8edfc9df4b180c70a5923702d43666362 Mon Sep 17 00:00:00 2001 From: mppalves Date: Thu, 21 Dec 2023 18:16:21 +0100 Subject: [PATCH 03/23] new pastr suit calc --- .buildlibrary | 2 +- CITATION.cff | 5 +++-- DESCRIPTION | 4 ++-- R/calcPastureSuit.R | 9 +-------- README.md | 6 +++--- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 9f783341..86f9a3ec 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '27487080' +ValidationKey: '27512368' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 41b03d2f..6611e3cb 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.5 -date-released: '2023-12-13' +version: 1.39.6 +date-released: '2023-12-17' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: - family-names: Karstens @@ -18,6 +18,7 @@ authors: given-names: Michael - family-names: Alves given-names: Marcos + email: pedrosa@pik-potsdam.de - family-names: Beier given-names: Felicitas email: beier@pik-potsdam.de diff --git a/DESCRIPTION b/DESCRIPTION index 1e75b54e..be75c4ab 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.39.5 -Date: 2023-12-13 +Version: 1.39.6 +Date: 2023-12-17 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/calcPastureSuit.R b/R/calcPastureSuit.R index 4ca2bf72..44a2dc28 100644 --- a/R/calcPastureSuit.R +++ b/R/calcPastureSuit.R @@ -100,15 +100,8 @@ calcPastureSuit <- function(climatetype = "MRI-ESM2-0:ssp126", pastureSuitArea <- (pastureSuit * landArea * 100) / 1e6 # (from km2 (x100) to mha (/1e6)) - # New part: Calculating changing year after year - - #pastureSuitAreaChanges <- pastureSuitArea - #for (i in 1:(length(getYears(pastureSuitArea)) - 1)) { - # pastureSuitAreaChanges[, i + 1, ] <- (pastureSuitArea[, i + 1, ] - pastureSuitArea[, i, ]) - #} - - #pastureSuitAreaChanges[, 1, ] <- 0 pastureSuitArea <- toolHoldConstantBeyondEnd(pastureSuitArea) + getItems(pastureSuitArea, dim = 3) <- NULL return(list( x = pastureSuitArea, diff --git a/README.md b/README.md index ec0ee632..6b59c55b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.39.5** +R package **mrmagpie**, version **1.39.6** [![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 (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.39.6, . 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 = {2023}, - note = {R package version 1.39.5}, + note = {R package version 1.39.6}, doi = {10.5281/zenodo.4319612}, url = {https://github.com/pik-piam/mrmagpie}, } From e42b59d0c040d106e81f2ba2f47b933ff4f7ccfb Mon Sep 17 00:00:00 2001 From: mppalves Date: Sat, 13 Apr 2024 21:30:17 +0200 Subject: [PATCH 04/23] updating calc past --- R/calcPastureSuit.R | 24 ++++--- R/calcPastureSuitOld.R | 130 ++++++++++++++++++++++++++++++++++++++ man/calcPastureSuitOld.Rd | 31 +++++++++ 3 files changed, 175 insertions(+), 10 deletions(-) create mode 100644 R/calcPastureSuitOld.R create mode 100644 man/calcPastureSuitOld.Rd diff --git a/R/calcPastureSuit.R b/R/calcPastureSuit.R index 44a2dc28..b12de3d5 100644 --- a/R/calcPastureSuit.R +++ b/R/calcPastureSuit.R @@ -59,26 +59,30 @@ calcPastureSuit <- function(climatetype = "MRI-ESM2-0:ssp126", cellPet <- dimSums(cellPet[, years, ], dim = 3) # Cell area calculation + land <- calcOutput("LanduseInitialisation", input_magpie = TRUE, + aggregate = FALSE, cellular = TRUE, cells = cells, + years = "y1995", round = 6) + landArea <- setYears(dimSums(land, dim = 3), NULL) - landcoords <- cellPet[, 1, 1] - landcoords[] <- 1 - landcoords <- as.RasterBrick(landcoords) +# landcoords <- cellPet[, 1, 1] +# landcoords[] <- 1 +# landcoords <- as.RasterBrick(landcoords) - cellSize <- raster::area(landcoords) - cellSize <- cellSize * landcoords - cellSize <- as.magpie(cellSize) - landArea <- cellSize +# cellSize <- raster::area(landcoords) +# cellSize <- cellSize * landcoords +# cellSize <- as.magpie(cellSize) +# landArea <- cellSize cellorder <- population - dimnames(cellorder)$x.y.iso <- gsub("\\.\\w+$", "", dimnames(cellorder)$x.y.iso) - cellorder <- match(dimnames(cellorder)$x.y.iso, dimnames(landArea)$x.y) + # dimnames(cellorder)$x.y.iso <- gsub("\\.\\w+$", "", dimnames(cellorder)$x.y.iso) + cellorder <- match(dimnames(cellorder)$x.y.iso, dimnames(landArea)$x.y.iso) # Reorder the dimensions of landArea to match Population landArea <- landArea[cellorder, , ] getCells(landArea) <- getCells(population) # population density - popDensity <- (population * 1e6) / landArea # population density in number of people per km2 + popDensity <- (population *1e6) / landArea * 10000 # population density in number of people per km2 popDensity[is.infinite(popDensity)] <- 0 popDensity[is.nan(popDensity)] <- 0 diff --git a/R/calcPastureSuitOld.R b/R/calcPastureSuitOld.R new file mode 100644 index 00000000..56d1145c --- /dev/null +++ b/R/calcPastureSuitOld.R @@ -0,0 +1,130 @@ +#' @title calcPastureSuit +#' @description Calculate glassland suitable for pasture management based +#' on population and aridity criteria. +#' +#' @param lpjml Defines LPJmL version for crop/grass and natveg specific inputs +#' @param climatetype Switch between different climate scenarios +#' +#' @return List of magpie object with results on cluster level +#' @author Marcos Alves +#' @examples +#' \dontrun{ +#' calcOutput("PastureSuitOld") +#' } +#' @importFrom raster area rasterFromXYZ + +calcPastureSuitOld <- function(climatetype = "MRI-ESM2-0:ssp126", lpjml = "LPJmL4_for_MAgPIE_44ac93de") { + + x <- toolSplitSubtype(climatetype, list(climatemodel = NULL, scenario = NULL)) + + # Extract stage argument information + if (grepl("GSWP3-W5E5", climatetype)) { + stage <- "smoothed" + } else { + stage <- "harmonized2020" + } + + # Drivers of managed pastures + population <- calcOutput("GridPop", subtype = "all", cellular = TRUE, FiveYear = TRUE, + harmonize_until = 2015, + aggregate = FALSE)[, , toupper(substring(x$scenario, first = 0, last = 4))] + + cellPrep <- calcOutput("LPJmLClimateInput", climatetype = climatetype, + variable = "precipitation:monthlySum", + stage = stage, + lpjmlVersion = lpjml, + aggregate = FALSE) + + + cellPet <- calcOutput(type = "LPJmL_new", climatetype = climatetype, + subtype = "mpet", + stage = stage, + version = lpjml, + aggregate = FALSE) + + cellPrep <- mrwater::toolLPJcell2MAgPIEcell(cellPrep) + cellPet <- mrwater::toolLPJcell2MAgPIEcell(cellPet) + + yearsCellPet <- intersect(getYears(cellPet), findset("time")) + yearsCellPrep <- intersect(findset("time"), getYears(cellPrep)) + years <- intersect(yearsCellPet, yearsCellPrep) + cellPrep <- dimSums(cellPrep[, years, ], dim = 3) + cellPet <- dimSums(cellPet[, years, ], dim = 3) + + # Cell area calculation + + land <- calcOutput("LanduseInitialisation", input_magpie = TRUE, + aggregate = FALSE, cellular = TRUE, cells = cells, + years = "y1995", round = 6) + landArea <- setYears(dimSums(land, dim = 3), NULL) + + #after merging to + #landArea <- calcOutput("LandArea", aggregate = FALSE) / 100 # transformed to km^2 #nolint + + # population density + population <- population[getCells(cellPet), , ] # fixing the order of the population cells (should not be necessary!) + popDensity <- (population * 1e6) / landArea # population density in number of people per km2 + popDensity[is.infinite(popDensity)] <- 0 + popDensity[is.nan(popDensity)] <- 0 + + years <- intersect(getYears(popDensity), getYears(cellPrep)) + + aridity <- cellPrep[, years, ] / cellPet[, years, ] + aridity[is.infinite(aridity) | is.nan(aridity)] <- 0 + # 0.5 aridity threshold for managed pastures. Same from HYDE 3.2. + aridity[aridity < 0.5] <- 0 + aridity[aridity >= 0.5] <- 1 + + # pasture suitability check + pastureSuit <- aridity + popDensity <- popDensity[, getYears(pastureSuit), ] + pastureSuit[popDensity < 5] <- 0 # 5 hab km2 population threshold for managed pastures. Same from HYDE 3.2. + + ### UNCLEAR IF THIS MAKES SENSE AS IS (with new landArea variable which is in mha) + pastureSuitArea <- (pastureSuit * landArea * 100) / 1e6 # (from km2 (x100) to mha (/1e6)) + pastureSuitArea <- collapseDim(pastureSuitArea) + pastureSuitArea <- toolHoldConstantBeyondEnd(pastureSuitArea) + + # calibration to historical values + + histPastr <- setNames(calcOutput("LanduseInitialisation", cellular = TRUE, + nclasses = "nine", aggregate = FALSE)[, , c("past")], "pastr") + pastAll <- intersect(getYears(histPastr), getYears(pastureSuitArea)) + + pastLy <- findset("past") + pastLy <- pastLy[length(pastLy)] # past last year + future <- setdiff(getYears(pastureSuitArea), pastAll) + + map <- toolGetMapping("CountryToCellMapping.csv", type = "cell") + pastureSuitAreaReg <- toolAggregate(pastureSuitArea, rel = map, from = "celliso", to = "iso") + histPastrReg <- toolAggregate(histPastr, rel = map, from = "celliso", to = "iso") + calibReg <- histPastrReg[, pastLy, ] / pastureSuitAreaReg[, pastLy, ] + calibReg[is.infinite(calibReg)] <- 1 + calibReg[is.nan(calibReg)] <- 0 + pastureSuitArea[, future, ] <- toolAggregate(calibReg, rel = map, + from = "iso", to = "celliso") * pastureSuitArea[, future, ] + + pastureSuitArea[is.infinite(pastureSuitArea) | is.nan(pastureSuitArea) | is.na(pastureSuitArea)] <- 0 + pastureSuitArea[pastureSuitArea < 0] <- 0 + pastureSuitArea[, pastAll, ] <- histPastr[, pastAll, ] + + y <- intersect(pastAll, getYears(pastureSuitArea)) + pastureSuitArea[, y, ] <- histPastr[, intersect(pastAll, getYears(pastureSuitArea)), ] + pastureSuitArea <- toolHoldConstant(pastureSuitArea, findset("time")) + pastureSuitArea <- collapseNames(pastureSuitArea) + pastureSuitArea[, pastAll, ] <- histPastr[, pastAll, ] + #maybe change to: pastureSuitArea[, pastAll, ] <- max(histPastr[, pastAll, ], pastureSuitArea[, pastAll, ]) #nolint + pastureSuitArea <- setNames(pastureSuitArea, "yields") + + return(list(x = pastureSuitArea, + weight = NULL, + unit = "Mha", + description = "Area suitable for pasture management in mha", + isocountries = FALSE)) +} + +cellPrep +cellPet + +cellPrep["BRA",,] |> dimSums(dim = 1) |> plot() +population["BRA",,] |> dimSums(dim = 1) diff --git a/man/calcPastureSuitOld.Rd b/man/calcPastureSuitOld.Rd new file mode 100644 index 00000000..1aaf04b9 --- /dev/null +++ b/man/calcPastureSuitOld.Rd @@ -0,0 +1,31 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/calcPastureSuitOld.R +\name{calcPastureSuitOld} +\alias{calcPastureSuitOld} +\title{calcPastureSuit} +\usage{ +calcPastureSuitOld( + climatetype = "MRI-ESM2-0:ssp126", + lpjml = "LPJmL4_for_MAgPIE_44ac93de" +) +} +\arguments{ +\item{climatetype}{Switch between different climate scenarios} + +\item{lpjml}{Defines LPJmL version for crop/grass and natveg specific inputs} +} +\value{ +List of magpie object with results on cluster level +} +\description{ +Calculate glassland suitable for pasture management based +on population and aridity criteria. +} +\examples{ +\dontrun{ +calcOutput("PastureSuitOld") +} +} +\author{ +Marcos Alves +} From dbcf754eb54df063277a55ebb257b8301d0c4633 Mon Sep 17 00:00:00 2001 From: mppalves Date: Sun, 14 Apr 2024 00:43:36 +0200 Subject: [PATCH 05/23] build library and incresing version --- .buildlibrary | 2 +- CITATION.cff | 5 ++--- DESCRIPTION | 4 ++-- R/calcPastureSuit.R | 8 -------- README.md | 6 +++--- 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index c9d34d02..8bec7133 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '285734130' +ValidationKey: '28749150' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/CITATION.cff b/CITATION.cff index ff371e8e..0b18b5fe 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.44.15 -date-released: '2024-04-09' +version: 1.45.0 +date-released: '2024-04-14' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: - family-names: Karstens @@ -18,7 +18,6 @@ authors: given-names: Michael - family-names: Alves given-names: Marcos - email: pedrosa@pik-potsdam.de - family-names: Beier given-names: Felicitas email: beier@pik-potsdam.de diff --git a/DESCRIPTION b/DESCRIPTION index 412487e8..fb3aec92 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.44.15 -Date: 2024-04-09 +Version: 1.45.0 +Date: 2024-04-14 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/calcPastureSuit.R b/R/calcPastureSuit.R index d3e628ea..a5cbc47e 100644 --- a/R/calcPastureSuit.R +++ b/R/calcPastureSuit.R @@ -106,11 +106,3 @@ calcPastureSuit <- function(climatetype = "MRI-ESM2-0:ssp126", isocountries = FALSE )) } -library(lucode2) -buildLibrary( - lib = "/p/projects/landuse/users/pedrosa/piam/mrmagpie", - cran = F, - updateType = NULL, - updateLucode2 = TRUE, - autoCheckRepoUpToDate = TRUE -) \ No newline at end of file diff --git a/README.md b/README.md index 02ea97e2..5ac7c673 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.44.15** +R package **mrmagpie**, version **1.45.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 , R package version 1.44.15, . +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 (URL: https://doi.org/10.5281/zenodo.4319612), R package version 1.45.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.44.15}, + note = {R package version 1.45.0}, doi = {10.5281/zenodo.4319612}, url = {https://github.com/pik-piam/mrmagpie}, } From 8c5842c8899045beff737e789e43a85b12a91892 Mon Sep 17 00:00:00 2001 From: Jan Philipp Dietrich Date: Thu, 25 Apr 2024 12:05:11 +0200 Subject: [PATCH 06/23] adjust package to mrcommons split --- DESCRIPTION | 6 +-- NAMESPACE | 14 +++---- R/calcAfforestationMask.R | 14 +++---- R/calcAgeClassDistribution.R | 4 +- R/calcAreaEquippedForIrrigation.R | 1 + R/calcAvlLandSi.R | 6 +-- R/calcDegradationYieldReduction.R | 4 +- R/calcEFRRockstroem.R | 3 +- R/calcEFRSmakthin.R | 3 +- R/calcEnvmtlFlow.R | 3 +- R/calcGrasslandBiomass.R | 28 ++++++------- R/calcIrrigation.R | 13 ++++--- R/calcLabourProdImpact.R | 43 ++++++++++---------- R/calcLabourProdImpactEmu.R | 7 ++-- R/calcPeatland.R | 65 ++++++++++++++++--------------- R/calcPeatland2.R | 17 ++++---- R/calcPotentialForestArea.R | 2 +- R/calcSoilCharacteristics.R | 2 +- R/calcTopsoilCarbon.R | 2 +- R/correctAvlLandSi.R | 9 ++--- R/correctBendingTheCurve.R | 9 ++--- R/correctGFAD.R | 2 +- R/correctSoilClassification.R | 9 ++--- R/correctTransportDistance.R | 9 ++--- R/readGFAD.R | 3 +- R/readGPM2.R | 2 +- R/readGridPopIsimip.R | 2 +- R/readLabourProdImpactEmu.R | 38 +++++++++--------- R/readLeifeld2018.R | 2 +- R/readMAPSPAM.R | 2 +- R/readMehta2022.R | 2 +- 31 files changed, 160 insertions(+), 166 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9b583bcf..8056abb5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -25,10 +25,10 @@ BugReports: https://github.com/pik-piam/mrmagpie/issues Depends: madrat (>= 2.8.0), magclass (>= 3.17), - mrcommons (>= 1.37.0), + mrcommons (>= 1.40.7), mrland (>= 0.51.0), mrsoil (>= 2.0.0), - mrwater (>= 1.11.0), + mrwater (>= 1.12.0), R (>= 3.5.0) Imports: abind, @@ -40,7 +40,7 @@ Imports: luplot (>= 3.56.0), luscale, magpiesets, - mstools, + mstools (>= 0.5.1), ncdf4, pbapply, raster, diff --git a/NAMESPACE b/NAMESPACE index 82a30e14..484128c8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -72,15 +72,15 @@ importFrom(magclass,where) importFrom(magclass,wrap) importFrom(magpiesets,addLocation) importFrom(magpiesets,findset) -importFrom(mrcommons,toolCell2isoCell) -importFrom(mrcommons,toolCoord2Isocell) -importFrom(mrcommons,toolCoord2Isocoord) -importFrom(mrcommons,toolGetMappingCoord2Country) -importFrom(mrcommons,toolHarmonize2Baseline) -importFrom(mrcommons,toolIso2CellCountries) -importFrom(mrcommons,toolLPJmLVersion) importFrom(mrland,spatial_header) +importFrom(mrlandcore,toolLPJmLVersion) +importFrom(mstools,toolCell2isoCell) +importFrom(mstools,toolCoord2Isocell) +importFrom(mstools,toolCoord2Isocoord) +importFrom(mstools,toolGetMappingCoord2Country) +importFrom(mstools,toolHarmonize2Baseline) importFrom(mstools,toolHoldConstant) +importFrom(mstools,toolIso2CellCountries) importFrom(ncdf4,nc_open) importFrom(ncdf4,ncvar_get) importFrom(pbapply,pbapply) diff --git a/R/calcAfforestationMask.R b/R/calcAfforestationMask.R index 4eced82f..1904654f 100644 --- a/R/calcAfforestationMask.R +++ b/R/calcAfforestationMask.R @@ -16,26 +16,26 @@ calcAfforestationMask <- function(subtype, cells = "lpjcell") { if (subtype == "unrestricted") { r <- terra::rast(res = 0.5, vals = 1) - } else if (subtype == "noboreal") { #Exclude boreal regions > 50deg N + } else if (subtype == "noboreal") { # Exclude boreal regions > 50deg N r <- terra::rast(res = 0.5, vals = 1) lat <- terra::init(r, "y") |> terra::mask(r) - r <- terra::mask(r, lat>50, maskvalue=TRUE, updatevalue=0) - } else if (subtype == "onlytropical") { #only tropical areas between 20deg S and 20deg N + r <- terra::mask(r, lat > 50, maskvalue = TRUE, updatevalue = 0) + } else if (subtype == "onlytropical") { # only tropical areas between 20deg S and 20deg N r <- terra::rast(res = 0.5, vals = 1) lat <- terra::init(r, "y") |> terra::mask(r) - r <- terra::mask(r, lat > 20, maskvalue=TRUE, updatevalue=0) - r <- terra::mask(r, lat < -20, maskvalue=TRUE, updatevalue=0) + r <- terra::mask(r, lat > 20, maskvalue = TRUE, updatevalue = 0) + r <- terra::mask(r, lat < -20, maskvalue = TRUE, updatevalue = 0) } # get spatial mapping - map <- mrcommons::toolGetMappingCoord2Country(pretty = TRUE) + map <- mstools::toolGetMappingCoord2Country(pretty = TRUE) # transform raster to magpie object x <- as.magpie(terra::extract(r, map[c("lon", "lat")])[, -1], spatial = 1) dimnames(x) <- list("x.y.iso" = paste(map$coords, map$iso, sep = "."), "t" = NULL, "d3" = NULL) if (cells == "magpiecell") { - x <- mrcommons::toolCoord2Isocell(x, cells = cells) + x <- mstools::toolCoord2Isocell(x, cells = cells) } weight <- calcOutput("LandArea", aggregate = FALSE, cells = cells) diff --git a/R/calcAgeClassDistribution.R b/R/calcAgeClassDistribution.R index 49ac0259..fe1c6991 100644 --- a/R/calcAgeClassDistribution.R +++ b/R/calcAgeClassDistribution.R @@ -12,16 +12,16 @@ #' } #' #' @importFrom magclass where +#' @importFrom mstools toolCoord2Isocell calcAgeClassDistribution <- function(cells = "lpjcell") { - # Cell fraction from poulter data set poulterDataset <- readSource("GFAD", convert = "onlycorrect") # Calculate cellarea mapping <- toolGetMappingCoord2Country() cb <- toolGetMapping("LPJ_CellBelongingsToCountries.csv", - type = "cell", where = "mrcommons") + type = "cell", where = "mrcommons") cellArea <- (111e3 * 0.5) * (111e3 * 0.5) * cos(cb$lat / 180 * pi) cellArea <- as.magpie(cellArea, spatial = 1) getItems(cellArea, dim = 1, raw = TRUE) <- paste(mapping$coords, mapping$iso, sep = ".") diff --git a/R/calcAreaEquippedForIrrigation.R b/R/calcAreaEquippedForIrrigation.R index 9d45bc2e..7d3b9325 100644 --- a/R/calcAreaEquippedForIrrigation.R +++ b/R/calcAreaEquippedForIrrigation.R @@ -22,6 +22,7 @@ #' calcOutput("AreaEquippedForIrrigation", source = "LUH2v2", cellular = TRUE, aggregate = FALSE) #' } #' @importFrom magpiesets findset +#' @importFrom mstools toolCoord2Isocell #' #' @export diff --git a/R/calcAvlLandSi.R b/R/calcAvlLandSi.R index a3961aa6..7242c09a 100644 --- a/R/calcAvlLandSi.R +++ b/R/calcAvlLandSi.R @@ -13,7 +13,7 @@ #' #' @importFrom madrat readSource calcOutput #' @importFrom magclass dimSums getCells getYears getNames mbind collapseDim -#' @importFrom mrcommons toolCoord2Isocell toolGetMappingCoord2Country +#' @importFrom mstools toolCoord2Isocell toolGetMappingCoord2Country #' @importFrom magpiesets addLocation #' @@ -69,7 +69,7 @@ calcAvlLandSi <- function(cells = "lpjcell") { weight = NULL, unit = "Mha", description = paste0("si and nsi0 areas based on Ramankutty", - "suitability information and LUH area", - "information from initialization year"), + "suitability information and LUH area", + "information from initialization year"), isocountries = FALSE)) } diff --git a/R/calcDegradationYieldReduction.R b/R/calcDegradationYieldReduction.R index 76f2e5a9..abb6dbab 100644 --- a/R/calcDegradationYieldReduction.R +++ b/R/calcDegradationYieldReduction.R @@ -15,7 +15,7 @@ calcDegradationYieldReduction <- function(cells = "lpjcell") { # create a dummy data set, which is later used to define yield impacts of land degradation - coordMapping <- mrcommons::toolGetMappingCoord2Country() + coordMapping <- mstools::toolGetMappingCoord2Country() cellnames <- paste(coordMapping$coords, coordMapping$iso, sep = ".") x <- new.magpie(cells_and_regions = cellnames, years = seq(1995, 2150, 5), @@ -24,7 +24,7 @@ calcDegradationYieldReduction <- function(cells = "lpjcell") { fill = 0) if (cells == "magpiecell") { - x <- mrcommons::toolCoord2Isocell(x, cells = cells) + x <- mstools::toolCoord2Isocell(x, cells = cells) } return(list(x = x, diff --git a/R/calcEFRRockstroem.R b/R/calcEFRRockstroem.R index 106c33a8..0ef98164 100644 --- a/R/calcEFRRockstroem.R +++ b/R/calcEFRRockstroem.R @@ -13,7 +13,8 @@ #' @import magclass #' @import madrat #' @importFrom stats quantile -#' @importFrom mrcommons toolHarmonize2Baseline toolLPJmLVersion +#' @importFrom mstools toolHarmonize2Baseline +#' @importFrom mrlandcore toolLPJmLVersion #' #' @return magpie object in cellular resolution #' @author Felicitas Beier, Jens Heinke diff --git a/R/calcEFRSmakthin.R b/R/calcEFRSmakthin.R index b1dd083f..90200e8b 100644 --- a/R/calcEFRSmakthin.R +++ b/R/calcEFRSmakthin.R @@ -22,7 +22,8 @@ #' @import magclass #' @import madrat #' @importFrom stats quantile -#' @importFrom mrcommons toolHarmonize2Baseline toolLPJmLVersion +#' @importFrom mstools toolHarmonize2Baseline +#' @importFrom mrlandcore toolLPJmLVersion #' #' @return magpie object in cellular resolution #' @author Felicitas Beier, Abhijeet Mishra diff --git a/R/calcEnvmtlFlow.R b/R/calcEnvmtlFlow.R index c1677e75..4159eaaa 100644 --- a/R/calcEnvmtlFlow.R +++ b/R/calcEnvmtlFlow.R @@ -11,7 +11,8 @@ #' @import magclass #' @import madrat #' @importFrom stats quantile -#' @importFrom mrcommons toolHarmonize2Baseline toolLPJmLVersion +#' @importFrom mstools toolHarmonize2Baseline +#' @importFrom mrlandcore toolLPJmLVersion #' #' @return magpie object in cellular resolution #' @author Felicitas Beier diff --git a/R/calcGrasslandBiomass.R b/R/calcGrasslandBiomass.R index 10de31af..2dde5757 100644 --- a/R/calcGrasslandBiomass.R +++ b/R/calcGrasslandBiomass.R @@ -1,5 +1,6 @@ #' @title calcGrasslandBiomass -#' @description Calculates pasture biomass demand for the historical period split between rangelands and managed pastures. +#' @description Calculates pasture biomass demand for the historical period split +#' between rangelands andmanaged pastures. #' @param cells "magpiecell" for 59199 cells or "lpjcell" for 67420 cells #' @return Regional biomass demand #' @author Marcos Alves @@ -9,11 +10,10 @@ #' \dontrun{ #' calcOutput("GrasslandBiomass") #' } -#' @importFrom mrcommons toolCoord2Isocell +#' @importFrom mstools toolCoord2Isocell #' @importFrom magpiesets findset calcGrasslandBiomass <- function(cells = "lpjcell") { - # select years magYearsPast <- findset("past") @@ -33,17 +33,11 @@ calcGrasslandBiomass <- function(cells = "lpjcell") { # "other land" that is assumed to be used for grazing in those three countries. grasslLand["IND", , "pastr"] <- grasslLand["IND", , "pastr"] + - setNames(dimSums(land["IND", , c("primother", "secdother")], - dim = 3), - "pastr") + setNames(dimSums(land["IND", , c("primother", "secdother")], dim = 3), "pastr") grasslLand["BGD", , "pastr"] <- grasslLand["BGD", , "pastr"] + - setNames(dimSums(land["BGD", , c("primother", "secdother")], - dim = 3), - "pastr") + setNames(dimSums(land["BGD", , c("primother", "secdother")], dim = 3), "pastr") grasslLand["PAK", , "pastr"] <- grasslLand["PAK", , "pastr"] + - setNames(dimSums(land["PAK", , c("primother", "secdother")], - dim = 3), - "pastr") + setNames(dimSums(land["PAK", , c("primother", "secdother")], dim = 3), "pastr") grassYld <- calcOutput("GrasslandsYields", lpjml = "lpjml5p2_pasture", @@ -66,7 +60,7 @@ calcGrasslandBiomass <- function(cells = "lpjcell") { livestock <- setNames(readSource("GLW3", subtype = "Aw"), "liv_numb") if (cells == "magpiecell") { - livestock <- toolCoord2Isocell(livestock) + livestock <- toolCoord2Isocell(livestock) } livestock[livestock < 1] <- 0 @@ -80,11 +74,11 @@ calcGrasslandBiomass <- function(cells = "lpjcell") { livstSplit <- livestock * potBioMassShare livstSplit <- collapseNames(livstSplit) if (cells == "lpjcell") { - livstSplitCtry <- dimSums(livstSplit, dim = c("x", "y")) + livstSplitCtry <- dimSums(livstSplit, dim = c("x", "y")) } else if (cells == "magpiecell") { - livstSplitCtry <- dimSums(livstSplit, dim = 1.2) + livstSplitCtry <- dimSums(livstSplit, dim = 1.2) } else { - stop("Please select cells argument in calcGrasslandBiomass") + stop("Please select cells argument in calcGrasslandBiomass") } livstShareCtry <- livstSplitCtry[, , "pastr"] / dimSums(livstSplitCtry, dim = 3) livstShareCtry[is.nan(livstShareCtry) | is.infinite(livstShareCtry)] <- 0 @@ -96,7 +90,7 @@ calcGrasslandBiomass <- function(cells = "lpjcell") { # with the production of grass in pastures and rangelands in a country. That can be # derived by the fact that the feedbaskets assume the same feed ingredients shares # within a country. - commonCtrs <- intersect(getItems(biomass, dim = 1), + commonCtrs <- intersect(getItems(biomass, dim = 1), unique(getItems(livstShareCtry, dim = 1))) biomassSplit <- biomass[commonCtrs, , ] * livstShareCtry[commonCtrs, , ] biomassSplit <- toolCountryFill(biomassSplit, fill = 0) diff --git a/R/calcIrrigation.R b/R/calcIrrigation.R index d603f91a..532d1c6b 100644 --- a/R/calcIrrigation.R +++ b/R/calcIrrigation.R @@ -18,7 +18,8 @@ #' } #' #' @importFrom magpiesets findset -#' @importFrom mrcommons toolLPJmLVersion toolGetMappingCoord2Country toolCoord2Isocell +#' @importFrom mrlandcore toolLPJmLVersion +#' @importFrom mstools toolGetMappingCoord2Country toolCoord2Isocell #' @importFrom madrat toolGetMapping calcOutput toolAggregate #' @importFrom magclass dimSums getItems getSets collapseNames #' @importFrom withr local_options @@ -59,16 +60,16 @@ calcIrrigation <- function(lpjml = c(natveg = "LPJmL4_for_MAgPIE_44ac93de", crop # Clustering weight: totalCropland <- dimSums(calcOutput("Croparea", sectoral = "kcr", physical = TRUE, - cellular = TRUE, cells = "lpjcell", - years = "y1995", round = 6, - irrigation = TRUE, aggregate = FALSE), - dim = 3.2) + cellular = TRUE, cells = "lpjcell", + years = "y1995", round = 6, + irrigation = TRUE, aggregate = FALSE), + dim = 3.2) map <- toolGetMappingCoord2Country() getItems(totalCropland, dim = 1, raw = TRUE) <- paste(map$coords, map$iso, sep = ".") getSets(totalCropland) <- c("x", "y", "iso", "year", "irrigation") weightCropArea <- collapseNames(totalCropland[, , "irrigated"]) + - rainfedweight * collapseNames(totalCropland[, , "rainfed"]) + rainfedweight * collapseNames(totalCropland[, , "rainfed"]) # Reduce to 59199 cells if (cells == "magpiecell") { diff --git a/R/calcLabourProdImpact.R b/R/calcLabourProdImpact.R index ac5be705..2c084a51 100644 --- a/R/calcLabourProdImpact.R +++ b/R/calcLabourProdImpact.R @@ -4,61 +4,60 @@ #' @param subtype data source comes from #' @param cellular cellular is true #' @param cells "magpiecell" or "lpjcell" -#' @return List of magpie objects with results on 0.5deg grid level, weights based on production value, unit (ratio) and description. +#' @return List of magpie objects with results on 0.5deg grid level, weights +#' based on production value, unit (ratio) and description. #' @author David Chen #' @importFrom magpiesets findset #' @importFrom mstools toolHoldConstant #' @importFrom magclass collapseNames -calcLabourProdImpact <-function(timestep = "5year", subtype="Orlov", cellular=TRUE, cells = "lpjcell"){ +calcLabourProdImpact <- function(timestep = "5year", subtype = "Orlov", cellular = TRUE, cells = "lpjcell") { - if (subtype=="Orlov"){ + if (subtype == "Orlov") { - out <- readSource("LabourProdImpactOrlov", subtype="IPSL-CM5A-LR_rcp85_wbgtod_hothaps_400W.nc", convert=FALSE) + out <- readSource("LabourProdImpactOrlov", subtype = "IPSL-CM5A-LR_rcp85_wbgtod_hothaps_400W.nc", convert = FALSE) out <- toolTimeSpline(out) - tran <- readSource("LabourProdImpactOrlov", subtype="IPSL-CM5A-LR_rcp60_wbgtod_hothaps_400W.nc", convert=FALSE) + tran <- readSource("LabourProdImpactOrlov", subtype = "IPSL-CM5A-LR_rcp60_wbgtod_hothaps_400W.nc", convert = FALSE) tran <- toolTimeSpline(tran) - out[,c(2006:2020),] <- tran[,c(2006:2020),] + out[, c(2006:2020), ] <- tran[, c(2006:2020), ] - if(timestep == "5year"){ - #add future - out <- out[,seq(1985,2095,5),] + if (timestep == "5year") { + # add future + out <- out[, seq(1985, 2095, 5), ] - past <- new.magpie(cells_and_regions = getCells(out), years=seq(1965,1980,5), names=getNames(out),fill=1) - past[,seq(1965,1980,5),] <- setYears(out[,1985,],NULL) - out <- mbind(past,out) + past <- new.magpie(cells_and_regions = getCells(out), years = seq(1965, 1980, 5), names = getNames(out), fill = 1) + past[, seq(1965, 1980, 5), ] <- setYears(out[, 1985, ], NULL) + out <- mbind(past, out) out <- toolHoldConstantBeyondEnd(out) out <- collapseNames(out) - } - - else if(timestep=="yearly"){ + } else if (timestep == "yearly") { - past <- new.magpie(cells_and_regions = getCells(out), years=c(1965:1980), names=getNames(out),fill=1) - past[,c(1965:1980),] <- setYears(out[,1981,],NULL) - out <- mbind(past,out) + past <- new.magpie(cells_and_regions = getCells(out), years = c(1965:1980), names = getNames(out), fill = 1) + past[, c(1965:1980), ] <- setYears(out[, 1981, ], NULL) + out <- mbind(past, out) out <- toolHoldConstantBeyondEnd(out) out <- collapseNames(out) } } - #weight <- calcOutput("ValueProduction",aggregate=F)[,2010,] - #no weight yet because doesn't work in old preprocessing + + # no weight yet because doesn't work in old preprocessing if (subtype != "Orlov") { stop("Not a Valid Subtype") } if (cells == "magpiecell") { - x <- mrcommons::toolCoord2Isocell(x, cells = cells) + x <- mstools::toolCoord2Isocell(x, cells = cells) } return(list(x = out, weight = NULL, unit = "Percentage of total labour productivity", - isocountries = (!cellular & (nregions(out)!=1)), + isocountries = (!cellular & (nregions(out) != 1)), description = "Labour productivity impacts as percentage of full labour prod 1")) } diff --git a/R/calcLabourProdImpactEmu.R b/R/calcLabourProdImpactEmu.R index 9e32e3df..fb8e4d20 100644 --- a/R/calcLabourProdImpactEmu.R +++ b/R/calcLabourProdImpactEmu.R @@ -55,14 +55,15 @@ calcLabourProdImpactEmu <- function(timestep = "5year", cellular = TRUE, avlCropAreaWeight[avlCropAreaWeight == 0] <- 10^-10 if (cells == "magpiecell") { - out <- mrcommons::toolCoord2Isocell(out, cells = cells, fillMissing = 1) + out <- mstools::toolCoord2Isocell(out, cells = cells, fillMissing = 1) } return(list(x = out, weight = avlCropAreaWeight, unit = "Percentage of total labour productivity (1)", - description = "Remaining labour productivity as percentage of full labour productivity after accounting for - climate change impacts on labour productivity", + description = "Remaining labour productivity as percentage of full labour + productivity after accounting for climate change impacts on + labour productivity", isocountries = FALSE)) } diff --git a/R/calcPeatland.R b/R/calcPeatland.R index f02a74e0..1162046d 100644 --- a/R/calcPeatland.R +++ b/R/calcPeatland.R @@ -1,7 +1,10 @@ #' @title calcPeatland #' @description This function calculates degraded and intact peatland area at cell level. -#' The function takes degraded and intact peatland area from the Global Peatland Database (GPD) at the national level and downscales the peatland area to grid cell level using gridded potential peatland area. -#' The GPD has been provided by Alexandra Barthelmes. The potential peatland area has been provided by Leifeld_2018 (DOI 10.1038/s41467-018-03406-6). +#' The function takes degraded and intact peatland area from the Global Peatland Database +#' (GPD) at the national level and downscales the peatland area to grid cell level using +#' gridded potential peatland area. +#' The GPD has been provided by Alexandra Barthelmes. The potential peatland area has been +#' provided by Leifeld_2018 (DOI 10.1038/s41467-018-03406-6). #' @param subtype degraded (default) or intact #' @param cells "magpiecell" or "lpjcell" #' @@ -15,50 +18,48 @@ #' #' @importFrom magclass clean_magpie #' @importFrom madrat toolGetMapping toolAggregate -#' @importFrom mrcommons toolIso2CellCountries +#' @importFrom mstools toolIso2CellCountries -calcPeatland <-function(subtype = "degraded", cells = "lpjcell"){ +calcPeatland <- function(subtype = "degraded", cells = "lpjcell") { - GPD <- readSource("GPD", convert = TRUE) + gpd <- readSource("GPD", convert = TRUE) potPeatArea <- readSource("Leifeld2018", convert = "onlycorrect") # Total and drained peatland area - PeatAreaTotal <- collapseNames(GPD[, , "PeatAreaTotal"]) - names(dimnames(PeatAreaTotal)) <- c("iso", "t", "d3") - PeatAreaDrained <- collapseNames(GPD[, , "PeatAreaDrained"]) - names(dimnames(PeatAreaDrained)) <- c("iso", "t", "d3") + peatAreaTotal <- collapseNames(gpd[, , "PeatAreaTotal"]) + names(dimnames(peatAreaTotal)) <- c("iso", "t", "d3") + peatAreaDrained <- collapseNames(gpd[, , "PeatAreaDrained"]) + names(dimnames(peatAreaDrained)) <- c("iso", "t", "d3") - #Dissag. from country to cell - #CountryToCell <- toolGetMapping("CountryToCellMapping.csv", type = "cell") + # Dissag. from country to cell map <- toolGetMappingCoord2Country(pretty = TRUE) - PeatAreaTotal <- toolAggregate(x=toolIso2CellCountries(PeatAreaTotal, cells = "lpjcell"), rel = map, weight = potPeatArea, dim = 1, from = "iso", to = "coords") - names(dimnames(PeatAreaTotal)) <- c("coords","t","d3") - PeatAreaDrained <- toolAggregate(x=toolIso2CellCountries(PeatAreaDrained, cells = "lpjcell"), rel = map, weight = potPeatArea, dim = 1, from = "iso", to = "coords") - names(dimnames(PeatAreaDrained)) <- c("coords", "t", "d3") + peatAreaTotal <- toolAggregate(x = toolIso2CellCountries(peatAreaTotal, cells = "lpjcell"), rel = map, + weight = potPeatArea, dim = 1, from = "iso", to = "coords") + names(dimnames(peatAreaTotal)) <- c("coords", "t", "d3") + peatAreaDrained <- toolAggregate(x = toolIso2CellCountries(peatAreaDrained, cells = "lpjcell"), rel = map, + weight = potPeatArea, dim = 1, from = "iso", to = "coords") + names(dimnames(peatAreaDrained)) <- c("coords", "t", "d3") # potPeatArea is the upper limit of peatland area in a cell; this will reduce the peatland area of GPD! - PeatAreaTotal[PeatAreaTotal > potPeatArea] <- potPeatArea[PeatAreaTotal > potPeatArea] - PeatAreaDrained[PeatAreaDrained > potPeatArea] <- potPeatArea[PeatAreaDrained > potPeatArea] + peatAreaTotal[peatAreaTotal > potPeatArea] <- potPeatArea[peatAreaTotal > potPeatArea] + peatAreaDrained[peatAreaDrained > potPeatArea] <- potPeatArea[peatAreaDrained > potPeatArea] - # check; GPD is somewhat higher because we used potPeatArea as upper limit! - # dimSums(GPD,dim=1) - # dimSums(PeatAreaTotal,dim=1) - # dimSums(PeatAreaDrained,dim=1) + dimnames(peatAreaTotal) <- list("x.y.iso" = paste(map$coords, map$iso, sep = "."), "t" = NULL, "d3" = NULL) + dimnames(peatAreaDrained) <- list("x.y.iso" = paste(map$coords, map$iso, sep = "."), "t" = NULL, "d3" = NULL) + peatAreaIntact <- peatAreaTotal - peatAreaDrained - dimnames(PeatAreaTotal) <- list("x.y.iso" = paste(map$coords, map$iso, sep = "."), "t" = NULL, "d3" = NULL) - dimnames(PeatAreaDrained) <- list("x.y.iso" = paste(map$coords, map$iso, sep = "."), "t" = NULL, "d3" = NULL) - PeatAreaIntact <- PeatAreaTotal - PeatAreaDrained - - if(subtype=="degraded") { - description <- "Degraded peatland area (Mha) in 0.5 degree resolution based on Humpenoeder et al 2020 (DOI 10.1088/1748-9326/abae2a)" - x <- PeatAreaDrained - } else if(subtype == "intact") { - description <- "Intact peatland area (Mha) in 0.5 degree resolution based on Humpenoeder et al 2020 (DOI 10.1088/1748-9326/abae2a)" - x <- PeatAreaIntact + if (subtype == "degraded") { + description <- "Degraded peatland area (Mha) in 0.5 degree resolution based on Humpenoeder + et al 2020 (DOI 10.1088/1748-9326/abae2a)" + x <- peatAreaDrained + } else if (subtype == "intact") { + description <- "Intact peatland area (Mha) in 0.5 degree resolution based on Humpenoeder + et al 2020 (DOI 10.1088/1748-9326/abae2a)" + x <- peatAreaIntact } if (cells == "magpiecell") { - x <- mrcommons::toolCoord2Isocell(x, cells = cells) + x <- mstools::toolCoord2Isocell(x, cells = cells) } return(list(x = x, diff --git a/R/calcPeatland2.R b/R/calcPeatland2.R index 26398952..0831bd74 100644 --- a/R/calcPeatland2.R +++ b/R/calcPeatland2.R @@ -23,22 +23,21 @@ calcPeatland2 <- function(cells = "magpiecell") { gpm2 <- readSource("GPM2", convert = "onlycorrect") # Dissag. GPD2022 from country to cell with GPM2 as weight - map <- mrcommons::toolGetMappingCoord2Country(pretty = TRUE) - outCell <- toolAggregate(x = mrcommons::toolIso2CellCountries(gpd2022, cells = "lpjcell"), rel = map, + map <- mstools::toolGetMappingCoord2Country(pretty = TRUE) + outCell <- toolAggregate(x = mstools::toolIso2CellCountries(gpd2022, cells = "lpjcell"), rel = map, weight = gpm2, dim = 1, from = "iso", to = "coords") names(dimnames(outCell)) <- c("coords", "t", "d3") dimnames(outCell) <- list("x.y.iso" = paste(map$coords, map$iso, sep = "."), "t" = NULL, "d3" = getNames(outCell)) if (cells == "magpiecell") { - outCell <- mrcommons::toolCoord2Isocell(outCell) + outCell <- mstools::toolCoord2Isocell(outCell) } description <- "Intact and degraded peatland area (Mha) by land-use type, based GPD 2022 and GPM2.0" - return(list( - x = outCell, - weight = NULL, - unit = "Mha", - description = description, - isocountries = FALSE)) + return(list(x = outCell, + weight = NULL, + unit = "Mha", + description = description, + isocountries = FALSE)) } diff --git a/R/calcPotentialForestArea.R b/R/calcPotentialForestArea.R index 65772598..01285d5c 100644 --- a/R/calcPotentialForestArea.R +++ b/R/calcPotentialForestArea.R @@ -23,7 +23,7 @@ #' #' @importFrom madrat readSource calcOutput toolCountryFill #' @importFrom magclass dimSums getYears -#' @importFrom mrcommons toolCoord2Isocell +#' @importFrom mstools toolCoord2Isocell calcPotentialForestArea <- function(refData = "lpj", countryLevel = FALSE, cells = "lpjcell", lpjml = c(natveg = "LPJmL4_for_MAgPIE_44ac93de"), diff --git a/R/calcSoilCharacteristics.R b/R/calcSoilCharacteristics.R index fb4ece53..636764c4 100644 --- a/R/calcSoilCharacteristics.R +++ b/R/calcSoilCharacteristics.R @@ -23,7 +23,7 @@ calcSoilCharacteristics <- function() { # THIS FUNCTION NEEDS A MAJOR REWRITE # Creating aggregation weights for the physical variables # #Future implementation - # map <- mrcommons:::toolGetMappingCoord2Country() + # map <- mstools:::toolGetMappingCoord2Country() # x <- new.magpie(cells_and_regions=map$coords) # getSets(x)[c(1,2)] <- c("x", "y") # x[,,1] <- 1 diff --git a/R/calcTopsoilCarbon.R b/R/calcTopsoilCarbon.R index b06a4920..fd9efae9 100644 --- a/R/calcTopsoilCarbon.R +++ b/R/calcTopsoilCarbon.R @@ -15,7 +15,7 @@ #' } #' #' @importFrom magpiesets findset -#' @importFrom mrcommons toolCoord2Isocell +#' @importFrom mstools toolCoord2Isocell calcTopsoilCarbon <- function(cells = "lpjcell", lpjml = c(natveg = "LPJmL4_for_MAgPIE_44ac93de", crop = "ggcmi_phase3_nchecks_9ca735cb"), diff --git a/R/correctAvlLandSi.R b/R/correctAvlLandSi.R index 1f73515f..51568c32 100644 --- a/R/correctAvlLandSi.R +++ b/R/correctAvlLandSi.R @@ -6,17 +6,16 @@ #' @seealso #' \code{\link{readAvlLandSi}} #' @examples -#' #' \dontrun{ -#' readSource("AvlLandSi", convert="onlycorrect") +#' readSource("AvlLandSi", convert = "onlycorrect") #' } #' #' @importFrom madrat toolConditionalReplace -#' @importFrom mrcommons toolCell2isoCell +#' @importFrom mstools toolCell2isoCell -correctAvlLandSi <- function(x){ +correctAvlLandSi <- function(x) { - x <- toolConditionalReplace(x, conditions = c("is.na()","<0"), replaceby = 0) + x <- toolConditionalReplace(x, conditions = c("is.na()", "<0"), replaceby = 0) x <- toolCell2isoCell(x) return(x) diff --git a/R/correctBendingTheCurve.R b/R/correctBendingTheCurve.R index dfe345e9..3e696770 100644 --- a/R/correctBendingTheCurve.R +++ b/R/correctBendingTheCurve.R @@ -4,18 +4,17 @@ #' @return List of magpie objects with results on cellular level, weight, unit and description. #' @author Patrick v. Jeetze, Michael Windisch #' @examples -#' #' \dontrun{ -#' readSource("BendingTheCurve", subtype="rr_layer", convert="onlycorrect") +#' readSource("BendingTheCurve", subtype = "rr_layer", convert = "onlycorrect") #' } #' #' @importFrom madrat toolConditionalReplace -#' @importFrom mrcommons toolCell2isoCell +#' @importFrom mstools toolCell2isoCell -correctBendingTheCurve <- function(x){ +correctBendingTheCurve <- function(x) { - x <- toolConditionalReplace(x, conditions = c("is.na()","<0"), replaceby = 0) + x <- toolConditionalReplace(x, conditions = c("is.na()", "<0"), replaceby = 0) return(x) } diff --git a/R/correctGFAD.R b/R/correctGFAD.R index 350aa01e..67d8c706 100644 --- a/R/correctGFAD.R +++ b/R/correctGFAD.R @@ -12,7 +12,7 @@ #' } #' #' @importFrom madrat toolConditionalReplace -#' @importFrom mrcommons toolCoord2Isocoord +#' @importFrom mstools toolCoord2Isocoord correctGFAD <- function(x) { diff --git a/R/correctSoilClassification.R b/R/correctSoilClassification.R index 28a48160..9509d624 100644 --- a/R/correctSoilClassification.R +++ b/R/correctSoilClassification.R @@ -6,18 +6,17 @@ #' @seealso #' \code{\link{readSoilClassification}}, #' @examples -#' #' \dontrun{ -#' readSource("SoilClassification", subtype="HWSD.soil", convert="onlycorrect") +#' readSource("SoilClassification", subtype = "HWSD.soil", convert = "onlycorrect") #' } #' #' @import magclass #' @importFrom madrat toolConditionalReplace -#' @importFrom mrcommons toolCell2isoCell +#' @importFrom mstools toolCell2isoCell -correctSoilClassification <- function(x){ +correctSoilClassification <- function(x) { - x <- toolConditionalReplace(x, conditions = c("<1",">13", "!is.integer()"), replaceby = 0) + x <- toolConditionalReplace(x, conditions = c("<1", ">13", "!is.integer()"), replaceby = 0) x <- toolCell2isoCell(x) return(x) diff --git a/R/correctTransportDistance.R b/R/correctTransportDistance.R index f39d9ce4..cd34bd8f 100644 --- a/R/correctTransportDistance.R +++ b/R/correctTransportDistance.R @@ -6,17 +6,16 @@ #' @seealso #' \code{\link{readTransportDistance}} #' @examples -#' #' \dontrun{ -#' readSource("TransportDistance", convert="onlycorrect") +#' readSource("TransportDistance", convert = "onlycorrect") #' } #' #' @importFrom madrat toolConditionalReplace -#' @importFrom mrcommons toolCell2isoCell +#' @importFrom mstools toolCell2isoCell -correctTransportDistance <- function(x){ +correctTransportDistance <- function(x) { - x <- toolConditionalReplace(x, conditions = c("is.na()","<0"), replaceby = 0) + x <- toolConditionalReplace(x, conditions = c("is.na()", "<0"), replaceby = 0) x <- toolCell2isoCell(x) return(x) diff --git a/R/readGFAD.R b/R/readGFAD.R index 13389781..f9368f7b 100644 --- a/R/readGFAD.R +++ b/R/readGFAD.R @@ -9,14 +9,13 @@ #' } #' @importFrom raster brick subset as.matrix t #' @importFrom ncdf4 nc_open ncvar_get -#' @importFrom mrcommons toolGetMappingCoord2Country +#' @importFrom mstools toolGetMappingCoord2Country #' @importFrom magclass clean_magpie add_dimension setYears getSets #' @export readGFAD <- function() { poulterData <- "GFAD_V1-1.nc" - gfad <- nc_open(poulterData) mapping <- toolGetMappingCoord2Country() diff --git a/R/readGPM2.R b/R/readGPM2.R index 002ff220..eb30e8c7 100644 --- a/R/readGPM2.R +++ b/R/readGPM2.R @@ -33,7 +33,7 @@ readGPM2 <- function() { r3 <- terra::aggregate(a, fact = 48, fun = "sum", na.rm = TRUE) # get spatial mapping - map <- mrcommons::toolGetMappingCoord2Country(pretty = TRUE) + map <- mstools::toolGetMappingCoord2Country(pretty = TRUE) # transform raster to magpie object x <- as.magpie(terra::extract(r3, map[c("lon", "lat")])[, -1], spatial = 1) diff --git a/R/readGridPopIsimip.R b/R/readGridPopIsimip.R index dfabc7d1..4d8020b5 100644 --- a/R/readGridPopIsimip.R +++ b/R/readGridPopIsimip.R @@ -12,7 +12,7 @@ #' @import magclass #' @importFrom raster extent brick #' @importFrom magpiesets findset -#' @importFrom mrcommons toolGetMappingCoord2Country +#' @importFrom mstools toolGetMappingCoord2Country #' #' @export diff --git a/R/readLabourProdImpactEmu.R b/R/readLabourProdImpactEmu.R index d24d473e..59cfe95f 100644 --- a/R/readLabourProdImpactEmu.R +++ b/R/readLabourProdImpactEmu.R @@ -5,7 +5,7 @@ #' @author Michael Windisch, Florian Humpenöder, Felicitas Beier #' @seealso \code{\link{readSource}} #' @importFrom magclass new.magpie read.magpie mbind -#' @importFrom mrcommons toolCoord2Isocell +#' @importFrom mstools toolCoord2Isocell readLabourProdImpactEmu <- function() { @@ -14,24 +14,24 @@ readLabourProdImpactEmu <- function() { for (exp in (c("CTL_rcp585", "CTL_rcp119", "FRST", "CROP", "HARV", "IRR"))) { for (int in c("300", "400")) { for (sta in c("ensmean", "ensstd")) { - for (fct in c("ISO", "HOTHAPS")) { - tmp <- read.magpie(paste0(exp, "/", exp, "_", sta, "_laborprod_wby_grdays_", fct, "_", int, "_0.5.nc")) - # reduce to 67420 cells and fill missings with 0 - inter <- new.magpie(cells_and_regions = mapping$coords, - years = getItems(tmp, dim = 2), - names = getItems(tmp, dim = 3), - fill = 0) - tmp <- tmp[intersect(getItems(inter, dim = 1), getItems(tmp, dim = 1)), , ] - inter[intersect(getItems(inter, dim = 1), getItems(tmp, dim = 1)), , ] <- tmp - inter <- toolCoord2Isocoord(inter) - # clean up object dimensions - getYears(inter) <- seq(from = 1995, to = 2095, by = 1) - inter <- collapseNames(inter) - getNames(inter) <- paste0(exp, ".", fct, ".", int, "W", ".", sta) - getSets(inter) <- c("x", "y", "iso", "year", "data") - # bind to previous inputs - x <- mbind(x, inter) - } + for (fct in c("ISO", "HOTHAPS")) { + tmp <- read.magpie(paste0(exp, "/", exp, "_", sta, "_laborprod_wby_grdays_", fct, "_", int, "_0.5.nc")) + # reduce to 67420 cells and fill missings with 0 + inter <- new.magpie(cells_and_regions = mapping$coords, + years = getItems(tmp, dim = 2), + names = getItems(tmp, dim = 3), + fill = 0) + tmp <- tmp[intersect(getItems(inter, dim = 1), getItems(tmp, dim = 1)), , ] + inter[intersect(getItems(inter, dim = 1), getItems(tmp, dim = 1)), , ] <- tmp + inter <- toolCoord2Isocoord(inter) + # clean up object dimensions + getYears(inter) <- seq(from = 1995, to = 2095, by = 1) + inter <- collapseNames(inter) + getNames(inter) <- paste0(exp, ".", fct, ".", int, "W", ".", sta) + getSets(inter) <- c("x", "y", "iso", "year", "data") + # bind to previous inputs + x <- mbind(x, inter) + } } } } diff --git a/R/readLeifeld2018.R b/R/readLeifeld2018.R index b0f403ed..f9ede257 100644 --- a/R/readLeifeld2018.R +++ b/R/readLeifeld2018.R @@ -18,7 +18,7 @@ readLeifeld2018 <- function() { a <- terra::cellSize(rp2[[1]], unit = "ha", mask = TRUE) a <- a * 1e-6 # get spatial mapping - map <- mrcommons::toolGetMappingCoord2Country(pretty = TRUE) + map <- mstools::toolGetMappingCoord2Country(pretty = TRUE) # transform raster to magpie object x <- as.magpie(terra::extract(a, map[c("lon", "lat")])[, -1], spatial = 1) # set dimension names diff --git a/R/readMAPSPAM.R b/R/readMAPSPAM.R index e02fe249..e51545e5 100644 --- a/R/readMAPSPAM.R +++ b/R/readMAPSPAM.R @@ -5,7 +5,7 @@ #' @param subtype It can be either "harvested" or "physical" area #' @importFrom terra rast values crds aggregate #' @importFrom luscale speed_aggregate -#' @importFrom mrcommons toolGetMappingCoord2Country +#' @importFrom mstools toolGetMappingCoord2Country #' @importFrom magpiesets findset #' @importFrom magclass new.magpie #' @seealso [readSource()] diff --git a/R/readMehta2022.R b/R/readMehta2022.R index b825ba2a..f8e247a7 100644 --- a/R/readMehta2022.R +++ b/R/readMehta2022.R @@ -9,7 +9,7 @@ #' } #' @importFrom terra aggregate project rast global #' @importFrom magclass as.magpie -#' @importFrom mrcommons toolGetMappingCoord2Country +#' @importFrom mstools toolGetMappingCoord2Country readMehta2022 <- function() { From 34b5961ba1527d936ca05523e2721fa635f4b7ee Mon Sep 17 00:00:00 2001 From: Jan Philipp Dietrich Date: Thu, 25 Apr 2024 12:23:33 +0200 Subject: [PATCH 07/23] - adjusted package to mrcommons split - fixed various linter warnings --- .buildlibrary | 6 +++--- CITATION.cff | 2 +- DESCRIPTION | 3 ++- NAMESPACE | 1 + R/imports.R | 2 +- README.md | 6 +++--- man/calcGrasslandBiomass.Rd | 3 ++- man/calcLabourProdImpact.Rd | 3 ++- man/calcPeatland.Rd | 7 +++++-- man/correctAvlLandSi.Rd | 3 +-- man/correctBendingTheCurve.Rd | 3 +-- man/correctSoilClassification.Rd | 3 +-- man/correctTransportDistance.Rd | 3 +-- 13 files changed, 24 insertions(+), 21 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 6fecfb6b..9844faf2 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,8 +1,8 @@ -ValidationKey: '28963480' +ValidationKey: '29161860' AutocreateReadme: yes AcceptedWarnings: -- 'Warning: package ''.*'' was built under R version' -- 'Warning: namespace ''.*'' is not available and has been replaced' +- 'Warning: package .* was built under R version' +- 'Warning: namespace .* is not available and has been replaced' AcceptedNotes: - unable to verify current time - includes the non-default packages diff --git a/CITATION.cff b/CITATION.cff index 0d14d0f7..b377ae13 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: 'mrmagpie: madrat based MAgPIE Input Data Library' -version: 1.46.0 +version: 1.47.0 date-released: '2024-04-25' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: diff --git a/DESCRIPTION b/DESCRIPTION index d5a63acf..3ca81096 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.46.0 +Version: 1.47.0 Date: 2024-04-25 Authors@R: c( person("Kristine", "Karstens", , "karstens@pik-potsdam.de", role = c("aut", "cre")), @@ -26,6 +26,7 @@ Depends: madrat (>= 2.8.0), magclass (>= 3.17), mrcommons (>= 1.40.7), + mrlandcore, mrland (>= 0.51.0), mrsoil (>= 2.0.0), mrwater (>= 1.12.0), diff --git a/NAMESPACE b/NAMESPACE index 484128c8..ed82a4e2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -22,6 +22,7 @@ import(magclass) import(magpiesets) import(mrcommons) import(mrland) +import(mrlandcore) import(mrsoil) import(mrwater) import(mstools) diff --git a/R/imports.R b/R/imports.R index 54954d12..1c672b1a 100644 --- a/R/imports.R +++ b/R/imports.R @@ -1,4 +1,4 @@ # Generated by lucode2: do not edit by hand -#' @import madrat magclass mrcommons mrland mrsoil mrwater +#' @import madrat magclass mrcommons mrlandcore mrland mrsoil mrwater NULL diff --git a/README.md b/README.md index 72dc2b9f..97ab070b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.46.0** +R package **mrmagpie**, version **1.47.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 , R package version 1.46.0, . +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 (URL: https://doi.org/10.5281/zenodo.4319612), R package version 1.47.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.46.0}, + note = {R package version 1.47.0}, doi = {10.5281/zenodo.4319612}, url = {https://github.com/pik-piam/mrmagpie}, } diff --git a/man/calcGrasslandBiomass.Rd b/man/calcGrasslandBiomass.Rd index c5b28f18..5b82ed2c 100644 --- a/man/calcGrasslandBiomass.Rd +++ b/man/calcGrasslandBiomass.Rd @@ -13,7 +13,8 @@ calcGrasslandBiomass(cells = "lpjcell") Regional biomass demand } \description{ -Calculates pasture biomass demand for the historical period split between rangelands and managed pastures. +Calculates pasture biomass demand for the historical period split +between rangelands andmanaged pastures. } \examples{ \dontrun{ diff --git a/man/calcLabourProdImpact.Rd b/man/calcLabourProdImpact.Rd index a6ae5a03..50f22add 100644 --- a/man/calcLabourProdImpact.Rd +++ b/man/calcLabourProdImpact.Rd @@ -21,7 +21,8 @@ calcLabourProdImpact( \item{cells}{"magpiecell" or "lpjcell"} } \value{ -List of magpie objects with results on 0.5deg grid level, weights based on production value, unit (ratio) and description. +List of magpie objects with results on 0.5deg grid level, weights +based on production value, unit (ratio) and description. } \description{ Labour productivity impacts diff --git a/man/calcPeatland.Rd b/man/calcPeatland.Rd index 4d0aae75..3bce84aa 100644 --- a/man/calcPeatland.Rd +++ b/man/calcPeatland.Rd @@ -16,8 +16,11 @@ magpie object in cellular resolution } \description{ This function calculates degraded and intact peatland area at cell level. -The function takes degraded and intact peatland area from the Global Peatland Database (GPD) at the national level and downscales the peatland area to grid cell level using gridded potential peatland area. -The GPD has been provided by Alexandra Barthelmes. The potential peatland area has been provided by Leifeld_2018 (DOI 10.1038/s41467-018-03406-6). +The function takes degraded and intact peatland area from the Global Peatland Database +(GPD) at the national level and downscales the peatland area to grid cell level using +gridded potential peatland area. +The GPD has been provided by Alexandra Barthelmes. The potential peatland area has been +provided by Leifeld_2018 (DOI 10.1038/s41467-018-03406-6). } \examples{ \dontrun{ diff --git a/man/correctAvlLandSi.Rd b/man/correctAvlLandSi.Rd index 2ac811cc..ad552f6e 100644 --- a/man/correctAvlLandSi.Rd +++ b/man/correctAvlLandSi.Rd @@ -16,9 +16,8 @@ List of magpie objects with results on cellular level, weight, unit and descript Read Available Land Si } \examples{ - \dontrun{ - readSource("AvlLandSi", convert="onlycorrect") +readSource("AvlLandSi", convert = "onlycorrect") } } diff --git a/man/correctBendingTheCurve.Rd b/man/correctBendingTheCurve.Rd index 5fbc8d47..a8d63fa1 100644 --- a/man/correctBendingTheCurve.Rd +++ b/man/correctBendingTheCurve.Rd @@ -16,9 +16,8 @@ List of magpie objects with results on cellular level, weight, unit and descript Read bending the curve data } \examples{ - \dontrun{ - readSource("BendingTheCurve", subtype="rr_layer", convert="onlycorrect") +readSource("BendingTheCurve", subtype = "rr_layer", convert = "onlycorrect") } } diff --git a/man/correctSoilClassification.Rd b/man/correctSoilClassification.Rd index 9824c15b..b8c6df87 100644 --- a/man/correctSoilClassification.Rd +++ b/man/correctSoilClassification.Rd @@ -16,9 +16,8 @@ List of magpie objects with results on cellular level, weight, unit and descript Correct soil classification } \examples{ - \dontrun{ - readSource("SoilClassification", subtype="HWSD.soil", convert="onlycorrect") +readSource("SoilClassification", subtype = "HWSD.soil", convert = "onlycorrect") } } diff --git a/man/correctTransportDistance.Rd b/man/correctTransportDistance.Rd index 08200f10..25c28eb5 100644 --- a/man/correctTransportDistance.Rd +++ b/man/correctTransportDistance.Rd @@ -16,9 +16,8 @@ List of magpie objects with results on cellular level, weight, unit and descript Read transport distance file } \examples{ - \dontrun{ - readSource("TransportDistance", convert="onlycorrect") +readSource("TransportDistance", convert = "onlycorrect") } } From 9dbb899c685274c5af33947cdefb7391f40c489c Mon Sep 17 00:00:00 2001 From: mppalves Date: Sun, 12 May 2024 19:04:22 +0200 Subject: [PATCH 08/23] Adressing comments (Jan and kristina) --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- R/calcPastureSuit.R | 30 +++++++++++++++--------------- README.md | 8 ++++---- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 2f55c52d..427c64b3 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '29200821' +ValidationKey: '29385400' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 6a2a5b4d..9616c432 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.47.1 -date-released: '2024-05-08' +version: 1.48.0 +date-released: '2024-05-12' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: - family-names: Karstens diff --git a/DESCRIPTION b/DESCRIPTION index d1f04725..d86305e5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.47.1 -Date: 2024-05-08 +Version: 1.48.0 +Date: 2024-05-12 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/calcPastureSuit.R b/R/calcPastureSuit.R index a5cbc47e..a7e28b22 100644 --- a/R/calcPastureSuit.R +++ b/R/calcPastureSuit.R @@ -51,7 +51,6 @@ calcPastureSuit <- function(climatetype = "MRI-ESM2-0:ssp126", aggregate = FALSE ) - yearsCellPet <- intersect(getYears(cellPet), findset("time")) yearsCellPrep <- intersect(findset("time"), getYears(cellPrep)) years <- intersect(yearsCellPet, yearsCellPrep) @@ -64,34 +63,35 @@ calcPastureSuit <- function(climatetype = "MRI-ESM2-0:ssp126", years = "y1995", round = 6) landArea <- setYears(dimSums(land, dim = 3), NULL) - cellorder <- population - cellorder <- match(dimnames(cellorder)$x.y.iso, dimnames(landArea)$x.y.iso) - - # Reorder the dimensions of landArea to match Population - landArea <- landArea[cellorder, , ] - getCells(landArea) <- getCells(population) - - # population density - popDensity <- (population * 1e6) / landArea * 10000 # population density in number of people per km2 + # Calculate population density in people per km2: (Million people / Mha) = (1e6 / 10000) + popDensity <- population / landArea * 1e6 / 10000 popDensity[is.infinite(popDensity)] <- 0 popDensity[is.nan(popDensity)] <- 0 years <- intersect(getYears(popDensity), getYears(cellPrep)) + # Following the methodology presented in HYDE3.2 + # (https://essd.copernicus.org/articles/9/927/2017/essd-9-927-2017.pdf), + # to distinguish between these types of grasslands in a simple and transparent + # way, also historically, a population density and an aridity index are applied, + # based on expert judgement. Low animal densities can be related to either low + # population density or to low productivity of the natural vegetation, which is + # approximated via the aridity index. When the aridity index (defined as annual + # precipitation divided by annual evapotranspiration) of a grid cell is greater than 0.5, + # and population density is greater than 5 inhabitants km^2, then it is defined + # as suitable for managed pastures, otherwise rangelands. + aridity <- cellPrep[, years, ] / cellPet[, years, ] aridity[is.infinite(aridity) | is.nan(aridity)] <- 0 - # 0.5 aridity threshold for managed pastures. Same from HYDE 3.2. aridity[aridity < 0.5] <- 0 aridity[aridity >= 0.5] <- 1 - # pasture suitability check pastureSuit <- aridity popDensity <- popDensity[, getYears(pastureSuit), ] - cellorder <- match(dimnames(pastureSuit)$x.y.iso, dimnames(popDensity)$x.y.iso) - popDensity <- popDensity[cellorder] - pastureSuit[popDensity < 5] <- 0 # 5 hab km2 population threshold for managed pastures. Same from HYDE 3.2. + popDensity <- popDensity > 5 + pastureSuit <- pastureSuit * popDensity pastureSuitArea <- (pastureSuit * landArea * 100) / 1e6 # (from km2 (x100) to mha (/1e6)) diff --git a/README.md b/README.md index 4ef01fac..b78b399b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.47.1** +R package **mrmagpie**, version **1.48.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 , R package version 1.47.1, . +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 (URL: https://doi.org/10.5281/zenodo.4319612), R package version 1.48.0, . A BibTeX entry for LaTeX users is @@ -48,8 +48,8 @@ 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.47.1}, - url = {https://github.com/pik-piam/mrmagpie}, + note = {R package version 1.48.0}, doi = {10.5281/zenodo.4319612}, + url = {https://github.com/pik-piam/mrmagpie}, } ``` From 6c6da72dd8c7cec83694809d05607fd547c8974b Mon Sep 17 00:00:00 2001 From: Pascal Sauer Date: Mon, 13 May 2024 15:36:28 +0200 Subject: [PATCH 09/23] importFrom mstools --- DESCRIPTION | 12 ++++++------ R/calcAfforestationMask.R | 5 +++-- R/calcDegradationYieldReduction.R | 6 +++--- R/calcLabourProdImpact.R | 5 ++--- R/calcLabourProdImpactEmu.R | 4 ++-- R/calcPeatland.R | 4 ++-- R/calcPeatland2.R | 8 ++++---- R/calcSoilCharacteristics.R | 3 ++- R/readGPM2.R | 4 ++-- R/readLeifeld2018.R | 4 ++-- 10 files changed, 28 insertions(+), 27 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d60c2ae5..c1594719 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -25,11 +25,11 @@ BugReports: https://github.com/pik-piam/mrmagpie/issues Depends: madrat (>= 2.8.0), magclass (>= 3.17), - mrcommons (>= 1.40.7), - mrlandcore, - mrland (>= 0.51.0), + mrcommons (>= 1.41.0), + mrlandcore (>= 1.0.0), + mrland (>= 0.59.0), mrsoil (>= 2.0.0), - mrwater (>= 1.12.0), + mrwater (>= 1.13.0), R (>= 3.5.0) Imports: abind, @@ -38,9 +38,9 @@ Imports: dplyr, ggplot2, lpjclass, - luplot (>= 3.56.0), + luplot (>= 3.64.0), magpiesets, - mstools (>= 0.5.1), + mstools (>= 0.6.0), ncdf4, pbapply, raster, diff --git a/R/calcAfforestationMask.R b/R/calcAfforestationMask.R index 1904654f..92041607 100644 --- a/R/calcAfforestationMask.R +++ b/R/calcAfforestationMask.R @@ -11,6 +11,7 @@ #' } #' #' @importFrom magclass as.magpie +#' @importFrom mstools toolGetMappingCoord2Country toolCoord2Isocell calcAfforestationMask <- function(subtype, cells = "lpjcell") { @@ -29,13 +30,13 @@ calcAfforestationMask <- function(subtype, cells = "lpjcell") { # get spatial mapping - map <- mstools::toolGetMappingCoord2Country(pretty = TRUE) + map <- toolGetMappingCoord2Country(pretty = TRUE) # transform raster to magpie object x <- as.magpie(terra::extract(r, map[c("lon", "lat")])[, -1], spatial = 1) dimnames(x) <- list("x.y.iso" = paste(map$coords, map$iso, sep = "."), "t" = NULL, "d3" = NULL) if (cells == "magpiecell") { - x <- mstools::toolCoord2Isocell(x, cells = cells) + x <- toolCoord2Isocell(x, cells = cells) } weight <- calcOutput("LandArea", aggregate = FALSE, cells = cells) diff --git a/R/calcDegradationYieldReduction.R b/R/calcDegradationYieldReduction.R index abb6dbab..4580bd65 100644 --- a/R/calcDegradationYieldReduction.R +++ b/R/calcDegradationYieldReduction.R @@ -11,11 +11,11 @@ #' calcOutput("DegradationYieldReduction", aggregate = FALSE) #' } #' @importFrom magpiesets findset -#' +#' @importFrom mstools toolGetMappingCoord2Country toolCoord2Isocell calcDegradationYieldReduction <- function(cells = "lpjcell") { # create a dummy data set, which is later used to define yield impacts of land degradation - coordMapping <- mstools::toolGetMappingCoord2Country() + coordMapping <- toolGetMappingCoord2Country() cellnames <- paste(coordMapping$coords, coordMapping$iso, sep = ".") x <- new.magpie(cells_and_regions = cellnames, years = seq(1995, 2150, 5), @@ -24,7 +24,7 @@ calcDegradationYieldReduction <- function(cells = "lpjcell") { fill = 0) if (cells == "magpiecell") { - x <- mstools::toolCoord2Isocell(x, cells = cells) + x <- toolCoord2Isocell(x, cells = cells) } return(list(x = x, diff --git a/R/calcLabourProdImpact.R b/R/calcLabourProdImpact.R index 2c084a51..d4bd392b 100644 --- a/R/calcLabourProdImpact.R +++ b/R/calcLabourProdImpact.R @@ -10,8 +10,7 @@ #' @importFrom magpiesets findset #' @importFrom mstools toolHoldConstant #' @importFrom magclass collapseNames - - +#' @importFrom mstools toolCoord2Isocell calcLabourProdImpact <- function(timestep = "5year", subtype = "Orlov", cellular = TRUE, cells = "lpjcell") { if (subtype == "Orlov") { @@ -52,7 +51,7 @@ calcLabourProdImpact <- function(timestep = "5year", subtype = "Orlov", cellular } if (cells == "magpiecell") { - x <- mstools::toolCoord2Isocell(x, cells = cells) + x <- toolCoord2Isocell(x, cells = cells) } return(list(x = out, diff --git a/R/calcLabourProdImpactEmu.R b/R/calcLabourProdImpactEmu.R index fb8e4d20..922cf8aa 100644 --- a/R/calcLabourProdImpactEmu.R +++ b/R/calcLabourProdImpactEmu.R @@ -8,7 +8,7 @@ #' @return List of magpie object of gridded (0.5) labour productivity as percentage of full labour prod 1 #' @author Michael Windisch, Florian Humpenöder #' @importFrom magclass dimSums mbind - +#' @importFrom mstools toolCoord2Isocell calcLabourProdImpactEmu <- function(timestep = "5year", cellular = TRUE, subtype = "impact", cells = "lpjcell") { @@ -55,7 +55,7 @@ calcLabourProdImpactEmu <- function(timestep = "5year", cellular = TRUE, avlCropAreaWeight[avlCropAreaWeight == 0] <- 10^-10 if (cells == "magpiecell") { - out <- mstools::toolCoord2Isocell(out, cells = cells, fillMissing = 1) + out <- toolCoord2Isocell(out, cells = cells, fillMissing = 1) } return(list(x = out, diff --git a/R/calcPeatland.R b/R/calcPeatland.R index 1162046d..44e86737 100644 --- a/R/calcPeatland.R +++ b/R/calcPeatland.R @@ -18,7 +18,7 @@ #' #' @importFrom magclass clean_magpie #' @importFrom madrat toolGetMapping toolAggregate -#' @importFrom mstools toolIso2CellCountries +#' @importFrom mstools toolIso2CellCountries toolCoord2Isocell calcPeatland <- function(subtype = "degraded", cells = "lpjcell") { @@ -59,7 +59,7 @@ calcPeatland <- function(subtype = "degraded", cells = "lpjcell") { } if (cells == "magpiecell") { - x <- mstools::toolCoord2Isocell(x, cells = cells) + x <- toolCoord2Isocell(x, cells = cells) } return(list(x = x, diff --git a/R/calcPeatland2.R b/R/calcPeatland2.R index 0831bd74..17261e2b 100644 --- a/R/calcPeatland2.R +++ b/R/calcPeatland2.R @@ -14,7 +14,7 @@ #' } #' #' @importFrom madrat toolAggregate - +#' @importFrom mstools toolGetMappingCoord2Country toolIso2CellCountries toolCoord2Isocell calcPeatland2 <- function(cells = "magpiecell") { # Country-level data on intact and degraded peatland from Global Peatland Database for 2022 (GPD2022) gpd2022 <- readSource("GPD2022", convert = TRUE) @@ -23,14 +23,14 @@ calcPeatland2 <- function(cells = "magpiecell") { gpm2 <- readSource("GPM2", convert = "onlycorrect") # Dissag. GPD2022 from country to cell with GPM2 as weight - map <- mstools::toolGetMappingCoord2Country(pretty = TRUE) - outCell <- toolAggregate(x = mstools::toolIso2CellCountries(gpd2022, cells = "lpjcell"), rel = map, + map <- toolGetMappingCoord2Country(pretty = TRUE) + outCell <- toolAggregate(x = toolIso2CellCountries(gpd2022, cells = "lpjcell"), rel = map, weight = gpm2, dim = 1, from = "iso", to = "coords") names(dimnames(outCell)) <- c("coords", "t", "d3") dimnames(outCell) <- list("x.y.iso" = paste(map$coords, map$iso, sep = "."), "t" = NULL, "d3" = getNames(outCell)) if (cells == "magpiecell") { - outCell <- mstools::toolCoord2Isocell(outCell) + outCell <- toolCoord2Isocell(outCell) } description <- "Intact and degraded peatland area (Mha) by land-use type, based GPD 2022 and GPM2.0" diff --git a/R/calcSoilCharacteristics.R b/R/calcSoilCharacteristics.R index 636764c4..0feed4f4 100644 --- a/R/calcSoilCharacteristics.R +++ b/R/calcSoilCharacteristics.R @@ -14,6 +14,7 @@ #' @importFrom raster area #' @importFrom dplyr left_join #' @importFrom raster crs<- +#' @importFrom mstools toolGetMappingCoord2Country #' calcSoilCharacteristics <- function() { @@ -23,7 +24,7 @@ calcSoilCharacteristics <- function() { # THIS FUNCTION NEEDS A MAJOR REWRITE # Creating aggregation weights for the physical variables # #Future implementation - # map <- mstools:::toolGetMappingCoord2Country() + # map <- toolGetMappingCoord2Country() # x <- new.magpie(cells_and_regions=map$coords) # getSets(x)[c(1,2)] <- c("x", "y") # x[,,1] <- 1 diff --git a/R/readGPM2.R b/R/readGPM2.R index 19d9129a..f24a4477 100644 --- a/R/readGPM2.R +++ b/R/readGPM2.R @@ -7,7 +7,7 @@ #' readSource("GPM2", convert = "onlycorrect") #' } #' @importFrom magclass as.magpie - +#' @importFrom mstools toolGetMappingCoord2Country readGPM2 <- function() { previousOptions <- terra::terraOptions(print = FALSE) terra::terraOptions(tempdir = withr::local_tempdir(tmpdir = getConfig("tmpfolder")), @@ -34,7 +34,7 @@ readGPM2 <- function() { r3 <- terra::aggregate(a, fact = 48, fun = "sum", na.rm = TRUE) # get spatial mapping - map <- mstools::toolGetMappingCoord2Country(pretty = TRUE) + map <- toolGetMappingCoord2Country(pretty = TRUE) # transform raster to magpie object x <- as.magpie(terra::extract(r3, map[c("lon", "lat")])[, -1], spatial = 1) diff --git a/R/readLeifeld2018.R b/R/readLeifeld2018.R index c4658993..d6337aa3 100644 --- a/R/readLeifeld2018.R +++ b/R/readLeifeld2018.R @@ -7,7 +7,7 @@ #' readSource("Leifeld2018", convert = "onlycorrect") #' } #' @importFrom magclass as.magpie - +#' @importFrom mstools toolGetMappingCoord2Country readLeifeld2018 <- function() { # projection is +proj=igh x <- terra::rast("Degradation_raster_homolosine_hires_rev4.tif") @@ -18,7 +18,7 @@ readLeifeld2018 <- function() { cellArea <- terra::cellSize(rp2[[1]], unit = "ha", mask = FALSE) * 1e-6 cellArea <- terra::mask(cellArea, rp2[[1]]) # get spatial mapping - map <- mstools::toolGetMappingCoord2Country(pretty = TRUE) + map <- toolGetMappingCoord2Country(pretty = TRUE) # transform raster to magpie object x <- as.magpie(terra::extract(cellArea, map[c("lon", "lat")])[, -1], spatial = 1) # set dimension names From ae5413854ee9ea4d6c08faddf27732fbd251a150 Mon Sep 17 00:00:00 2001 From: Pascal Sauer Date: Mon, 13 May 2024 16:06:30 +0200 Subject: [PATCH 10/23] build --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- README.md | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 1199447e..4621c606 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '' +ValidationKey: '29386880' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package .* was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 6a2a5b4d..78d9e34a 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.47.1 -date-released: '2024-05-08' +version: 1.48.0 +date-released: '2024-05-13' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: - family-names: Karstens diff --git a/DESCRIPTION b/DESCRIPTION index c1594719..afa83381 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.47.1.9001 -Date: 2024-05-08 +Version: 1.48.0 +Date: 2024-05-13 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/README.md b/README.md index 43205c7d..d0c3ff38 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.47.1.9001** +R package **mrmagpie**, version **1.48.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 , R package version 1.47.1.9001, . +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.48.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.47.1.9001}, + note = {R package version 1.48.0}, url = {https://github.com/pik-piam/mrmagpie}, doi = {10.5281/zenodo.4319612}, } From d89de988347ad3bf1e59d283fe53b42f7294adbb Mon Sep 17 00:00:00 2001 From: David Hoetten Date: Thu, 16 May 2024 17:15:34 +0200 Subject: [PATCH 11/23] use region and country --- R/toolApplyRegionNames.R | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/R/toolApplyRegionNames.R b/R/toolApplyRegionNames.R index e6e94369..be9cb5ee 100644 --- a/R/toolApplyRegionNames.R +++ b/R/toolApplyRegionNames.R @@ -33,15 +33,18 @@ toolApplyRegionNames <- function(cdata, regionscode) { # Get countries from magpie object and extend mapping isocountries <- getItems(cdata, dim = 1.3, full = TRUE) - isoMap <- data.frame(CountryCode = isocountries) - map <- base::merge(isoMap, map, by = "CountryCode", + isoMap <- data.frame(country = isocountries) + # rename column names from old to new convention, if necessary + if ("CountryCode" %in% names(map)) names(map)[names(map) == "CountryCode"] <- "country" + if ("RegionCode" %in% names(map)) names(map)[names(map) == "RegionCode"] <- "region" + map <- base::merge(isoMap, map, by = "country", all.x = TRUE, sort = FALSE, no.dups = TRUE) # correct cell order - map <- map[match(isocountries, map$CountryCode), ] + map <- map[match(isocountries, map$country), ] # Add regional information to magpie object getItems(cdata, dim = 1, raw = TRUE) <- paste(gsub(".*\\.", "", getItems(cdata, dim = 1)), - map$RegionCode, + map$region, as.character(seq_along(isocountries)), sep = ".") getSets(cdata, fulldim = FALSE)[1] <- "country.region.cell" From db1702bab172f900c75c40796bda3b1b2cce7919 Mon Sep 17 00:00:00 2001 From: David Hoetten Date: Fri, 17 May 2024 11:19:05 +0200 Subject: [PATCH 12/23] buildLibrary --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- README.md | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 4621c606..703f2ca3 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '29386880' +ValidationKey: '29412660' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package .* was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 78d9e34a..f8e02eb9 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.48.0 -date-released: '2024-05-13' +version: 1.48.1 +date-released: '2024-05-17' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: - family-names: Karstens diff --git a/DESCRIPTION b/DESCRIPTION index afa83381..cdce582b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.48.0 -Date: 2024-05-13 +Version: 1.48.1 +Date: 2024-05-17 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/README.md b/README.md index d0c3ff38..9184bf8c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.48.0** +R package **mrmagpie**, version **1.48.1** [![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.48.0, . +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 (URL: https://doi.org/10.5281/zenodo.4319612), R package version 1.48.1, . A BibTeX entry for LaTeX users is @@ -48,8 +48,8 @@ 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.48.0}, - url = {https://github.com/pik-piam/mrmagpie}, + note = {R package version 1.48.1}, doi = {10.5281/zenodo.4319612}, + url = {https://github.com/pik-piam/mrmagpie}, } ``` From 45ddb7679458e35a973cac577e20cc33f07cad50 Mon Sep 17 00:00:00 2001 From: pvjeetze Date: Wed, 5 Jun 2024 10:32:01 +0200 Subject: [PATCH 13/23] added time dimension to potential forest --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- R/fullCELLULARMAGPIE.R | 4 ++-- README.md | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 703f2ca3..380be54f 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '29412660' +ValidationKey: '29460678' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package .* was built under R version' diff --git a/CITATION.cff b/CITATION.cff index f8e02eb9..9d4ecbea 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.48.1 -date-released: '2024-05-17' +version: 1.48.2 +date-released: '2024-06-05' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: - family-names: Karstens diff --git a/DESCRIPTION b/DESCRIPTION index cdce582b..45065a8c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.48.1 -Date: 2024-05-17 +Version: 1.48.2 +Date: 2024-06-05 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/fullCELLULARMAGPIE.R b/R/fullCELLULARMAGPIE.R index fc53febf..8bbe4703 100644 --- a/R/fullCELLULARMAGPIE.R +++ b/R/fullCELLULARMAGPIE.R @@ -337,12 +337,12 @@ fullCELLULARMAGPIE <- function(rev = numeric_version("0.1"), dev = "", file = paste0("forestageclasses_", ctype, ".mz")) calcOutput("PotentialForestArea", - refData = "lpj", cells = cells, lpjml = lpjml, climatetype = climatetype, years = "y2100", + refData = "lpj", cells = cells, lpjml = lpjml, climatetype = climatetype, years = lpjYears, aggregate = FALSE, round = roundArea, file = "pot_forest_area_0.5.mz" ) calcOutput("PotentialForestArea", - refData = "lpj", cells = cells, lpjml = lpjml, climatetype = climatetype, years = "y2100", + refData = "lpj", cells = cells, lpjml = lpjml, climatetype = climatetype, years = lpjYears, aggregate = "cluster", round = roundArea, file = paste0("pot_forest_area_", ctype, ".mz") ) diff --git a/README.md b/README.md index 9184bf8c..fd2023c3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.48.1** +R package **mrmagpie**, version **1.48.2** [![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.48.2, . 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.48.1}, + note = {R package version 1.48.2}, doi = {10.5281/zenodo.4319612}, url = {https://github.com/pik-piam/mrmagpie}, } From cf62acb02226cffdc28f955674269aa76b56cc1c Mon Sep 17 00:00:00 2001 From: pvjeetze Date: Wed, 5 Jun 2024 13:37:33 +0200 Subject: [PATCH 14/23] changed GCM ref year in lpjml data to 2025 --- .buildlibrary | 2 +- CITATION.cff | 2 +- DESCRIPTION | 4 ++-- README.md | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 380be54f..df56ac4b 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '29460678' +ValidationKey: '29619710' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package .* was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 9d4ecbea..aecf66a0 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: 'mrmagpie: madrat based MAgPIE Input Data Library' -version: 1.48.2 +version: 1.49.0 date-released: '2024-06-05' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: diff --git a/DESCRIPTION b/DESCRIPTION index 45065a8c..3dcbd4b6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.48.2 +Version: 1.49.0 Date: 2024-06-05 Authors@R: c( person("Kristine", "Karstens", , "karstens@pik-potsdam.de", role = c("aut", "cre")), @@ -26,7 +26,7 @@ Depends: madrat (>= 2.8.0), magclass (>= 3.17), mrcommons (>= 1.41.0), - mrlandcore (>= 1.0.0), + mrlandcore (>= 1.1.0), mrland (>= 0.59.0), mrsoil (>= 2.0.0), mrwater (>= 1.13.0), diff --git a/README.md b/README.md index fd2023c3..2585c366 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.48.2** +R package **mrmagpie**, version **1.49.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 , R package version 1.48.2, . +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.49.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.48.2}, + note = {R package version 1.49.0}, doi = {10.5281/zenodo.4319612}, url = {https://github.com/pik-piam/mrmagpie}, } From aaa59b1e34e8a98aaf7e6eb6202885d66df67f58 Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 14 Jun 2024 21:28:44 +0200 Subject: [PATCH 15/23] added iso files for tree cover and peatland --- .buildlibrary | 2 +- CITATION.cff | 5 +++-- DESCRIPTION | 4 ++-- R/fullCELLULARMAGPIE.R | 5 +++++ README.md | 8 ++++---- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index df56ac4b..79eac738 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '29619710' +ValidationKey: '29653008' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package .* was built under R version' diff --git a/CITATION.cff b/CITATION.cff index aecf66a0..ad222891 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.49.0 -date-released: '2024-06-05' +version: 1.49.1 +date-released: '2024-06-14' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: - family-names: Karstens @@ -37,6 +37,7 @@ authors: given-names: Pascal email: pascal.sauer@pik-potsdam.de license: LGPL-3.0 +keywords: ~ repository-code: https://github.com/pik-piam/mrmagpie doi: 10.5281/zenodo.4319612 diff --git a/DESCRIPTION b/DESCRIPTION index 3dcbd4b6..c7323a67 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.49.0 -Date: 2024-06-05 +Version: 1.49.1 +Date: 2024-06-14 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/fullCELLULARMAGPIE.R b/R/fullCELLULARMAGPIE.R index 8bbe4703..5d0d6bc2 100644 --- a/R/fullCELLULARMAGPIE.R +++ b/R/fullCELLULARMAGPIE.R @@ -245,6 +245,9 @@ fullCELLULARMAGPIE <- function(rev = numeric_version("0.1"), dev = "", calcOutput("CroplandTreecover", aggregate = "cluster", cells = cells, round = roundArea, file = paste0("CroplandTreecover_", ctype, ".mz")) + calcOutput("CroplandTreecover", + aggregate = FALSE, cells = cells, country_level = TRUE, + round = roundArea, file = "CroplandTreecover_iso.cs2") calcOutput("SNVTargetCropland", aggregate = FALSE, cells = cells, @@ -459,6 +462,8 @@ fullCELLULARMAGPIE <- function(rev = numeric_version("0.1"), dev = "", file = "f58_peatland_area_0.5.mz") calcOutput("Peatland2", aggregate = "cluster", cells = cells, round = roundArea, file = paste0("f58_peatland_area_", ctype, ".mz")) + calcOutput("Peatland2", aggregate = FALSE, cells = cells, round = roundArea, + country_level = TRUE, file = "f58_peatland_area_iso.cs3") # 59 som calcOutput("SOMinitialsiationPools", aggregate = "cluster", round = 6, cells = cells, diff --git a/README.md b/README.md index 2585c366..fdb32723 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.49.0** +R package **mrmagpie**, version **1.49.1** [![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.49.0, . +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.49.1, . A BibTeX entry for LaTeX users is @@ -48,8 +48,8 @@ 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.49.0}, - doi = {10.5281/zenodo.4319612}, + note = {R package version 1.49.1}, url = {https://github.com/pik-piam/mrmagpie}, + doi = {10.5281/zenodo.4319612}, } ``` From ee5b29628f31f75c93ce4a4085ac294a1c5083f0 Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 14 Jun 2024 22:51:20 +0200 Subject: [PATCH 16/23] iso peatland --- .buildlibrary | 2 +- CITATION.cff | 2 +- DESCRIPTION | 2 +- R/calcPeatland2.R | 8 +++++++- README.md | 6 +++--- man/calcPeatland2.Rd | 5 ++++- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 79eac738..dd89be02 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '29653008' +ValidationKey: '29672896' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package .* was built under R version' diff --git a/CITATION.cff b/CITATION.cff index ad222891..6903895a 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: 'mrmagpie: madrat based MAgPIE Input Data Library' -version: 1.49.1 +version: 1.49.2 date-released: '2024-06-14' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: diff --git a/DESCRIPTION b/DESCRIPTION index c7323a67..6324bc66 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.49.1 +Version: 1.49.2 Date: 2024-06-14 Authors@R: c( person("Kristine", "Karstens", , "karstens@pik-potsdam.de", role = c("aut", "cre")), diff --git a/R/calcPeatland2.R b/R/calcPeatland2.R index 17261e2b..dd20644a 100644 --- a/R/calcPeatland2.R +++ b/R/calcPeatland2.R @@ -5,6 +5,8 @@ #' from the Global Peatland Map 2.0 (GPM2) #' The data has been provided by Alexandra Barthelmes. #' @param cells number of cells to be returned: magpiecell (59199), lpjcell (67420) +#' @param countryLevel Whether output shall be at country level. +#' Requires aggregate=FALSE in calcOutput. #' @return magpie object in cellular resolution #' @author Florian Humpenoeder #' @@ -15,7 +17,7 @@ #' #' @importFrom madrat toolAggregate #' @importFrom mstools toolGetMappingCoord2Country toolIso2CellCountries toolCoord2Isocell -calcPeatland2 <- function(cells = "magpiecell") { +calcPeatland2 <- function(cells = "magpiecell", countryLevel = FALSE) { # Country-level data on intact and degraded peatland from Global Peatland Database for 2022 (GPD2022) gpd2022 <- readSource("GPD2022", convert = TRUE) @@ -33,6 +35,10 @@ calcPeatland2 <- function(cells = "magpiecell") { outCell <- toolCoord2Isocell(outCell) } + if (countryLevel) { + outCell <- toolCountryFill(dimSums(outCell, dim = c("x", "y")), fill = 0) + } + description <- "Intact and degraded peatland area (Mha) by land-use type, based GPD 2022 and GPM2.0" return(list(x = outCell, diff --git a/README.md b/README.md index fdb32723..600d95b4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.49.1** +R package **mrmagpie**, version **1.49.2** [![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.49.1, . +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.49.2, . 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.49.1}, + note = {R package version 1.49.2}, url = {https://github.com/pik-piam/mrmagpie}, doi = {10.5281/zenodo.4319612}, } diff --git a/man/calcPeatland2.Rd b/man/calcPeatland2.Rd index 8f18fc32..3d9c266b 100644 --- a/man/calcPeatland2.Rd +++ b/man/calcPeatland2.Rd @@ -4,10 +4,13 @@ \alias{calcPeatland2} \title{calcPeatland2} \usage{ -calcPeatland2(cells = "magpiecell") +calcPeatland2(cells = "magpiecell", countryLevel = FALSE) } \arguments{ \item{cells}{number of cells to be returned: magpiecell (59199), lpjcell (67420)} + +\item{countryLevel}{Whether output shall be at country level. +Requires aggregate=FALSE in calcOutput.} } \value{ magpie object in cellular resolution From 2fe992ea6e6ea6b338c849fd5d511c1ce22b6afb Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 15 Jun 2024 00:00:03 +0200 Subject: [PATCH 17/23] bugfix --- .buildlibrary | 2 +- CITATION.cff | 2 +- DESCRIPTION | 2 +- R/calcPeatland2.R | 2 +- R/fullCELLULARMAGPIE.R | 4 ++-- README.md | 6 +++--- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index dd89be02..dad7cd9e 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '29672896' +ValidationKey: '29692784' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package .* was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 6903895a..9d723ab1 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: 'mrmagpie: madrat based MAgPIE Input Data Library' -version: 1.49.2 +version: 1.49.3 date-released: '2024-06-14' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: diff --git a/DESCRIPTION b/DESCRIPTION index 6324bc66..e305a988 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.49.2 +Version: 1.49.3 Date: 2024-06-14 Authors@R: c( person("Kristine", "Karstens", , "karstens@pik-potsdam.de", role = c("aut", "cre")), diff --git a/R/calcPeatland2.R b/R/calcPeatland2.R index dd20644a..7a9ee4c3 100644 --- a/R/calcPeatland2.R +++ b/R/calcPeatland2.R @@ -36,7 +36,7 @@ calcPeatland2 <- function(cells = "magpiecell", countryLevel = FALSE) { } if (countryLevel) { - outCell <- toolCountryFill(dimSums(outCell, dim = c("x", "y")), fill = 0) + outCell <- toolCountryFill(dimSums(outCell, dim = 1.2), fill = 0) } description <- "Intact and degraded peatland area (Mha) by land-use type, based GPD 2022 and GPM2.0" diff --git a/R/fullCELLULARMAGPIE.R b/R/fullCELLULARMAGPIE.R index 5d0d6bc2..dcc1cbde 100644 --- a/R/fullCELLULARMAGPIE.R +++ b/R/fullCELLULARMAGPIE.R @@ -246,7 +246,7 @@ fullCELLULARMAGPIE <- function(rev = numeric_version("0.1"), dev = "", aggregate = "cluster", cells = cells, round = roundArea, file = paste0("CroplandTreecover_", ctype, ".mz")) calcOutput("CroplandTreecover", - aggregate = FALSE, cells = cells, country_level = TRUE, + aggregate = FALSE, cells = cells, countryLevel = TRUE, round = roundArea, file = "CroplandTreecover_iso.cs2") calcOutput("SNVTargetCropland", @@ -463,7 +463,7 @@ fullCELLULARMAGPIE <- function(rev = numeric_version("0.1"), dev = "", calcOutput("Peatland2", aggregate = "cluster", cells = cells, round = roundArea, file = paste0("f58_peatland_area_", ctype, ".mz")) calcOutput("Peatland2", aggregate = FALSE, cells = cells, round = roundArea, - country_level = TRUE, file = "f58_peatland_area_iso.cs3") + countryLevel = TRUE, file = "f58_peatland_area_iso.cs3") # 59 som calcOutput("SOMinitialsiationPools", aggregate = "cluster", round = 6, cells = cells, diff --git a/README.md b/README.md index 600d95b4..ceedd737 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.49.2** +R package **mrmagpie**, version **1.49.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 , R package version 1.49.2, . +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.49.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 Alexandre Köberle and Patrick {v. Jeetze} and Abhijeet Mishra and Florian Humpenoeder and Pascal Sauer}, year = {2024}, - note = {R package version 1.49.2}, + note = {R package version 1.49.3}, url = {https://github.com/pik-piam/mrmagpie}, doi = {10.5281/zenodo.4319612}, } From 58314c0dc3796a0175ce3c122890dd330ca930b7 Mon Sep 17 00:00:00 2001 From: florianh Date: Sat, 15 Jun 2024 10:56:45 +0200 Subject: [PATCH 18/23] bugfix --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- R/calcPeatland2.R | 20 ++++++++++++++++---- README.md | 6 +++--- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index dad7cd9e..124004a8 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '29692784' +ValidationKey: '29714166' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package .* was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 9d723ab1..2dc73390 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.49.3 -date-released: '2024-06-14' +version: 1.49.4 +date-released: '2024-06-15' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: - family-names: Karstens diff --git a/DESCRIPTION b/DESCRIPTION index e305a988..2610f8c9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.49.3 -Date: 2024-06-14 +Version: 1.49.4 +Date: 2024-06-15 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/calcPeatland2.R b/R/calcPeatland2.R index 7a9ee4c3..394ddac6 100644 --- a/R/calcPeatland2.R +++ b/R/calcPeatland2.R @@ -31,12 +31,24 @@ calcPeatland2 <- function(cells = "magpiecell", countryLevel = FALSE) { names(dimnames(outCell)) <- c("coords", "t", "d3") dimnames(outCell) <- list("x.y.iso" = paste(map$coords, map$iso, sep = "."), "t" = NULL, "d3" = getNames(outCell)) - if (cells == "magpiecell") { - outCell <- toolCoord2Isocell(outCell) - } if (countryLevel) { - outCell <- toolCountryFill(dimSums(outCell, dim = 1.2), fill = 0) + + outCell <- toolCountryFill(dimSums(outCell, dim = c("x", "y")), fill = 0) + + } else { + + if (cells == "magpiecell") { + + outCell <- toolCoord2Isocell(outCell) + + } else if (cells == "lpjcell") { + + outCell <- outCell + + } else { + stop("Please specify cells argument") + } } description <- "Intact and degraded peatland area (Mha) by land-use type, based GPD 2022 and GPM2.0" diff --git a/README.md b/README.md index ceedd737..d9dc098f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.49.3** +R package **mrmagpie**, version **1.49.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.49.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.49.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.49.3}, + note = {R package version 1.49.4}, url = {https://github.com/pik-piam/mrmagpie}, doi = {10.5281/zenodo.4319612}, } From 299097ca0001ef217a255a2bfa5272d44e7ded0a Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Sun, 16 Jun 2024 00:46:10 +0200 Subject: [PATCH 19/23] add output argument to soilcarbon --- .buildlibrary | 2 +- CITATION.cff | 5 ++--- DESCRIPTION | 4 ++-- R/fullCELLULARMAGPIE.R | 8 +++++--- README.md | 8 ++++---- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 124004a8..78dbeb4b 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '29714166' +ValidationKey: '29735550' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package .* was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 2dc73390..4bc353b6 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.49.4 -date-released: '2024-06-15' +version: 1.49.5 +date-released: '2024-06-16' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: - family-names: Karstens @@ -37,7 +37,6 @@ authors: given-names: Pascal email: pascal.sauer@pik-potsdam.de license: LGPL-3.0 -keywords: ~ repository-code: https://github.com/pik-piam/mrmagpie doi: 10.5281/zenodo.4319612 diff --git a/DESCRIPTION b/DESCRIPTION index 2610f8c9..cdfb7838 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.49.4 -Date: 2024-06-15 +Version: 1.49.5 +Date: 2024-06-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"), diff --git a/R/fullCELLULARMAGPIE.R b/R/fullCELLULARMAGPIE.R index dcc1cbde..16d54b57 100644 --- a/R/fullCELLULARMAGPIE.R +++ b/R/fullCELLULARMAGPIE.R @@ -473,6 +473,8 @@ fullCELLULARMAGPIE <- function(rev = numeric_version("0.1"), dev = "", if (dev == "+newSOC") { + histClimatetype <- toolLPJmLVersion(version = lpjml[["natveg"]], + climatetype = climatetype)$baseline_hist calcOutput("CarbonInputMultiplier", aggregate = "region", round = 6, file = "f59_cinput_multiplier.cs3") calcOutput("CarbonInputMultiplier", inputType = "kcr", aggregate = "region", @@ -485,9 +487,9 @@ fullCELLULARMAGPIE <- function(rev = numeric_version("0.1"), dev = "", 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"]], round = 6, - file = "f59_topsoilc_actualstate.cs3") + calcOutput("SoilCarbon", aggregate = "region", years = "y1995", output = "actualstate", + lpjmlNatveg = lpjml[["natveg"]], climatetype = histClimatetype, + round = 6, file = "f59_topsoilc_actualstate.cs3") } ##### AGGREGATION ###### diff --git a/README.md b/README.md index d9dc098f..b490a11a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.49.4** +R package **mrmagpie**, version **1.49.5** [![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.49.4, . +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.49.5, . A BibTeX entry for LaTeX users is @@ -48,8 +48,8 @@ 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.49.4}, - url = {https://github.com/pik-piam/mrmagpie}, + note = {R package version 1.49.5}, doi = {10.5281/zenodo.4319612}, + url = {https://github.com/pik-piam/mrmagpie}, } ``` From 7fd994d6952a7dc639bbd63b1047dc106035720a Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Sun, 16 Jun 2024 15:34:19 +0200 Subject: [PATCH 20/23] add natural soc and land area for 1990 --- .buildlibrary | 2 +- CITATION.cff | 2 +- DESCRIPTION | 2 +- R/fullCELLULARMAGPIE.R | 9 ++++++++- README.md | 6 +++--- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 78dbeb4b..45c9b23f 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '29735550' +ValidationKey: '29835000' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package .* was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 4bc353b6..02f6abde 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: 'mrmagpie: madrat based MAgPIE Input Data Library' -version: 1.49.5 +version: 1.50.0 date-released: '2024-06-16' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: diff --git a/DESCRIPTION b/DESCRIPTION index cdfb7838..2d46d5f6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.49.5 +Version: 1.50.0 Date: 2024-06-16 Authors@R: c( person("Kristine", "Karstens", , "karstens@pik-potsdam.de", role = c("aut", "cre")), diff --git a/R/fullCELLULARMAGPIE.R b/R/fullCELLULARMAGPIE.R index 16d54b57..0d4f5182 100644 --- a/R/fullCELLULARMAGPIE.R +++ b/R/fullCELLULARMAGPIE.R @@ -475,6 +475,10 @@ fullCELLULARMAGPIE <- function(rev = numeric_version("0.1"), dev = "", histClimatetype <- toolLPJmLVersion(version = lpjml[["natveg"]], climatetype = climatetype)$baseline_hist + calcOutput("LanduseInitialisation", nclasses = "seven", + aggregate = "region", cellular = FALSE, cells = cells, + input_magpie = TRUE, selectyears = "y1990", + round = roundArea, file = "f59_land_y1990.cs3") calcOutput("CarbonInputMultiplier", aggregate = "region", round = 6, file = "f59_cinput_multiplier.cs3") calcOutput("CarbonInputMultiplier", inputType = "kcr", aggregate = "region", @@ -487,9 +491,12 @@ fullCELLULARMAGPIE <- function(rev = numeric_version("0.1"), dev = "", calcOutput("DecayFuture", aggregate = "region", years = lpjYears, lpjmlNatveg = lpjml[["natveg"]], climatetype = climatetype, round = 6, file = "f59_topsoilc_decay.cs3") - calcOutput("SoilCarbon", aggregate = "region", years = "y1995", output = "actualstate", + calcOutput("SoilCarbon", aggregate = "region", years = "y1990", output = "actualstate", lpjmlNatveg = lpjml[["natveg"]], climatetype = histClimatetype, round = 6, file = "f59_topsoilc_actualstate.cs3") + calcOutput("SoilCarbon", aggregate = "region", years = "y1990", output = "naturalstate", + lpjmlNatveg = lpjml[["natveg"]], climatetype = histClimatetype, + round = 6, file = "f59_topsoilc_naturalstate.cs3") } ##### AGGREGATION ###### diff --git a/README.md b/README.md index b490a11a..7e355d34 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.49.5** +R package **mrmagpie**, version **1.50.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 , R package version 1.49.5, . +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.50.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.49.5}, + note = {R package version 1.50.0}, doi = {10.5281/zenodo.4319612}, url = {https://github.com/pik-piam/mrmagpie}, } From d87ebc659e0f7b26887dcb1b15c8f9980c971d12 Mon Sep 17 00:00:00 2001 From: Kristine Karstens Date: Sun, 16 Jun 2024 16:13:01 +0200 Subject: [PATCH 21/23] bugfix dev flag for newSOC --- .buildlibrary | 2 +- CITATION.cff | 2 +- DESCRIPTION | 2 +- R/fullCELLULARMAGPIE.R | 2 +- README.md | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 45c9b23f..bc168a0b 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '29835000' +ValidationKey: '29854890' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package .* was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 02f6abde..c293d024 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: 'mrmagpie: madrat based MAgPIE Input Data Library' -version: 1.50.0 +version: 1.50.1 date-released: '2024-06-16' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: diff --git a/DESCRIPTION b/DESCRIPTION index 2d46d5f6..aef59a95 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.50.0 +Version: 1.50.1 Date: 2024-06-16 Authors@R: c( person("Kristine", "Karstens", , "karstens@pik-potsdam.de", role = c("aut", "cre")), diff --git a/R/fullCELLULARMAGPIE.R b/R/fullCELLULARMAGPIE.R index 0d4f5182..3dba4670 100644 --- a/R/fullCELLULARMAGPIE.R +++ b/R/fullCELLULARMAGPIE.R @@ -471,7 +471,7 @@ fullCELLULARMAGPIE <- function(rev = numeric_version("0.1"), dev = "", calcOutput("SOCLossShare", aggregate = "cluster", rate = "loss", round = 6, cells = cells, file = paste0("cshare_released_", ctype, ".mz")) - if (dev == "+newSOC") { + if (grepl("newSOC", dev)) { histClimatetype <- toolLPJmLVersion(version = lpjml[["natveg"]], climatetype = climatetype)$baseline_hist diff --git a/README.md b/README.md index 7e355d34..b367aa3a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.50.0** +R package **mrmagpie**, version **1.50.1** [![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.50.0, . +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.50.1, . 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.50.0}, + note = {R package version 1.50.1}, doi = {10.5281/zenodo.4319612}, url = {https://github.com/pik-piam/mrmagpie}, } From 3c6bb298d8e5288371341423f876d27f7a42bf1b Mon Sep 17 00:00:00 2001 From: Felicitas Date: Mon, 17 Jun 2024 14:14:53 +0200 Subject: [PATCH 22/23] added non-agricultural water withdrawals for entire year --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- R/fullCELLULARMAGPIE.R | 4 ++++ README.md | 6 +++--- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index bc168a0b..7a10fa1f 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '29854890' +ValidationKey: '29876282' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package .* was built under R version' diff --git a/CITATION.cff b/CITATION.cff index c293d024..6891ba6f 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.50.1 -date-released: '2024-06-16' +version: 1.50.2 +date-released: '2024-06-17' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: - family-names: Karstens diff --git a/DESCRIPTION b/DESCRIPTION index aef59a95..f17d57c9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.50.1 -Date: 2024-06-16 +Version: 1.50.2 +Date: 2024-06-17 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/fullCELLULARMAGPIE.R b/R/fullCELLULARMAGPIE.R index 3dba4670..b6c0f415 100644 --- a/R/fullCELLULARMAGPIE.R +++ b/R/fullCELLULARMAGPIE.R @@ -416,6 +416,10 @@ fullCELLULARMAGPIE <- function(rev = numeric_version("0.1"), dev = "", aggregate = "cluster", cells = cells, file = paste0("watdem_nonagr_grper_", ctype, ".mz")) + calcOutput("WaterUseNonAg", datasource = "WATERGAP_ISIMIP", usetype = "all:withdrawal", + selectyears = lpjYears, seasonality = "total", lpjml = lpjml, climatetype = climatetype, + aggregate = "cluster", cells = cells, + file = paste0("watdem_nonagr_total_", ctype, ".mz")) # 44 biodiversity calcOutput("BiomeType", aggregate = "cluster", cells = cells, round = roundArea, diff --git a/README.md b/README.md index b367aa3a..978fd23e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.50.1** +R package **mrmagpie**, version **1.50.2** [![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.50.1, . +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.50.2, . 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.50.1}, + note = {R package version 1.50.2}, doi = {10.5281/zenodo.4319612}, url = {https://github.com/pik-piam/mrmagpie}, } From f74c7e3bd906a1924ea01712692cc7dffbd26a36 Mon Sep 17 00:00:00 2001 From: mppalves Date: Tue, 18 Jun 2024 09:41:52 +0200 Subject: [PATCH 23/23] Updated max past function and rebuilt --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- R/{calcPastureSuit.R => calcMaxPastureSuit.R} | 12 ++++++------ R/fullCELLULARMAGPIE.R | 8 ++++---- README.md | 6 +++--- man/{calcPastureSuit.Rd => calcMaxPastureSuit.Rd} | 14 +++++++------- 7 files changed, 25 insertions(+), 25 deletions(-) rename R/{calcPastureSuit.R => calcMaxPastureSuit.R} (91%) rename man/{calcPastureSuit.Rd => calcMaxPastureSuit.Rd} (71%) diff --git a/.buildlibrary b/.buildlibrary index 7a10fa1f..01350ec6 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '29876282' +ValidationKey: '30036920' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package .* was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 6891ba6f..9e98d159 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.50.2 -date-released: '2024-06-17' +version: 1.51.0 +date-released: '2024-06-18' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: - family-names: Karstens diff --git a/DESCRIPTION b/DESCRIPTION index f17d57c9..07d38fef 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.50.2 -Date: 2024-06-17 +Version: 1.51.0 +Date: 2024-06-18 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/calcPastureSuit.R b/R/calcMaxPastureSuit.R similarity index 91% rename from R/calcPastureSuit.R rename to R/calcMaxPastureSuit.R index a7e28b22..4fb4ca02 100644 --- a/R/calcPastureSuit.R +++ b/R/calcMaxPastureSuit.R @@ -1,5 +1,5 @@ -#' @title calcPastureSuit -#' @description Calculate glassland suitable for pasture management based +#' @title calcMaxPastureSuit +#' @description Calculate maximum glassland suitable for pasture management based #' on population and aridity criteria. #' #' @param lpjml Defines LPJmL version for crop/grass and natveg specific inputs @@ -11,14 +11,14 @@ #' @author Marcos Alves, Kristine Karstens, Alexandre Köberle #' @examples #' \dontrun{ -#' calcOutput("PastureSuit") +#' calcOutput("MaxPastureSuit") #' } #' @importFrom raster area rasterFromXYZ -calcPastureSuit <- function(climatetype = "MRI-ESM2-0:ssp126", - lpjml = "LPJmL4_for_MAgPIE_44ac93de", - cells = "lpjcell") { +calcMaxPastureSuit <- function(climatetype = "MRI-ESM2-0:ssp126", + lpjml = "LPJmL4_for_MAgPIE_44ac93de", + cells = "lpjcell") { x <- toolSplitSubtype(climatetype, list(climatemodel = NULL, scenario = NULL)) # Extract stage argument information diff --git a/R/fullCELLULARMAGPIE.R b/R/fullCELLULARMAGPIE.R index b6c0f415..103c8d92 100644 --- a/R/fullCELLULARMAGPIE.R +++ b/R/fullCELLULARMAGPIE.R @@ -273,10 +273,10 @@ fullCELLULARMAGPIE <- function(rev = numeric_version("0.1"), dev = "", lsu_levels = c(seq(0, 2.2, 0.2), 2.5), past_mngmt = "mdef", file = paste0("f31_grassl_yld.mz"), years = magYears, cells = cells, aggregate = FALSE) - calcOutput("PastureSuit", climatetype = climatetype, lpjml = lpjml[["natveg"]], cells = cells, - file = paste0("f31_pastr_suitability_", ctype, ".mz"), years = magYears, aggregate = "cluster") - calcOutput("PastureSuit", climatetype = climatetype, lpjml = lpjml[["natveg"]], cells = cells, - file = "f31_pastr_suitability.mz", years = magYears, aggregate = FALSE) + calcOutput("MaxPastureSuit", climatetype = climatetype, lpjml = lpjml[["natveg"]], cells = cells, + file = paste0("f31_max_managed_pasture_", ctype, ".mz"), years = magYears, aggregate = "cluster") + calcOutput("MaxPastureSuit", climatetype = climatetype, lpjml = lpjml[["natveg"]], cells = cells, + file = "f31_max_managed_pasture.mz", years = magYears, aggregate = FALSE) if (grepl("+PastrMngtLevels", dev)) { calcOutput("PastrMngtLevels", climatetype = paste0("MRI-ESM2-0", ":", climatescen), diff --git a/README.md b/README.md index 978fd23e..ea9969a6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.50.2** +R package **mrmagpie**, version **1.51.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 , R package version 1.50.2, . +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 (URL: https://doi.org/10.5281/zenodo.4319612), R package version 1.51.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.50.2}, + note = {R package version 1.51.0}, doi = {10.5281/zenodo.4319612}, url = {https://github.com/pik-piam/mrmagpie}, } diff --git a/man/calcPastureSuit.Rd b/man/calcMaxPastureSuit.Rd similarity index 71% rename from man/calcPastureSuit.Rd rename to man/calcMaxPastureSuit.Rd index 4f3ef13d..97fc0a62 100644 --- a/man/calcPastureSuit.Rd +++ b/man/calcMaxPastureSuit.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/calcPastureSuit.R -\name{calcPastureSuit} -\alias{calcPastureSuit} -\title{calcPastureSuit} +% Please edit documentation in R/calcMaxPastureSuit.R +\name{calcMaxPastureSuit} +\alias{calcMaxPastureSuit} +\title{calcMaxPastureSuit} \usage{ -calcPastureSuit( +calcMaxPastureSuit( climatetype = "MRI-ESM2-0:ssp126", lpjml = "LPJmL4_for_MAgPIE_44ac93de", cells = "lpjcell" @@ -22,12 +22,12 @@ Options: "magpiecell" (59199), "lpjcell" (67420)} List of magpie object with results on cluster level } \description{ -Calculate glassland suitable for pasture management based +Calculate maximum glassland suitable for pasture management based on population and aridity criteria. } \examples{ \dontrun{ -calcOutput("PastureSuit") +calcOutput("MaxPastureSuit") } } \author{