Skip to content

Commit

Permalink
Initial compare scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
robinhasse committed May 7, 2024
1 parent 15181be commit 783ba16
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.Rhistory
.RData
.Ruserdata
*.pdf
*_Rmd/*
2 changes: 2 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ Imports:
gamstransfer (>= 3.0.1),
madrat,
magclass,
mip (>= 0.148.15),
piamPlotComparison,
yaml
Suggests:
covr,
Expand Down
49 changes: 49 additions & 0 deletions inst/compareScenarios/cs_01_stocks_flows.Rmd
Original file line number Diff line number Diff line change
@@ -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
41 changes: 41 additions & 0 deletions inst/compareScenarios/preprocessing.R
Original file line number Diff line number Diff line change
@@ -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))
4 changes: 3 additions & 1 deletion man/dot-agg.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/dot-readBrickSets.Rd → man/readBrickSets.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions man/reportAgg.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/reportBuildingStock.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/reportConstruction.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/reportDemolition.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 783ba16

Please sign in to comment.