-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/pik-piam/mrremind into we…
…o-ref
- Loading branch information
Showing
18 changed files
with
527 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", , "[email protected]", role = c("aut", "cre")), | ||
person("Renato", "Rodrigues", role = "aut"), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`") | ||
} | ||
|
||
} |
Oops, something went wrong.