forked from pik-piam/mrremind
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GAINS data update including primary PM25
- Loading branch information
rauner
committed
Oct 11, 2021
1 parent
e698a13
commit f1dd0c1
Showing
10 changed files
with
873 additions
and
776 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,6 @@ | |
.RData | ||
.Ruserdata | ||
fe_variables.csv | ||
.github/workflows/lucode2-check.yaml | ||
.buildlibrary | ||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,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)) | ||
|
||
} |
Oops, something went wrong.