Skip to content

Commit

Permalink
Increment version number
Browse files Browse the repository at this point in the history
  • Loading branch information
robinhasse committed Oct 15, 2024
1 parent 19fe38c commit 14160fd
Show file tree
Hide file tree
Showing 20 changed files with 207 additions and 215 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '1459854'
ValidationKey: '1480814'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ jobs:
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: |
any::lucode2
any::covr
any::madrat
any::magclass
any::citation
any::gms
any::goxygen
any::GDPuc
lucode2
covr
madrat
magclass
citation
gms
goxygen
GDPuc
# piam packages also available on CRAN (madrat, magclass, citation,
# gms, goxygen, GDPuc) will usually have an outdated binary version
# available; by using extra-packages we get the newest 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.3
date-released: '2024-10-02'
version: 0.7.4
date-released: '2024-10-15'
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.3
Date: 2024-10-02
Version: 0.7.4
Date: 2024-10-15
Authors@R: c(
person("Robin", "Hasse", , "robin.hasse@pik-potsdam.de", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-1818-3186")),
Expand Down
6 changes: 3 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ export(convertHDDCDD)
export(convertHDDCDDtemp)
export(convertOdyssee)
export(convertPFUDB)
export(convertTCEP)
export(convertSPIUG)
export(convertTCEP)
export(convertUNHouseholds)
export(convertUniclima)
export(fullEDGEBUILDINGS)
Expand All @@ -68,8 +68,8 @@ export(readDeetman2020)
export(readECEMF)
export(readEEAfloorspace)
export(readEHI)
export(readETSAP)
export(readEHPA)
export(readETSAP)
export(readEUBuildingsDB)
export(readEUBuildingsObservatory)
export(readEnergiforsk2016)
Expand All @@ -82,8 +82,8 @@ export(readHDDCDDtemp)
export(readHotmaps)
export(readOdyssee)
export(readPFUDB)
export(readTCEP)
export(readSPIUG)
export(readTCEP)
export(readUNHouseholds)
export(readUniclima)
export(toolCountryFillAvg)
Expand Down
13 changes: 7 additions & 6 deletions R/calcHeatingSystemReplacement.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ calcHeatingSystemReplacement <- function() {

# replace boiler to boiler replacement by more detailed breakdown
replaceMatrix <- mbind(
(replaceMatrix[["allHeating"]])[, , "Boiler.Boiler", invert = TRUE],
replaceMatrix[["boilerToBoiler"]])
replaceMatrix[["allHeating"]][, , "Boiler.Boiler", invert = TRUE],
replaceMatrix[["boilerToBoiler"]]
)



Expand All @@ -51,7 +52,7 @@ calcHeatingSystemReplacement <- function() {
toolAggregate(map, from = "technology", to = "technologyBRICK", dim = 3.2, partrel = TRUE)

# remove zero that the aggregation introduced
replaceMatrix <- replaceMatrix[,, replaceMatrix > 0]
replaceMatrix <- replaceMatrix[, , replaceMatrix > 0]

# disaggregate flows between HP and boilers to boiler technologies
replaceMatrix <- do.call(mbind, lapply(getNames(replaceMatrix), function(n) {
Expand All @@ -73,7 +74,8 @@ calcHeatingSystemReplacement <- function() {
weight = replaceMatrix %>%
mselect(flows[dimDisagg]) %>%
dimSums(dimKeep))
})) %>% mbind(replaceMatrix[, , grep("_", getNames(replaceMatrix), value = TRUE), invert = TRUE])
})) %>%
mbind(replaceMatrix[, , grep("_", getNames(replaceMatrix), value = TRUE), invert = TRUE])

# normalise back
replaceMatrix <- proportions(replaceMatrix) %>%
Expand All @@ -86,6 +88,5 @@ calcHeatingSystemReplacement <- function() {
min = 0,
max = 1,
description = "Share of respondents that replaced a heating system",
unit = "1"
))
unit = "1"))
}
30 changes: 14 additions & 16 deletions R/calcHeatingSystemSales.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ calcHeatingSystemSales <- function() {
mselect(corrected = TRUE) %>%
.removeNADims() %>%
.mapToBRICK(mapEHPA, from = "hpType")
# salesHpEurobserver <- readSource("EurObservER", subtype = "HPbarometer")



Expand All @@ -50,12 +49,12 @@ calcHeatingSystemSales <- function() {
## many European countries ====

# common regions
reg <- Reduce(intersect,lapply(list(salesTotal, salesEff, salesHp),
getItems, dim = 1))
reg <- Reduce(intersect, lapply(list(salesTotal, salesEff, salesHp),
getItems, dim = 1))

# all time steps
t <- Reduce(union,lapply(list(salesTotal, salesEff, salesHp),
getItems, dim = 2))
t <- Reduce(union, lapply(list(salesTotal, salesEff, salesHp),
getItems, dim = 2))

# extrapolate to all time steps
salesTotal <- .time_interpolate(salesTotal, t, 0.2)
Expand All @@ -68,7 +67,6 @@ calcHeatingSystemSales <- function() {
salesMissing <- salesTotal[reg, , ] - dimSums(sales)
salesMissing[salesMissing < 0] <- 0
incompleteFactor <- 1 + salesMissing / dimSums(sales[, , incompleteHs])
incompleteFactorGlo <- 1 + dimSums(salesMissing, 1) / dimSums(sales[, , incompleteHs], c(1, 3))
sales[, , incompleteHs] <- sales[, , incompleteHs] * incompleteFactor

# add zeros for missing technologies
Expand All @@ -81,8 +79,8 @@ calcHeatingSystemSales <- function() {

### AUT ####
mapBMK <- toolGetMapping("technologyMapping_BMK.csv",
type = "sectoral",
where = "mredgebuildings")
type = "sectoral",
where = "mredgebuildings")
bmk <- readSource("BMK")["AUT", t] %>%
.mapToBRICK(mapBMK, from = "technology")
hs <- setdiff(getItems(bmk, "hs"), "sobo_biom")
Expand All @@ -102,8 +100,8 @@ calcHeatingSystemSales <- function() {

### ESP ####
mapFEGECA <- toolGetMapping("technologyMapping_FEGECA.csv",
type = "sectoral",
where = "mredgebuildings") %>%
type = "sectoral",
where = "mredgebuildings") %>%
filter(.data[["considerSales"]])
# scale sum of gabo and libo to match total of boilers and add gas heaters
fegeca <- readSource("FEGECA")["ESP", , ] %>%
Expand Down Expand Up @@ -171,7 +169,6 @@ calcHeatingSystemSales <- function() {
dimSums(c("variable", "typ", "loc", "vin")) %>%
.removeNADims("region") %>%
.time_interpolate(t, 0.3)
pop <- calcOutput("PopulationPast", aggregate = FALSE)

# based on dwelling numbers for all regions that have stock data
salesExtrStock <- .predictSales(sales, stock)
Expand All @@ -183,7 +180,7 @@ calcHeatingSystemSales <- function() {


salesExtr <- salesExtrStock
salesExtr[getItems(sales, 1), ,] <- sales
salesExtr[getItems(sales, 1), , ] <- sales


## District heating ====
Expand Down Expand Up @@ -255,16 +252,17 @@ calcHeatingSystemSales <- function() {


.toDf <- function(x) {
x %>% as.quitte() %>%
x %>%
as.quitte() %>%
removeColNa()
}


.time_interpolate <- function(dataset,
interpolated_year,
.time_interpolate <- function(dataset, # nolint: object_name_linter.
interpolated_year, # nolint: object_name_linter.
wLinear = 1,
nonNegative = TRUE,
integrate_interpolated_years = FALSE) {
integrate_interpolated_years = FALSE) { # nolint: object_name_linter.
out <- wLinear * time_interpolate(dataset,
interpolated_year,
integrate_interpolated_years,
Expand Down
3 changes: 1 addition & 2 deletions R/calcUValueSource.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ calcUValueSource <- function(subtype = c("EUBuildingsObservatory", "ETSAP")) {
min = 0,
isocountries = FALSE,
unit = "W/m2K",
description = paste("U-values as reported by", subtype)
))
description = paste("U-values as reported by", subtype)))
}
2 changes: 1 addition & 1 deletion R/convertBMK.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ convertBMK <- function(x) {

# translate technologies to English
mapBMK <- toolGetMapping("technologyMapping_BMK.csv",
type = "sectoral", where = "mredgebuildings")
type = "sectoral", where = "mredgebuildings")
mapBMK <- stats::setNames(mapBMK[["technology"]],
mapBMK[["technologyAUT"]])
getItems(x, 3) <- unname(mapBMK[getItems(x, 3)])
Expand Down
2 changes: 1 addition & 1 deletion R/convertEHI.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ convertEHI <- function(x) {
}))

# split aggregated regions
weight <- feBuildings <- calcOutput("FEdemandBuildings", aggregate = FALSE) %>%
weight <- calcOutput("FEdemandBuildings", aggregate = FALSE) %>%
dimSums("typ") %>%
time_interpolate(getItems(x, 2), extrapolation_type = "constant")

Expand Down
11 changes: 6 additions & 5 deletions R/convertEUBuildingsDB.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ convertEUBuildingsDB <- function(x, subtype) {

# manually drop erroneous data points
if (category == "BuildingStockCharacteristics") {
data[, 2017, c("Total floor area of single family dwellings_m2",
"Total floor area of multi family dwellings_m2")] <- NA
data[, 2017, c("Total floor area of single family dwellings_m2",
"Total floor area of multi family dwellings_m2")] <- NA
}

# fill missing regions with NA
Expand All @@ -66,11 +66,12 @@ convertEUBuildingsDB <- function(x, subtype) {
# the shares perfectly add up to 1, so 'more than 5' means '5 or more'
getNames(data) <- gsub(
"^(Number|Share) of dwelling(s|) |occupied by | persons.*|_1$", "",
gsub("with single-person households", "1",
gsub("more than ", ">=", getNames(data))))
gsub("with single-person households", "1",
gsub("more than ", ">=", getNames(data)))
)
getSets(data)[3] <- "householdSize"
},
stop("'", subtype, "' is an invalid subtype.")
stop("'", subtype, "' is an invalid subtype.")
)

return(data)
Expand Down
3 changes: 2 additions & 1 deletion R/convertEurObservER.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ convertEurObservER <- function(x, subtype) {
# Check that there are only unique values in disregarded columns
nUnique <- lapply(
apply(select(ts, -any_of(c("period", "reportperiod", "value"))), 2, unique),
length)
length
)
if (any(nUnique > 1)) {
stop(paste(names(nUnique)[which(nUnique > 1)], collapse = ", "),
"have more than one unique value. Group by more dimensions.")
Expand Down
2 changes: 1 addition & 1 deletion R/convertFEGECA.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ convertFEGECA <- function(x) {

# translate technologies to English
mapFEGECA <- toolGetMapping("technologyMapping_FEGECA.csv",
type = "sectoral", where = "mredgebuildings")
type = "sectoral", where = "mredgebuildings")
mapFEGECA <- stats::setNames(mapFEGECA[["variable"]],
mapFEGECA[["variableESP"]])
getItems(x, 3.1) <- unname(mapFEGECA[getItems(x, 3.1)])
Expand Down
3 changes: 1 addition & 2 deletions R/readCensusHub.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
readCensusHub <- function(subtype) {

# pick file
files <- list(
typeVintage = "csvoutput_HC53_2022_04_08_17_01.csv")
files <- list(typeVintage = "csvoutput_HC53_2022_04_08_17_01.csv")

data <- toolSubtypeSelect(subtype, files) %>%
read.csv() %>%
Expand Down
2 changes: 1 addition & 1 deletion R/readEHPA.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ readEHPA <- function(subtype = "hpSales") {
},
hpMarketShare = {

file = "EHPA_market_report_2023_Final full report_Table3.5-1.txt"
file <- "EHPA_market_report_2023_Final full report_Table3.5-1.txt"
data <- read.csv(file, sep = " ", comment.char = "#") %>%
rename(region = "X") %>%
pivot_longer(matches("X\\d{4}"), names_to = "period") %>%
Expand Down
Loading

0 comments on commit 14160fd

Please sign in to comment.