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 8, 2024
1 parent 15181be commit ca5866e
Show file tree
Hide file tree
Showing 14 changed files with 128 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
ValidationKey: '218185'
ValidationKey: '397020'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
AcceptedNotes: ~
AcceptedNotes: Namespaces in Imports field not imported from\:\n *.mip. .piamPlotComparison.
allowLinterWarnings: no
enforceVersionUpdate: no
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/*
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exclude: '^tests/testthat/_snaps/.*$'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: 2c9f875913ee60ca25ce70243dc24d5b6415598c # frozen: v4.6.0
hooks:
- id: check-case-conflict
- id: check-json
Expand All @@ -15,7 +15,7 @@ repos:
- id: mixed-line-ending

- repo: https://github.com/lorenzwalthert/precommit
rev: v0.4.0
rev: 7910e0323d7213f34275a7a562b9ef0fde8ce1b9 # frozen: v0.4.2
hooks:
- id: parsable-R
- id: deps-in-desc
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'reportbrick: Reporting package for BRICK'
version: 0.1.1
date-released: '2024-04-22'
version: 0.2.0
date-released: '2024-05-08'
abstract: This package contains BRICK-specific routines to report model results. The
main functionality is to generate a mif-file from a given BRICK model run folder.
authors:
Expand Down
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: reportbrick
Title: Reporting package for BRICK
Version: 0.1.1
Date: 2024-04-22
Version: 0.2.0
Date: 2024-05-08
Authors@R:
person("Robin", "Hasse", , "[email protected]",
role = c("aut", "cre"),
Expand All @@ -15,6 +15,8 @@ Imports:
gamstransfer (>= 3.0.1),
madrat,
magclass,
mip (>= 0.148.15),
piamPlotComparison,
yaml
Suggests:
covr,
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Reporting package for BRICK

R package **reportbrick**, version **0.1.1**
R package **reportbrick**, version **0.2.0**

[![CRAN status](https://www.r-pkg.org/badges/version/reportbrick)](https://cran.r-project.org/package=reportbrick) [![R build status](https://github.com/pik-piam/reportbrick/workflows/check/badge.svg)](https://github.com/pik-piam/reportbrick/actions) [![codecov](https://codecov.io/gh/pik-piam/reportbrick/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/reportbrick)
[![CRAN status](https://www.r-pkg.org/badges/version/reportbrick)](https://cran.r-project.org/package=reportbrick) [![R build status](https://github.com/pik-piam/reportbrick/workflows/check/badge.svg)](https://github.com/pik-piam/reportbrick/actions) [![codecov](https://codecov.io/gh/pik-piam/reportbrick/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/reportbrick) [![r-universe](https://pik-piam.r-universe.dev/badges/reportbrick)](https://pik-piam.r-universe.dev/builds)

## Purpose and Functionality

Expand Down Expand Up @@ -38,7 +38,7 @@ In case of questions / problems please contact Robin Hasse <robin.hasse@pik-pots

To cite package **reportbrick** in publications use:

Hasse R (2024). _reportbrick: Reporting package for BRICK_. R package version 0.1.1, <https://github.com/pik-piam/reportbrick>.
Hasse R (2024). _reportbrick: Reporting package for BRICK_. R package version 0.2.0, <https://github.com/pik-piam/reportbrick>.

A BibTeX entry for LaTeX users is

Expand All @@ -47,7 +47,7 @@ A BibTeX entry for LaTeX users is
title = {reportbrick: Reporting package for BRICK},
author = {Robin Hasse},
year = {2024},
note = {R package version 0.1.1},
note = {R package version 0.2.0},
url = {https://github.com/pik-piam/reportbrick},
}
```
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 ca5866e

Please sign in to comment.