Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '1483200'
ValidationKey: '1505260'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
options(repos = c(pikpiam = 'https://pik-piam.r-universe.dev',
CRAN = Sys.getenv('RSPM')))
pak::pak()

- name: Run pre-commit checks
shell: bash
run: |
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ message: If you use this software, please cite it using the metadata from this f
type: software
title: 'edgebuildings: Model for the projection of global energy demand in the buildings
sector'
version: 0.7.2
date-released: '2026-05-27'
version: 0.7.3
date-released: '2026-06-16'
abstract: 'The Energy Demand GEnerator projects energy demand for buildings both at
the useful and final energy level. It covers the global demand and five energy services:
space heating, space cooling, appliances and lighting (treated together) water heating
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: edgebuildings
Title: Model for the projection of global energy demand in the buildings sector
Version: 0.7.2
Version: 0.7.3
Authors@R: c(
person(given = "Antoine", family = "Levesque",
role = c("aut")),
Expand Down Expand Up @@ -64,5 +64,5 @@ Suggests:
rmarkdown,
rprojroot,
xmpdf
Date: 2026-05-27
Date: 2026-06-16
VignetteBuilder: knitr
8 changes: 5 additions & 3 deletions R/buildingsProjections.R
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,11 @@ buildingsProjections <- function(config,
#--- Add RCP scenario to scenario name if existent

if (!identical(config[[scen, "rcpScen"]], "noCC")) {
df <- mutate(df, scenario = ifelse(.data[["scenario"]] != "history",
paste0(.data[["scenario"]], "_rcp", config[[scen, "rcpScen"]]),
.data[["scenario"]]))
df <- mutate(df,
scenario = sub("-.*", "", .data$scenario),
scenario = ifelse(.data[["scenario"]] != "history",
paste0(.data[["scenario"]], "_rcp", sub("\\.", "_", config[[scen, "rcpScen"]])),
.data[["scenario"]]))
}


Expand Down
2 changes: 1 addition & 1 deletion R/getShareECprojections.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ getShareECprojections <- function(config,

# hdd
hdd <- hddcdd %>%
filter(.data[["variable"]] == "HDD", .data[["scenario"]] == config[, "hddcddScen"],
filter(.data[["variable"]] == "HDD", .data[["scenario"]] == scen,
.data[["period"]] == endOfHistory) %>%
select(-"variable", -"period", -"scenario") %>%
rename(hdd = "value")
Expand Down
16 changes: 8 additions & 8 deletions R/prepHDDCDD.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ prepHDDCDD <- function(hddcdd, config, regionmap) {
# scenarios
socioScen <- config[["hddcddScen"]] %>% unlist()
climScen <- config[["rcpScen"]] %>% unlist()
climScen <- sub("\\.", "_", climScen)

socioClimScen <- paste(socioScen, climScen, sep = "_")

Expand All @@ -65,13 +66,13 @@ prepHDDCDD <- function(hddcdd, config, regionmap) {
buildScenInput(subtype = "mapping",
regionmap = regionmap) %>%
rename("fullconv" = "value") %>%
mutate(scenario = socioClimScen)
mutate(scenario = scenConfig)

yearTargetCDD <- config[["speed_CDD"]] %>%
buildScenInput(subtype = "mapping",
regionmap = regionmap) %>%
rename("fullconv" = "value") %>%
mutate(scenario = socioClimScen)
mutate(scenario = scenConfig)


# PROCESS DATA ---------------------------------------------------------------
Expand Down Expand Up @@ -106,7 +107,7 @@ prepHDDCDD <- function(hddcdd, config, regionmap) {
colHist <- paste(typeDD, tlimHist[[typeDD]], sep = "_")
colTarget <- paste(typeDD, tlimTargetReg, sep = "_")


# Process standard CDD/HDD with climScen
hddcdd %>%
# filter relevant subset
filter(.data$region == reg,
Expand All @@ -117,10 +118,10 @@ prepHDDCDD <- function(hddcdd, config, regionmap) {
!is.na(.data$value)) %>%

# unite "historical" and ...
mutate(rcp = climScen) %>%
mutate(scenario = scenConfig) %>%
select(-"ssp", -"rcp") %>%

# unite scenario and variable cols
unite(col = "scenario", c("ssp", "rcp"), sep = "_") %>%
# unite variable cols
unite(col = "variable", c("variable", "tlim"), sep = "_") %>%
pivot_wider(names_from = "variable", values_from = "value") %>%

Expand All @@ -137,8 +138,7 @@ prepHDDCDD <- function(hddcdd, config, regionmap) {
filter(!is.na(.data[["value"]])) %>%

# prepare for output
mutate(variable = typeDD,
scenario = scenConfig) %>%
mutate(variable = typeDD) %>%
select("region", "period", "variable", "scenario", "value")
}))
}))
Expand Down
82 changes: 74 additions & 8 deletions R/runEdgeBuildings.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
#' always required and will be automatically included if not specified, as it
#' provides reference values and is used for carrier share extension between
#' historic data and scenario start.
#' @param includeClimate logical, if TRUE, each scenario will be expanded with
#' climate variants by creating additional columns with RCP suffixes (1.9, 2.6,
#' 4.5, 6.0, 7.0). The original scenario column is kept as the noCC case. For
#' example, "SSP2" will be expanded to "SSP2", "SSP2-1.9", "SSP2-2.6", "SSP2-4.5",
#' "SSP2-6.0", and "SSP2-7.0". Default is FALSE.
#'
#' @author Falk Benke, Robin Hasse
#'
Expand All @@ -28,7 +33,8 @@ runEdgeBuildings <- function(config = "config_remind.csv",
madratDir = NULL,
inputdataRevision = "0.5.12",
forceDownload = FALSE,
scenario = NULL) {
scenario = NULL,
includeClimate = FALSE) {

# TODO: relocate data_internal
# TODO: fix all warnings and errors (lucode2::buildLibrary)
Expand Down Expand Up @@ -57,7 +63,7 @@ runEdgeBuildings <- function(config = "config_remind.csv",

if (!is.null(scenario)) {
# Read config to get column names
configData <- read.csv2(config, stringsAsFactors = FALSE)
configData <- read.csv2(config, stringsAsFactors = FALSE, check.names = FALSE)
configCols <- names(configData)

# Available scenarios are all columns except 'parameter' and 'valueComment'
Expand All @@ -83,7 +89,13 @@ runEdgeBuildings <- function(config = "config_remind.csv",
columnsToKeep <- c("parameter", "valueComment", scenario)
filteredConfig <- configData[, columnsToKeep, drop = FALSE]

# Write filtered config directly to start folder
# Expand with climate scenarios if requested
if (includeClimate) {
message("Expanding scenarios with climate variants (RCP: 1.9, 2.6, 4.5, 6.0, 7.0)")
filteredConfig <- .expandClimateScenarios(filteredConfig)
}

# Write filtered/expanded config directly to start folder
filteredConfigPath <- file.path(getSystemFile("start", package = "edgebuildings"),
"config.csv")
write.csv2(filteredConfig,
Expand All @@ -96,11 +108,25 @@ runEdgeBuildings <- function(config = "config_remind.csv",

message("Filtering to scenario(s): ", paste(scenario, collapse = ", "))
} else {
# Copy config to internal start folder without filtering
file.copy(config,
file.path(getSystemFile("start", package = "edgebuildings"),
"config.csv"),
overwrite = TRUE)
# Read config
configData <- read.csv2(config, stringsAsFactors = FALSE, check.names = FALSE)

# Expand with climate scenarios if requested
if (includeClimate) {
message("Expanding scenarios with climate variants (RCP: 1.9, 2.6, 4.5, 6.0, 7.0)")
configData <- .expandClimateScenarios(configData)
}

# Write config to internal start folder
filteredConfigPath <- file.path(getSystemFile("start", package = "edgebuildings"),
"config.csv")
write.csv2(configData,
filteredConfigPath,
row.names = FALSE,
quote = FALSE)

# Update config to point to version in start folder for later use
config <- filteredConfigPath
}


Expand Down Expand Up @@ -174,3 +200,43 @@ runEdgeBuildings <- function(config = "config_remind.csv",
reportResults(runFolderDir, reporting, cfgText)
}
}



#' Expand config with climate scenarios
#'
#' Internal helper function to expand scenario columns with climate variants.
#' For each scenario column, creates 5 additional columns with RCP suffixes
#' (1.9, 2.6, 4.5, 6.0, 7.0) while keeping the original column as the noCC case.
#'
#' @param configData data frame, the config data to expand
#' @return data frame with expanded scenario columns
#' @keywords internal
.expandClimateScenarios <- function(configData) {

# Get scenario column names (exclude 'parameter' and 'valueComment')
scenarioCols <- setdiff(names(configData), c("parameter", "valueComment"))

# Climate RCP scenarios to add
rcpScenarios <- c("1.9", "2.6", "4.5", "6.0", "7.0")

# Create expanded config starting with base columns
expandedConfig <- configData[, c("parameter", "valueComment"), drop = FALSE]

# For each scenario, create climate variants
for (scen in scenarioCols) {
# Add original scenario (noCC case) first
expandedConfig[[scen]] <- configData[[scen]]

# Add climate variants
for (rcp in rcpScenarios) {
newScenName <- paste0(scen, "-", rcp)
# Copy all values from original scenario
expandedConfig[[newScenName]] <- configData[[scen]]
# Update rcpScen parameter for this scenario
expandedConfig["rcpScen", newScenName] <- rcp
}
}

return(expandedConfig)
}
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Model for the projection of global energy demand in the buildings sector

R package **edgebuildings**, version **0.7.2**
R package **edgebuildings**, version **0.7.3**

[![R build status](https://github.com/ricardarosemann/edgebuildings/workflows/check/badge.svg)](https://github.com/ricardarosemann/edgebuildings/actions) [![codecov](https://codecov.io/gh/ricardarosemann/edgebuildings/branch/master/graph/badge.svg)](https://app.codecov.io/gh/ricardarosemann/edgebuildings) [![r-universe](https://pik-piam.r-universe.dev/badges/edgebuildings)](https://pik-piam.r-universe.dev/builds)
[![R build status](https://github.com/hagento/edgebuildings/workflows/check/badge.svg)](https://github.com/hagento/edgebuildings/actions) [![codecov](https://codecov.io/gh/hagento/edgebuildings/branch/master/graph/badge.svg)](https://app.codecov.io/gh/hagento/edgebuildings) [![r-universe](https://pik-piam.r-universe.dev/badges/edgebuildings)](https://pik-piam.r-universe.dev/builds)

## Purpose and Functionality

Expand All @@ -29,13 +29,13 @@ The additional repository can be made available permanently by adding the line a

After that the most recent version of the package can be installed using `install.packages`:

```r
```r
install.packages("edgebuildings")
```

Package updates can be installed using `update.packages` (make sure that the additional repository has been added before running that command):

```r
```r
update.packages()
```

Expand All @@ -55,15 +55,15 @@ In case of questions / problems please contact Robin Hasse <robin.hasse@pik-pots

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

Levesque A, Hasse R, Tockhorn H, Rosemann R, Führlich P (2026). "edgebuildings: Model for the projection of global energy demand in the buildings sector - Version 0.7.2."
Levesque A, Hasse R, Tockhorn H, Rosemann R, Führlich P (2026). "edgebuildings: Model for the projection of global energy demand in the buildings sector - Version 0.7.3."

A BibTeX entry for LaTeX users is

```latex
@Misc{,
title = {edgebuildings: Model for the projection of global energy demand in the buildings sector - Version 0.7.2},
title = {edgebuildings: Model for the projection of global energy demand in the buildings sector - Version 0.7.3},
author = {Antoine Levesque and Robin Hasse and Hagen Tockhorn and Ricarda Rosemann and Pascal Führlich},
date = {2026-05-27},
date = {2026-06-16},
year = {2026},
}
```
20 changes: 20 additions & 0 deletions man/dot-expandClimateScenarios.Rd

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

9 changes: 8 additions & 1 deletion man/runEdgeBuildings.Rd

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

Loading