diff --git a/.buildlibrary b/.buildlibrary index e8618ed..4b6da5e 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '1236714' +ValidationKey: '1397480' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/CITATION.cff b/CITATION.cff index b797c51..c85ff1c 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -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.6.2 -date-released: '2024-08-12' +version: 0.7.0 +date-released: '2024-08-29' abstract: Prepare data to be used by the EDGE-Buildings model. authors: - family-names: Hasse diff --git a/DESCRIPTION b/DESCRIPTION index 2ecefc5..f60b14b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mredgebuildings Title: Prepare data to be used by the EDGE-Buildings model -Version: 0.6.2 -Date: 2024-08-12 +Version: 0.7.0 +Date: 2024-08-29 Authors@R: c( person("Robin", "Hasse", , "robin.hasse@pik-potsdam.de", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-1818-3186")), diff --git a/NAMESPACE b/NAMESPACE index 863ea68..f8d3c73 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -10,6 +10,7 @@ export(calcFEUE) export(calcFEUEefficiencies) export(calcFEbyEUEC) export(calcFEdemandBuildings) +export(calcFloorspacePast) export(calcHeatingCapacity) export(calcHeatingSystem) export(calcHouseholdSize) diff --git a/R/calcFloorspacePast.R b/R/calcFloorspacePast.R index 307ac7d..5007080 100644 --- a/R/calcFloorspacePast.R +++ b/R/calcFloorspacePast.R @@ -14,12 +14,12 @@ #' @author Robin Hasse, Antoine Levesque, Hagen Tockhorn #' #' @importFrom madrat readSource calcOutput toolCountryFill -#' @importFrom quitte as.quitte calc_addVariable factor.data.frame +#' @importFrom quitte as.quitte calc_addVariable factor.data.frame interpolate_missing_periods #' @importFrom dplyr filter mutate select anti_join group_by left_join %>% -#' ungroup .data %>% +#' ungroup .data %>% group_modify #' @importFrom rlang .data #' @importFrom magclass mbind as.magpie collapseDim mselect -#' @importFrom tidyr spread +#' @importFrom tidyr spread replace_na #' #' @export @@ -37,25 +37,12 @@ calcFloorspacePast <- function() { } - #' Predict missing historic floorspace data - #' - #' A linear regression is performed to establish a general relationship between - #' floorspace per capita and gdp per capita and population density. - #' Predicted values are corrected w.r.t. to historical data where available, - #' otherwise the prediction is chosen. - #' - #' @param df data.frame containing floorspace per capita - #' @param gdppop data.frame containing gdp per capita - #' @param dens data.frame containing population density - #' @param endOfHistory upper temporal boundary of historic data - #' @param periodBegin lower temporal boundary of historic data - #' - #' @importFrom quitte factor.data.frame interpolate_missing_periods - #' @importFrom tidyr replace_na - #' @importFrom dplyr group_modify - #' - #' @returns floorspace per capita with filled missing entries - + # Predict missing historic floorspace data + # + # A linear regression is performed to establish a general relationship between + # floorspace per capita and gdp per capita and population density. + # Predicted values are corrected w.r.t. to historical data where available, + # otherwise the prediction is chosen. makeFloorspaceProjection <- function(df, gdppop, dens, endOfHistory, periodBegin) { # Clean data diff --git a/R/calcPFUDB.R b/R/calcPFUDB.R index c695bd3..ba6d5b0 100644 --- a/R/calcPFUDB.R +++ b/R/calcPFUDB.R @@ -42,26 +42,6 @@ calcPFUDB <- function() { } } - # convert enduse "appliances" to "refrigerators" with respective scaling factor - addThermal <- function(df, mapping, fridgeShare) { - df <- df %>% - filter(.data[["enduse"]] != "lighting") %>% - left_join(mapping %>% - select(-"RegionCodeEUR", -"RegionCodeEUR_ETP", -"X") %>% - rename(region = "CountryCode") %>% - left_join(fridgeShare, by = "RegionCode") %>% - select(-"RegionCode"), - by = "region") %>% - mutate(value = ifelse(.data[["enduse"]] != "appliances", - .data[["value"]], - .data[["value"]] * .data[["share"]]), - enduse = ifelse(.data[["enduse"]] == "appliances", - "refrigerators", - as.character(.data[["enduse"]]))) %>% - select(-"share") - return(df) - } - # PARAMETERS ----------------------------------------------------------------- @@ -175,7 +155,7 @@ calcPFUDB <- function() { mutate(value = ifelse(is.na(.data[["value.x"]]), .data[["value.y"]], .data[["value.x"]])) %>% - addThermal(regmappingEDGE, fridgeShare) %>% + toolAddThermal(regmappingEDGE, fridgeShare) %>% select("region", "period", "carrier", "enduse", "value") diff --git a/R/calcShareETP.R b/R/calcShareETP.R index 6b4604d..8261f4f 100644 --- a/R/calcShareETP.R +++ b/R/calcShareETP.R @@ -179,6 +179,8 @@ calcShareETP <- function(subtype = c("enduse", "carrier"), feOnly = FALSE) { group_by(across(all_of(c("region", "period")))) %>% mutate(value = proportions(.data[["value"]])) %>% ungroup() + } else { + etpFilter <- shareCorr } } @@ -188,7 +190,7 @@ calcShareETP <- function(subtype = c("enduse", "carrier"), feOnly = FALSE) { # return only FE data if (isTRUE(feOnly)) { - feData <- shareCorr %>% + feData <- etpFilter %>% as.quitte() %>% mutate(value = .data[["value"]] * PJ2EJ, unit = "EJ") %>% diff --git a/R/calcShareOdyssee.R b/R/calcShareOdyssee.R index 15991f3..632bbf1 100644 --- a/R/calcShareOdyssee.R +++ b/R/calcShareOdyssee.R @@ -109,13 +109,17 @@ calcShareOdyssee <- function(subtype = c("enduse", "carrier", "enduse_carrier"), meanApplightShares <- odyssee %>% filter(.data[["enduse"]] %in% c("lighting", "appliances"), !is.na(.data[["value"]])) %>% - group_by(across(all_of(c("region", "period", "sector", "carrier")))) %>% + group_by(across(all_of(c("period", "sector", "carrier", "enduse")))) %>% + mutate(value = sum(.data[["value"]], na.rm = TRUE)) %>% + ungroup() %>% + group_by(across(all_of(c("period", "sector", "carrier")))) %>% mutate(value = proportions(.data[["value"]])) %>% ungroup() %>% group_by(across(all_of(c("period", "sector", "enduse")))) %>% mutate(share = mean(.data[["value"]])) %>% ungroup() %>% - select(all_of(c("period", "carrier", "sector", "enduse", "share"))) + select(all_of(c("period", "carrier", "sector", "enduse", "share"))) %>% + unique() # split existing aggregated data into "appliances" and "lighting" applightData <- odysseeData %>% diff --git a/R/calcShares.R b/R/calcShares.R index c567327..c080d6e 100644 --- a/R/calcShares.R +++ b/R/calcShares.R @@ -24,7 +24,6 @@ #' @param subtype specifies share #' @param carrierCorrection allows additional corrections #' @param feOnly specifies if shares or quantities are returned -#' @param feWeights calculate additional FE weights for share aggregation #' #' @note The parameter "feOnly" is only applicable to IEA_ETP and TCEP data, #' since this is the necessary data to do a full disaggregation of EU and EC @@ -38,9 +37,8 @@ #' #' @author Hagen Tockhorn, Robin Hasse #' -#' @importFrom rlang .data #' @importFrom dplyr mutate as_tibble filter select rename group_by across -#' all_of ungroup %>% .data left_join summarise group_modify cross_join +#' all_of ungroup %>% .data left_join reframe group_modify cross_join .data #' @importFrom tidyr replace_na unite complete #' @importFrom madrat toolGetMapping calcOutput readSource toolCountryFill #' @importFrom magclass time_interpolate as.magpie @@ -53,8 +51,7 @@ calcShares <- function(subtype = c("carrier_nonthermal", "enduse_nonthermal", "enduse_thermal"), carrierCorrection = FALSE, - feOnly = FALSE, - feWeights = TRUE) { + feOnly = FALSE) { @@ -66,43 +63,6 @@ calcShares <- function(subtype = c("carrier_nonthermal", thermVar <- strsplit(subtype, "_")[[1]][2] - - #---Corrections for specific carrier shares - # nolint start - correction <- inline.data.frame( - "region; enduse; carrier; value", - ".*; water_heating; heat; 0", - "(OCD|EUR|USA); (water_heating|cooking); biomod; 0", - "EUR; (water_heating|cooking); biotrad; 0", - "RUS; space_heating; heat; 0.60", - "RUS; (water_heating|cooking); natgas; 0.70", - "RUS; (water_heating|cooking); elec; 0.07", - "RUS; space_heating; elec; 0.03", - "RUS; (space_heating|water_heating|cooking); coal; 0.04", - "RUS; (space_heating|water_heating|cooking); petrol; 0.10", - "IND; (space_heating|water_heating); biotrad; 0.80", - "IND; (space_heating|water_heating|cooking); coal; 0.10", - "IND; (space_heating|water_heating); petrol; 0.12", - "IND; (space_heating|water_heating); natgas; 0", - "IND; (space_heating|water_heating); elec; 0.02", - "IND; cooking; natgas; 0.04", - "IND; cooking; (biotrad|petrol); 0.50") %>% - unite("regex", all_of(c("region", "enduse", "carrier")), sep = "\\.") - # nolint end - - - # Enduse-Carrier combinations which will be systematically excluded - exclude <- toolGetMapping(name = "excludeEnduseCarrier.csv", - type = "sectoral", - where = "mredgebuildings") - - - # Percentage of Appliances for Refrigerators - fridgeShare <- rbind(data.frame(RegionCode = "USA", share = 0.12), - data.frame(RegionCode = c("EUR", "OCD", "RUS", "JPN"), share = 0.17), - data.frame(RegionCode = c("CHN", "IND", "NCD", "AFR", "MIE", "OAS"), share = 0.3)) - - # Regions taken into account from WEO regWEO <- c("Africa", "Middle East", "Japan") @@ -114,11 +74,6 @@ calcShares <- function(subtype = c("carrier_nonthermal", # Shares - # IEA - ieaIO <- calcOutput("IOEdgeBuildings", subtype = "output_EDGE_buildings", - aggregate = FALSE) %>% - as.quitte(na.rm = TRUE) - # Odyssee sharesOdyssee <- calcOutput("ShareOdyssee", subtype = shareOf, aggregate = FALSE) %>% @@ -171,6 +126,21 @@ calcShares <- function(subtype = c("carrier_nonthermal", type = "regional", where = "mredgebuildings") + # Carrier share corrections + shareCorrections <- toolGetMapping(name = "correction_carrierShares.csv", + type = "sectoral", + where = "mredgebuildings") + + # Percentage of Appliances for Refrigerators + fridgeShare <- toolGetMapping(name = "fridgeShare.csv", + type = "sectoral", + where = "mredgebuildings") + + # Enduse-Carrier combinations which will be systematically excluded + exclude <- toolGetMapping(name = "excludeEnduseCarrier.csv", + type = "sectoral", + where = "mredgebuildings") + @@ -184,31 +154,6 @@ calcShares <- function(subtype = c("carrier_nonthermal", } - addThermal <- function(df, mapping, fridgeShare) { - df <- df %>% - filter(.data[["enduse"]] != "lighting") %>% - left_join(regmappingEDGE %>% - select(-"RegionCodeEUR", -"RegionCodeEUR_ETP", -"X") %>% - rename(region = "CountryCode") %>% - left_join(fridgeShare, by = "RegionCode") %>% - select(-"RegionCode"), - by = "region") %>% - mutate(value = ifelse(.data[["enduse"]] != "appliances", - .data[["value"]], - .data[["value"]] * .data[["share"]]), - enduse = ifelse(.data[["enduse"]] == "appliances", - "refrigerators", - as.character(.data[["enduse"]]))) %>% - select(-"share") - - if (!feOnly) { - df <- normalize(df, shareOf) - return(df) - } - - return(df) - } - # PROCESS DATA --------------------------------------------------------------- @@ -244,7 +189,7 @@ calcShares <- function(subtype = c("carrier_nonthermal", - if (!feOnly) { + if (isFALSE(feOnly)) { # Extrapolate ETP FE Data evolutionFactor <- sharesTCEP %>% left_join(regmappingETP %>% @@ -307,62 +252,65 @@ calcShares <- function(subtype = c("carrier_nonthermal", select(-"value.x", -"value.y") } - if (feOnly || feWeights) { - # Extrapolate ETP FE Data - evolutionFactor <- dataTCEP %>% - left_join(regmappingETP %>% - select("CountryCode", "EEAReg") %>% - rename(region = "CountryCode", - regionAgg = "EEAReg"), - by = "region") %>% - group_by(across(all_of(c("regionAgg", "enduse", "period")))) %>% - summarise(value = sum(.data[["value"]], na.rm = TRUE)) %>% - ungroup() %>% - group_by(across(all_of(c("regionAgg", "enduse")))) %>% - summarise(factor = .data[["value"]] / dplyr::lead(.data[["value"]])) %>% - ungroup() %>% - filter(!is.na(.data[["factor"]])) %>% - left_join(regmappingETP %>% - select("CountryCode", "EEAReg") %>% - rename(region = "CountryCode", - regionAgg = "EEAReg"), - by = "regionAgg") %>% - select(-"regionAgg") - - - dataETPstart <- feETP %>% - left_join(evolutionFactor, by = c("region", "enduse")) %>% - mutate(value = .data[["value"]] * .data[["factor"]], - period = 2000) %>% - select(-"factor") %>% - filter(!is.na(.data[["value"]])) - - dataETPfull <- rbind(dataETPstart, - feETP %>% - filter(!is.na(.data[["value"]]))) + # Calculate FE Data - - dataETPfull <- dataETPfull %>% - select(-"unit") %>% - quitte::factor.data.frame() %>% - as.quitte() %>% - interpolate_missing_periods(period = seq(1990, 2020)) %>% - group_by(across(all_of(c("region", "enduse")))) %>% - group_modify(~ extrapolateMissingPeriods(.x, key = "value")) %>% - ungroup() %>% - select("region", "period", "enduse", "value") - - - # NOTE: The linear regression might lead to negative values which will be - # filled up with small values and then re-normalized. - # (However, this is a very practical fix...) - - dataETPfull <- dataETPfull %>% - mutate(value = ifelse(.data[["value"]] < 0, 1e-6, .data[["value"]])) - - if (feOnly) {data <- dataETPfull} #nolint - else {regFE <- dataETPfull} #nolint + # Extrapolate ETP FE Data + evolutionFactor <- dataTCEP %>% + left_join(regmappingETP %>% + select("CountryCode", "EEAReg") %>% + rename(region = "CountryCode", + regionAgg = "EEAReg"), + by = "region") %>% + group_by(across(all_of(c("regionAgg", "enduse", "period")))) %>% + reframe(value = sum(.data[["value"]], na.rm = TRUE)) %>% + group_by(across(all_of(c("regionAgg", "enduse")))) %>% + reframe(factor = .data[["value"]] / dplyr::lead(.data[["value"]])) %>% + filter(!is.na(.data[["factor"]])) %>% + left_join(regmappingETP %>% + select("CountryCode", "EEAReg") %>% + rename(region = "CountryCode", + regionAgg = "EEAReg"), + by = "regionAgg") %>% + select(-"regionAgg") + + + dataETPstart <- feETP %>% + left_join(evolutionFactor, by = c("region", "enduse")) %>% + mutate(value = .data[["value"]] * .data[["factor"]], + period = 2000) %>% + select(-"factor") %>% + filter(!is.na(.data[["value"]])) + + + dataETPfull <- rbind(dataETPstart, + feETP %>% + filter(!is.na(.data[["value"]]))) + + + dataETPfull <- dataETPfull %>% + select(-"unit") %>% + quitte::factor.data.frame() %>% + as.quitte() %>% + interpolate_missing_periods(period = seq(1990, 2020)) %>% + group_by(across(all_of(c("region", "enduse")))) %>% + group_modify(~ extrapolateMissingPeriods(.x, key = "value")) %>% + ungroup() %>% + select("region", "period", "enduse", "value") + + + # NOTE: The linear regression might lead to negative values which will be + # filled up with small values and then re-normalized. + # (However, this is a very practical fix...) + + dataETPfull <- dataETPfull %>% + mutate(value = ifelse(.data[["value"]] < 0, 1e-6, .data[["value"]])) + + if (feOnly) { + data <- dataETPfull + } else { + regFE <- dataETPfull %>% + mutate(value = replace_na(.data[["value"]], 0)) } } @@ -383,7 +331,7 @@ calcShares <- function(subtype = c("carrier_nonthermal", interpolate_missing_periods(period = seq(1990, 2020), expand.values = TRUE) - if (carrierCorrection == TRUE) { + if (isTRUE(carrierCorrection)) { # The Carrier resolution will be extended by a further added resolution for # Enduses, which are however not disaggregated. This only serves the purpose # of facilitating specific corrections. @@ -445,66 +393,36 @@ calcShares <- function(subtype = c("carrier_nonthermal", # Make more specific corrections - for (i in rownames(correction)) { - data <- data %>% - mutate(value = unlist(ifelse( - grepl(correction[i, "regex"], - paste(.data[["RegionCode"]], .data[["enduse"]], .data[["carrier"]], - sep = ".")), - correction[i, "value"], - .data[["value"]] - ))) - } - - - # Remove Mapping Column - data <- select(data, -"RegionCode") - - # Re-Normalize - data <- normalize(data, shareOf) + data <- data %>% + left_join(shareCorrections, by = c("RegionCode" = "region", "enduse", "carrier")) %>% + mutate(value = ifelse(is.na(.data[["correction"]]), + .data[["value"]], + .data[["correction"]])) %>% + select(-"correction", -"RegionCode") %>% + normalize(shareOf) } } + if (isFALSE(feOnly)) { + # replace NA's + data <- data %>% + mutate(value = replace_na(.data[["value"]], 0)) + } + #---Thermal Part if (thermVar == "thermal") { if (shareOf == "enduse") { data <- data %>% - addThermal(regmappingEDGE, fridgeShare) + toolAddThermal(regmappingEDGE, fridgeShare, feOnly = FALSE, shareOf) - if (feWeights) { + if (isFALSE(feOnly)) { regFE <- regFE %>% - addThermal(regmappingEDGE, fridgeShare) + toolAddThermal(regmappingEDGE, fridgeShare) } } } - #---Weights: Regional Shares of FE - # Weights consist of the share of each region's FE demand relative to global FE demand. - # FE data is taken from ieaIO. - regShare <- ieaIO %>% - mutate(carrier = .data[["variable"]]) %>% - select("region", "period", "carrier", "value") %>% - group_by(across(all_of(c("period", "region")))) %>% - filter(!all(.data[["value"]] == 0)) %>% - summarise(value = sum(.data[["value"]], na.rm = TRUE)) %>% - ungroup() %>% - group_by(across(all_of(c("region")))) %>% - complete(period = unique(data$period)) %>% - ungroup() %>% - interpolate_missing_periods(expand.values = TRUE) %>% - group_by(across(all_of(c("period")))) %>% - mutate(value = proportions(.data[["value"]])) - - regFE <- regFE %>% - mutate(value = replace_na(.data[["value"]], 0)) - - - if (feWeights) { - data <- data %>% - mutate(value = replace_na(.data[["value"]], 0)) - } - @@ -516,30 +434,24 @@ calcShares <- function(subtype = c("carrier_nonthermal", as.magpie() %>% toolCountryFill(1, verbosity = 2) - regShare <- regShare %>% - as.magpie() %>% - collapseDim() %>% - time_interpolate(getItems(data, 2)) %>% - toolCountryFill(1, verbosity = 2) - - regFE <- regFE %>% - as.magpie() %>% - collapseDim() %>% - time_interpolate(getItems(data, 2)) %>% - toolCountryFill(1, verbosity = 2) - - if (isTRUE(feOnly)) { - weight <- regShare - unit <- "EJ" - max <- NULL + weight <- NULL + unit <- "EJ" + max <- NULL description <- "Final energy demand of carrier or end use in buildings" } else { + regFE <- regFE %>% + as.magpie() %>% + collapseDim() %>% + time_interpolate(getItems(data, 2)) %>% + toolCountryFill(1, verbosity = 2) + weight <- regFE - unit <- "1" - max <- 1 + unit <- "1" + max <- 1 + description <- "Share of carrier or end use in buildings final energy demand" } diff --git a/R/toolAddThermal.R b/R/toolAddThermal.R new file mode 100644 index 0000000..064d2ef --- /dev/null +++ b/R/toolAddThermal.R @@ -0,0 +1,44 @@ +#' Introduce refrigerators as appliances +#' +#' @param df data.frame +#' @param mapping original EDGE-B region mapping +#' @param fridgeShare regional shares of refrigerators +#' @param feOnly are absolute values (TRUE) or shares (FALSE) considered? +#' @param shareOf column name to calculate share of - must be given if feOnly = FALSE +#' +#' @author Hagen Tockhorn +#' +#' @importFrom dplyr filter left_join select + +toolAddThermal <- function(df, mapping, fridgeShare, feOnly = TRUE, shareOf = NULL) { + df <- df %>% + filter(.data[["enduse"]] != "lighting") %>% + left_join(mapping %>% + select(-"RegionCodeEUR", -"RegionCodeEUR_ETP", -"X") %>% + rename(region = "CountryCode") %>% + left_join(fridgeShare, by = "RegionCode") %>% + select(-"RegionCode"), + by = "region") %>% + mutate(value = ifelse(.data[["enduse"]] != "appliances", + .data[["value"]], + .data[["value"]] * .data[["share"]]), + enduse = ifelse(.data[["enduse"]] == "appliances", + "refrigerators", + as.character(.data[["enduse"]]))) %>% + select(-"share") + + if (!feOnly) { + if (is.character(shareOf) && (shareOf %in% colnames(df))) { + df <- df %>% + group_by(across(-all_of(c(shareOf, "value")))) %>% + mutate(value = .data[["value"]] / sum(.data[["value"]], na.rm = TRUE)) %>% + ungroup() + } else { + stop("Please give existing col name.") + } + + return(df) + } + + return(df) +} diff --git a/R/toolDisaggregate.R b/R/toolDisaggregate.R index 1356561..43076f3 100644 --- a/R/toolDisaggregate.R +++ b/R/toolDisaggregate.R @@ -23,7 +23,7 @@ #' @param dataDisagg data.frame similar to \code{data} but already disaggregated #' by carriers and end uses. The average distribution of its disaggregation #' will be used as the target distribution for the minisation. -#' @param regionmapping data.frame with the columns \code{region} and +#' @param regionMapping data.frame with the columns \code{region} and #' \code{regionAgg} that maps the regions between \code{data} and #' \code{enduseShares}. #' @param outliers list of regions where naive disaggregation estimate shall @@ -238,7 +238,7 @@ toolDisaggregate <- function(data, -#' Disaggregate energy demand within on aggregated region +#' Disaggregate energy demand within an aggregated region #' #' Disaggregate regional energy demand per carrier by end use while meeting the #' end use shares in the aggregated region. diff --git a/README.md b/README.md index 2a9c56a..34d7dd6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Prepare data to be used by the EDGE-Buildings model -R package **mredgebuildings**, version **0.6.2** +R package **mredgebuildings**, version **0.7.0** [![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) @@ -38,7 +38,7 @@ In case of questions / problems please contact Robin Hasse . +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.0, . A BibTeX entry for LaTeX users is @@ -47,11 +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}, -<<<<<<< HEAD note = {R package version 0.7.0}, -======= - note = {R package version 0.6.2}, ->>>>>>> 8aff157d9945bce34154e6bab672c915009a6bf7 url = {https://github.com/pik-piam/mredgebuildings}, } ``` diff --git a/inst/extdata/sectoral/correction_carrierShares.csv b/inst/extdata/sectoral/correction_carrierShares.csv new file mode 100644 index 0000000..5c4793b --- /dev/null +++ b/inst/extdata/sectoral/correction_carrierShares.csv @@ -0,0 +1,76 @@ +region,enduse,carrier,correction +NCD,water_heating,heat,0.0 +OAS,water_heating,heat,0.0 +AFR,water_heating,heat,0.0 +FIN,water_heating,heat,0.0 +MIE,water_heating,heat,0.0 +OCD,water_heating,heat,0.0 +AUT,water_heating,heat,0.0 +BEL,water_heating,heat,0.0 +BGR,water_heating,heat,0.0 +BRA,water_heating,heat,0.0 +CHN,water_heating,heat,0.0 +CYP,water_heating,heat,0.0 +CZE,water_heating,heat,0.0 +DEU,water_heating,heat,0.0 +DNK,water_heating,heat,0.0 +ESP,water_heating,heat,0.0 +EST,water_heating,heat,0.0 +FRA,water_heating,heat,0.0 +GBR,water_heating,heat,0.0 +GRC,water_heating,heat,0.0 +HRV,water_heating,heat,0.0 +HUN,water_heating,heat,0.0 +IND,water_heating,heat,0.0 +IRL,water_heating,heat,0.0 +ITA,water_heating,heat,0.0 +JPN,water_heating,heat,0.0 +LTU,water_heating,heat,0.0 +LUX,water_heating,heat,0.0 +LVA,water_heating,heat,0.0 +MEX,water_heating,heat,0.0 +MLT,water_heating,heat,0.0 +NLD,water_heating,heat,0.0 +POL,water_heating,heat,0.0 +USA,water_heating,heat,0.0 +PRT,water_heating,heat,0.0 +ROU,water_heating,heat,0.0 +RUS,water_heating,heat,0.0 +SVK,water_heating,heat,0.0 +SVN,water_heating,heat,0.0 +SWE,water_heating,heat,0.0 +ZAF,water_heating,heat,0.0 +OCD,water_heating,biomod,0.0 +OCD,cooking,biomod,0.0 +EUR,water_heating,biomod,0.0 +EUR,cooking,biomod,0.0 +USA,water_heating,biomod,0.0 +USA,cooking,biomod,0.0 +EUR,water_heating,biotrad,0.0 +EUR,cooking,biotrad,0.0 +RUS,space_heating,heat,0.6 +RUS,water_heating,natgas,0.7 +RUS,cooking,natgas,0.7 +RUS,water_heating,elec,0.07 +RUS,cooking,elec,0.07 +RUS,space_heating,elec,0.03 +RUS,space_heating,coal,0.04 +RUS,water_heating,coal,0.04 +RUS,cooking,coal,0.04 +RUS,space_heating,petrol,0.1 +RUS,water_heating,petrol,0.1 +RUS,cooking,petrol,0.1 +IND,space_heating,biotrad,0.8 +IND,water_heating,biotrad,0.8 +IND,space_heating,coal,0.1 +IND,water_heating,coal,0.1 +IND,cooking,coal,0.1 +IND,space_heating,petrol,0.12 +IND,water_heating,petrol,0.12 +IND,space_heating,natgas,0.0 +IND,water_heating,natgas,0.0 +IND,space_heating,elec,0.02 +IND,water_heating,elec,0.02 +IND,cooking,natgas,0.04 +IND,cooking,biotrad,0.5 +IND,cooking,petrol,0.5 diff --git a/inst/extdata/sectoral/fridgeShare.csv b/inst/extdata/sectoral/fridgeShare.csv new file mode 100644 index 0000000..5e6899f --- /dev/null +++ b/inst/extdata/sectoral/fridgeShare.csv @@ -0,0 +1,12 @@ +RegionCode,share +USA,0.12 +EUR,0.17 +OCD,0.17 +RUS,0.17 +JPN,0.17 +CHN,0.3 +IND,0.3 +NCD,0.3 +AFR,0.3 +MIE,0.3 +OAS,0.3 diff --git a/man/calcShares.Rd b/man/calcShares.Rd index 7aa0fa9..bd93642 100644 --- a/man/calcShares.Rd +++ b/man/calcShares.Rd @@ -8,8 +8,7 @@ calcShares( subtype = c("carrier_nonthermal", "carrier_thermal", "enduse_nonthermal", "enduse_thermal"), carrierCorrection = FALSE, - feOnly = FALSE, - feWeights = TRUE + feOnly = FALSE ) } \arguments{ @@ -18,8 +17,6 @@ calcShares( \item{carrierCorrection}{allows additional corrections} \item{feOnly}{specifies if shares or quantities are returned} - -\item{feWeights}{calculate additional FE weights for share aggregation} } \value{ data.frame with historic energy demands diff --git a/man/dot-disaggregate.Rd b/man/dot-disaggregate.Rd index 1e509d3..db38679 100644 --- a/man/dot-disaggregate.Rd +++ b/man/dot-disaggregate.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/toolDisaggregate.R \name{.disaggregate} \alias{.disaggregate} -\title{Disaggregate energy demand within on aggregated region} +\title{Disaggregate energy demand within an aggregated region} \usage{ .disaggregate(subset, key) } diff --git a/man/makeFloorspaceProjection.Rd b/man/makeFloorspaceProjection.Rd deleted file mode 100644 index f3660ec..0000000 --- a/man/makeFloorspaceProjection.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/calcFloorspacePast.R -\name{makeFloorspaceProjection} -\alias{makeFloorspaceProjection} -\title{Predict missing historic floorspace data} -\usage{ -makeFloorspaceProjection(df, gdppop, dens, endOfHistory, periodBegin) -} -\arguments{ -\item{df}{data.frame containing floorspace per capita} - -\item{gdppop}{data.frame containing gdp per capita} - -\item{dens}{data.frame containing population density} - -\item{endOfHistory}{upper temporal boundary of historic data} - -\item{periodBegin}{lower temporal boundary of historic data} -} -\value{ -floorspace per capita with filled missing entries -} -\description{ -A linear regression is performed to establish a general relationship between -floorspace per capita and gdp per capita and population density. -Predicted values are corrected w.r.t. to historical data where available, -otherwise the prediction is chosen. -} diff --git a/man/toolAddThermal.Rd b/man/toolAddThermal.Rd new file mode 100644 index 0000000..d02535d --- /dev/null +++ b/man/toolAddThermal.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/toolAddThermal.R +\name{toolAddThermal} +\alias{toolAddThermal} +\title{Introduce refrigerators as appliances} +\usage{ +toolAddThermal(df, mapping, fridgeShare, feOnly = TRUE, shareOf = NULL) +} +\arguments{ +\item{df}{data.frame} + +\item{mapping}{original EDGE-B region mapping} + +\item{fridgeShare}{regional shares of refrigerators} + +\item{feOnly}{are absolute values (TRUE) or shares (FALSE) considered?} + +\item{shareOf}{column name to calculate share of - must be given if feOnly = FALSE} +} +\description{ +Introduce refrigerators as appliances +} +\author{ +Hagen Tockhorn +} diff --git a/man/toolCalcShares.Rd b/man/toolCalcShares.Rd new file mode 100644 index 0000000..98d7012 --- /dev/null +++ b/man/toolCalcShares.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/toolCalcShares.R +\name{toolCalcShares} +\alias{toolCalcShares} +\title{Calculate Shares} +\usage{ +toolCalcShares(df, colShare) +} +\arguments{ +\item{df}{data.frame} + +\item{colShare}{column to be grouped over} +} +\value{ +data.frame with calculated shares for colShare +} +\description{ +Calculate Shares +} +\author{ +Hagen Tockhorn +} diff --git a/man/toolDisaggregate.Rd b/man/toolDisaggregate.Rd index 1db3798..24e0e1e 100644 --- a/man/toolDisaggregate.Rd +++ b/man/toolDisaggregate.Rd @@ -33,7 +33,7 @@ end uses in \code{enduseShares} are considered.} by carriers and end uses. The average distribution of its disaggregation will be used as the target distribution for the minisation.} -\item{regionmapping}{data.frame with the columns \code{region} and +\item{regionMapping}{data.frame with the columns \code{region} and \code{regionAgg} that maps the regions between \code{data} and \code{enduseShares}.} }