Skip to content

Commit

Permalink
Merge pull request #520 from fbenke-pik/eea
Browse files Browse the repository at this point in the history
Update EEA GHG Detailed Projections to 2023 Values
  • Loading branch information
fbenke-pik authored Jul 10, 2024
2 parents f78b7a0 + e5b3833 commit dc16ed9
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '36399136'
ValidationKey: '36420877'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -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.182.8
date-released: '2024-07-08'
version: 0.182.9
date-released: '2024-07-09'
abstract: The mrremind packages contains data preprocessing for the REMIND model.
authors:
- family-names: Baumstark
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
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.182.8
Date: 2024-07-08
Version: 0.182.9
Date: 2024-07-09
Authors@R: c(
person("Lavinia", "Baumstark", , "[email protected]", role = c("aut", "cre")),
person("Renato", "Rodrigues", role = "aut"),
Expand Down
36 changes: 19 additions & 17 deletions R/calcEEAGHGProjections.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
#'
#' @author Falk Benke
#'
#' @importFrom dplyr select mutate left_join
#' @importFrom dplyr select mutate left_join filter
#' @importFrom rlang sym
#' @importFrom quitte calc_addVariable
#' @export

calcEEAGHGProjections <- function() {
mapping <- toolGetMapping(type = "sectoral", name = "mappingEEAGHGProjections.csv", where = "mappingfolder")

mapping <- toolGetMapping(type = "sectoral",
name = "mappingEEAGHGProjections.csv", where = "mrremind")
eea <- readSource("EEA_EuropeanEnvironmentAgency", subtype = "projections")

projectionsOverview <- as.data.frame(eea) %>%
Expand All @@ -20,47 +21,46 @@ calcEEAGHGProjections <- function() {
"region" = "Region", "year" = "Year", "model" = "Data1",
"Category" = "Data2", "Gas" = "Data3", "value" = "Value"
) %>%
mutate(!!sym("Category") := gsub("_", ".", !!sym("Category"))) %>%
mutate("Category" = gsub("_", ".", !!sym("Category"))) %>%
left_join(mapping, by = c("Category", "Gas")) %>%
filter(!is.na(!!sym("Variable"))) %>%
select("region", "year", "model", "variable" = "Variable", "value") %>%
calc_addVariable(
quitte::calc_addVariable(
"`Emi|GHG|Industry|ETS`" = "`Emi|GHG|Industrial Processes|ETS` + `Emi|GHG|Energy|Demand|Industry|ETS`",
"`Emi|GHG|Industry|ESR`" = "`Emi|GHG|Industrial Processes|ESR` + `Emi|GHG|Energy|Demand|Industry|ESR`",
# "`Emi|GHG|Industry`" = "`Emi|GHG|Industry|ETS` + `Emi|GHG|Industry|ESR`", # currently calculated in detailed source
"`Emi|GHG|Intl aviation in ETS|ETS`" = "`Emi|GHG|w/ Intl aviation` - `Emi|GHG`",
completeMissing = F
) %>%
mutate(
!!sym("value") := !!sym("value") / 1000,
!!sym("model") := paste0("EEA_", !!sym("model")),
!!sym("variable") := paste0(!!sym("variable"), " (Mt CO2eq/yr)")
"value" = !!sym("value") / 1000,
"model" = paste0("EEA_", !!sym("model")),
"variable" = paste0(!!sym("variable"), " (Mt CO2eq/yr)")
)

eeaDetail <- readSource("EEA_EuropeanEnvironmentAgency", subtype = "projections-detailed")
mappingDetailed <- toolGetMapping(type = "sectoral", name = "mappingEEAGHGProjectionsDetailed.csv",
where = "mappingfolder")
mappingDetailed <- toolGetMapping(type = "sectoral", name = "mappingEEAGHGProjectionsDetailed.csv",
where = "mrremind")

projectionsDetail <- as.data.frame(eeaDetail) %>%
filter(!is.na(!!sym("Value"))) %>%
select(
"region" = "Region", "year" = "Year", "model" = "Data1",
"Category" = "Data2", "Gas" = "Data3", "value" = "Value"
) %>%
mutate(!!sym("Category") := gsub("_", ".", !!sym("Category"))) %>%
mutate("Category" = gsub("_", ".", !!sym("Category"))) %>%
left_join(mappingDetailed, by = c("Category", "Gas")) %>%
filter(!is.na(!!sym("Variable"))) %>%
mutate(!!sym("value") := as.numeric(!!sym("value")) * !!sym("factor")) %>%
mutate("value" = as.numeric(!!sym("value")) * !!sym("factor")) %>%
select("region", "year", "model", "variable" = "Variable", "value", "unit") %>%
calc_addVariable(
quitte::calc_addVariable(
"`Emi|CO2|Industry`" = "`Emi|CO2|Energy|Demand|Industry` + `Emi|CO2|Industrial Processes`",
"`Emi|GHG|Industry`" = "`Emi|GHG|Energy|Demand|Industry` + `Emi|GHG|Industrial Processes`",
"`Emi|CO2|Energy|Demand|Buildings`" = "`Emi|CO2|Energy|Demand|Buildings|Residential` + `Emi|CO2|Energy|Demand|Buildings|Commercial`",
completeMissing = F, units = c("Mt CO2/yr", "Mt CO2eq/yr", "Mt CO2/yr")
) %>%
mutate(
!!sym("variable") := paste0(!!sym("variable"), " (", !!sym("unit"), ")"),
!!sym("model") := paste0("EEA_", !!sym("model"))
"variable" = paste0(!!sym("variable"), " (", !!sym("unit"), ")"),
"model" = paste0("EEA_", !!sym("model"))
) %>%
select(-"unit")

Expand All @@ -70,8 +70,10 @@ calcEEAGHGProjections <- function() {
!!sym("region"), !!sym("year"), !!sym("model"), !!sym("variable"),
.keep_all = TRUE
)

x <- as.magpie(projections, spatial = 1, temporal = 2, datacol = 5) %>%
toolCountryFill(fill = NA, verbosity = 2)
toolCountryFill(fill = NA, verbosity = 2) %>%
toolFillEU34Countries()

return(list(
x = x,
Expand Down
5 changes: 1 addition & 4 deletions R/calcHistorical.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ calcHistorical <- function() {

# Region specific historical data ====

# EEA GHG Projections
EEA_GHGProjections <- toolFillEU34Countries(calcOutput("EEAGHGProjections", aggregate = FALSE, warnNA = FALSE))

# EEA GHG Sectoral Historical Data
EEA_GHGSectoral <- toolFillEU34Countries(readSource("EEA_EuropeanEnvironmentAgency", subtype = "sectoral"))
EEA_GHGSectoral <- add_dimension(EEA_GHGSectoral, dim = 3.1, add = "model", nm = "EEA_historical")
Expand Down Expand Up @@ -233,7 +230,7 @@ calcHistorical <- function() {
fe_iea, fe_weo, pe_iea, pe_weo, trade, pop, gdp,
ceds, primap, cdiac, LU_EDGAR_LU, LU_CEDS,
LU_FAO_EmisLUC, LU_FAO_EmisAg, LU_PRIMAPhist, IRENAcap, emiEurostat,
EEA_GHGSectoral, EEA_GHGTotal, EEA_GHGProjections, Emi_Reference,
EEA_GHGSectoral, EEA_GHGTotal, Emi_Reference,
worldsteel, USGS_cement
)

Expand Down
10 changes: 10 additions & 0 deletions R/fullVALIDATIONREMIND.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ fullVALIDATIONREMIND <- function(rev = 0) {
)

# EDGAR8 Emissions----

edg8 <- calcOutput(
type = "Emissions", datasource = "EDGAR8",
aggregate = columnsForAggregation, warnNA = FALSE,
Expand Down Expand Up @@ -131,6 +132,15 @@ fullVALIDATIONREMIND <- function(rev = 0) {
writeArgs = list(scenario = "historical")
)

# EU National GHG Projections ----

calcOutput(
type = "EEAGHGProjections", file = valfile,
aggregate = columnsForAggregation, append = TRUE, warnNA = FALSE,
try = FALSE, years = years,
writeArgs = list(scenario = "historical")
)

# Global Energy Monitor ----

calcOutput(
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MadRat REMIND Input Data Package

R package **mrremind**, version **0.182.8**
R package **mrremind**, version **0.182.9**

[![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)

Expand Down Expand Up @@ -39,7 +39,7 @@ In case of questions / problems please contact Lavinia Baumstark <lavinia@pik-po

To cite package **mrremind** in publications use:

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.182.8, <https://github.com/pik-piam/mrremind>.
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.182.9, <https://github.com/pik-piam/mrremind>.

A BibTeX entry for LaTeX users is

Expand All @@ -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.182.8},
note = {R package version 0.182.9},
url = {https://github.com/pik-piam/mrremind},
}
```
22 changes: 22 additions & 0 deletions inst/extdata/sectoral/mappingEEAGHGProjections.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Variable;Category;Gas
Emi|GHG;Total excluding LULUCF;Total GHG emissions (ktCO2e)
Emi|GHG|ESR;Total excluding LULUCF;ESR emissions (ktCO2e)
Emi|GHG|ETS;Total excluding LULUCF;ETS emissions (ktCO2e)
Emi|GHG|Supply|ETS;1.A.1. Energy industries;ETS emissions (ktCO2e)
Emi|GHG|Supply|ESR;1.A.1. Energy industries;ESR emissions (ktCO2e)
Emi|GHG|Supply|FugitiveEmifromFuels|ETS;1.B. Fugitive emissions from fuels;ETS emissions (ktCO2e)
Emi|GHG|Energy|Demand|Industry|ETS;1.A.2. Manufacturing industries and construction;ETS emissions (ktCO2e)
Emi|GHG|Industrial Processes|ETS;2. Industrial processes;ETS emissions (ktCO2e)
Emi|GHG|Energy|Demand|Industry|ESR;1.A.2. Manufacturing industries and construction;ESR emissions (ktCO2e)
Emi|GHG|Energy|Demand|Transport|ESR;1.A.3. Transport;ESR emissions (ktCO2e)
Emi|GHG|Industrial Processes|ESR;2. Industrial processes;ESR emissions (ktCO2e)
Emi|GHG|Energy|Demand|Industry;1.A.2. Manufacturing industries and construction;Total GHG emissions (ktCO2e)
Emi|GHG|Industrial Processes;2. Industrial processes;Total GHG emissions (ktCO2e)
Emi|GHG|Agriculture;3. Agriculture;ESR emissions (ktCO2e)
Emi|GHG|Supply|FugitiveEmifromFuels|ESR;1.B. Fugitive emissions from fuels;ESR emissions (ktCO2e)
Emi|GHG|Demand|Other Sectors(Residential+X)|ESR;1.A.4. Other sectors;ESR emissions (ktCO2e)
Emi|GHG|Waste;5. Waste;ESR emissions (ktCO2e)
Emi|GHG|Bunkers|Aviation;IB.Aviation;Total GHG emissions (ktCO2e)
Emi|GHG|Bunkers|Navigation;IB.Navigation;Total GHG emissions (ktCO2e)
Emi|GHG|w/o LULUCF;Total excluding LULUCF;Total GHG emissions (ktCO2e)
Emi|GHG|w/ Intl aviation;Total excluding LULUCF (incl. Int. Aviation);Total GHG emissions (ktCO2e)
19 changes: 19 additions & 0 deletions inst/extdata/sectoral/mappingEEAGHGProjectionsDetailed.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Variable;Category;Gas;unit;factor
Emi|CO2;Total excluding LULUCF;CO2 (kt);Mt CO2/yr;0.001
Emi|GHG;Total excluding LULUCF;Total GHG emissions (ktCO2e);Mt CO2eq/yr;0.001
Emi|CO2|Energy;1. Energy;CO2 (kt);Mt CO2/yr;0.001
Emi|GHG|Energy;1. Energy;Total GHG emissions (ktCO2e);Mt CO2eq/yr;0.001
Emi|CO2|Energy|Supply;1.A.1. Energy industries;CO2 (kt);Mt CO2/yr;0.001
Emi|CO2|Energy|Supply|Electricity and Heat;1.A.1.a. Public electricity and heat production;CO2 (kt);Mt CO2/yr;0.001
Emi|CO2|Energy|Demand|Industry;1.A.2. Manufacturing industries and construction;CO2 (kt);Mt CO2/yr;0.001
Emi|GHG|Energy|Demand|Industry;1.A.2. Manufacturing industries and construction;Total GHG emissions (ktCO2e);Mt CO2eq/yr;0.001
Emi|CO2|Energy|Demand|Transport;1.A.3. Transport;CO2 (kt);Mt CO2/yr;0.001
Emi|CO2|Energy|Demand|Buildings|Commercial;1.A.4.a. Commercial/Institutional;CO2 (kt);Mt CO2/yr;0.001
Emi|CO2|Energy|Demand|Buildings|Residential;1.A.4.b. Residential;CO2 (kt);Mt CO2/yr;0.001
Emi|CO2|Industrial Processes;2. Industrial processes;CO2 (kt);Mt CO2/yr;0.001
Emi|GHG|Industrial Processes;2. Industrial processes;Total GHG emissions (ktCO2e);Mt CO2eq/yr;0.001
Emi|GHG|Agriculture;3. Agriculture;Total GHG emissions (ktCO2e);Mt CO2eq/yr;0.001
Emi|CO2|Land-Use Change;4. Land Use, Land-Use Change and Forestry (LULUCF, reported emissions and removals) (9);CO2 (kt);Mt CO2/yr;0.001
Emi|GHG|Land-Use Change;4. Land Use, Land-Use Change and Forestry (LULUCF, reported emissions and removals) (9);Total GHG emissions (ktCO2e);Mt CO2eq/yr;0.001
Emi|GHG|Waste;5. Waste;Total GHG emissions (ktCO2e);Mt CO2eq/yr;0.001
Emi|CO2|Energy|Demand|Transport|International Bunkers;International bunkers;CO2 (kt);Mt CO2/yr;0.001

0 comments on commit dc16ed9

Please sign in to comment.