Skip to content

Commit 5c6c62e

Browse files
committed
read csv instead of toolreadSets
1 parent bbb7a07 commit 5c6c62e

15 files changed

+147
-123
lines changed

R/calcIAvailRate.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ calcIAvailRate <- function() {
2323
fEndHorizon <- readEvalGlobal(system.file(file.path("extdata", "main.gms"), package = "mrprom"))["fEndHorizon"]
2424

2525
# Get power plant set from GAMS code
26-
sets <- toolreadSets(system.file(file.path("extdata", "sets.gms"), package = "mrprom"), "PGALL")
27-
set_pgall <- unlist(strsplit(sets[, 1], ","))
26+
sets <- toolGetMapping(name = "PGALL.csv",
27+
type = "blabla_export",
28+
where = "mrprom")
29+
30+
set_pgall <- as.character(sets[, 1])
2831

2932
df <- data.frame(variable = set_pgall,
3033
period = 2020,

R/calcIDataElecProd.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@ calcIDataElecProd <- function() {
2727
x <- x[, c(max(fStartHorizon, min(getYears(x, as.integer = TRUE))) : max(getYears(x, as.integer = TRUE))), ]
2828

2929
# load current OPENPROM set configuration
30-
sets <- toolreadSets(system.file(file.path("extdata", "sets.gms"), package = "mrprom"), "PGALL")
31-
sets <- unlist(strsplit(sets[, 1], ","))
30+
sets <- toolGetMapping(name = "PGALL.csv",
31+
type = "blabla_export",
32+
where = "mrprom")
33+
34+
sets <- as.character(sets[, 1])
3235

3336
# use enerdata-openprom mapping to extract correct data from source
3437
map <- toolGetMapping(name = "prom-enerdata-elecprod-mapping.csv",

R/calcIDataGrossInlCons.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ calcIDataGrossInlCons <- function() {
4545
as.magpie()
4646

4747
# load OPENPROM EFS set
48-
sets <- toolreadSets(system.file(file.path("extdata", "sets.gms"), package = "mrprom"), "EFS")
49-
sets <- unlist(strsplit(sets[, 1], ","))
48+
sets <- toolGetMapping(name = "EFS.csv",
49+
type = "blabla_export",
50+
where = "mrprom")
51+
52+
sets <- as.character(sets[, 1])
5053

5154
## Only keep items with the Mtoe unit
5255
x <- x[, , "Mtoe", pmatch = TRUE]

R/calcIDataTransTech.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,17 @@ calcIDataTransTech <- function() {
4343
type = "sectoral",
4444
where = "mrprom")
4545
# load current OPENPROM set configuration
46-
TRANSFINAL <- toolreadSets(system.file(file.path("extdata", "sets.gms"), package = "mrprom"), "TRANSFINAL")
47-
TRANSFINAL <- unlist(strsplit(TRANSFINAL[, 1], ","))
46+
TRANSFINAL <- toolGetMapping(name = "TRANSE.csv",
47+
type = "blabla_export",
48+
where = "mrprom")
49+
50+
TRANSFINAL <- as.character(TRANSFINAL[, 1])
4851

49-
TTECH <- toolreadSets(system.file(file.path("extdata", "sets.gms"), package = "mrprom"), "TTECH")
50-
TTECH <- unlist(strsplit(TTECH[, 1], ","))
52+
TTECH <- toolGetMapping(name = "TTECH.csv",
53+
type = "blabla_export",
54+
where = "mrprom")
55+
56+
TTECH <- as.character(TTECH[, 1])
5157

5258
#make dataframe with all the available variables
5359
x <- as.data.frame(expand.grid(TTECH, TRANSFINAL, years))

R/calcIDecomPlants.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ calcIDecomPlants <- function() {
2929
x <- x %>% drop_na(period)
3030

3131
# load current OPENPROM set configuration
32-
sets <- toolreadSets(system.file(file.path("extdata", "sets.gms"), package = "mrprom"), "PGALL")
33-
sets <- unlist(strsplit(sets[, 1], ","))
32+
33+
sets <- toolGetMapping(name = "PGALL.csv",
34+
type = "blabla_export",
35+
where = "mrprom")
36+
37+
sets <- as.character(sets[, 1])
3438

3539
# use iInvPlants-openprom mapping to extract correct data from source
3640
map <- toolGetMapping(name = "iInvPlants-mapping.csv",

R/calcIEnvPolicies.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ calcIEnvPolicies <- function() {
8080

8181

8282
# load current OPENPROM set configuration
83-
POLICIES_set <- toolreadSets(system.file(file.path("extdata", "sets.gms"), package = "mrprom"), "POLICIES_set")
84-
POLICIES_set <- unlist(strsplit(POLICIES_set[, 1], ","))
85-
POLICIES_set <- POLICIES_set[c(1, 3:5, 11:13)]
83+
sets <- toolGetMapping(name = "POLICIES_set.csv",
84+
type = "blabla_export",
85+
where = "mrprom")
86+
87+
POLICIES_set <- as.character(sets[c(sets[, 1] %in% c("TRADE", "OPT", "REN", "EFF", "exogCV_NPi", "exogCV_1_5C", "exogCV_2C")), 1])
8688

8789
x <- expand_grid(POLICIES_set, unique(qx["region"]), unique(qx["period"]))
8890
x["value"] <- NA

R/calcIFuelCons.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ calcIFuelCons <- function(subtype = "DOMSE") {
3232
x <- x[, c(fStartHorizon:lastYear), ]
3333

3434
# load current OPENPROM set configuration
35-
sets <- toolreadSets(system.file(file.path("extdata", "sets.gms"), package = "mrprom"), subtype)
36-
sets <- unlist(strsplit(sets[, 1], ","))
35+
sets <- toolGetMapping(paste0(subtype, ".csv"),
36+
type = "blabla_export",
37+
where = "mrprom")
38+
39+
sets <- as.character(sets[, 1])
3740

3841
# use enerdata-openprom mapping to extract correct data from source
3942
map <- toolGetMapping(name = "prom-enerdata-fucon-mapping.csv",

R/calcIFuelPrice.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ calcIFuelPrice <- function() {
3737
for (i in c("NENSE", "DOMSE", "INDSE", "TRANSE", "PG")) { # define main OPEN-PROM sectors that we need data for
3838
sets <- NULL
3939
# load current OPENPROM set configuration for each sector
40-
try(sets <- toolreadSets(system.file(file.path("extdata", "sets.gms"), package = "mrprom"), i))
41-
try(sets <- unlist(strsplit(sets[, 1], ",")))
42-
if (is.null(sets)) sets <- i
40+
try(sets <- toolGetMapping(paste0(i, ".csv"),
41+
type = "blabla_export",
42+
where = "mrprom"))
43+
try(sets <- as.character(sets[, 1]))
44+
if (length(sets) == 0) sets <- i
4345

4446
## filter mapping to keep only i sectors
4547
map <- filter(map0, map0[, "SBS"] %in% sets)

R/calcIInvPlants.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ calcIInvPlants <- function() {
2828
x <- x %>% drop_na(period)
2929

3030
# load current OPENPROM set configuration
31-
sets <- toolreadSets(system.file(file.path("extdata", "sets.gms"), package = "mrprom"), "PGALL")
32-
sets <- unlist(strsplit(sets[, 1], ","))
31+
sets <- toolGetMapping(paste0("PGALL.csv"),
32+
type = "blabla_export",
33+
where = "mrprom")
34+
35+
sets <- as.character(sets[, 1])
3336

3437
# use iInvPlants-openprom mapping to extract correct data from source
3538
map <- toolGetMapping(name = "iInvPlants-mapping.csv",

R/calcIMatFacPlaAvailCap.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ calcIMatFacPlaAvailCap <- function() {
2222
fEndHorizon <- readEvalGlobal(system.file(file.path("extdata", "main.gms"), package = "mrprom"))["fEndHorizon"]
2323

2424
# load current OPENPROM set configuration
25-
sets <- toolreadSets(system.file(file.path("extdata", "sets.gms"), package = "mrprom"), "PGALL")
26-
sets <- unlist(strsplit(sets[, 1], ","))
25+
sets <- toolGetMapping(paste0("PGALL.csv"),
26+
type = "blabla_export",
27+
where = "mrprom")
28+
29+
sets <- as.character(sets[, 1])
2730

2831
sets_remove <- c("CTHBMSWAS", "CCCGT", "PGLHYD", "PGSHYD", "PGWND", "PGSOL",
2932
"PGANUC", "PGAPSS", "PGAPSSL", "PGACGSL", "PGACGS", "PGAGGS")

0 commit comments

Comments
 (0)