Skip to content

Commit

Permalink
GAINS data update including primary PM25
Browse files Browse the repository at this point in the history
  • Loading branch information
rauner committed Oct 11, 2021
1 parent e698a13 commit f1dd0c1
Show file tree
Hide file tree
Showing 10 changed files with 873 additions and 776 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '15503740'
ValidationKey: '15696130'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
.RData
.Ruserdata
fe_variables.csv
.github/workflows/lucode2-check.yaml
.buildlibrary

2 changes: 1 addition & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "mrremind: MadRat REMIND Input Data Package",
"version": "0.82.0",
"version": "0.83.0",
"description": "<p>The mrremind packages contains data preprocessing for the REMIND model.<\/p>",
"creators": [
{
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: mrremind
Type: Package
Title: MadRat REMIND Input Data Package
Version: 0.82.0
Date: 2021-10-07
Version: 0.83.0
Date: 2021-10-11
Authors@R: c(person("Lavinia", "Baumstark", email = "lavinia@pik-potsdam.de", role = c("aut","cre")),
person("Renato", "Rodrigues", role = "aut"),
person("Antoine", "Levesque", role = "aut"),
Expand Down
695 changes: 365 additions & 330 deletions R/calcEmissionFactors.R

Large diffs are not rendered by default.

447 changes: 233 additions & 214 deletions R/calcGAINS.R

Large diffs are not rendered by default.

130 changes: 64 additions & 66 deletions R/calcGAINSEmi.R
Original file line number Diff line number Diff line change
@@ -1,101 +1,99 @@
#' Calculate air pollution emissions and emission factors from GAINS data
#'
#'
#' Provides input data for exoGAINSAirpollutants.R
#'
#'
#'
#'
#' @return Emissions and emission factors
#' @author Sebastian Rauner
#' @param subtype "emission_factors", "emissions","emissions_starting_values"
#' @seealso \code{\link{calcOutput}}
#' @examples
#'
#' \dontrun{
#' \dontrun{
#' calcOutput("calcGAINSEmi")
#' }
#'
calcGAINSEmi <- function(subtype = "emissions") {

if (!(subtype %in% c("emission_factors", "emissions", "emissions_starting_values"))) stop('subtype must be in c("emission_factors", "emissions","emissions_starting_values")')

if (subtype == "emissions") {
emi_gains_ext_in <- calcOutput("GAINS", subtype = "emissions", sectoral_resolution = "extended", aggregate = FALSE) # in Mt
emi_gains_agg_in <- calcOutput("GAINS", subtype = "emissions", sectoral_resolution = "aggregated", aggregate = FALSE) # in Mt

calcGAINSEmi <- function(subtype="emissions") {

if (!(subtype %in% c("emission_factors", "emissions","emissions_starting_values"))) stop('subtype must be in c("emission_factors", "emissions","emissions_starting_values")')

if(subtype=="emissions") {
emi_gains_ext_in <- calcOutput("GAINS",subtype = "emissions",sectoral_resolution="extended",aggregate=FALSE) # in Mt
emi_gains_agg_in <- calcOutput("GAINS",subtype = "emissions",sectoral_resolution="aggregated",aggregate=FALSE) # in Mt


# mainly: combine extended and aggregated GAINS data by appending
# waste sectors from extended to aggregated and then using
# aggregated only

# construct mappings: add waste from extended mapping to aggregated mapping
map_mix <- toolGetMapping(type = "sectoral", name = "mappingGAINSmixedtoREMIND17activities.csv")
map_waste <- map_mix[map_mix$GAINS %in% c("Waste_Solid_Industrial","Waste_Solid_Municipal","Waste_Water_Industrial","Waste_Water_Municipal"),]
map_mix <- read.csv(toolGetMapping("mappingGAINSmixedtoREMIND17activities.csv", type = "sectoral"), stringsAsFactors = FALSE)
map_waste <- map_mix[map_mix$GAINS %in% c("Waste_Solid_Industrial", "Waste_Solid_Municipal", "Waste_Water_Industrial", "Waste_Water_Municipal"), ]

# append waste ef and emi from extended to aggregated
emi_gains <- mbind(emi_gains_agg_in,emi_gains_ext_in[,,map_waste$GAINS])
emi_gains <- mbind(emi_gains_agg_in, emi_gains_ext_in[, , map_waste$GAINS])

# many of the 2005 values seem to be outliers
warning("GAINS data for 2005 was set to 2010 values (for emi and ef) because 2005 often seems to be an outlier!!!\n")
emi_gains[,2005,] <- setYears(emi_gains[,2010,])
emi_gains[, 2005, ] <- setYears(emi_gains[, 2010, ])

x <- emi_gains
unit = 'Mt'
description = 'Emissions from GAINS for all CEDS setors execpt aviation and shipping'
weight = NULL
unit <- "Mt"
description <- "Emissions from GAINS for all CEDS setors execpt aviation and shipping"
weight <- NULL

}
if(subtype=="emission_factors") {
ef_gains_ext_in <- calcOutput("GAINS",subtype = "emission_factors",sectoral_resolution="extended",aggregate=FALSE) # in Tg/TWa
ef_gains_agg_in <- calcOutput("GAINS",subtype = "emission_factors",sectoral_resolution="aggregated",aggregate=FALSE) # in Tg/TWa
emi_gains_ext_in <- calcOutput("GAINS",subtype = "emissions",sectoral_resolution="extended",aggregate=FALSE) # in Mt
emi_gains_agg_in <- calcOutput("GAINS",subtype = "emissions",sectoral_resolution="aggregated",aggregate=FALSE) # in Mt

if (subtype == "emission_factors") {
ef_gains_ext_in <- calcOutput("GAINS", subtype = "emission_factors", sectoral_resolution = "extended", aggregate = FALSE) # in Tg/TWa
ef_gains_agg_in <- calcOutput("GAINS", subtype = "emission_factors", sectoral_resolution = "aggregated", aggregate = FALSE) # in Tg/TWa
emi_gains_ext_in <- calcOutput("GAINS", subtype = "emissions", sectoral_resolution = "extended", aggregate = FALSE) # in Mt
emi_gains_agg_in <- calcOutput("GAINS", subtype = "emissions", sectoral_resolution = "aggregated", aggregate = FALSE) # in Mt

# mainly: combine extended and aggregated GAINS data by appending
# waste sectors from extended to aggregated and then using
# aggregated only

# construct mappings: add waste from extended mapping to aggregated mapping
map_mix <- toolGetMapping(type = "sectoral", name = "mappingGAINSmixedtoREMIND17activities.csv")
map_waste <- map_mix[map_mix$GAINS %in% c("Waste_Solid_Industrial","Waste_Solid_Municipal","Waste_Water_Industrial","Waste_Water_Municipal"),]
map_mix <- read.csv(toolGetMapping("mappingGAINSmixedtoREMIND17activities.csv", type = "sectoral"), stringsAsFactors = FALSE)
map_waste <- map_mix[map_mix$GAINS %in% c("Waste_Solid_Industrial", "Waste_Solid_Municipal", "Waste_Water_Industrial", "Waste_Water_Municipal"), ]

# append waste ef and emi from extended to aggregated
ef_gains <- mbind(ef_gains_agg_in, ef_gains_ext_in[,,map_waste$GAINS])
emi_gains <- mbind(emi_gains_agg_in,emi_gains_ext_in[,,map_waste$GAINS])
ef_gains <- mbind(ef_gains_agg_in, ef_gains_ext_in[, , map_waste$GAINS])
emi_gains <- mbind(emi_gains_agg_in, emi_gains_ext_in[, , map_waste$GAINS])


# many of the 2005 values seem to be outliers
warning("GAINS data for 2005 was set to 2010 values (for emi and ef) because 2005 often seems to be an outlier!!!\n")
ef_gains[,2005,] <- setYears(ef_gains[,2010,])
emi_gains[,2005,] <- setYears(emi_gains[,2010,])
ef_gains[, 2005, ] <- setYears(ef_gains[, 2010, ])
emi_gains[, 2005, ] <- setYears(emi_gains[, 2010, ])

w <- emi_gains


x <- ef_gains
unit = 'Mt/TWa'
description = 'Emission factors from GAINS for all CEDS setors execpt aviation and shipping'
weight=w
unit <- "Mt/TWa"
description <- "Emission factors from GAINS for all CEDS setors execpt aviation and shipping"
weight <- w

}


if(subtype=="emissions_starting_values") {


start_value_REMIND_regions <- readSource(type="REMIND_11Regi", subtype="AP_starting_values", convert = TRUE)


if (subtype == "emissions_starting_values") {


start_value_REMIND_regions <- readSource(type = "REMIND_11Regi", subtype = "AP_starting_values", convert = TRUE)

x <- start_value_REMIND_regions
unit = 'Mt'
description = 'AP starting values for the first iteration of REMIND'
weight = NULL
unit <- "Mt"
description <- "AP starting values for the first iteration of REMIND"
weight <- NULL

}
return(list(x=x,
weight=weight,
unit=unit,
description=description))


return(list(x = x,
weight = weight,
unit = unit,
description = description))

}
Loading

0 comments on commit f1dd0c1

Please sign in to comment.