Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter IEA ETP production data using a custom aggregation function #537

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
17 changes: 15 additions & 2 deletions R/calcIEA_ETP.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#' @export

calcIEA_ETP <- function() {

mapping <- toolGetMapping("Mapping_IEA_ETP.csv", type = "reportingVariables", where = "mrremind") %>%
filter(!is.na(!!sym("REMIND")), !!sym("REMIND") != "") %>%
mutate("Conversion" = as.numeric(!!sym("Conversion"))) %>%
Expand Down Expand Up @@ -52,11 +51,25 @@ calcIEA_ETP <- function() {
x <- aggregate(value ~ region + year + model + variable, x, sum, na.action = na.pass) %>%
as.magpie()

.customAggregate <- function(x, rel, to = NULL) {
out <- toolAggregate(x, rel = rel, to = to)

# remove cement and industry production for all regions except for GLO
if ("GLO" %in% getItems(out, dim = 1)) {
out[setdiff(getItems(out, dim = 1), "GLO"), ,
c("Production|Industry|Cement (Mt/yr)", "Production|Industry|Steel (Mt/yr)")] <- NA

} else {
out <- out[, , c("Production|Industry|Cement (Mt/yr)", "Production|Industry|Steel (Mt/yr)"), invert = TRUE]
}
return(out)
}

return(list(
x = x,
weight = NULL,
aggregationFunction = .customAggregate,
unit = c("EJ/yr", "Mt CO2/yr", "Mt/yr", "bn pkm/yr", "bn tkm/yr"),
description = "IEA ETP projections as REMIND variables"
))

}
71 changes: 0 additions & 71 deletions R/filter_historical_mif.R

This file was deleted.

3 changes: 0 additions & 3 deletions R/fullVALIDATIONREMIND.R
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,4 @@ fullVALIDATIONREMIND <- function(rev = 0) {
try = FALSE, years = years,
writeArgs = list(scenario = "historical", model = "INDSTAT2")
)

# filter variables that are too imprecise on regional level ----
filter_historical_mif()
}
7 changes: 0 additions & 7 deletions inst/extdata/historical_mif_filter_table.csv

This file was deleted.

Loading