Skip to content

Commit

Permalink
adjust description based on IEA version
Browse files Browse the repository at this point in the history
  • Loading branch information
fbenke-pik committed Feb 13, 2024
1 parent 3a664df commit b794b73
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ jobs:
shell: Rscript {0}
run: lucode2:::validkey(stopIfInvalid = TRUE)

- name: Verify that lucode2::buildLibrary was successful
shell: Rscript {0}
run: lucode2:::isVersionUpdated()

- name: Checks
shell: Rscript {0}
run: |
Expand Down
3 changes: 2 additions & 1 deletion R/calcFE.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ calcFE <- function(source = "IEA", scenario_proj = "SSP2", ieaVersion = "default
colnames(map) <- gsub("io", "names_in", colnames(map))

# Give description
descript <- "IEA Final Energy Data based on 2022 version of IEA Energy Balances"
ieaYear <- if (ieaVersion == "default") 2022 else 2023
descript <- paste0("IEA Final Energy Data based on ", ieaYear, " version of IEA Energy Balances")

#------ PROCESS DATA ------------------------------------------
# select data that have names
Expand Down
6 changes: 4 additions & 2 deletions R/calcIO.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ calcIO <- function(subtype = c("input", "output", "output_biomass", "trade",
}

ieaSubtype <- if (ieaVersion == "default") "EnergyBalances" else "EnergyBalances-latest"
ieaYear <- if (ieaVersion == "default") 2022 else 2023

# read in data and convert from ktoe to EJ
data <- readSource("IEA", subtype = ieaSubtype) * 4.1868e-5
Expand Down Expand Up @@ -177,7 +178,8 @@ calcIO <- function(subtype = c("input", "output", "output_biomass", "trade",
# In order to split the REMIND technology biotr between biotr and biotrmod,
# We use the traditional biomass split for EDGE buildings and divide by the total quantity of FE biomass

edgeBio <- calcOutput("IOEdgeBuildings", subtype = "output_EDGE_buildings", ieaVersion = ieaVersion, aggregate = FALSE)
edgeBio <- calcOutput("IOEdgeBuildings", subtype = "output_EDGE_buildings",
ieaVersion = ieaVersion, aggregate = FALSE)
feBio <- calcOutput("IO", subtype = "output_biomass", ieaVersion = ieaVersion, aggregate = FALSE)
shareBiotrad <- edgeBio[, , "biotrad"] / (feBio[, , "sesobio.fesob.tdbiosob"] + feBio[, , "sesobio.fesoi.tdbiosoi"])
shareBiotrad[is.na(shareBiotrad)] <- 0
Expand Down Expand Up @@ -237,5 +239,5 @@ calcIO <- function(subtype = c("input", "output", "output_biomass", "trade",
}

return(list(x = reminditems, weight = NULL, unit = "EJ",
description = "IEA SE Output Data based on 2022 edition of IEA World Energy Balances"))
description = paste0("IEA SE Output Data based on ", ieaYear, " edition of IEA World Energy Balances")))
}
16 changes: 11 additions & 5 deletions R/calcPE.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ calcPE <- function(subtype = "IEA", ieaVersion = "default") {
getNames(x) <- paste0(getNames(x), " (EJ/yr)")

# add loss to electricity
x[, , "PE|Coal|Electricity (EJ/yr)"] <- x[, , "PE|Coal|Electricity (EJ/yr)"] + x[, , "PE|Coal|Electricity|Loss (EJ/yr)"]
x[, , "PE|Biomass|Electricity (EJ/yr)"] <- x[, , "PE|Biomass|Electricity (EJ/yr)"] + x[, , "PE|Biomass|Electricity|Loss (EJ/yr)"]
x[, , "PE|Gas|Electricity (EJ/yr)"] <- x[, , "PE|Gas|Electricity (EJ/yr)"] + x[, , "PE|Gas|Electricity|Loss (EJ/yr)"]
x <- x[, , c("PE|Coal|Electricity|Loss (EJ/yr)", "PE|Biomass|Electricity|Loss (EJ/yr)", "PE|Gas|Electricity|Loss (EJ/yr)"), invert = TRUE]
x[, , "PE|Coal|Electricity (EJ/yr)"] <- x[, , "PE|Coal|Electricity (EJ/yr)"] +
x[, , "PE|Coal|Electricity|Loss (EJ/yr)"]
x[, , "PE|Biomass|Electricity (EJ/yr)"] <- x[, , "PE|Biomass|Electricity (EJ/yr)"] +
x[, , "PE|Biomass|Electricity|Loss (EJ/yr)"]
x[, , "PE|Gas|Electricity (EJ/yr)"] <- x[, , "PE|Gas|Electricity (EJ/yr)"] +
x[, , "PE|Gas|Electricity|Loss (EJ/yr)"]
x <- x[, , c("PE|Coal|Electricity|Loss (EJ/yr)", "PE|Biomass|Electricity|Loss (EJ/yr)",
"PE|Gas|Electricity|Loss (EJ/yr)"), invert = TRUE]

# add more variables
x <- mbind(x, setNames(dimSums(x[, , "PE|", pmatch = TRUE], dim = 3), "PE (EJ/yr)"))
Expand All @@ -41,9 +45,11 @@ calcPE <- function(subtype = "IEA", ieaVersion = "default") {
x <- mbind(x, setNames(dimSums(x[, , "PE|Gas", pmatch = TRUE], dim = 3), "PE|Gas (EJ/yr)"))
x <- mbind(x, setNames(dimSums(x[, , "PE|Biomass", pmatch = TRUE], dim = 3), "PE|Biomass (EJ/yr)"))

ieaYear <- if (ieaVersion == "default") 2022 else 2023

return(list(x = x, weight = NULL, unit = "EJ",
description = "IEA Primary Energy Data based on 2022 version of IEA Energy Balances"))
description = paste0("IEA Primary Energy Data based on ", ieaYear,
" version of IEA Energy Balances")))

} else if (subtype == "IEA_WEO") {

Expand Down

0 comments on commit b794b73

Please sign in to comment.