diff --git a/.buildlibrary b/.buildlibrary index 667fcb6d..46f93da8 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '36687448' +ValidationKey: '37105140' AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' - 'Warning: namespace ''.*'' is not available and has been replaced' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62f13da6..7ccf77e0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: mixed-line-ending - repo: https://github.com/lorenzwalthert/precommit - rev: 7910e0323d7213f34275a7a562b9ef0fde8ce1b9 # frozen: v0.4.2 + rev: bae853d82da476eee0e0a57960ee6b741a3b3fb7 # frozen: v0.4.3 hooks: - id: parsable-R - id: deps-in-desc diff --git a/CITATION.cff b/CITATION.cff index c0448e62..24e8b48f 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: 'mrremind: MadRat REMIND Input Data Package' -version: 0.184.1 -date-released: '2024-07-24' +version: 0.186.0 +date-released: '2024-08-14' abstract: The mrremind packages contains data preprocessing for the REMIND model. authors: - family-names: Baumstark diff --git a/DESCRIPTION b/DESCRIPTION index 98a0e686..31b97cae 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrremind Title: MadRat REMIND Input Data Package -Version: 0.184.1 -Date: 2024-07-24 +Version: 0.186.0 +Date: 2024-08-14 Authors@R: c( person("Lavinia", "Baumstark", , "lavinia@pik-potsdam.de", role = c("aut", "cre")), person("Renato", "Rodrigues", role = "aut"), diff --git a/NAMESPACE b/NAMESPACE index 74c49214..f9a4438f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -23,6 +23,7 @@ export(calcIndustry_Value_Added) export(calcODYM_RECC) export(calcOtherFossilInElectricity) export(calcPlasticsEoL) +export(calcProjectPipelines) export(calcShareIndFE) export(calcSteelStock) export(calcSteel_Projections) @@ -45,6 +46,7 @@ export(convertUBA) export(convertUNFCCC) export(convertUNIDO) export(convertUSGS) +export(exportThresholds) export(filter_historical_mif) export(readADVANCE_WP2) export(readAGEB) diff --git a/R/calcCCScapacity.R b/R/calcCCScapacity.R index 9393eced..1b7a01ad 100644 --- a/R/calcCCScapacity.R +++ b/R/calcCCScapacity.R @@ -41,6 +41,6 @@ calcCCScapacity <- function(subtype) { x = x, weight = NULL, unit = "MtCO2/yr", - description = "CCS capacitiy derived from IEA CCUS project database" + description = "CCS capacity derived from IEA CCUS project database" )) } diff --git a/R/calcGlobalEnergyMonitor.R b/R/calcGlobalEnergyMonitor.R index 5301beb0..0ed29433 100644 --- a/R/calcGlobalEnergyMonitor.R +++ b/R/calcGlobalEnergyMonitor.R @@ -1,4 +1,6 @@ -#' Calculate REMIND variables from Global Energy Monitor +#' Calc capacities from Global Energy Monitor +#' +#' Calculate near-term expectations of capacities for use in fullVALIDATION.R #' #' @md #' @return A [`magpie`][magclass::magclass] object. @@ -13,6 +15,10 @@ calcGlobalEnergyMonitor <- function() { # set 0s in other CHA countries than China to approximate CHA as China x[c("HKG", "MAC", "TWN"), , ] <- 0 + # ASSUMPTION: sum over all statuses + # this means that all planned projects will be realized! + x <- dimSums(x, dim = "status") + return(list( x = x, weight = NULL, diff --git a/R/calcProjectPipelines.R b/R/calcProjectPipelines.R new file mode 100644 index 00000000..f593f786 --- /dev/null +++ b/R/calcProjectPipelines.R @@ -0,0 +1,191 @@ +#' calc Project Pipelines +#' +#' Calculate the expected near-term deployment of technologies based on +#' projects that are currently either being built or in a planning stage +#' for some technologies multiple sources are available +#' +#' @author Pascal Weigmann +#' +#' @param subtype choose technology `biomass`, `coal`, `geothermal`, `hydro`, +#' `nuclear`, `solar`, `wind` or `CCS` +#' +#' @export +calcProjectPipelines <- function(subtype) { + # CCS #### + # Discussion about CCS assumptions + # https://gitlab.pik-potsdam.de/REMIND/committed/-/issues/1 + if (subtype == "CCS") { + + x <- readSource("IEA_CCUS", subtype = "pipeline") + + # take away 50% of capacities from Norway and UK and shift to EUR + x[c("NOR", "GBR"), , ] <- x[c("NOR", "GBR"), , ] * 0.5 + + mapping <- toolGetMapping("extramapping_EU27.csv", + where = "mappingfolder", type = "regional") %>% + filter(.data$EU27_map == "EU27") + eu27 <- unique(mapping$CountryCode) + + # sum up EU27 capacities and add half of Norway / UK capacities + eu27Pool <- + dimSums(x[eu27, , ], dim = 1) + dimSums(x[c("NOR", "GBR"), , ], dim = 1) + getItems(eu27Pool, dim = 1) <- "EU27" + + # distribute EU27 pool to the countries according to GDP + gdp <- calcOutput("GDP", aggregate = FALSE)[eu27, 2020, "gdp_SSP2EU"] + eu27Pool <- toolAggregate(eu27Pool, + rel = mapping, weight = gdp, + from = "EU27_map", to = "CountryCode") + x[eu27, , ] <- eu27Pool + + # ASSUMPTION: no projects are under way in Brasil which means all thresholds are equal + # to avoid this, add manually an upper estimate of what could still be planned in BRA + x["BRA", 2025:2029, "Carbon Management|Storage.planned"] <- + x["BRA", 2025:2029, "Carbon Management|Storage.planned"] + 2 + x["BRA", 2030, "Carbon Management|Storage.planned"] <- + x["BRA", 2030, "Carbon Management|Storage.planned"] + 10 + + + # formulation of upper and lower bounds for the near-term validation + x <- mbind( + x, + # ASSUMPTION: min_red = operational + setNames(x[, , "Carbon Management|Storage.operational"], + "Carbon Management|Storage.min_red"), + + # ASSUMPTION: min_yel = operational + 0.5*construction + setNames(x[, , "Carbon Management|Storage.operational"] + + x[, , "Carbon Management|Storage.construction"]*0.5, + "Carbon Management|Storage.min_yel"), + + # ASSUMPTION: max_yel = operational + construction + 0.3*planned + setNames(x[, , "Carbon Management|Storage.operational"] + + x[, , "Carbon Management|Storage.construction"] + + x[, , "Carbon Management|Storage.planned"]*0.3, + "Carbon Management|Storage.max_yel"), + + # ASSUMPTION: max_red = operational + construction + planned + setNames(x[, , "Carbon Management|Storage.operational"] + + x[, , "Carbon Management|Storage.construction"] + + x[, , "Carbon Management|Storage.planned"], + "Carbon Management|Storage.max_red")) + + # meta data + x <- add_dimension(x, dim = 3.1, add = "model", nm = "IEA CCUS") + x <- add_dimension(x, dim = 3.4, add = "unit", nm = "MtCO2/yr") + unit <- "MtCO2/yr" + description <- "CCS project pipeline from IEA CCUS project database" + + # Hydro #### + # Discussion about Hydro assumptions + # https://gitlab.pik-potsdam.de/REMIND/committed/-/issues/2 + } else if (subtype == "hydro") { + # without pumped storage + x <- readSource("GlobalEnergyMonitor") + x <- x[, , "Hydro", pmatch = T] + + x <- mbind(x, + # ASSUMPTION: min_red = operating + setNames(x[, , "operating"], + "GlobalEnergyMonitor.Cap|Electricity|Hydro.min_red.GW"), + + # ASSUMPTION: min_yel = operating + 0.5*construction + 0.2*pre-construction + setNames(x[, , "operating"] + + x[, , "construction"]*0.5 + + x[, , "pre-construction"]*0.2, + "GlobalEnergyMonitor.Cap|Electricity|Hydro.min_yel.GW"), + + # ASSUMPTION: max_yel = operating + construction + 0.8*pre-construction + 0.3*announced + setNames(x[, , "operating"] + + x[, , "construction"] + + x[, , "pre-construction"]*0.8 + + x[, , "announced"]*0.3, + "GlobalEnergyMonitor.Cap|Electricity|Hydro.max_yel.GW"), + + # ASSUMPTION: max_red = operating + construction + pre-construction + announced + setNames(x[, , "operating"] + + x[, , "construction"] + + x[, , "pre-construction"] + + x[, , "announced"], + "GlobalEnergyMonitor.Cap|Electricity|Hydro.max_red.GW") + ) + + # meta data + unit <- "GW" + description <- "Hydro project pipeline from GEM" + + # TODO: coming up next + # # Biomass #### + # } else if (subtype == "biomass") { + # x <- readSource("GlobalEnergyMonitor") + # x <- x[, , "Biomass", pmatch = T] + # + # + # # meta data + # unit <- "GW" + # description <- "Biomass project pipeline from GEM" + # + # # Nuclear #### + # } else if (subtype == "nuclear") { + # x <- readSource("GlobalEnergyMonitor") + # x <- x[, , "Nuclear", pmatch = T] + # + # + # + # # meta data + # unit <- "GW" + # description <- "Nuclear project pipeline from GEM" + # + # # Coal #### + # } else if (subtype == "coal") { + # x <- readSource("GlobalEnergyMonitor") + # x <- x[, , "Coal", pmatch = T] + # + # + # + # # meta data + # unit <- "GW" + # description <- "Coal project pipeline from GEM" + # + # # Geothermal #### + # } else if (subtype == "geothermal") { + # x <- readSource("GlobalEnergyMonitor") + # x <- x[, , "Geothermal", pmatch = T] + # + # + # + # # meta data + # unit <- "GW" + # description <- "Geothermal project pipeline from GEM" + # # Solar #### + # } else if (subtype == "solar") { + # x <- readSource("GlobalEnergyMonitor") + # x <- x[, , "Solar", pmatch = T] + # + # # meta data + # unit <- "GW" + # description <- "Solar project pipeline from GEM" + # + # # Wind #### + # } else if (subtype == "wind") { + # x <- readSource("GlobalEnergyMonitor") + # x <- x[, , "Wind", pmatch = T] + # + # # + # + # + # # meta data + # unit <- "GW" + # description <- "Wind project pipeline from GEM" + # + } + + x <- x[ ,c(2025, 2030), ] + + return(list( + x = x, + unit = unit, + weight = NULL, + description = description + )) + } diff --git a/R/convertGlobalEnergyMonitor.R b/R/convertGlobalEnergyMonitor.R index 95664186..4f883da3 100644 --- a/R/convertGlobalEnergyMonitor.R +++ b/R/convertGlobalEnergyMonitor.R @@ -7,6 +7,6 @@ #' @export convertGlobalEnergyMonitor <- function(x) { getItems(x, dim = 1) <- toolCountry2isocode(getItems(x, dim = 1)) - x <- toolCountryFill(x, no_remove_warning = "KOS", verbosity = 2) + x <- toolCountryFill(x, no_remove_warning = "KOS", verbosity = 2, fill = 0) return(x) } diff --git a/R/exportThresholds.R b/R/exportThresholds.R new file mode 100644 index 00000000..624d2495 --- /dev/null +++ b/R/exportThresholds.R @@ -0,0 +1,76 @@ +#' export validation thresholds +#' +#' assemble near-term thresholds from project pipelines and potentially other +#' data sources and export them to a file +#' +#' @author Pascal Weigmann +#' @param type choose either "config" to export thresholds as used in the +#' validationConfig or "full" to export all pipeline data +#' @param years choose years to include, currenty only 2025 and 2030 are +#' available, if NULL uses all available years +#' @export +exportThresholds <- function(type = "config", years = NULL) { + + # get region mappings for aggregation ---- + # Determines all regions data should be aggregated to by examining the columns + # of the `regionmapping` and `extramappings` currently configured. + rel <- "global" # always compute global aggregate + for (mapping in c(getConfig("regionmapping"), getConfig("extramappings"))) { + columns <- setdiff( + colnames(toolGetMapping(mapping, "regional")), + c("X", "CountryCode") + ) + + if (any(columns %in% rel)) { + warning( + "The following column(s) from ", mapping, + " exist in another mapping an will be ignored: ", + paste(columns[columns %in% rel], collapse = ", ") + ) + } + rel <- unique(c(rel, columns)) + } + + columnsForAggregation <- gsub( + "RegionCode", "region", + paste(rel, collapse = "+") + ) + + # the following magclass objects are expected to have the dimensions "status" + # as dim 3.3 + ccs <- calcOutput("ProjectPipelines", subtype = "CCS", + aggregate = columnsForAggregation, round = 3, + warnNA = FALSE, try = FALSE, years = years) + + hydro <- calcOutput("ProjectPipelines", subtype = "hydro", + aggregate = columnsForAggregation, round = 3, + warnNA = FALSE, try = FALSE, years = years) + + # combine and export data to madrat output folder + out <- mbind(ccs, hydro) + if (type == "full") { + # write report containing all available data, including all statuses and + # thresholds attached to "variable" + outfile <- "pipelines.mif" + as.quitte(out) %>% + mutate(variable = paste(variable, status, sep = "|")) %>% + select(-scenario, -status) %>% + as.magpie() %>% + write.report(file = paste0(getConfig("outputfolder"), "/", outfile)) + + } else if (type == "config") { + # write report containing only the "min/max" thresholds in extra columns + # (as used in a validationConfig) + outfile <- "thresholds.mif" + out[, , c("min_", "max_"), pmatch = TRUE] %>% + as.quitte() %>% + pivot_wider(names_from = "status") %>% + select(-scenario) %>% + write.csv(file = paste0(getConfig("outputfolder"), "/", outfile), + row.names = FALSE, quote = FALSE) + + } else { + warning("`type` must be either `full` or `config`") + } + +} diff --git a/R/readGlobalEnergyMonitor.R b/R/readGlobalEnergyMonitor.R index 8767f7da..56687c93 100644 --- a/R/readGlobalEnergyMonitor.R +++ b/R/readGlobalEnergyMonitor.R @@ -1,7 +1,8 @@ #' Read Global Energy Monitor data #' +#' read GEM data for all available technologies and relevant statuses #' -#' @author Rahel Mandaroux, Falk Benke +#' @author Rahel Mandaroux, Falk Benke, Pascal Weigmann #' #' @importFrom dplyr filter mutate select #' @importFrom readxl read_xlsx @@ -9,122 +10,106 @@ #' #' @export readGlobalEnergyMonitor <- function() { - notebooks <- list( - "Bioenergy" = list( - file = "Global-Bioenergy-Power-Tracker-January-2023.xlsx", - variable = "Cap|Electricity|Biomass", - statusCol = "Operating Status" - ), - "Hydropower" = list( - file = "Global-Hydropower-Tracker-May-2023.xlsx", - variable = "Cap|Electricity|Hydro", - # Hydro Power might affect 2 countries, we assign it to the first one - countryCol = "Country 1", - startCol = "Start Year", - endCol = "Retired Year" - ), - "Nuclear" = list( - file = "Global-Nuclear-Power-Tracker-January-2023.xlsx", - variable = "Cap|Electricity|Nuclear", - startCol = "Start Year", - endCol = "Retired Year" - ), - "Solar" = list( - file = "Global-Solar-Power-Tracker-May-2023.xlsx", - variable = "Cap|Electricity|Solar" - ), - "Wind Offshore" = list( - file = "Global-Wind-Power-Tracker-May-2023.xlsx", - variable = "Cap|Electricity|Wind|Offshore", - typeCol = "Installation Type", - typeVals = c("offshore hard mount", "offshore mount unknown", "offshore floating") - ), - "Wind Onshore" = list( - file = "Global-Wind-Power-Tracker-May-2023.xlsx", - variable = "Cap|Electricity|Wind|Onshore", - typeCol = "Installation Type", - typeVals = c("onshore") - ), - "Coal" = list( - file = "Global-Coal-Plant-Tracker-July-2023.xlsx", - variable = "Cap|Coal", - sheetName = "Units", - projectCol = "Plant name" - ) - ) + # GEM GIPT 2024 + # file available after filling out questionnaire: + # https://globalenergymonitor.org/projects/global-integrated-power-tracker/download-data/ + d <- read_excel("Global-Integrated-Power-June-2024.xlsx", + sheet = "Power facilities", + trim_ws = TRUE, + col_types = "text") %>% + select(variable = "Type", + tech = "Technology", + region = "Country/area", + value = "Capacity (MW)", + status = "Status", + start = "Start year", + end = "Retired year", + # hydropower specific columns for shared projects + c1 = "Country/area 1 (hydropower only)", + c2 = "Country/area 2 (hydropower only)", + v1 = "Country/area 1 Capacity (MW) (hydropower only)", + v2 = "Country/area 2 Capacity (MW) (hydropower only)") %>% + filter(status %in% c("announced", "pre-construction", "construction", "operating")) %>% + # ASSUMPTION: rows with empty start year are ignored + # only look at pipeline until 2030 + filter(!is.na(start), start < 2031) %>% + # Oil/Gas needs to be separated by technology or fuel (seems complicated?) + # remove for now + filter(variable != "oil/gas") %>% + mutate(start = as.numeric(start), end = as.numeric(end), value = as.numeric(value)) - out <- NULL + # no end year defined: + # use average lifetime of technology (from generisdata_tech) + lifetime <- c(coal = 40, bioenergy = 40, nuclear = 50, hydropower = 130, + geothermal = 30, wind = 25, solar = 30) + for (tech in names(lifetime)) { + d[is.na(d$end) & d$variable == tech, "end"] <- + d[is.na(d$end) & d$variable == tech, "start"] + lifetime[[tech]] + } - for (nb in notebooks) { - cols <- c( - "region" = ifelse(is.null(nb$countryCol), "Country", nb$countryCol), - "project" = ifelse(is.null(nb$projectCol), "Project Name", nb$projectCol), - "value" = "Capacity (MW)", - "status" = ifelse(is.null(nb$statusCol), "Status", nb$statusCol), - "start" = ifelse(is.null(nb$startCol), "Start year", nb$startCol), - "end" = ifelse(is.null(nb$endCol), "Retired year", nb$endCol) - ) + # special case hydropower: some projects are divided between 2 countries + # find all of these cases and put them in 2 rows, one per country + d <- rbind( + d[is.na(d$c2), ], + d[!is.na(d$c2), ] %>% mutate(region = c1, value = as.numeric(v1)), + d[!is.na(d$c2), ] %>% mutate(region = c2, value = as.numeric(v2)) + ) %>% + select(-c1, -c2, -v1, -v2) - if (!is.null(nb$typeCol)) { - cols <- c(cols, "type" = nb$typeCol) - } + # use proper variable names + d[d$variable == "coal", "variable"] <- "Cap|Electricity|Coal" + d[d$variable == "bioenergy", "variable"] <- "Cap|Electricity|Biomass" + d[d$variable == "nuclear", "variable"] <- "Cap|Electricity|Nuclear" + d[d$variable == "geothermal", "variable"] <- "Cap|Electricity|Geothermal" - data <- read_excel( - path = nb$file, - sheet = ifelse(is.null(nb$sheetName), "Data", nb$sheetName), - trim_ws = TRUE, col_types = "text" - ) %>% - select(all_of(cols)) %>% - mutate( - "value" = as.numeric(!!sym("value")), - "start" = as.numeric(!!sym("start")), - "end" = as.numeric(!!sym("end")) - ) + # remove pumped storage, keep ca. 3 GW of "conventional and pumped storage" + d <- d[!d$tech %in% "pumped storage", ] + d[d$variable == "hydropower", "variable"] <- "Cap|Electricity|Hydro" - if (!is.null(nb$typeCol)) { - data <- data %>% - filter( - !!sym("type") %in% nb$typeVals - ) %>% - select(-"type") - } + # separate wind into on- and offshore, "Unknown"/"blank" are all onshore + offshore_tech <- c("Offshore hard mount", "Offshore floating", "Offshore mount unknown") + d[d$variable == "wind" & d$tech %in% offshore_tech, "variable"] <- "Cap|Electricity|Wind|Offshore" + d[d$variable == "wind", "variable"] <- "Cap|Electricity|Wind|Onshore" + # separate solar into PV and CSP (called "Solar Thermal" by GEM) + d[d$variable == "solar" & d$tech == "Solar Thermal", "variable"] <- "Cap|Electricity|Solar|CSP" + d[d$variable == "solar", "variable"] <- "Cap|Electricity|Solar|PV" - # read in completed projects - completed <- data %>% filter(!is.na(!!sym("start")), !is.na(!!sym("end"))) + # transform data from list of capacities with start and end date + # to sum of active capacities in 2025 and 2030 + d <- mutate(d, end = pmin(end, 2030)) # improves performance of next step + tmp_list <- vector("list", nrow(d)) + for (i in seq_len(nrow(d))) { + tmp_list[[i]] <- data.frame( + d[i, c("region", "value", "variable", "status")], + period = seq(as.numeric(d[i, "start"]), as.numeric(d[i, "end"]), 1) + ) + } + tmp <- do.call(rbind, tmp_list) %>% + group_by(region, variable, status, period) %>% + summarise(value = sum(value)) %>% + filter(period %in% c(2025, 2030)) - # read in projects with start year and no retirement, as well as a status - # indicating probable realization, assume them running until 2050 - # rows with empty start year are ignored - status <- c("announced", "pre-construction", "construction", "operating") - ongoing <- data %>% - filter( - !is.na(!!sym("start")), is.na(!!sym("end")), - !!sym("status") %in% status - ) %>% - mutate("end" = 2050) + # convert to magclass object + x <- as.magpie(tmp, spatial = "region") + x[is.na(x)] <- 0 - production <- rbind(completed, ongoing) - tmp <- NULL - for (i in seq_len(nrow(production))) { - d <- data.frame( - production[i, c("region", "value", "project")], - period = seq(as.numeric(production[i, "start"]), as.numeric(production[i, "end"]), 1) - ) - tmp <- rbind(tmp, d) - } - cap <- aggregate(value ~ region + period, data = tmp, FUN = sum) %>% - mutate("variable" = nb$variable) %>% - select("region", "period", "variable", "value") + # add solar and wind totals as variables + x <- mbind( + x, + dimSums(x[, , c("Cap|Electricity|Solar|PV", "Cap|Electricity|Solar|CSP")], dim = 3.1) %>% + add_dimension(dim = 3.1, add = "variable", nm = "Cap|Electricity|Solar"), + dimSums(x[, , c("Cap|Electricity|Wind|Offshore", "Cap|Electricity|Wind|Onshore")], dim = 3.1) %>% + add_dimension(dim = 3.1, add = "variable", nm = "Cap|Electricity|Wind") + ) - out <- rbind(out, cap) - } - x <- as.magpie(out, spatial = 1) + # collapse variable and status dimension into one + # getNames(x) <- gsub(pattern = "\\.", replacement = "|", x = getNames(x)) - # convert to GW + # convert MW to GW x <- x / 1000 - x <- add_dimension(x, dim = 3.2, add = "unit", nm = "GW") - x <- add_dimension(x, dim = 3.1, add = "model", nm = "Global Energy Monitor") + x <- add_dimension(x, dim = 3.4, add = "unit", nm = "GW") + x <- add_dimension(x, dim = 3.1, add = "model", nm = "GlobalEnergyMonitor") return(x) } diff --git a/R/readIEA_CCUS.R b/R/readIEA_CCUS.R index 1cafb17a..e49277a8 100644 --- a/R/readIEA_CCUS.R +++ b/R/readIEA_CCUS.R @@ -4,17 +4,19 @@ #' #' @author Anne Merfort, Falk Benke #' -#' @param subtype either `historical` for data from until 2022 or `projections` -#' for projections in 2020, 2025 and 2030 +#' @param subtype either `historical` for data until 2023, +#' `projections` for "high" and "low" projections up to 2030 used as input-data +#' or `pipeline` separated by status for use in formulating near-term bounds #' @importFrom dplyr filter mutate select #' @importFrom readxl read_xlsx #' #' @export readIEA_CCUS <- function(subtype) { + # ASSUMPTION: transport and storage are limiting factors for CCS # project types filter applied to source projectTypes <- c("Full chain", "Storage", "T&S") - data <- read_excel("IEA CCUS Projects Database 2023.xlsx", + data <- read_excel("IEA CCUS Projects Database 2024.xlsx", sheet = "CCUS Projects Database" ) %>% select( @@ -24,25 +26,44 @@ readIEA_CCUS <- function(subtype) { "start" = "Operation", "end" = "Suspension/decommissioning", "status" = "Project Status", - "value" = "Announced capacity (high) (Mt CO2/yr)" + "value" = "Estimated capacity by IEA (Mt CO2/yr)" ) %>% # remove entries without announced capacities and not matching project type - filter(!is.na(.data$value), .data$type %in% projectTypes) %>% - # if empty, assume project start in 2030 - # end in 2030, unless decommissioned before - mutate( - "start" = ifelse(is.na(.data$start), 2030, .data$start), - "end" = ifelse(is.na(.data$end), 2030, .data$end) - ) %>% - # remove entries where suspension is before operation or in same year - filter(.data$start <= .data$end) + filter(!is.na(.data$value), .data$type %in% projectTypes) - # manually assign shared project(s) to one country + # manually assign shared project(s) to one (currently: first) country data[data$project == "EU2NSEA", "country"] <- "Norway" + data[data$country == "Japan-unknown", "country"] <- "Japan" + + # correct typo in IEA Data + data[data$country == "Lybia", "country"] <- "Libya" + + # share capacities of projects by multiple countries according to their GDP + gdp <- calcOutput("GDP", aggregate = FALSE) + gdp_JPN <- as.numeric(gdp["JPN", 2020, "gdp_SSP2EU"]) + gdp_AUS <- as.numeric(gdp["AUS", 2020, "gdp_SSP2EU"]) + gdp_MYS <- as.numeric(gdp["MYS", 2020, "gdp_SSP2EU"]) + + JM <- data[data$country == "Japan-Malaysia", ] + AJ <- data[data$country == "Australia-Japan", ] + + # remove mixed-country data and attach single country data weighted by GDP + data <- data %>% + filter(!country %in% c("Japan-Malaysia", "Australia-Japan")) %>% + rbind( + mutate(JM, country = "Japan", value = value*gdp_JPN/(gdp_JPN+gdp_MYS)), + mutate(JM, country = "Malaysia", value = value*gdp_MYS/(gdp_JPN+gdp_MYS)), + mutate(AJ, country = "Australia", value = value*gdp_AUS/(gdp_JPN+gdp_AUS)), + mutate(AJ, country = "Japan", value = value*gdp_JPN/(gdp_JPN+gdp_AUS)) + ) if (subtype == "historical") { hist <- data %>% - filter(.data$start <= 2022) + filter(.data$start <= 2023, + .data$status != "Suspended/cancelled/decommissioned") + # ASSUMPTION: if no end year is given, assume project remains active at + # least until present + hist[is.na(hist$end), "end"] <- 2023 tmp <- NULL for (i in seq_len(nrow(hist))) { @@ -56,7 +77,7 @@ readIEA_CCUS <- function(subtype) { } cap <- aggregate(value ~ country + period, data = tmp, FUN = sum) %>% - filter(.data$period <= 2022) %>% + filter(.data$period <= 2023) %>% mutate(variable = "Carbon Management|Storage") cap <- cap[, c("country", "period", "variable", "value")] @@ -64,12 +85,24 @@ readIEA_CCUS <- function(subtype) { } else if (subtype == "projections") { + # ASSUMPTION: if empty start year, assume project start in 2030 + # end in 2030, unless decommissioned before + proj <- data %>% + mutate( + "start" = ifelse(is.na(.data$start), 2030, .data$start), + "end" = ifelse(is.na(.data$end), 2030, .data$end) + ) %>% + # remove entries where suspension is before operation or in same year + filter(.data$start < .data$end) + + # ASSUMPTION: low or high expectations for realized projects by status statusLow <- c("Operational", "Under construction") statusHigh <- c(statusLow, "Planned") - proj <- data %>% + proj <- proj %>% filter(.data$status %in% statusHigh) + # convert to data.frame with yearly active capacities tmp <- NULL for (i in seq_len(nrow(proj))) { tmp <- rbind( @@ -97,8 +130,58 @@ readIEA_CCUS <- function(subtype) { cap <- cap[, c("country", "period", "variable", "value")] x <- as.magpie(cap, spatial = 1) x <- x[, c(2020, 2025, 2030), ] + + } else if (subtype == "pipeline") { + + # ASSUMPTION: if empty start year, remove project + # assume projects run at least until 2030 + pipe <- data %>% + filter(!is.na(.data$start)) %>% + mutate("end" = ifelse(is.na(.data$end), 2030, .data$end)) %>% + # remove entries where suspension is before operation or in same year + filter(.data$start < .data$end) %>% + # remove cancelled projects + filter(.data$status != "Suspended/cancelled/decommissioned") + + # convert to data.frame with yearly active capacities + tmp <- NULL + for (i in seq_len(nrow(pipe))) { + tmp <- rbind( + tmp, + data.frame( + pipe[i, c("country", "status", "value")], + period = seq(as.numeric(pipe[i, "start"]), as.numeric(pipe[i, "end"]), 1) + ) + ) + } + + # aggregate by country and period, new variables depending on status + capOp <- aggregate(value ~ country + period, + data = filter(tmp, .data$status %in% "Operational"), + FUN = sum + ) %>% + mutate(status = "operational") + + capCon <- aggregate(value ~ country + period, + data = filter(tmp, .data$status %in% "Under construction"), + FUN = sum + ) %>% + mutate(status = "construction") + + capPlan <- aggregate(value ~ country + period, + data = filter(tmp, .data$status %in% "Planned"), + FUN = sum + ) %>% + mutate(status = "planned") + + cap <- rbind(capOp, capCon, capPlan) %>% + mutate(variable = "Carbon Management|Storage") + cap <- cap[, c("country", "period", "variable", "status", "value")] + x <- as.magpie(cap, spatial = 1) + } else { - stop("Invalid subtype. Must be eiter `historical` or `projections`") + stop("Invalid subtype. Must be either + `historical`, `pipeline` or `projections`") } x[is.na(x)] <- 0 diff --git a/README.md b/README.md index ef12c4c0..86802723 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MadRat REMIND Input Data Package -R package **mrremind**, version **0.184.1** +R package **mrremind**, version **0.186.0** [![CRAN status](https://www.r-pkg.org/badges/version/mrremind)](https://cran.r-project.org/package=mrremind) [![R build status](https://github.com/pik-piam/mrremind/workflows/check/badge.svg)](https://github.com/pik-piam/mrremind/actions) [![codecov](https://codecov.io/gh/pik-piam/mrremind/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mrremind) [![r-universe](https://pik-piam.r-universe.dev/badges/mrremind)](https://pik-piam.r-universe.dev/builds) @@ -39,7 +39,7 @@ In case of questions / problems please contact Lavinia Baumstark . +Baumstark L, Rodrigues R, Levesque A, Oeser J, Bertram C, Mouratiadou I, Malik A, Schreyer F, Soergel B, Rottoli M, Mishra A, Dirnaichner A, Pehl M, Giannousakis A, Klein D, Strefler J, Feldhaus L, Brecha R, Rauner S, Dietrich J, Bi S, Benke F, Weigmann P, Richters O, Hasse R, Fuchs S, Mandaroux R, Koch J (2024). _mrremind: MadRat REMIND Input Data Package_. R package version 0.186.0, . A BibTeX entry for LaTeX users is @@ -48,7 +48,7 @@ A BibTeX entry for LaTeX users is title = {mrremind: MadRat REMIND Input Data Package}, author = {Lavinia Baumstark and Renato Rodrigues and Antoine Levesque and Julian Oeser and Christoph Bertram and Ioanna Mouratiadou and Aman Malik and Felix Schreyer and Bjoern Soergel and Marianna Rottoli and Abhijeet Mishra and Alois Dirnaichner and Michaja Pehl and Anastasis Giannousakis and David Klein and Jessica Strefler and Lukas Feldhaus and Regina Brecha and Sebastian Rauner and Jan Philipp Dietrich and Stephen Bi and Falk Benke and Pascal Weigmann and Oliver Richters and Robin Hasse and Sophie Fuchs and Rahel Mandaroux and Johannes Koch}, year = {2024}, - note = {R package version 0.184.1}, + note = {R package version 0.186.0}, url = {https://github.com/pik-piam/mrremind}, } ``` diff --git a/man/calcGlobalEnergyMonitor.Rd b/man/calcGlobalEnergyMonitor.Rd index e02460ee..9df6ca71 100644 --- a/man/calcGlobalEnergyMonitor.Rd +++ b/man/calcGlobalEnergyMonitor.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/calcGlobalEnergyMonitor.R \name{calcGlobalEnergyMonitor} \alias{calcGlobalEnergyMonitor} -\title{Calculate REMIND variables from Global Energy Monitor} +\title{Calc capacities from Global Energy Monitor} \usage{ calcGlobalEnergyMonitor() } @@ -10,7 +10,7 @@ calcGlobalEnergyMonitor() A \code{\link[magclass:magclass-package]{magpie}} object. } \description{ -Calculate REMIND variables from Global Energy Monitor +Calculate near-term expectations of capacities for use in fullVALIDATION.R } \author{ Falk Benke diff --git a/man/calcProjectPipelines.Rd b/man/calcProjectPipelines.Rd new file mode 100644 index 00000000..17d52beb --- /dev/null +++ b/man/calcProjectPipelines.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/calcProjectPipelines.R +\name{calcProjectPipelines} +\alias{calcProjectPipelines} +\title{calc Project Pipelines} +\usage{ +calcProjectPipelines(subtype) +} +\arguments{ +\item{subtype}{choose technology `biomass`, `coal`, `geothermal`, `hydro`, +`nuclear`, `solar`, `wind` or `CCS`} +} +\description{ +Calculate the expected near-term deployment of technologies based on +projects that are currently either being built or in a planning stage +for some technologies multiple sources are available +} +\author{ +Pascal Weigmann +} diff --git a/man/exportThresholds.Rd b/man/exportThresholds.Rd new file mode 100644 index 00000000..aca6e114 --- /dev/null +++ b/man/exportThresholds.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/exportThresholds.R +\name{exportThresholds} +\alias{exportThresholds} +\title{export validation thresholds} +\usage{ +exportThresholds(type = "config", years = NULL) +} +\arguments{ +\item{type}{choose either "config" to export thresholds as used in the +validationConfig or "full" to export all pipeline data} + +\item{years}{choose years to include, currenty only 2025 and 2030 are +available, if NULL uses all available years} +} +\description{ +assemble near-term thresholds from project pipelines and potentially other +data sources and export them to a file +} +\author{ +Pascal Weigmann +} diff --git a/man/readGlobalEnergyMonitor.Rd b/man/readGlobalEnergyMonitor.Rd index 35c4fed6..453bf758 100644 --- a/man/readGlobalEnergyMonitor.Rd +++ b/man/readGlobalEnergyMonitor.Rd @@ -7,8 +7,8 @@ readGlobalEnergyMonitor() } \description{ -Read Global Energy Monitor data +read GEM data for all available technologies and relevant statuses } \author{ -Rahel Mandaroux, Falk Benke +Rahel Mandaroux, Falk Benke, Pascal Weigmann } diff --git a/man/readIEA_CCUS.Rd b/man/readIEA_CCUS.Rd index 90d71e07..8c847359 100644 --- a/man/readIEA_CCUS.Rd +++ b/man/readIEA_CCUS.Rd @@ -7,8 +7,9 @@ readIEA_CCUS(subtype) } \arguments{ -\item{subtype}{either `historical` for data from until 2022 or `projections` -for projections in 2020, 2025 and 2030} +\item{subtype}{either `historical` for data until 2023, +`projections` for "high" and "low" projections up to 2030 used as input-data + or `pipeline` separated by status for use in formulating near-term bounds} } \description{ Reads in capacities from projects in IEA CCUS database