Skip to content

Commit

Permalink
read in energy prices and taxes
Browse files Browse the repository at this point in the history
  • Loading branch information
fbenke-pik committed Feb 4, 2025
1 parent 0ddd1d4 commit 4a460d3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
15 changes: 15 additions & 0 deletions R/convertIEA_EnergyPrices.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#' Convert IEA Energy Prices
#'
#' @author Falk Benke
#' @importFrom madrat toolCountry2isocode
convertIEA_EnergyPrices <- function(x) {
# remove regions
x <- x[c("OECDEUR", "OECDTOT"), , invert = TRUE]
getItems(x, dim = 1) <- toolCountry2isocode(getItems(x, dim = 1))

# remove quarterly data
x <- x[, !grepl("^[1-4]Q", getYears(x)), invert = TRUE]

x <- toolCountryFill(x, NA, verbosity = 2)
return(x)
}
17 changes: 17 additions & 0 deletions R/readIEA_EnergyPrices.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#' Read IEA Energy Prices
#'
#' Read-in an IEA Energy Prices file as magpie object
#'
#' @author Falk Benke
#' @importFrom data.table
#' @importFrom madrat as.magpie
readIEA_EnergyPrices <- function() {
data <- data.table::fread(
file = file.path("2022", "EPT_prices_USD.TXT"),
col.names = c("SECTOR", "COUNTRY", "PRODUCT", "UNIT", "TIME", "value"),
colClasses = c("character", "character", "character", "character", "character", "numeric"),
sep = " ", stringsAsFactors = FALSE, na.strings = c("x", "..", "c"), skip = 0, showProgress = FALSE
)

return(as.magpie(data, spatial = 2, temporal = 5))
}

0 comments on commit 4a460d3

Please sign in to comment.