diff --git a/.buildlibrary b/.buildlibrary index 752f9d5..eaff75e 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '2310172334175' +ValidationKey: '3946000' AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' - 'Warning: namespace ''.*'' is not available and has been replaced' diff --git a/CITATION.cff b/CITATION.cff index 9b55a30..34a731e 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: 'mrsoil: MadRat Soil Organic Carbon Budget Library' -version: 1.17.11.9003 -date-released: '2024-01-03' +version: 2.0.0 +date-released: '2024-01-08' abstract: This packages provides functions for soil organic carbon budget for mineral soils using the steady-state method (Tier 2) of the 2019 Refinement to the 2006 IPP Guidelines for National Greenhouse Gas Inventories. diff --git a/DESCRIPTION b/DESCRIPTION index 271205e..513789e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: mrsoil Type: Package Title: MadRat Soil Organic Carbon Budget Library -Version: 1.17.11.9003 -Date: 2024-01-03 +Version: 2.0.0 +Date: 2024-01-08 Authors@R: c(person("Kristine", "Karstens", email = "karstens@pik-potsdam.de", role = c("aut","cre")), person("Jan Philipp", "Dietrich", email = "dietrich@pik-potsdam.de", role = "aut")) Description: This packages provides functions for soil organic carbon budget for mineral soils using the steady-state method (Tier 2) of the 2019 Refinement to the 2006 IPP Guidelines for National Greenhouse Gas Inventories. @@ -11,14 +11,11 @@ Depends: magclass(>= 5.15.4), madrat(>= 1.86.0), mrcommons(>= 0.11.9), - mrvalidation(>= 2.4.3), - mrmagpie (>= 0.35.0) + mrdrivers(>= 1.0.0) Imports: magpiesets, readxl, - reshape2, lpjclass, - ncdf4, utils, jsonlite License: LGPL-3 | file LICENSE diff --git a/NAMESPACE b/NAMESPACE index baf905b..80ae637 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,29 +5,18 @@ export(toolSoilCarbonCycling) import(madrat) import(magclass) import(mrcommons) -import(mrmagpie) -import(mrvalidation) +import(mrdrivers) importFrom(jsonlite,fromJSON) importFrom(lpjclass,read.LPJ_input) importFrom(madrat,toolSubtypeSelect) -importFrom(madrat,toolTimeAverage) importFrom(madrat,vcat) importFrom(magclass,collapseDim) importFrom(magclass,dimCode) -importFrom(magclass,getYears) importFrom(magclass,setNames) -importFrom(magclass,setYears) -importFrom(magpiesets,Cell2Country) importFrom(magpiesets,addLocation) importFrom(magpiesets,findset) -importFrom(ncdf4,nc_open) -importFrom(ncdf4,ncvar_get) importFrom(readxl,read_excel) -importFrom(reshape2,colsplit) -importFrom(stats,complete.cases) importFrom(stats,quantile) importFrom(utils,download.file) importFrom(utils,read.csv) importFrom(utils,tail) -importFrom(utils,untar) -importFrom(utils,write.csv) diff --git a/R/calcCarbonInputMultiplier.R b/R/calcCarbonInputMultiplier.R index 3337740..3766cdf 100644 --- a/R/calcCarbonInputMultiplier.R +++ b/R/calcCarbonInputMultiplier.R @@ -26,10 +26,10 @@ calcCarbonInputMultiplier <- function() { inputProp <- NULL # get lignin to c and nitrogen to c values for all residues classes inputProp <- mbind(inputProp, - calcOutput("ParamResidues", source = "IPCC+woody", aggregate = FALSE)) + calcOutput("ParamResidues", input = "IPCC+woody", aggregate = FALSE)) # get lignin to c and nitrogen to c values for all manure classes inputProp <- mbind(inputProp, - calcOutput("ParamManure", source = "IPCC", aggregate = FALSE)) + calcOutput("ParamManure", input = "IPCC", aggregate = FALSE)) # get lignin to c and nitrogen to c values for generic input classes param <- readSource("IPCC", subtype = "residues_table5p5b", convert = FALSE) generic <- "Generic value for crops not indicated below" @@ -49,6 +49,9 @@ calcCarbonInputMultiplier <- function() { setNames(dimSums(weight, dim = 3), "generic"), collapseNames(calcOutput("CarbonManure", aggregate = FALSE)[, "y1995", "c"])) + getSets(out, fulldim = FALSE)[1] <- "x.y.iso" + getSets(weight, fulldim = FALSE)[1] <- "x.y.iso" + return(list(x = out, weight = weight, unit = "tC per ha", diff --git a/R/calcCarbonLitter.R b/R/calcCarbonLitter.R index c0159c8..9faca31 100644 --- a/R/calcCarbonLitter.R +++ b/R/calcCarbonLitter.R @@ -27,13 +27,13 @@ calcCarbonLitter <- function(lpjmlNatveg = "LPJmL4_for_MAgPIE_44ac93de", # load and convert LPjmL data litfallc <- calcOutput("LPJmL_new", version = lpjmlNatveg, climatetype = climatetype, stage = stage, - subtype = "alitterfallc", aggregate = FALSE, ) + subtype = "alitterfallc", aggregate = FALSE, ) litburnc <- calcOutput("LPJmL_new", version = lpjmlNatveg, climatetype = climatetype, stage = stage, - subtype = "alitterburnc", aggregate = FALSE) + subtype = "alitterburnc", aggregate = FALSE) litfallcWood <- calcOutput("LPJmL_new", version = lpjmlNatveg, climatetype = climatetype, stage = stage, - subtype = "alitterfallc_wood", aggregate = FALSE) + subtype = "alitterfallc_wood", aggregate = FALSE) litburncWood <- calcOutput("LPJmL_new", version = lpjmlNatveg, climatetype = climatetype, stage = stage, - subtype = "alitterburnc_wood", aggregate = FALSE) + subtype = "alitterburnc_wood", aggregate = FALSE) litfallc <- toolConditionalReplace(litfallc - litburnc, "<0", 0) litfallcWood <- toolConditionalReplace(litfallcWood - litburncWood, "<0", 0) @@ -61,7 +61,7 @@ calcCarbonLitter <- function(lpjmlNatveg = "LPJmL4_for_MAgPIE_44ac93de", climatetype = ifelse(fixFpc, "GSWP3-W5E5:historical", climatetype), stage = ifelse(fixFpc & (mode != "historicalSpinup"), "smoothed", stage), subtype = "fpc", aggregate = FALSE)[, , "fraction natural vegetation", invert = TRUE] - if(fixFpc) fpc <- toolFillYears(fpc, years = getYears(out)) + if (fixFpc) fpc <- toolFillYears(fpc, years = getYears(out)) woodyPfts <- getNames(fpc[, , "grass", invert = TRUE, pmatch = TRUE]) treeFrac <- dimSums(fpc[, , woodyPfts], dim = 3) @@ -69,7 +69,7 @@ calcCarbonLitter <- function(lpjmlNatveg = "LPJmL4_for_MAgPIE_44ac93de", # Use turnover parameters per pft to calculate leaf fraction in soft tissue litter # (soft tissue = fine roots + leaves) lpjmlPar <- readSource("LPJmL_par", subtype = "pft_lpjml4", - convert = FALSE)[, , "sapwood", invert = TRUE, pmatch = TRUE] + convert = FALSE)[, , "sapwood", invert = TRUE, pmatch = TRUE] leafFrac <- collapseDim(lpjmlPar[, , "turnover_root"] / dimSums(lpjmlPar, dim = 3.2)) # Load data from Brovkin et al. on leaf parameters (lignin and nitrogen concentration (per dry matter)) @@ -113,6 +113,9 @@ calcCarbonLitter <- function(lpjmlNatveg = "LPJmL4_for_MAgPIE_44ac93de", weight <- calcOutput("LanduseInitialisation", aggregate = FALSE, cellular = TRUE, years = "y1995") weight <- collapseDim(dimSums(weight[, , "crop", invert = TRUE], dim = 3)) + getSets(out, fulldim = FALSE)[1] <- "x.y.iso" + getSets(weight, fulldim = FALSE)[1] <- "x.y.iso" + return(list(x = out, weight = weight, unit = "tC per ha, tn per tc, tLn per tC", diff --git a/R/calcCarbonManure.R b/R/calcCarbonManure.R index dfc0e9c..b1eedfc 100644 --- a/R/calcCarbonManure.R +++ b/R/calcCarbonManure.R @@ -26,7 +26,7 @@ calcCarbonManure <- function() { # Cut high input values at 10 tC/ha manureInput <- toolConditionalReplace(manureInput, conditions = "> 10", replaceby = 10) # Load parameters for lignin and nitrogen - param <- calcOutput("ParamManure", source = "IPCC", aggregate = FALSE) + param <- calcOutput("ParamManure", input = "IPCC", aggregate = FALSE) kli <- findset("kli") attributes <- c("c", "LC", "NC") @@ -36,6 +36,7 @@ calcCarbonManure <- function() { out[, , "c"] <- manureInput out[, , c("NC", "LC")] <- param + getSets(out, fulldim = FALSE)[1] <- "x.y.iso" return(list(x = out, weight = NULL, diff --git a/R/calcCarbonResidues.R b/R/calcCarbonResidues.R index 0669e38..74e01bc 100644 --- a/R/calcCarbonResidues.R +++ b/R/calcCarbonResidues.R @@ -17,8 +17,10 @@ calcCarbonResidues <- function() { kcr2kres <- toolGetMapping("mappingCrop2Residue.csv", type = "sectoral", where = "mrcommons") residueBiomassBg <- toolAggregate(residueBiomass, rel = kcr2kres, from = "kcr", to = "kres", dim = 3.2)[, , "bg"][, , "c"] - callResFB <- function() calcOutput("ResFieldBalancePast", cellular = TRUE, - products = "kres", aggregate = FALSE) + callResFB <- function() { + calcOutput("ResFieldBalancePast", cellular = TRUE, + products = "kres", aggregate = FALSE) + } residueRecyclingAg <- add_dimension(collapseNames(callResFB()[, , "recycle"][, , "c"]), dim = 3.1, add = "residues", nm = "ag") @@ -30,7 +32,7 @@ calcCarbonResidues <- function() { ## Cut high input values at 10 tC/ha residueRecycling <- toolConditionalReplace(residueRecycling, conditions = "> 10", replaceby = 10) # Load parameters for lignin and nitrogen and aggregate them to kres - param <- calcOutput("ParamResidues", aggregate = FALSE, source = "IPCC+woody") + param <- calcOutput("ParamResidues", aggregate = FALSE, input = "IPCC+woody") weight <- collapseNames(dimSums(residueBiomass, dim = "residues")) param <- toolAggregate(param, weight = weight, rel = kcr2kres, from = "kcr", to = "kres", dim = 3.1) @@ -41,6 +43,7 @@ calcCarbonResidues <- function() { out[, , "c"] <- residueRecycling out[, , c("LC", "NC")] <- param + getSets(out, fulldim = FALSE)[1] <- "x.y.iso" return(list(x = out, weight = NULL, diff --git a/R/calcDecayFuture.R b/R/calcDecayFuture.R index 003e52a..e99134d 100644 --- a/R/calcDecayFuture.R +++ b/R/calcDecayFuture.R @@ -25,7 +25,6 @@ calcDecayFuture <- function(lpjmlNatveg = "LPJmL4_for_MAgPIE_44ac93de", climatetype = "GSWP3-W5E5:historical") { - # Create settings for LPJmL/GCM from version and climatetype argument cfg <- toolClimateInputVersion(lpjmlVersion = lpjmlNatveg, climatetype = climatetype) @@ -45,7 +44,7 @@ calcDecayFuture <- function(lpjmlNatveg = "LPJmL4_for_MAgPIE_44ac93de", } weight <- collapseDim(calcOutput("SoilCarbon", aggregate = FALSE, years = "y1995", - lpjmlNatveg = lpjmlNatveg, climatetype = cfg$baselineHist)) + lpjmlNatveg = lpjmlNatveg, climatetype = cfg$baselineHist)) weight <- mbind(add_dimension(collapseDim(weight[, , "crop"] + 10^(-10)), dim = 3.2, add = "tillage", nm = "fulltill"), add_dimension(collapseDim(weight[, , "crop"] + 10^(-10)), @@ -53,9 +52,11 @@ calcDecayFuture <- function(lpjmlNatveg = "LPJmL4_for_MAgPIE_44ac93de", add_dimension(collapseDim(weight[, , "natveg"] + 10^(-10)), dim = 3.2, add = "tillage", nm = "notill")) - return(list(x = out, - weight = weight, - unit = "per yr", - description = "Decay rate for all SOC sub-pool per year", - isocountries = FALSE)) + getSets(out, fulldim = FALSE)[1] <- "x.y.iso" + getSets(weight, fulldim = FALSE)[1] <- "x.y.iso" + return(list(x = out, + weight = weight, + unit = "per yr", + description = "Decay rate for all SOC sub-pool per year", + isocountries = FALSE)) } diff --git a/R/calcDecayRaw.R b/R/calcDecayRaw.R index fd194a7..58a6495 100644 --- a/R/calcDecayRaw.R +++ b/R/calcDecayRaw.R @@ -43,11 +43,11 @@ calcDecayRaw <- function(lpjmlNatveg = "LPJmL4_for_MAgPIE_44ac93de", # check years and dims if (!is.null(out) && (is.null(getYears(out)) || is.null(getYears(tmp)))) { tmp <- magpie_expand(tmp, collapseDim(out[, , 1], dim = 3)) - out <- magpie_expand(out, collapseDim(tmp, dim =3)) + out <- magpie_expand(out, collapseDim(tmp, dim = 3)) } years <- intersect(getYears(tmp), getYears(out)) - if(!is.null(years)){ + if (!is.null(years)) { out <- out[, years, ] tmp <- tmp[, years, ] } @@ -95,14 +95,14 @@ calcDecayRaw <- function(lpjmlNatveg = "LPJmL4_for_MAgPIE_44ac93de", cellSandFrac <- calcOutput("SandFrac", aggregate = FALSE) # harmonize years - .getCommonYears <- function(listOfYearVectors){ - nullIndex <- which(sapply(listOfYearVectors, is.null)) - if(length(nullIndex) != 0) { + .getCommonYears <- function(listOfYearVectors) { + nullIndex <- which(vapply(listOfYearVectors, is.null, logical(1))) + if (length(nullIndex) != 0) { vcat(1, "There are objects with no years (NULL) provided.") listOfYearVectors <- listOfYearVectors[-nullIndex] } commonYears <- Reduce(intersect, listOfYearVectors) - if(length(commonYears) == 0) vcat(0, "There are no common years objects provided.") + if (length(commonYears) == 0) vcat(0, "There are no common years objects provided.") return(commonYears) } @@ -110,9 +110,9 @@ calcDecayRaw <- function(lpjmlNatveg = "LPJmL4_for_MAgPIE_44ac93de", getYears(cellTillFactor), getYears(cellWfactor))) - if(!is.null(getYears(cellTempFactor))) cellTempFactor <- cellTempFactor[, years, ] - if(!is.null(getYears(cellTillFactor))) cellTillFactor <- cellTillFactor[, years, ] - if(!is.null(getYears(cellWfactor))) cellWfactor <- cellWfactor[, years, ] + if (!is.null(getYears(cellTempFactor))) cellTempFactor <- cellTempFactor[, years, ] + if (!is.null(getYears(cellTillFactor))) cellTillFactor <- cellTillFactor[, years, ] + if (!is.null(getYears(cellWfactor))) cellWfactor <- cellWfactor[, years, ] activeDecay <- param[, , "kfaca"] * cellWfactor * cellTempFactor * cellTillFactor * (param[, , "k3par1"] + param[, , "k3par2"] * cellSandFrac) @@ -123,12 +123,13 @@ calcDecayRaw <- function(lpjmlNatveg = "LPJmL4_for_MAgPIE_44ac93de", slowDecay <- .clean(slowDecay, "slow", "sub") passiveDecay <- .clean(passiveDecay, "passive", "sub") - if(length(getNames(passiveDecay)) != length(getNames(activeDecay))) { + if (length(getNames(passiveDecay)) != length(getNames(activeDecay))) { passiveDecay <- dimOrder(magpie_expand(passiveDecay, collapseDim(activeDecay[, , "rainfed"], keepdim = 3.3)), - perm = c(2,3,1), dim = 3) + perm = c(2, 3, 1), dim = 3) } decay <- magpiesort(mbind(activeDecay, slowDecay, passiveDecay)) + getSets(decay, fulldim = FALSE)[1] <- "x.y.iso" return(list(x = decay, weight = NULL, diff --git a/R/calcIrrigationMonth.R b/R/calcIrrigationMonth.R deleted file mode 100644 index ce584d1..0000000 --- a/R/calcIrrigationMonth.R +++ /dev/null @@ -1,19 +0,0 @@ -#' @title calcIrrigationMonth -#' @description This function calculates the length of irrigation period crop type specific -#' -#' @return magpie object in cellular resolution -#' @author Kristine Karstens -#' -#' @examples -#' \dontrun{ calcOutput("IrrigationMonth", aggregate = FALSE) } -#' -#' @import madrat -#' @import magclass -#' @import mrcommons - -calcIrrigationMonth <- function() { - - sdate <- readSource("LPJmL", subtype="LPJmL5:CRU_4.sdate", convert="onlycorrect") - hdate <- readSource("LPJmL", subtype="LPJmL5:CRU_4.hdate", convert="onlycorrect") - -} diff --git a/R/calcLanduse.R b/R/calcLanduse.R index 9fc408a..5768846 100644 --- a/R/calcLanduse.R +++ b/R/calcLanduse.R @@ -23,6 +23,8 @@ calcLanduse <- function(period = "states_1900to2010", output = "total") { landuse <- toolLanduseChange(calcOutput("Landuse", period = period, aggregate = FALSE)) } + getSets(landuse, fulldim = FALSE)[1] <- "x.y.iso" + return(list(x = landuse, weight = NULL, unit = "Mha", diff --git a/R/calcParamManure.R b/R/calcParamManure.R index 9754240..dc5796c 100644 --- a/R/calcParamManure.R +++ b/R/calcParamManure.R @@ -1,7 +1,7 @@ #' @title calcParamManure #' @description Bring all parameter settings (lignin, nitrogen) for residues together #' -#' @param source "IPCC" for IPCC Guideline values +#' @param input "IPCC" for IPCC Guideline values #' @return List of magpie object with results on global level, unit and description. #' @author Kristine Karstens #' @@ -9,12 +9,11 @@ #' \dontrun{ #' calcOutput("ParamManure") #' } - -calcParamManure <- function(source = "IPCC") { +calcParamManure <- function(input = "IPCC") { kli <- magpiesets::findset("kli") c2dm <- 0.45 - if(grepl("IPCC", source)){ + if (grepl("IPCC", input)) { param <- readSource("IPCC", subtype = "manure_table5p5c", convert = FALSE) @@ -26,7 +25,7 @@ calcParamManure <- function(source = "IPCC") { out[, , "LC"] <- param[, , "LC_dm"] / c2dm / 100 } else { - stop("'source' unknown.") + stop("'input' unknown.") } return(list(x = out, diff --git a/R/calcParamResidues.R b/R/calcParamResidues.R index 88bdabd..736e835 100644 --- a/R/calcParamResidues.R +++ b/R/calcParamResidues.R @@ -1,8 +1,8 @@ #' @title calcParamResidues #' @description Bring all parameter settings (lignin, nitrogen) for residues together #' -#' @param source "IPCC" for IPCC Guideline values -#' "IPCC+woody" for IPCC Guideline values + Feedipedia for woody +#' @param input "IPCC" for IPCC Guideline values +#' "IPCC+woody" for IPCC Guideline values + Feedipedia for woody #' @return List of magpie object with results on global level, unit and description. #' @author Kristine Karstens #' @@ -10,13 +10,11 @@ #' \dontrun{ #' calcOutput("ParamResidues") #' } - -calcParamResidues <- function(source = "IPCC+woody") { +calcParamResidues <- function(input = "IPCC+woody") { kcr <- magpiesets::findset("kcr") c2dm <- 0.45 - if(grepl("IPCC", source)){ - + if (grepl("IPCC", input)) { # Load IPCC parameters and create mapping param <- readSource("IPCC", subtype = "residues_table5p5b", convert = FALSE) generic <- "Generic value for crops not indicated below" @@ -44,20 +42,20 @@ calcParamResidues <- function(source = "IPCC+woody") { names <- as.vector(outer(kcr, c("NC", "LC"), paste, sep = ".")) out <- new.magpie("GLO", NULL, names, fill = 0, sets = c("region", "year", "kcr", "attributes")) - for(k in kcr) { + for (k in kcr) { # Take mean value over all categories and divide by carbon density - out[ , , k] <- as.vector(dimSums(param[ , , kcr2T5p5B[[k]]], dim = 3.1) / c2dm / length(kcr2T5p5B[[k]])) + out[, , k] <- as.vector(dimSums(param[, , kcr2T5p5B[[k]]], dim = 3.1) / c2dm / length(kcr2T5p5B[[k]])) } - if(source == "IPCC+woody"){ + if (input == "IPCC+woody") { # Assume higher lignin content of residue for crop trees woodyTypes <- c("betr", "oilpalm") - LCwoody <- 0.145 / c2dm # 0.145 lignin content from feedipedia.org (mean value of oil palm residues) - out[,, "LC"][,, woodyTypes] <- LCwoody + lcWoody <- 0.145 / c2dm # 0.145 lignin content from feedipedia.org (mean value of oil palm residues) + out[, , "LC"][, , woodyTypes] <- lcWoody } } else { - stop("'source' unknown.") + stop("'input' unknown.") } return(list(x = out, diff --git a/R/calcSOCDebt.R b/R/calcSOCDebt.R deleted file mode 100644 index c0707d5..0000000 --- a/R/calcSOCDebt.R +++ /dev/null @@ -1,27 +0,0 @@ -#' @title calcSOCDebt -#' @description This function calculates and return SOC stocks and debts from Soil Carbon Debt github repo -#' -#' @return magpie object in cellular resolution -#' @author Kristine Karstens -#' -#' @seealso -#' \code{\link[mrvalidation]{readSoilCarbonDebt}} -#' -#' @examples -#' \dontrun{ calcOutput("calcSOCDebt", aggregate = FALSE) } - -calcSOCDebt <- function() { - - x <- toolCoord2Isocell(readSource("SoilCarbonDebt", convert = "onlycorrect")) - x <- x[ , , "SOCS_noLU", invert = TRUE] - x[ , , "SOCS_noLU"] - - area <- calcOutput("LUH2v2", landuse_types = "LUH2v2", irrigation = FALSE, cellular = TRUE, aggregate = FALSE) - area <- setYears(dimSums(area[, 2010, ], dim = 3), NULL) - - return(list( - x = x, - weight = area, - unit = "tons C per ha", - description = "Soil Carbon Debt according to Sanderman et al., 2017", - isocountries = FALSE)) -} diff --git a/R/calcSOCPointData.R b/R/calcSOCPointData.R deleted file mode 100644 index e0fd2ab..0000000 --- a/R/calcSOCPointData.R +++ /dev/null @@ -1,23 +0,0 @@ -#' @title calcSOCPointData -#' @description This function return SOC point data for validation from Sanderman et al., 2017 -#' -#' @return magpie object in cellular resolution -#' @author Kristine Karstens -#' -#' @seealso -#' \code{\link[mrsoil]{readSanderman}} -#' -#' @examples -#' \dontrun{ calcOutput("calcSOCPointData", aggregate = FALSE) } - -calcSOCPointData <- function() { - - x <- readSource("Sanderman") - - return(list( - x = x, - weight = NULL, - unit = "tons C per ha", - description = "SOC point data for validation from Sanderman et al., 2017", - isocountries = FALSE)) -} diff --git a/R/calcSandFrac.R b/R/calcSandFrac.R index 60e66de..fa9dc14 100644 --- a/R/calcSandFrac.R +++ b/R/calcSandFrac.R @@ -31,6 +31,8 @@ calcSandFrac <- function() { getNames(sandfrac0to30) <- "sandfrac0to30" getYears(sandfrac0to30) <- NULL + getSets(sandfrac0to30, fulldim = FALSE)[1] <- "x.y.iso" + return(list(x = sandfrac0to30, weight = NULL, unit = "", diff --git a/R/calcSoilCarbon.R b/R/calcSoilCarbon.R index 00fede2..86b7ce9 100644 --- a/R/calcSoilCarbon.R +++ b/R/calcSoilCarbon.R @@ -39,6 +39,8 @@ calcSoilCarbon <- function(output = "actualstate", decay, landuse)[, , output] + getSets(out, fulldim = FALSE)[1] <- "x.y.iso" + return(list(x = out, weight = NULL, unit = "Mt C", diff --git a/R/calcSoilCarbonSpinup.R b/R/calcSoilCarbonSpinup.R index 73379aa..55e4d31 100644 --- a/R/calcSoilCarbonSpinup.R +++ b/R/calcSoilCarbonSpinup.R @@ -52,6 +52,8 @@ calcSoilCarbonSpinup <- function(lpjmlNatveg = "LPJmL4_for_MAgPIE_44ac93de", soilCarbonInit <- tmp[, tail(tmpYears, 1), c("actualstate", "naturalstate")] } + getSets(soilCarbonInit, fulldim = FALSE)[1] <- "x.y.iso" + return(list(x = soilCarbonInit, weight = NULL, unit = "Mt C", diff --git a/R/calcSteadyState.R b/R/calcSteadyState.R index 909204b..914122e 100644 --- a/R/calcSteadyState.R +++ b/R/calcSteadyState.R @@ -70,7 +70,7 @@ calcSteadyState <- function(lpjmlNatveg = "LPJmL4_for_MAgPIE_44ac93de", mode = "historicalSpinup", aggregate = FALSE) steadyState <- magpiesort(collapseNames(toolConditionalReplace(alpha / decay, "is.na()", 0))) - + getSets(steadyState, fulldim = FALSE)[1] <- "x.y.iso" ############################################################### return(list(x = steadyState, diff --git a/R/calcTempEffectDecomposition.R b/R/calcTempEffectDecomposition.R index eb228dd..1dd4f80 100644 --- a/R/calcTempEffectDecomposition.R +++ b/R/calcTempEffectDecomposition.R @@ -41,6 +41,8 @@ calcTempEffectDecomposition <- function(lpjmlNatveg = "LPJmL4_for_MAgPIE_44ac93d cellTmonthFactor <- ifelse(cellTemp > 45, 0, cellTmonthFactor) cellTfactor <- dimSums(cellTmonthFactor, dim = 3) / 12 + getSets(cellTfactor, fulldim = FALSE)[1] <- "x.y.iso" + return(list(x = cellTfactor, weight = NULL, # only cellular level supported unit = "", diff --git a/R/calcWaterEffectDecomposition.R b/R/calcWaterEffectDecomposition.R index 9f66253..dc3ed4d 100644 --- a/R/calcWaterEffectDecomposition.R +++ b/R/calcWaterEffectDecomposition.R @@ -101,6 +101,8 @@ calcWaterEffectDecomposition <- function(irrigation = "mixedirrig", stop("Irrigation setting is unknown. Please use: 'mixedirrig','rainfed' or 'irrigated'.") } + getSets(cellWfactor, fulldim = FALSE)[1] <- "x.y.iso" + return(list(x = cellWfactor, weight = NULL, # only cellular level supported unit = "", diff --git a/R/correctCRU.R b/R/correctCRU.R deleted file mode 100644 index e0e502f..0000000 --- a/R/correctCRU.R +++ /dev/null @@ -1,29 +0,0 @@ -#' @title correctCRU -#' @description Correct CRU content -#' @param x magpie object provided by the read function -#' @param subtype Switch between diffrent input -#' @return List of magpie objects with results on cellular level, weight, unit and description. -#' @author Kristine Karstens -#' @seealso -#' \code{\link{readCRU}}, -#' \code{\link{read.LPJ_input}} -#' @examples -#' -#' \dontrun{ -#' readSource("CRU", subtype="precipitation", convert="onlycorrect") -#' } -#' -#' @import madrat -#' @import magclass -#' @importFrom lpjclass read.LPJ_input - -correctCRU <- function(x, subtype){ - - x <- toolConditionalReplace(x, conditions = c("is.na()"), replaceby = 0) - if(subtype %in% c("precipitation", "potential_evap")){ - x <- toolConditionalReplace(x, conditions = c("<0"), replaceby = 0) - } - x <- toolCell2isoCell(x) - - return(x) -} diff --git a/R/downloadCENTURY.R b/R/downloadCENTURY.R deleted file mode 100644 index e4497cf..0000000 --- a/R/downloadCENTURY.R +++ /dev/null @@ -1,30 +0,0 @@ -#' @title downloadCENTURY -#' @description This function download the CENTURY model (available at 'https://www2.nrel.colostate.edu/projects/century/century.tar.Z') -#' -#' @author Kristine Karstens -#' -#' @seealso -#' \code{\link{downloadCENTURY}} -#' -#' @examples -#' \dontrun{ downloadSource("CENTURY") } - -downloadCENTURY <- function() { - - settings <- list(title = "CENTURY model obtained from https://www2.nrel.colostate.edu/projects/century/obtain2.htm", - url = "https://www2.nrel.colostate.edu/projects/century/century.tar.Z", - doi = "") - - download.file(settings$url, destfile="century.tar.Z", mode="wb") # use cent40_src.zip for windows - untar("century.tar.Z", files = "PARAMETER_FILES/") - unlink("century.tar.Z") - - return(list(url = settings$url, - doi = settings$doi, - title = settings$title, - author = "Colorado State University", - version = NULL, - release_date = "2000-06-11", - license = NULL, - reference = NULL)) -} diff --git a/R/imports.R b/R/imports.R index 43b9dbe..e4fda6e 100644 --- a/R/imports.R +++ b/R/imports.R @@ -1,4 +1,4 @@ # Generated by lucode2: do not edit by hand -#' @import magclass madrat mrcommons mrvalidation mrmagpie +#' @import magclass madrat mrcommons mrdrivers NULL diff --git a/R/readBrovkin.R b/R/readBrovkin.R index 5e59865..1819310 100644 --- a/R/readBrovkin.R +++ b/R/readBrovkin.R @@ -6,12 +6,12 @@ #' @author Kristine Karstens #' @examples #' \dontrun{ -#' readSource("Brovkin", convert = FALSE) +#' readSource("Brovkin", convert = FALSE) #' } #' #' @importFrom utils read.csv -readBrovkin <- function(){ +readBrovkin <- function() { out <- as.magpie(read.csv("table1_litter_decomposition_parameters.csv")) diff --git a/R/readCENTURY.R b/R/readCENTURY.R deleted file mode 100644 index d6d6936..0000000 --- a/R/readCENTURY.R +++ /dev/null @@ -1,50 +0,0 @@ -#' @title readCENTURY -#' @description Read parameter files in CENTURY model and return n/c- and lg/c-ratios -#' -#' @param subtype Switch between different parameter files -#' @return List of magpie objects with results on global level -#' -#' @author Kristine Karstens -#' @examples -#' \dontrun{ -#' readSource("CENTURY", subtype="tree") -#' } -#' -#' @importFrom reshape2 colsplit -#' @importFrom utils untar write.csv - -readCENTURY <- function(subtype="tree"){ - - files <- c(tree="tree.100") - file <- toolSubtypeSelect(subtype,files) - folder <- grep(".zip", list.files(), value=TRUE) - x <- readLines(paste0("PARAMETER_FILES/", file)) - - out <- NULL - full <- NULL - type <- NULL - - for(i in 1:(length(x)/112)){ - - tmp <- x[(1:112)+112*(i-1)] - header <- trimws(colsplit(tmp[1], " .", names=c("short","comment"))) - plantparts <- c("leaves", "fine_roots", "fine_branches", "large_wood", "coarse_roots") - parameters <- c("nmin","nmax","lg") - cratio <- new.magpie("GLO","y2000", names = as.vector(outer(parameters,plantparts, paste, sep="."))) - cratio[,,"nmin"] <- 1/unlist(colsplit(trimws(tmp)[c( 9,12,15,18,21)], " .", names=c("value","name"))[1]) - cratio[,,"nmax"] <- 1/unlist(colsplit(trimws(tmp)[c(24,27,30,33,36)], " .", names=c("value","name"))[1]) - cratio[,,"lg"] <- unlist(colsplit(trimws(tmp)[c(89:93)], " .", names=c("value","name"))[1]) - - tmp_out <- new.magpie("GLO",NULL, names = paste(header[1],as.vector(outer(plantparts, - c("nc_ratio","lgc_ratio"), paste, sep=".")), sep=".")) - tmp_out[,,"nc_ratio"] <- magpply(cratio[,,c("nmin","nmax")], mean, 3.2) - tmp_out[,,"lgc_ratio"] <- cratio[,,"lg"] - - out <- mbind(out, tmp_out) - full <- mbind(full, add_dimension(cratio, add="type", nm=header[1])) - type <- rbind(type, paste(header,collapse = " - ")) - write.csv(type, "TreeTypes.csv") - } - - return(out) -} diff --git a/R/readCRU.R b/R/readCRU.R deleted file mode 100644 index 3ceaf9a..0000000 --- a/R/readCRU.R +++ /dev/null @@ -1,67 +0,0 @@ -#' @title readCRU -#' @description Read CRU content -#' @param subtype Switch between different input -#' @return List of magpie objects with results on cellular level, weight, unit and description. -#' @author Kristine Karstens -#' @seealso -#' \code{\link[mrcommons]{readLPJmL}}, -#' \code{\link[lpjclass]{read.LPJ_input}} -#' @examples -#' -#' \dontrun{ -#' readSource("CRU", subtype="precipitation") -#' } -#' -#' @import madrat -#' @import magclass -#' @importFrom lpjclass read.LPJ_input -#' @importFrom ncdf4 nc_open ncvar_get - -readCRU <- function(subtype="precipitation"){ - - types <- c(precipitation = "pre", - temperature = "tmp", - potential_evap = "pet") - - type <- toolSubtypeSelect(subtype,types) - folder <- "CRU4p02/" - file <- grep(type, list.files(folder), value=TRUE) - years <- as.numeric(unlist(regmatches(file, gregexpr("\\d{4}",file)))) - format <- unlist(regmatches(file, gregexpr("\\.[a-z]*$",file))) - - print(file) - print(years) - - if(format == ".clm"){ - - x <- read.LPJ_input(file_name=paste0(folder,file), out_years=paste0("y",years[1]:years[2])) - x <- collapseNames(as.magpie(x)) - getNames(x) <- c("jan","feb","mar","apr","mai","jun","jul","aug","sep","oct","nov","dec") - - } else if(format == ".nc"){ - - nc.file <- ncdf4::nc_open(paste0(folder,file)) - nc.data <- ncdf4::ncvar_get(nc.file, type) - nc.lon <- ncdf4::ncvar_get(nc.file,"lon") - nc.lat <- ncdf4::ncvar_get(nc.file,"lat") - - #Load celliso names for 1:59199 magpie cells - cellNames <- rownames(magpie_coord) - ndays <- clean_magpie(as.magpie(c( jan=31, feb=28, mar=31, apr=30, mai=31, jun=30, jul=31, aug=31, sep=30, oct=31, nov=30, dec=31))) - years <- seq(years[1],years[2],1) - x <- as.array(new.magpie(cellNames, years, getNames(ndays) ,fill=NA)) - - for (j in 1:59199) { - ilon <- which(magpie_coord[j,1]==nc.lon) - ilat <- which(magpie_coord[j,2]==nc.lat) - for(a in 1:length(years)){ - x[j,a,] <- nc.data[ilon, ilat, (a-1)*12+(1:12)] - } - } - - # multiply number of days per month to get monthly data - x <- as.magpie(x)*ndays - } - - return(x) -} diff --git a/R/readIPCCSoil.R b/R/readIPCCSoil.R index 0a3a0cb..43f5aaf 100644 --- a/R/readIPCCSoil.R +++ b/R/readIPCCSoil.R @@ -6,7 +6,6 @@ #' @seealso #' \code{\link{downloadIPCCSoil}}, #' @examples -#' #' \dontrun{ #' readSource("IPCCSoil") #' } @@ -15,13 +14,14 @@ #' @importFrom readxl read_excel #' @importFrom utils read.csv -readIPCCSoil <- function(subtype="steady_state") { +readIPCCSoil <- function(subtype = "steady_state") { - if(subtype=="steady_state"){ + if (subtype == "steady_state") { - data <- read_excel("19R_V4_Ch05_Tier2_Steady_State_Method-Spreadsheet_advance.xlsx", sheet="Model Parameters", skip =2) + data <- read_excel("19R_V4_Ch05_Tier2_Steady_State_Method-Spreadsheet_advance.xlsx", + sheet = "Model Parameters", skip = 2) out <- new.magpie(names = as.vector(data$Parmeter), sets = c("region", "year", "data")) - out[,,as.vector(data$Parmeter)] <- as.numeric(data$Default) + out[, , as.vector(data$Parmeter)] <- as.numeric(data$Default) } diff --git a/R/readLPJmL_par.R b/R/readLPJmL_par.R index ec3f2de..8d1a4ca 100644 --- a/R/readLPJmL_par.R +++ b/R/readLPJmL_par.R @@ -7,12 +7,12 @@ #' @author Kristine Karstens #' @examples #' \dontrun{ -#' readSource("LPJmL_par", subtype="pft_lpjml4") +#' readSource("LPJmL_par", subtype = "pft_lpjml4") #' } #' #' @importFrom jsonlite fromJSON -readLPJmL_par <- function(subtype = "pft_lpjml4"){ +readLPJmL_par <- function(subtype = "pft_lpjml4") { #nolint:object_name_linter files <- c(pft_lpjml4 = "pft_lpjml4.js", pft_lpjml5 = "pft_lpjml5.js") @@ -20,7 +20,7 @@ readLPJmL_par <- function(subtype = "pft_lpjml4"){ file <- toolSubtypeSelect(subtype, files) pftpar <- jsonlite::fromJSON(file) pftpar <- do.call(data.frame, subset(pftpar, pftpar$cultivation_type == 0, - select = c("name", "turnover"))) + select = c("name", "turnover"))) names(pftpar) <- gsub("\\.", "_", names(pftpar)) out <- as.magpie(pftpar) diff --git a/R/readSanderman.R b/R/readSanderman.R deleted file mode 100644 index 535b56f..0000000 --- a/R/readSanderman.R +++ /dev/null @@ -1,42 +0,0 @@ -#' @title readSanderman -#' @description Read validation data from Sanderman et al., 2017 -#' -#' @return List of magpie objects with results on cellular level, weight, unit and description. -#' @author Kristine Karstens -#' -#' @examples -#' \dontrun{ -#' readSource("Sanderman") -#' } -#' -#' @import madrat -#' @importFrom readxl read_excel -#' @importFrom magpiesets Cell2Country -#' @importFrom stats complete.cases - -readSanderman <- function() { - - data <- as.data.frame(subset(read_excel("remnant_native_SOC_database_for_release.xlsx", sheet = "sites"), - select = c("Latitude", "Longitude", "Native/Ag/Restored", "30 cm SOC"))) - data$ID <- c(1:nrow(data)) - - raster2half <- function(x) { - return(trunc(x * 2) / 2 + sign(x) * 0.25) - } - data$lat <- raster2half(data$Latitude) - data$lon <- raster2half(data$Longitude) - - data <- data[complete.cases(data), ] - names(data) <- c("Latitude", "Longitude", "Native", "SOC", "ID", "lat", "lon") - - magpie_coord <- Cell2Country() - data <- subset(merge(magpie_coord, data, by = c("lon", "lat")), - select = c("Longitude", "Latitude", "Native", "celliso", "SOC", "ID")) - data$Native <- 1*(data$Native == "Native") - data$celliso <- paste(data$celliso, data$ID, sep = ".") - - out <- new.magpie(data$celliso, NULL, names = names(data)[-c(4)], - fill = as.matrix(data[, c(1:3, 5:6)]), - sets = c("iso.N", "years", "data")) - return(out) -} diff --git a/R/toolCarbonInputMultiplier.R b/R/toolCarbonInputMultiplier.R index acd5a5f..1f4faac 100644 --- a/R/toolCarbonInputMultiplier.R +++ b/R/toolCarbonInputMultiplier.R @@ -19,8 +19,7 @@ toolCarbonInputMultiplier <- function(inputProp, soilParam, f4act2slo, f2struc2act) { coords <- FALSE - if(any(hasCoords(inputProp) | hasCoords(soilParam) | - hasCoords(f4act2slo) | hasCoords(f2struc2act))) { + if (any(hasCoords(inputProp) | hasCoords(soilParam) | hasCoords(f4act2slo) | hasCoords(f2struc2act))) { coords <- TRUE } # empirical parameter to estimate metabolic fraction of residue input (intercept) @@ -94,12 +93,14 @@ toolCarbonInputMultiplier <- function(inputProp, soilParam, f4act2slo, f2struc2a slowIn * soilParam[, , "f6"] passiveIn <- collapseNames(passiveIn) - .prepareOut <- function(x, nm){add_dimension(collapseNames(x), dim = 3.1, add = "pool", nm = nm)} + .prepareOut <- function(x, nm) { + add_dimension(collapseNames(x), dim = 3.1, add = "pool", nm = nm) + } out <- mbind(.prepareOut(activeIn, nm = "active"), .prepareOut(slowIn, nm = "slow"), .prepareOut(passiveIn, nm = "passive")) - if(coords) getSets(out, fulldim = FALSE)[1] <- "x.y.iso" + if (coords) getSets(out, fulldim = FALSE)[1] <- "x.y.iso" return(out) } diff --git a/R/toolFreezeAverage.R b/R/toolFreezeAverage.R deleted file mode 100644 index 04fde9f..0000000 --- a/R/toolFreezeAverage.R +++ /dev/null @@ -1,20 +0,0 @@ -#' @title toolFreezeAverage -#' @description Calculates the 10 year average and freezes the effect for all years after -#' -#' @param x variable to freeze -#' @param freeze_year start of freeze period -#' @return magpie object wth froozen effect -#' @author Kristine Karstens -#' -#' @importFrom magclass getYears setYears -#' @importFrom madrat toolTimeAverage - -toolFreezeAverage <- function(x, freeze_year){ - - reset_years <- getYears(x, as.integer=TRUE) > freeze_year - avg <- toolTimeAverage(x[,seq(freeze_year-5,freeze_year+5,1),], 11) - x[,reset_years,] <- setYears(avg[,rep(1,sum(reset_years)),], getYears(x[,reset_years,])) - - return(x) -} - diff --git a/R/toolLanduseChange.R b/R/toolLanduseChange.R index 9f26887..06dcba0 100644 --- a/R/toolLanduseChange.R +++ b/R/toolLanduseChange.R @@ -5,17 +5,18 @@ #' @return List of magpie object with results on cellular level #' @author Kristine Karstens -toolLanduseChange <- function(landuse){ +toolLanduseChange <- function(landuse) { years <- getYears(landuse, as.integer = TRUE) - LanduseChange <- landuse[,years[2:length(years)],] - setYears(landuse[,years[2:length(years)]-1,], years[2:length(years)]) - LanduseChange <- mbind(add_dimension(LanduseChange, dim=3.1, add="change", nm="reduction"), - add_dimension(LanduseChange, dim=3.1, add="change", nm="expansion")) + landuseChange <- + landuse[, years[2:length(years)], ] - + setYears(landuse[, years[2:length(years)] - 1, ], years[2:length(years)]) + landuseChange <- mbind(add_dimension(landuseChange, dim = 3.1, add = "change", nm = "reduction"), + add_dimension(landuseChange, dim = 3.1, add = "change", nm = "expansion")) - LanduseChange[,,"reduction"][LanduseChange[,,"reduction"]>0] <- 0 - LanduseChange[,,"reduction"] <- (-1)*LanduseChange[,,"reduction"] - LanduseChange[,,"expansion"][LanduseChange[,,"expansion"]<0] <- 0 + landuseChange[, , "reduction"][landuseChange[, , "reduction"] > 0] <- 0 + landuseChange[, , "reduction"] <- (-1) * landuseChange[, , "reduction"] + landuseChange[, , "expansion"][landuseChange[, , "expansion"] < 0] <- 0 - return(LanduseChange) + return(landuseChange) } - diff --git a/README.md b/README.md index 7791b25..4fed0a9 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MadRat Soil Organic Carbon Budget Library -R package **mrsoil**, version **1.17.11.9003** +R package **mrsoil**, version **2.0.0** [![CRAN status](https://www.r-pkg.org/badges/version/mrsoil)](https://cran.r-project.org/package=mrsoil) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4317933.svg)](https://doi.org/10.5281/zenodo.4317933) [![R build status](https://github.com/pik-piam/mrsoil/workflows/check/badge.svg)](https://github.com/pik-piam/mrsoil/actions) [![codecov](https://codecov.io/gh/pik-piam/mrsoil/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mrsoil) [![r-universe](https://pik-piam.r-universe.dev/badges/mrsoil)](https://pik-piam.r-universe.dev/builds) @@ -38,7 +38,7 @@ In case of questions / problems please contact Kristine Karstens , R package version 1.17.11.9003, . +Karstens K, Dietrich J (2024). _mrsoil: MadRat Soil Organic Carbon Budget Library_. doi:10.5281/zenodo.4317933 , R package version 2.0.0, . A BibTeX entry for LaTeX users is @@ -47,7 +47,7 @@ A BibTeX entry for LaTeX users is title = {mrsoil: MadRat Soil Organic Carbon Budget Library}, author = {Kristine Karstens and Jan Philipp Dietrich}, year = {2024}, - note = {R package version 1.17.11.9003}, + note = {R package version 2.0.0}, doi = {10.5281/zenodo.4317933}, url = {https://github.com/pik-piam/mrsoil}, } diff --git a/man/calcIrrigationMonth.Rd b/man/calcIrrigationMonth.Rd deleted file mode 100644 index f387d95..0000000 --- a/man/calcIrrigationMonth.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/calcIrrigationMonth.R -\name{calcIrrigationMonth} -\alias{calcIrrigationMonth} -\title{calcIrrigationMonth} -\usage{ -calcIrrigationMonth() -} -\value{ -magpie object in cellular resolution -} -\description{ -This function calculates the length of irrigation period crop type specific -} -\examples{ -\dontrun{ calcOutput("IrrigationMonth", aggregate = FALSE) } - -} -\author{ -Kristine Karstens -} diff --git a/man/calcParamManure.Rd b/man/calcParamManure.Rd index db3cef4..1fcc88c 100644 --- a/man/calcParamManure.Rd +++ b/man/calcParamManure.Rd @@ -4,10 +4,10 @@ \alias{calcParamManure} \title{calcParamManure} \usage{ -calcParamManure(source = "IPCC") +calcParamManure(input = "IPCC") } \arguments{ -\item{source}{"IPCC" for IPCC Guideline values} +\item{input}{"IPCC" for IPCC Guideline values} } \value{ List of magpie object with results on global level, unit and description. diff --git a/man/calcParamResidues.Rd b/man/calcParamResidues.Rd index e0efa98..a2073a9 100644 --- a/man/calcParamResidues.Rd +++ b/man/calcParamResidues.Rd @@ -4,10 +4,10 @@ \alias{calcParamResidues} \title{calcParamResidues} \usage{ -calcParamResidues(source = "IPCC+woody") +calcParamResidues(input = "IPCC+woody") } \arguments{ -\item{source}{"IPCC" for IPCC Guideline values +\item{input}{"IPCC" for IPCC Guideline values "IPCC+woody" for IPCC Guideline values + Feedipedia for woody} } \value{ diff --git a/man/calcSOCDebt.Rd b/man/calcSOCDebt.Rd deleted file mode 100644 index b021fe6..0000000 --- a/man/calcSOCDebt.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/calcSOCDebt.R -\name{calcSOCDebt} -\alias{calcSOCDebt} -\title{calcSOCDebt} -\usage{ -calcSOCDebt() -} -\value{ -magpie object in cellular resolution -} -\description{ -This function calculates and return SOC stocks and debts from Soil Carbon Debt github repo -} -\examples{ - \dontrun{ calcOutput("calcSOCDebt", aggregate = FALSE) } -} -\seealso{ -\code{\link[mrvalidation]{readSoilCarbonDebt}} -} -\author{ -Kristine Karstens -} diff --git a/man/calcSOCPointData.Rd b/man/calcSOCPointData.Rd deleted file mode 100644 index 8f04a12..0000000 --- a/man/calcSOCPointData.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/calcSOCPointData.R -\name{calcSOCPointData} -\alias{calcSOCPointData} -\title{calcSOCPointData} -\usage{ -calcSOCPointData() -} -\value{ -magpie object in cellular resolution -} -\description{ -This function return SOC point data for validation from Sanderman et al., 2017 -} -\examples{ - \dontrun{ calcOutput("calcSOCPointData", aggregate = FALSE) } -} -\seealso{ -\code{\link[mrsoil]{readSanderman}} -} -\author{ -Kristine Karstens -} diff --git a/man/correctCRU.Rd b/man/correctCRU.Rd deleted file mode 100644 index 5589351..0000000 --- a/man/correctCRU.Rd +++ /dev/null @@ -1,33 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/correctCRU.R -\name{correctCRU} -\alias{correctCRU} -\title{correctCRU} -\usage{ -correctCRU(x, subtype) -} -\arguments{ -\item{x}{magpie object provided by the read function} - -\item{subtype}{Switch between diffrent input} -} -\value{ -List of magpie objects with results on cellular level, weight, unit and description. -} -\description{ -Correct CRU content -} -\examples{ - -\dontrun{ - readSource("CRU", subtype="precipitation", convert="onlycorrect") -} - -} -\seealso{ -\code{\link{readCRU}}, -\code{\link{read.LPJ_input}} -} -\author{ -Kristine Karstens -} diff --git a/man/downloadCENTURY.Rd b/man/downloadCENTURY.Rd deleted file mode 100644 index 51fe613..0000000 --- a/man/downloadCENTURY.Rd +++ /dev/null @@ -1,20 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/downloadCENTURY.R -\name{downloadCENTURY} -\alias{downloadCENTURY} -\title{downloadCENTURY} -\usage{ -downloadCENTURY() -} -\description{ -This function download the CENTURY model (available at 'https://www2.nrel.colostate.edu/projects/century/century.tar.Z') -} -\examples{ -\dontrun{ downloadSource("CENTURY") } -} -\seealso{ -\code{\link{downloadCENTURY}} -} -\author{ -Kristine Karstens -} diff --git a/man/readBrovkin.Rd b/man/readBrovkin.Rd index 2efa297..aba3062 100644 --- a/man/readBrovkin.Rd +++ b/man/readBrovkin.Rd @@ -14,7 +14,7 @@ Read parameter files from Brovkin Paper (doi:10.5194/bg-9-565-2012) } \examples{ \dontrun{ - readSource("Brovkin", convert = FALSE) +readSource("Brovkin", convert = FALSE) } } diff --git a/man/readCENTURY.Rd b/man/readCENTURY.Rd deleted file mode 100644 index 2f24eac..0000000 --- a/man/readCENTURY.Rd +++ /dev/null @@ -1,26 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/readCENTURY.R -\name{readCENTURY} -\alias{readCENTURY} -\title{readCENTURY} -\usage{ -readCENTURY(subtype = "tree") -} -\arguments{ -\item{subtype}{Switch between different parameter files} -} -\value{ -List of magpie objects with results on global level -} -\description{ -Read parameter files in CENTURY model and return n/c- and lg/c-ratios -} -\examples{ -\dontrun{ - readSource("CENTURY", subtype="tree") -} - -} -\author{ -Kristine Karstens -} diff --git a/man/readCRU.Rd b/man/readCRU.Rd deleted file mode 100644 index 3b7c281..0000000 --- a/man/readCRU.Rd +++ /dev/null @@ -1,31 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/readCRU.R -\name{readCRU} -\alias{readCRU} -\title{readCRU} -\usage{ -readCRU(subtype = "precipitation") -} -\arguments{ -\item{subtype}{Switch between different input} -} -\value{ -List of magpie objects with results on cellular level, weight, unit and description. -} -\description{ -Read CRU content -} -\examples{ - -\dontrun{ - readSource("CRU", subtype="precipitation") -} - -} -\seealso{ -\code{\link[mrcommons]{readLPJmL}}, -\code{\link[lpjclass]{read.LPJ_input}} -} -\author{ -Kristine Karstens -} diff --git a/man/readIPCCSoil.Rd b/man/readIPCCSoil.Rd index 5976c16..7c5c3a2 100644 --- a/man/readIPCCSoil.Rd +++ b/man/readIPCCSoil.Rd @@ -16,7 +16,6 @@ List of magpie objects with results on cellular level, weight, unit and descript Read IPCC Guideline tables } \examples{ - \dontrun{ readSource("IPCCSoil") } diff --git a/man/readLPJmL_par.Rd b/man/readLPJmL_par.Rd index 5e0798c..aa121d4 100644 --- a/man/readLPJmL_par.Rd +++ b/man/readLPJmL_par.Rd @@ -17,7 +17,7 @@ Read parameter files from LPJmL model } \examples{ \dontrun{ - readSource("LPJmL_par", subtype="pft_lpjml4") +readSource("LPJmL_par", subtype = "pft_lpjml4") } } diff --git a/man/readSanderman.Rd b/man/readSanderman.Rd deleted file mode 100644 index e6a2053..0000000 --- a/man/readSanderman.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/readSanderman.R -\name{readSanderman} -\alias{readSanderman} -\title{readSanderman} -\usage{ -readSanderman() -} -\value{ -List of magpie objects with results on cellular level, weight, unit and description. -} -\description{ -Read validation data from Sanderman et al., 2017 -} -\examples{ -\dontrun{ -readSource("Sanderman") -} - -} -\author{ -Kristine Karstens -} diff --git a/man/toolFreezeAverage.Rd b/man/toolFreezeAverage.Rd deleted file mode 100644 index b4176d1..0000000 --- a/man/toolFreezeAverage.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/toolFreezeAverage.R -\name{toolFreezeAverage} -\alias{toolFreezeAverage} -\title{toolFreezeAverage} -\usage{ -toolFreezeAverage(x, freeze_year) -} -\arguments{ -\item{x}{variable to freeze} - -\item{freeze_year}{start of freeze period} -} -\value{ -magpie object wth froozen effect -} -\description{ -Calculates the 10 year average and freezes the effect for all years after -} -\author{ -Kristine Karstens -}