diff --git a/.gitignore b/.gitignore index 5b6a065..b7fdc09 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ .Rhistory .RData .Ruserdata +*.pdf +*_Rmd/* \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index ab0b9fc..deeec60 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -15,6 +15,8 @@ Imports: gamstransfer (>= 3.0.1), madrat, magclass, + mip (>= 0.148.15), + piamPlotComparison, yaml Suggests: covr, diff --git a/inst/compareScenarios/cs_01_stocks_flows.Rmd b/inst/compareScenarios/cs_01_stocks_flows.Rmd new file mode 100644 index 0000000..57b63ee --- /dev/null +++ b/inst/compareScenarios/cs_01_stocks_flows.Rmd @@ -0,0 +1,49 @@ +# Stock and flows + +## Building stock + +```{r stock vars} +tot <- "Stock|Buildings" +subsec <- c("Stock|Residential", + "Stock|Commercial") +``` + +```{r StockSubsector} +showAreaAndBarPlots(data, vars = subsec, tot = tot, orderVars = "user", scales = "fixed") +``` + +### All buildings + +### Residential +```{r residential stock vars} +tot <- "Stock|Residential" +heatingRes <- paste(tot, heating, sep = "|") +vintageRes <- paste(tot, vintage, sep = "|") +typeRes <- paste(tot, type, sep = "|") +locationRes <- paste(tot, location, sep = "|") +``` + +#### by building type +```{r Stock-Residential-(type)} +showAreaAndBarPlots(data, vars = typeRes, tot = tot, orderVars = "user", scales = "fixed") +walk(typeRes, showLinePlots, data = data) +``` + +#### by location +```{r Stock-Residential-(location)} +showAreaAndBarPlots(data, vars = locationRes, tot = tot, orderVars = "user", scales = "fixed") +walk(locationRes, showLinePlots, data = data) +``` + +#### by construction cohort +```{r Stock-Residential-(vintage)} +showAreaAndBarPlots(data, vars = rev(vintageRes), tot = tot, orderVars = "user", scales = "fixed") +``` + +#### by Space heating +```{r Stock-Residential-(heating)} +showAreaAndBarPlots(data, vars = heatingRes, tot = tot, orderVars = "user", scales = "fixed") +walk(heatingRes, showLinePlots, data = data) +``` + +### Commercial diff --git a/inst/compareScenarios/preprocessing.R b/inst/compareScenarios/preprocessing.R new file mode 100644 index 0000000..b385de9 --- /dev/null +++ b/inst/compareScenarios/preprocessing.R @@ -0,0 +1,41 @@ +# Load additional libraries ---------------------------------------------------- + +library(dplyr) # nolint: undesirable_function_linter. + + + +# BRICK sets ------------------------------------------------------------------- + +# Sets are used in Rmd files to select variables + +subsec <- c( + "Residential", + "Commercial" +) +type <- c( + "SFH", + "MFH" +) +location <- c( + "Urban", + "Rural" +) +heating <- c( + "Biomass", + "District heating", + "Heat pump", + "Resistive electric", + "Gas", + "Liquids", + "Coal" +) + +# automatic identification of vintages to allow for different model resolutions +vintageRegex <- "(Before|After) \\d{4}|\\d{4} - \\d{4}" +vintage <- grep(vintageRegex, unique(data[["variable"]]), value = TRUE) %>% + unique() %>% + sub(pattern = paste0("^.*(", vintageRegex, ").*$"), replacement = "\\1") %>% + unique() +vintage <- c(grep("^Before", vintage, value = TRUE), + sort(grep("^\\d{4}", vintage, value = TRUE)), + grep("^After", vintage, value = TRUE)) diff --git a/man/dot-agg.Rd b/man/dot-agg.Rd index 7a0b0de..a813028 100644 --- a/man/dot-agg.Rd +++ b/man/dot-agg.Rd @@ -4,12 +4,14 @@ \alias{.agg} \title{Aggregate} \usage{ -.agg(x, agg) +.agg(x, agg, silent = TRUE) } \arguments{ \item{x}{MagPIE object, BRICK object} \item{agg}{named vector of dimensions to aggregate.} + +\item{silent}{boolean, suppress warnings and printing of dimension mapping} } \value{ aggregated MagPIE objects without sub dimensions in dim 3 diff --git a/man/dot-readBrickSets.Rd b/man/readBrickSets.Rd similarity index 68% rename from man/dot-readBrickSets.Rd rename to man/readBrickSets.Rd index dc4cb89..e2ed1ad 100644 --- a/man/dot-readBrickSets.Rd +++ b/man/readBrickSets.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/reportAgg.R -\name{.readBrickSets} -\alias{.readBrickSets} +% Please edit documentation in R/readBrickSets.R +\name{readBrickSets} +\alias{readBrickSets} \title{Read brickSets mapping} \usage{ -.readBrickSets(tmpl) +readBrickSets(tmpl) } \arguments{ \item{tmpl}{character, BRICK reporting template} diff --git a/man/reportAgg.Rd b/man/reportAgg.Rd index ab6e2e2..bb3f417 100644 --- a/man/reportAgg.Rd +++ b/man/reportAgg.Rd @@ -4,7 +4,14 @@ \alias{reportAgg} \title{Report aggregated quantities} \usage{ -reportAgg(x, name, tmpl = NULL, agg = NULL, rprt = NULL, silent = TRUE) +reportAgg( + x, + name, + brickSets = readBrickSets(NULL), + agg = NULL, + rprt = NULL, + silent = TRUE +) } \arguments{ \item{x}{MagPIE object, BRICK object} @@ -12,7 +19,7 @@ reportAgg(x, name, tmpl = NULL, agg = NULL, rprt = NULL, silent = TRUE) \item{name}{character, name of reporting variable. reported dimensions passed with \code{rprt} have to be escaped with curly brackets.} -\item{tmpl}{character, BRICK reporting template} +\item{brickSets}{named list, BRICK reporting template} \item{agg}{named vector of dimensions to aggregate. Names are dimension names of \code{x} and values are either set elements or subsets of set elements diff --git a/man/reportBuildingStock.Rd b/man/reportBuildingStock.Rd index 6f76e3c..369f685 100644 --- a/man/reportBuildingStock.Rd +++ b/man/reportBuildingStock.Rd @@ -4,12 +4,12 @@ \alias{reportBuildingStock} \title{Report building Stock} \usage{ -reportBuildingStock(gdx, tmpl = NULL) +reportBuildingStock(gdx, brickSets = NULL) } \arguments{ \item{gdx}{gams transfer container of the BRICK GDX} -\item{tmpl}{character, BRICK reporting template} +\item{brickSets}{character, BRICK reporting template} } \description{ Report quantities describing the stock of buildings diff --git a/man/reportConstruction.Rd b/man/reportConstruction.Rd index 1fd880c..121ab48 100644 --- a/man/reportConstruction.Rd +++ b/man/reportConstruction.Rd @@ -4,12 +4,12 @@ \alias{reportConstruction} \title{Report construction} \usage{ -reportConstruction(gdx, tmpl = NULL) +reportConstruction(gdx, brickSets = NULL) } \arguments{ \item{gdx}{gams transfer container of the BRICK GDX} -\item{tmpl}{character, BRICK reporting template} +\item{brickSets}{character, BRICK reporting template} } \description{ Report quantities describing the construction of new buildings diff --git a/man/reportDemolition.Rd b/man/reportDemolition.Rd index 4df61c4..4ee81af 100644 --- a/man/reportDemolition.Rd +++ b/man/reportDemolition.Rd @@ -4,12 +4,12 @@ \alias{reportDemolition} \title{Report demolition} \usage{ -reportDemolition(gdx, tmpl = NULL) +reportDemolition(gdx, brickSets = NULL) } \arguments{ \item{gdx}{gams transfer container of the BRICK GDX} -\item{tmpl}{character, BRICK reporting template} +\item{brickSets}{character, BRICK reporting template} } \description{ Report quantities describing the demolition of buildings