Skip to content

Commit

Permalink
Merge pull request #39 from robinhasse/renDepth
Browse files Browse the repository at this point in the history
Renovation depth
  • Loading branch information
robinhasse authored Oct 2, 2024
2 parents c284da1 + 88bcfc1 commit 4bbfa66
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '1438488'
ValidationKey: '1459854'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
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: 'mredgebuildings: Prepare data to be used by the EDGE-Buildings model'
version: 0.7.2
date-released: '2024-09-13'
version: 0.7.3
date-released: '2024-10-02'
abstract: Prepare data to be used by the EDGE-Buildings model.
authors:
- family-names: Hasse
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: mredgebuildings
Title: Prepare data to be used by the EDGE-Buildings model
Version: 0.7.2
Date: 2024-09-13
Version: 0.7.3
Date: 2024-10-02
Authors@R: c(
person("Robin", "Hasse", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-1818-3186")),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export(calcLifetimeParams)
export(calcMatchingReference)
export(calcPFUDB)
export(calcPopulationBuildings)
export(calcRenDepth)
export(calcRenovationCostModel)
export(calcShareETP)
export(calcShareOdyssee)
Expand Down
39 changes: 39 additions & 0 deletions R/calcRenDepth.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#' Calculate renovation depth
#'
#' The renovation depth is currently calculated based on the ratio of specific
#' useful energy demand after and before the renovation. This is valid under the
#' assumption that there is no change in behaviour (rebound effect) which we
#' currently make. Once adaptive behaviour is considered, we should use the
#' ratio of U-values.
#'
#' @author Robin Hasse
#'
#' @importFrom madrat toolGetMapping
#' @importFrom dplyr %>% .data left_join filter mutate select
#' @importFrom magclass as.magpie collapseDim
#' @export

calcRenDepth <- function() {

bsMap <- toolGetMapping("buildingShell.csv", "sectoral", "brick")

renDepth <- expand.grid(bs = bsMap[["bs"]],
bsr = c(bsMap[["bs"]], "0")) %>%
left_join(bsMap, by = c("bs")) %>%
left_join(bsMap, by = c(bsr = "bs"), suffix = c("Before", "After")) %>%
filter(.data[["energyLadderBefore"]] >= .data[["energyLadderAfter"]] |
.data[["bsr"]] == 0) %>%
mutate(value = ifelse(.data[["bsr"]] == "0",
0,
1 - .data[["relDemAfter"]] / .data[["relDemBefore"]])) %>%
select("bs", "bsr", "value") %>%
as.magpie() %>%
collapseDim()

return(list(x = renDepth,
isocountries = FALSE,
min = 0,
max = 1,
unit = "1",
description = "Renovation depth"))
}
3 changes: 2 additions & 1 deletion R/calcUEdemand.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ calcUEdemand <- function() {
select("vin", "vinHotmaps")

# map Hotmaps building types
typMap <- getBrickMapping("buildingType.csv") %>%
typMap <- toolGetMapping("buildingTypeMapping_Hotmaps.csv", "sectoral",
"mredgebuildings") %>%
select("typ", "typHotmaps")

# Useful energy demand for space heating (kWh/yr/m2)
Expand Down
2 changes: 2 additions & 0 deletions R/fullBRICK.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ fullBRICK <- function(rev = 0) {
calcOutput("UEdemand", file = "f_ueDemand.cs4r")
calcOutput("HeatingSystem", subtype = "Efficiency", file = "f_heatingEfficiency.cs4r")

calcOutput("RenDepth", aggregate = FALSE, file = "f_renovationDepth.cs4r")



# Life time ------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Prepare data to be used by the EDGE-Buildings model

R package **mredgebuildings**, version **0.7.2**
R package **mredgebuildings**, version **0.7.3**

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

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

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

Hasse R, Führlich P, Levesque A, Tockhorn H (2024). _mredgebuildings: Prepare data to be used by the EDGE-Buildings model_. R package version 0.7.2, <https://github.com/pik-piam/mredgebuildings>.
Hasse R, Führlich P, Levesque A, Tockhorn H (2024). _mredgebuildings: Prepare data to be used by the EDGE-Buildings model_. R package version 0.7.3, <https://github.com/pik-piam/mredgebuildings>.

A BibTeX entry for LaTeX users is

Expand All @@ -47,7 +47,7 @@ A BibTeX entry for LaTeX users is
title = {mredgebuildings: Prepare data to be used by the EDGE-Buildings model},
author = {Robin Hasse and Pascal Führlich and Antoine Levesque and Hagen Tockhorn},
year = {2024},
note = {R package version 0.7.2},
note = {R package version 0.7.3},
url = {https://github.com/pik-piam/mredgebuildings},
}
```
5 changes: 5 additions & 0 deletions inst/extdata/sectoral/buildingTypeMapping_Hotmaps.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
typ, typHotmaps
SFH,Residential sector|Single family- Terraced houses|Single family- Terraced houses
MFH,Residential sector|Appartment blocks|Appartment blocks
MFH,Residential sector|Multifamily houses|Multifamily houses
Com,Service sector|Total|Total
18 changes: 18 additions & 0 deletions man/calcRenDepth.Rd

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

0 comments on commit 4bbfa66

Please sign in to comment.