From 1fb99075bad13e8669e6bf425b211c4b29210372 Mon Sep 17 00:00:00 2001 From: Pascal Sauer Date: Thu, 15 Feb 2024 15:05:42 +0100 Subject: [PATCH 1/2] numeric_version --- R/calc2ndBioDem.R | 173 ++++++++++++------------ R/calcGHGPrices.R | 329 ++++++++++++++++++++++++---------------------- R/fullMAGPIE.R | 31 ++--- 3 files changed, 275 insertions(+), 258 deletions(-) diff --git a/R/calc2ndBioDem.R b/R/calc2ndBioDem.R index 781d1fc0..0a25ba95 100644 --- a/R/calc2ndBioDem.R +++ b/R/calc2ndBioDem.R @@ -1,122 +1,127 @@ #' @title calc2ndBioDem #' @description calculates 2nd generation bioenergy demand #' @return magpie object with results on country level, weight on country level, unit and description. -#' +#' #' @param datasource source to be used -#' @param rev data revision the output will be produced for (positive numeric) -#' -#' @examples -#' -#' \dontrun{ +#' @param rev data revision the output will be produced for (numeric_version) +#' +#' @examples +#' \dontrun{ #' calcOutput("2ndBioDem") #' } #' @import magclass #' @importFrom madrat readSource calcOutput #' @importFrom magclass collapseNames time_interpolate mbind lowpass -calc2ndBioDem <- function(datasource, rev = 0.1) { - +calc2ndBioDem <- function(datasource, rev = numeric_version("0.1")) { + if (datasource == "REMIND") { - x <- readSource("REMIND", subtype = paste0("extensive_",rev)) - x <- x[,,"Primary Energy Production|Biomass|Energy Crops (EJ/yr)"]*10^3 + x <- readSource("REMIND", subtype = paste0("extensive_", rev)) + x <- x[, , "Primary Energy Production|Biomass|Energy Crops (EJ/yr)"] * 10^3 x <- collapseNames(x) - first_remind_year <- sort(getYears(x))[1] - x <- time_interpolate(x,seq(1995,2150,5),extrapolation_type = "constant") - + firstRemindYear <- sort(getYears(x))[1] + x <- time_interpolate(x, seq(1995, 2150, 5), extrapolation_type = "constant") + # set values in initial years that are not existing in REMIND data to zero - x[,getYears(x) 4.58) { - strefler <- calcOutput("2ndBioDem",datasource="Strefler2021",aggregate = FALSE, rev = rev) - } else strefler <- NULL - - ssp <- time_interpolate(ssp,getYears(rem),extrapolation_type = "constant") - x <- mbind(ssp,rem,strefler) - - #years - years <- getYears(x,as.integer = T) - yr_hist <- years[years > 1995 & years <= 2020] - yr_fut <- years[years >= 2020] - - #apply lowpass filter (not applied on 1st time step, applied separately on historic and future period) + ssp <- calcOutput("2ndBioDem", datasource = "SSPResults", aggregate = FALSE, rev = rev) + rem <- calcOutput("2ndBioDem", datasource = "REMIND", aggregate = FALSE, rev = rev) + if (rev > numeric_version("4.58")) { + strefler <- calcOutput("2ndBioDem", datasource = "Strefler2021", aggregate = FALSE, rev = rev) + } else { + strefler <- NULL + } + + ssp <- time_interpolate(ssp, getYears(rem), extrapolation_type = "constant") + x <- mbind(ssp, rem, strefler) + + # years + years <- getYears(x, as.integer = TRUE) + yrHist <- years[years > 1995 & years <= 2020] + yrFut <- years[years >= 2020] + + # apply lowpass filter (not applied on 1st time step, applied separately on historic and future period) iter <- 3 - x <- mbind(x[,1995,],lowpass(x[,yr_hist,],i=iter),lowpass(x[,yr_fut,],i=iter)[,-1,]) - + x <- mbind(x[, 1995, ], lowpass(x[, yrHist, ], i = iter), lowpass(x[, yrFut, ], i = iter)[, -1, ]) + # sort scenarios alphabetically - x <- x[,,sort(getNames(x))] - - description <- "2nd generation bioenergy demand for different scenarios taken from R2M41 coupled runs and from IIASA SSP database" - - } else { - stop("Unknown datasource",datasource) + x <- x[, , sort(getNames(x))] + + description <- paste("2nd generation bioenergy demand for different scenarios", + "taken from R2M41 coupled runs and from IIASA SSP database") + + } else { + stop("Unknown datasource", datasource) } - - return(list(x=x, weight=NULL, - description=description, - unit="PJ per year", - note="bioenergy is demanded in the country which is expected to produce the bioenergy (demand after trade)")) - + + return(list(x = x, weight = NULL, + description = description, + unit = "PJ per year", + note = paste("bioenergy is demanded in the country which is expected", + "to produce the bioenergy (demand after trade)"))) } diff --git a/R/calcGHGPrices.R b/R/calcGHGPrices.R index 01ba7cc4..6e3dc92e 100644 --- a/R/calcGHGPrices.R +++ b/R/calcGHGPrices.R @@ -1,196 +1,211 @@ #' @title calcGHGPrices #' @description reads in GHG prices from past runs #' -#' @return list of magpie object with results on country level, weight on country level, unit and description. +#' @param emissions which type of emissions shall be returned. ghg just returns +#' n2o, ch4 and co2, pollutants a longer list including also air pollutants +#' @param datasource REMIND for prices from R2M4 coupled runs, REMMAG for old +#' coupled runs, SSPResults for prices from the SSP scenarios from the IIASA +#' database, SSP_and_REM for a combination of REMIND and SSPResults +#' @param rev data revision the output will be produced for (numeric_version). +#' @return list of magpie object with results on country level, weight on +#' country level, unit and description. #' @author David Chen, Benjamin Leon Bodirsky, David Klein -#' @param emissions which type of emissions shall be returned. ghg just returns n2o, ch4 and co2, pollutants a longer list including also air pollutants -#' @param datasource REMIND for prices from R2M4 coupled runs, REMMAG for old coupled runs, SSPResults for prices from the SSP scenarios from the IIASA database, SSP_and_REM for a combination of REMIND and SSPResults -#' @param rev data revision the output will be produced for (positive numeric). #' @seealso #' \code{\link{readSSPResults}} -#' @examples -#' -#' \dontrun{ +#' @examples +#' \dontrun{ #' calcOutput("GHGPrices") #' } #' @importFrom magpiesets findset #' @importFrom magclass complete_magpie #' @importFrom madrat toolFillYears -calcGHGPrices <- function(emissions="pollutants",datasource="REMMAG", rev=0.1) { - +calcGHGPrices <- function(emissions = "pollutants", datasource = "REMMAG", rev = numeric_version("0.1")) { + if (datasource == "REMIND") { - x <- readSource("REMIND", subtype = paste0("intensive_",rev)) - out_c <- x[,,"Price|Carbon (US$2005/t CO2)"]*44/12 # US$2005/tCO2 -> US$2005/tC - getNames(out_c,dim=2) <- "co2_c" - - out_n2o_direct <- x[,,"Price|N2O (US$2005/t N2O)"]*44/28 # US$2005/tN2O -> US$2005/tN - getNames(out_n2o_direct,dim=2) <- "n2o_n_direct" - - out_n2o_indirect <- x[,,"Price|N2O (US$2005/t N2O)"]*44/28 # US$2005/tN2O -> US$2005/tN - getNames(out_n2o_indirect,dim=2) <- "n2o_n_indirect" - - out_ch4 <- x[,,"Price|CH4 (US$2005/t CH4)"] - getNames(out_ch4,dim=2) <- "ch4" - - x <- mbind(out_n2o_direct,out_n2o_indirect,out_ch4,out_c) - - x <- time_interpolate(x,seq(1995,2150,5),extrapolation_type = "constant") - + x <- readSource("REMIND", subtype = paste0("intensive_", rev)) + outC <- x[, , "Price|Carbon (US$2005/t CO2)"] * 44 / 12 # US$2005/tCO2 -> US$2005/tC + getNames(outC, dim = 2) <- "co2_c" + + outN2oDirect <- x[, , "Price|N2O (US$2005/t N2O)"] * 44 / 28 # US$2005/tN2O -> US$2005/tN + getNames(outN2oDirect, dim = 2) <- "n2o_n_direct" + + outN2oIndirect <- x[, , "Price|N2O (US$2005/t N2O)"] * 44 / 28 # US$2005/tN2O -> US$2005/tN + getNames(outN2oIndirect, dim = 2) <- "n2o_n_indirect" + + outCh4 <- x[, , "Price|CH4 (US$2005/t CH4)"] + getNames(outCh4, dim = 2) <- "ch4" + + x <- mbind(outN2oDirect, outN2oIndirect, outCh4, outC) + + x <- time_interpolate(x, seq(1995, 2150, 5), extrapolation_type = "constant") + # Set prices to zero before and in 2020 - x[,getYears(x)<="y2020",]<-0 - - # find scenario names that have NPi or NDC in their name and set their GHG prices to zero (replicating the coupling script) - set_to_zero <- getNames(x)[grepl("NPi|NDC",getNames(x))] - x[,,set_to_zero] <- 0 - + x[, getYears(x) <= "y2020", ] <- 0 + + # find scenario names that have NPi or NDC in their name and set their GHG + # prices to zero (replicating the coupling script) + setToZero <- getNames(x)[grepl("NPi|NDC", getNames(x))] + x[, , setToZero] <- 0 + # swap dimensions (scenario and gas) such that in the output file gas is in lines and scenarios in columns - getNames(x) <- gsub("^([^\\.]*)\\.(.*$)","\\2.\\1",getNames(x)) - + getNames(x) <- gsub("^([^\\.]*)\\.(.*$)", "\\2.\\1", getNames(x)) + description <- "GHG certificate prices for different scenarios based on data from REMIND-MAgPIE coupling" - - + + } else if (datasource == "Strefler2021") { - x <- readSource("Strefler2021", subtype = paste0("intensive_",rev)) - out_c <- x[,,"Price|Carbon (US$2005/t CO2)"]*44/12 # US$2005/tCO2 -> US$2005/tC - getNames(out_c,dim=2) <- "co2_c" - - out_n2o_direct <- x[,,"Price|Carbon (US$2005/t CO2)"]*265*44/28 # US$2005/tN2O -> US$2005/tN - getNames(out_n2o_direct,dim=2) <- "n2o_n_direct" - - out_n2o_indirect <- x[,,"Price|Carbon (US$2005/t CO2)"]*265*44/28 # US$2005/tN2O -> US$2005/tN - getNames(out_n2o_indirect,dim=2) <- "n2o_n_indirect" - - out_ch4 <- x[,,"Price|Carbon (US$2005/t CO2)"]*28 - getNames(out_ch4,dim=2) <- "ch4" - - x <- mbind(out_n2o_direct,out_n2o_indirect,out_ch4,out_c) - - x <- time_interpolate(x,seq(1995,2150,5),extrapolation_type = "constant") - + x <- readSource("Strefler2021", subtype = paste0("intensive_", rev)) + outC <- x[, , "Price|Carbon (US$2005/t CO2)"] * 44 / 12 # US$2005/tCO2 -> US$2005/tC + getNames(outC, dim = 2) <- "co2_c" + + outN2oDirect <- x[, , "Price|Carbon (US$2005/t CO2)"] * 265 * 44 / 28 # US$2005/tN2O -> US$2005/tN + getNames(outN2oDirect, dim = 2) <- "n2o_n_direct" + + outN2oIndirect <- x[, , "Price|Carbon (US$2005/t CO2)"] * 265 * 44 / 28 # US$2005/tN2O -> US$2005/tN + getNames(outN2oIndirect, dim = 2) <- "n2o_n_indirect" + + outCh4 <- x[, , "Price|Carbon (US$2005/t CO2)"] * 28 + getNames(outCh4, dim = 2) <- "ch4" + + x <- mbind(outN2oDirect, outN2oIndirect, outCh4, outC) + + x <- time_interpolate(x, seq(1995, 2150, 5), extrapolation_type = "constant") + # Set prices to zero before and in 2020 - x[,getYears(x)<="y2020",]<-0 - - # find scenario names that have NPi or NDC in their name and set their GHG prices to zero (replicating the coupling script) - set_to_zero <- getNames(x)[grepl("NPI|NDC",getNames(x))] - x[,,set_to_zero] <- 0 - + x[, getYears(x) <= "y2020", ] <- 0 + + # find scenario names that have NPi or NDC in their name and set their GHG + # prices to zero (replicating the coupling script) + setToZero <- getNames(x)[grepl("NPI|NDC", getNames(x))] + x[, , setToZero] <- 0 + # swap dimensions (scenario and gas) such that in the output file gas is in lines and scenarios in columns - getNames(x) <- gsub("^([^\\.]*)\\.(.*$)","\\2.\\1",getNames(x)) - - description <- "GHG certificate prices for different scenarios taken from Strefler et al 2021 (DOI 10.1038/s41467-021-22211-2)" - - } else if(datasource=="REMMAG") { - x <- readSource("REMMAG","ghgprices") - if (emissions=="pollutants"){ - pollutants<-findset("pollutants") - y<-add_columns(x,dim = 3.1,addnm = setdiff(pollutants,getNames(x,dim=1))) - y[,,]<-0 - y[,,"ch4"]<-x[,,"ch4"] - y[,,"co2_c"]<-x[,,"co2_c"] - y[,,c("n2o_n_direct","n2o_n_indirect")]<-collapseNames(x[,,"n2o_n"]) - x<-y[,,pollutants] - } else if (emissions!="ghg") {stop("unknown emission type")} - + getNames(x) <- gsub("^([^\\.]*)\\.(.*$)", "\\2.\\1", getNames(x)) + + description <- paste("GHG certificate prices for different scenarios taken", + "from Strefler et al 2021 (DOI 10.1038/s41467-021-22211-2)") + + } else if (datasource == "REMMAG") { + x <- readSource("REMMAG", "ghgprices") + if (emissions == "pollutants") { + pollutants <- findset("pollutants") + y <- add_columns(x, dim = 3.1, addnm = setdiff(pollutants, getNames(x, dim = 1))) + y[, , ] <- 0 + y[, , "ch4"] <- x[, , "ch4"] + y[, , "co2_c"] <- x[, , "co2_c"] + y[, , c("n2o_n_direct", "n2o_n_indirect")] <- collapseNames(x[, , "n2o_n"]) + x <- y[, , pollutants] + } else if (emissions != "ghg") { + stop("unknown emission type") + } + description <- "ghg certificate prices for different scenarios based on data from REMIND-MAgPIE-coupling" - - - } else if (datasource=="SSPResults") { - - x<-readSource("SSPResults") - x<- collapseNames(x[,,"Price|Carbon (US$2005/t CO2)"]) - x<- x*44/12 - - pollutants<-findset("pollutants") - - y<-add_dimension(x,dim = 3.1,nm = "co2_c") - y<-add_columns(y,dim = 3.1,addnm = setdiff(pollutants,getNames(y,dim=1))) - - y[,,]<-0 - y[,,"co2_c"]<-x - y[,,"ch4"]<-(x*28*12/44) - y[,,c("n2o_n_direct","n2o_n_indirect")]<-collapseNames(x)*265*44/28*12/44 - x<-y[,,c(pollutants)] - - if(emissions=="ghg"){ - x=x[,,c("co2_c","n2o_n_direct","ch4")] - getNames(x, dim=3) <- c("co2_c", "n2o_n", "ch4") - } else if (emissions!="pollutants") {stop("emissions has to be set to ghg or pollutants")} - x[,c(2005,2010),]<-0 - - x<-time_interpolate(dataset = x[,2010+(0:9)*10,],interpolated_year = c(1965+(0:8)*5,2015+(0:8)*10),integrate_interpolated_years = TRUE,extrapolation_type = "constant") - x<-toolHoldConstantBeyondEnd(x) - - description <- "ghg certificate prices for different scenarios based on the multimodel SSP results from the IIASA DB" - - } else if (datasource=="S4N_project") { - + + + } else if (datasource == "SSPResults") { + + x <- readSource("SSPResults") + x <- collapseNames(x[, , "Price|Carbon (US$2005/t CO2)"]) + x <- x * 44 / 12 + + pollutants <- findset("pollutants") + + y <- add_dimension(x, dim = 3.1, nm = "co2_c") + y <- add_columns(y, dim = 3.1, addnm = setdiff(pollutants, getNames(y, dim = 1))) + + y[, , ] <- 0 + y[, , "co2_c"] <- x + y[, , "ch4"] <- (x * 28 * 12 / 44) + y[, , c("n2o_n_direct", "n2o_n_indirect")] <- collapseNames(x) * 265 * 44 / 28 * 12 / 44 + x <- y[, , c(pollutants)] + + if (emissions == "ghg") { + x <- x[, , c("co2_c", "n2o_n_direct", "ch4")] + getNames(x, dim = 3) <- c("co2_c", "n2o_n", "ch4") + } else if (emissions != "pollutants") { + stop("emissions has to be set to ghg or pollutants") + } + x[, c(2005, 2010), ] <- 0 + + x <- time_interpolate(dataset = x[, 2010 + (0:9) * 10, ], + interpolated_year = c(1965 + (0:8) * 5, 2015 + (0:8) * 10), + integrate_interpolated_years = TRUE, extrapolation_type = "constant") + x <- toolHoldConstantBeyondEnd(x) + + description <- paste("ghg certificate prices for different scenarios based", + "on the multimodel SSP results from the IIASA DB") + + } else if (datasource == "S4N_project") { # Carbon price (in USD2005 per t CO2) at country level - x <- readSource("S4Nproject_input", subtype="co2prices", convert="onlycorrect") + x <- readSource("S4Nproject_input", subtype = "co2prices", convert = "onlycorrect") # Extend years and set to 0 before 2030 - x <- toolFillYears(x,paste0("y", seq(1995, 2100,by=5))) - x[,paste0("y",seq(1995,2025,by=5)),] <- 0 - + x <- toolFillYears(x, paste0("y", seq(1995, 2100, by = 5))) + x[, paste0("y", seq(1995, 2025, by = 5)), ] <- 0 + # Convert in USD2005 per tons of carbon - x <- x*44/12 - + x <- x * 44 / 12 + # Add pollutants dimension to magpie object - pollutants<-findset("pollutants") - y <- add_dimension(x, dim=3.1, nm="co2_c") - y <- add_columns(y, dim=3.1, addnm=setdiff(pollutants,getNames(y,dim=1))) + pollutants <- findset("pollutants") + y <- add_dimension(x, dim = 3.1, nm = "co2_c") + y <- add_columns(y, dim = 3.1, addnm = setdiff(pollutants, getNames(y, dim = 1))) # Fill object with pollutant prices (including transformation to CO2-equivalents) - y[,,] <- 0 + y[, , ] <- 0 # CO2 in USD2005 per tons of C - y[,,"co2_c"] <- x + y[, , "co2_c"] <- x # CH4 in USD2005 per tons of CO2-equivalent - y[,,"ch4"] <- (x*28*12/44) + y[, , "ch4"] <- (x * 28 * 12 / 44) # N2O in USD2005 per tons of N - y[,,c("n2o_n_direct","n2o_n_indirect")] <- collapseNames(x)*265*44/28*12/44 - - x <- y[,,c(pollutants)] + y[, , c("n2o_n_direct", "n2o_n_indirect")] <- collapseNames(x) * 265 * 44 / 28 * 12 / 44 + + x <- y[, , c(pollutants)] # pollutant prices to be returned - if(emissions=="ghg"){ - x <- x[,,c("co2_c","n2o_n_direct","ch4")] - getNames(x, dim=1) <- c("co2_c", "n2o_n", "ch4") - } else if (emissions!="pollutants") { + if (emissions == "ghg") { + x <- x[, , c("co2_c", "n2o_n_direct", "ch4")] + getNames(x, dim = 1) <- c("co2_c", "n2o_n", "ch4") + } else if (emissions != "pollutants") { stop("emissions has to be set to ghg or pollutants") } # co2 pricing starts in 2015 - x[,c(2005,2010),] <- 0 + x[, c(2005, 2010), ] <- 0 # fill missing years in the future - x <- time_interpolate(x, seq(1995,2150,5), extrapolation_type="constant") - + x <- time_interpolate(x, seq(1995, 2150, 5), extrapolation_type = "constant") + description <- "ghg certificate prices for different scenarios based on CO2 prices provided by IMAGE" - - } else if (datasource=="SSP_and_REM") { - ssp <- calcOutput("GHGPrices",datasource = "SSPResults",aggregate = FALSE, rev = rev) - rem <- calcOutput("GHGPrices",datasource = "REMIND", aggregate = FALSE, rev = rev) - if (rev > 4.58) { - strefler <- calcOutput("GHGPrices",datasource = "Strefler2021", aggregate = FALSE, rev = rev) - } else strefler <- NULL - - - x <- mbind(ssp[,getYears(rem),],rem,strefler) - - x <- complete_magpie(x,fill=0) - + + } else if (datasource == "SSP_and_REM") { + ssp <- calcOutput("GHGPrices", datasource = "SSPResults", aggregate = FALSE, rev = rev) + rem <- calcOutput("GHGPrices", datasource = "REMIND", aggregate = FALSE, rev = rev) + if (rev > numeric_version("4.58")) { + strefler <- calcOutput("GHGPrices", datasource = "Strefler2021", aggregate = FALSE, rev = rev) + } else { + strefler <- NULL + } + + + x <- mbind(ssp[, getYears(rem), ], rem, strefler) + + x <- complete_magpie(x, fill = 0) + # sort scenarios alphabetically - x <- x[,,sort(getNames(x,dim=2))] - - description <- "ghg certificate prices for different scenarios based on data from REMIND-MAgPIE-coupling and the multimodel SSP results from the IIASA DB" - - } - - pop <- calcOutput("Population",aggregate=FALSE) - - return(list(x=x, weight=pop[,2010,1], - unit="US$ 2005 per t N2O-N CH4 and CO2-C", - description=description, - note="As weight for aggregation currently population data from 2010 is used.", - min=0, - max=10^7)) - + x <- x[, , sort(getNames(x, dim = 2))] + + description <- paste("ghg certificate prices for different scenarios based", + "on data from REMIND-MAgPIE-coupling and the multimodel SSP results from the IIASA DB") + + } + + pop <- calcOutput("Population", aggregate = FALSE) + + return(list(x = x, weight = pop[, 2010, 1], + unit = "US$ 2005 per t N2O-N CH4 and CO2-C", + description = description, + note = "As weight for aggregation currently population data from 2010 is used.", + min = 0, + max = 10^7)) + } diff --git a/R/fullMAGPIE.R b/R/fullMAGPIE.R index 1012f79e..d441f8d3 100644 --- a/R/fullMAGPIE.R +++ b/R/fullMAGPIE.R @@ -1,22 +1,24 @@ #' fullMAgPIE #' -#' Function that produces the complete regional data set required for running the -#' MAgPIE model. +#' Function that produces the regional data set for running the MAgPIE model. #' -#' @param rev data revision which should be used as input (positive numeric). +#' @param rev data revision which should be used as input (numeric_version). #' @param dev For developing purposes, apply changes as per dev flag #' @author Jan Philipp Dietrich, Benjamin Leon Bodirsky, Florian Humpenoeder, Edna J. Molina Bacca #' @seealso #' \code{\link{readSource}}, \code{\link{getCalculations}}, \code{\link{calcOutput}} #' @examples #' \dontrun{ -#' fullMAgPIE(revision = 12, mainfolder = "pathtowhereallfilesarestored") +#' retrieveData("MAGPIE", rev = numeric_version("12"), +#' mainfolder = "pathtowhereallfilesarestored") #' } #' -fullMAGPIE <- function(rev = 0.1, dev = "") { +fullMAGPIE <- function(rev = numeric_version("0.1"), dev = "") { - if (rev < 4.66) stop("mrland(>= 0.15.0) does not support revision below 4.63 anymore. - Please use a older snapshot/version of the library, if you need older revisions.") + if (rev < numeric_version("4.66")) { + stop("This version of mrland does not support revision below 4.66 anymore. ", + "Please use a older snapshot/version of the library, if you need older revisions.") + } magYears <- findset("time") magYearsPast <- findset("past") @@ -28,7 +30,7 @@ fullMAGPIE <- function(rev = 0.1, dev = "") { map <- toolGetMapping(getConfig("regionmapping"), type = "regional", where = "mappingfolder") superregion <- ifelse("superregion" %in% colnames(map), "superregion", "region") - cellsregions <- function(reg_revision = 0, map) { # nolint + cellsregions <- function(reg_revision, map) { # nolint # function which calculates the name vector for spatial 0.5 degree MAgPIE data sets # containing MAgPIE cell number and corresponding region regionscode <- regionscode(map) @@ -274,15 +276,10 @@ fullMAGPIE <- function(rev = 0.1, dev = "") { calcOutput("EF3confinement", selection = "recycling", round = 4, file = "f55_awms_recycling_share.cs4") # 56_ghg_policy - if (rev < 4) { - calcOutput("GHGPrices", emissions = "pollutants", years = shortYears, round = 2, - file = "f56_pollutant_prices.cs3") - } else { - calcOutput("GHGPrices", datasource = "SSP_and_REM", years = shortYears, round = 2, - file = "f56_pollutant_prices.cs3", rev = rev) - calcOutput("GHGPrices", datasource = "S4N_project", round = 2, - file = "f56_pollutant_prices_sim4nexus.cs3", rev = rev) - } + calcOutput("GHGPrices", datasource = "SSP_and_REM", years = shortYears, round = 2, + file = "f56_pollutant_prices.cs3", rev = rev) + calcOutput("GHGPrices", datasource = "S4N_project", round = 2, + file = "f56_pollutant_prices_sim4nexus.cs3", rev = rev) # 57 maccs shortYearsFrom2010 <- shortYears[as.integer(sub("y", "", shortYears)) >= 2010] From dc3568bee114c21c95d92d3195075fea1f85c070 Mon Sep 17 00:00:00 2001 From: Pascal Sauer Date: Thu, 15 Feb 2024 15:05:58 +0100 Subject: [PATCH 2/2] build --- .buildlibrary | 2 +- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- README.md | 8 ++++---- man/calc2ndBioDem.Rd | 8 +++----- man/calcGHGPrices.Rd | 22 ++++++++++++++-------- man/fullMAGPIE.Rd | 10 +++++----- 7 files changed, 31 insertions(+), 27 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 7fc356d8..f7339cef 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '10554510' +ValidationKey: '10575880' 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 725d8081..f6aa4170 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,8 +2,8 @@ cff-version: 1.2.0 message: If you use this software, please cite it using the metadata from this file. type: software title: 'mrland: MadRaT land data package' -version: 0.53.4 -date-released: '2024-02-12' +version: 0.53.5 +date-released: '2024-02-15' abstract: The package provides land related data via the madrat framework. authors: - family-names: Dietrich diff --git a/DESCRIPTION b/DESCRIPTION index 0163fd4e..8e7afa28 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrland Title: MadRaT land data package -Version: 0.53.4 -Date: 2024-02-12 +Version: 0.53.5 +Date: 2024-02-15 Authors@R: c( person("Jan Philipp", "Dietrich", , "dietrich@pik-potsdam.de", role = c("aut", "cre")), person("Abhijeet", "Mishra", role = "aut"), diff --git a/README.md b/README.md index 88d263c8..aed38cb4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MadRaT land data package -R package **mrland**, version **0.53.4** +R package **mrland**, version **0.53.5** [![CRAN status](https://www.r-pkg.org/badges/version/mrland)](https://cran.r-project.org/package=mrland) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3822083.svg)](https://doi.org/10.5281/zenodo.3822083) [![R build status](https://github.com/pik-piam/mrland/workflows/check/badge.svg)](https://github.com/pik-piam/mrland/actions) [![codecov](https://codecov.io/gh/pik-piam/mrland/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mrland) [![r-universe](https://pik-piam.r-universe.dev/badges/mrland)](https://pik-piam.r-universe.dev/builds) @@ -39,7 +39,7 @@ In case of questions / problems please contact Jan Philipp Dietrich , R package version 0.53.4, . +Dietrich J, Mishra A, Weindl I, Bodirsky B, Wang X, Baumstark L, Kreidenweis U, Klein D, Steinmetz N, Chen D, Humpenoeder F, von Jeetze P, Wirth S, Beier F, Hoetten D (2024). _mrland: MadRaT land data package_. doi:10.5281/zenodo.3822083 , R package version 0.53.5, . A BibTeX entry for LaTeX users is @@ -48,8 +48,8 @@ A BibTeX entry for LaTeX users is title = {mrland: MadRaT land data package}, author = {Jan Philipp Dietrich and Abhijeet Mishra and Isabelle Weindl and Benjamin Leon Bodirsky and Xiaoxi Wang and Lavinia Baumstark and Ulrich Kreidenweis and David Klein and Nele Steinmetz and David Chen and Florian Humpenoeder and Patrick {von Jeetze} and Stephen Wirth and Felicitas Beier and David Hoetten}, year = {2024}, - note = {R package version 0.53.4}, - doi = {10.5281/zenodo.3822083}, + note = {R package version 0.53.5}, url = {https://github.com/pik-piam/mrland}, + doi = {10.5281/zenodo.3822083}, } ``` diff --git a/man/calc2ndBioDem.Rd b/man/calc2ndBioDem.Rd index 36a88f89..5dcb2ac7 100644 --- a/man/calc2ndBioDem.Rd +++ b/man/calc2ndBioDem.Rd @@ -4,12 +4,12 @@ \alias{calc2ndBioDem} \title{calc2ndBioDem} \usage{ -calc2ndBioDem(datasource, rev = 0.1) +calc2ndBioDem(datasource, rev = numeric_version("0.1")) } \arguments{ \item{datasource}{source to be used} -\item{rev}{data revision the output will be produced for (positive numeric)} +\item{rev}{data revision the output will be produced for (numeric_version)} } \value{ magpie object with results on country level, weight on country level, unit and description. @@ -18,9 +18,7 @@ magpie object with results on country level, weight on country level, unit and d calculates 2nd generation bioenergy demand } \examples{ - - -\dontrun{ +\dontrun{ calcOutput("2ndBioDem") } } diff --git a/man/calcGHGPrices.Rd b/man/calcGHGPrices.Rd index 0f443b9b..a5f43c25 100644 --- a/man/calcGHGPrices.Rd +++ b/man/calcGHGPrices.Rd @@ -4,25 +4,31 @@ \alias{calcGHGPrices} \title{calcGHGPrices} \usage{ -calcGHGPrices(emissions = "pollutants", datasource = "REMMAG", rev = 0.1) +calcGHGPrices( + emissions = "pollutants", + datasource = "REMMAG", + rev = numeric_version("0.1") +) } \arguments{ -\item{emissions}{which type of emissions shall be returned. ghg just returns n2o, ch4 and co2, pollutants a longer list including also air pollutants} +\item{emissions}{which type of emissions shall be returned. ghg just returns +n2o, ch4 and co2, pollutants a longer list including also air pollutants} -\item{datasource}{REMIND for prices from R2M4 coupled runs, REMMAG for old coupled runs, SSPResults for prices from the SSP scenarios from the IIASA database, SSP_and_REM for a combination of REMIND and SSPResults} +\item{datasource}{REMIND for prices from R2M4 coupled runs, REMMAG for old +coupled runs, SSPResults for prices from the SSP scenarios from the IIASA +database, SSP_and_REM for a combination of REMIND and SSPResults} -\item{rev}{data revision the output will be produced for (positive numeric).} +\item{rev}{data revision the output will be produced for (numeric_version).} } \value{ -list of magpie object with results on country level, weight on country level, unit and description. +list of magpie object with results on country level, weight on +country level, unit and description. } \description{ reads in GHG prices from past runs } \examples{ - - -\dontrun{ +\dontrun{ calcOutput("GHGPrices") } } diff --git a/man/fullMAGPIE.Rd b/man/fullMAGPIE.Rd index 874e37dd..d94d9987 100644 --- a/man/fullMAGPIE.Rd +++ b/man/fullMAGPIE.Rd @@ -4,20 +4,20 @@ \alias{fullMAGPIE} \title{fullMAgPIE} \usage{ -fullMAGPIE(rev = 0.1, dev = "") +fullMAGPIE(rev = numeric_version("0.1"), dev = "") } \arguments{ -\item{rev}{data revision which should be used as input (positive numeric).} +\item{rev}{data revision which should be used as input (numeric_version).} \item{dev}{For developing purposes, apply changes as per dev flag} } \description{ -Function that produces the complete regional data set required for running the -MAgPIE model. +Function that produces the regional data set for running the MAgPIE model. } \examples{ \dontrun{ -fullMAgPIE(revision = 12, mainfolder = "pathtowhereallfilesarestored") +retrieveData("MAGPIE", rev = numeric_version("12"), + mainfolder = "pathtowhereallfilesarestored") } }