-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0ddd1d4
commit 4a460d3
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} |