Skip to content

Commit

Permalink
Removing gcamdata_files error
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Jun 17, 2022
1 parent e1af4e9 commit 3e904ba
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
14 changes: 13 additions & 1 deletion R/readgcam.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ readgcam <- function(gcamdatabase = NULL,
paramsSelectAll -> tblFinalNrgIntlAvShip -> datax -> group -> basin -> subRegion -> query -> subresource ->
transport -> gcamdata -> half.life -> lifetime -> read.csv -> sector_1 -> steepness -> PrimaryFuelCO2Coef ->
PrimaryFuelCO2Coef.name -> country -> grid_region -> 'io-coefficient' -> 'minicam.energy.input' ->
'remove.fraction' -> state -> subsector.name -> 'to.technology' -> coefficient -> tbl_carbon_capture_rate
'remove.fraction' -> state -> subsector.name -> 'to.technology' -> coefficient -> tbl_carbon_capture_rate ->
gcamdata_files

basedir <- getwd()

Expand Down Expand Up @@ -815,6 +816,10 @@ readgcam <- function(gcamdatabase = NULL,
}
}

if(!is.null(gcamdata_files)){
if(
file.exists(gcamdata_files[["/inst/extdata/gcam-usa/calibrated_techs_dispatch_usa"]]) &
file.exists(gcamdata_files[["/inst/extdata/gcam-usa/A23.elec_tech_mapping_cool"]])){
# Read in additional files
add_techs <- tibble::as_tibble(gcamdata_files[["/inst/extdata/gcam-usa/calibrated_techs_dispatch_usa"]]) %>%
dplyr::select(class1 = minicam.energy.input,
Expand All @@ -830,6 +835,7 @@ readgcam <- function(gcamdatabase = NULL,
dplyr::left_join(add_techs) %>%
dplyr::mutate(classLabel1="fuel",
classLabel2="technology")
}}

if(grepl("cerf",paramsSelect,ignore.case = T)){
tbl_comb <- tbl_comb %>%
Expand Down Expand Up @@ -1214,6 +1220,11 @@ readgcam <- function(gcamdatabase = NULL,


# Read in additional files
if(!is.null(gcamdata_files)){
if(
file.exists(gcamdata_files[["/inst/extdata/gcam-usa/calibrated_techs_dispatch_usa"]]) &
file.exists(gcamdata_files[["/inst/extdata/gcam-usa/A23.elec_tech_mapping_cool"]])){

add_techs <- tibble::as_tibble(gcamdata_files[["/inst/extdata/gcam-usa/calibrated_techs_dispatch_usa"]]) %>%
dplyr::select(class1 = minicam.energy.input,
class2a = technology) %>%
Expand All @@ -1229,6 +1240,7 @@ readgcam <- function(gcamdatabase = NULL,
dplyr::mutate(classLabel1="fuel",
classLabel2="technology")%>%
dplyr::filter(!is.na(class2))
}}

if(grepl("cerf",paramsSelect,ignore.case = T)){
tbl <- tbl %>%
Expand Down
23 changes: 19 additions & 4 deletions inst/extdata/devTests.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
#----------------------
# EXAMPLE FOR DOCS - gcamextractor - rchart - rmap
#----------------------
#..........................
# Check with releases of GCAM
#..........................
library(gcamextractor);

# List of params in gcamextractor
params <- gcamextractor::data_params; params

# GCAM 6.0
data <- readgcam(gcamdatabase = "C:/gcam/gcam-v6.0-Windows-Release-Package/output/database_basexdb",
folder = "test_gcamv6p0")

# GCAM 5.4
data <- readgcam(gcamdatabase = "C:/gcam/gcam-v5.4-Windows-Release-Package/output/database_basexdb",
folder = "test_gcamv5p4")

#..........................
# EXAMPLE FOR DOCS - gcamextractor - rchart - rmap
#..........................
library(gcamextractor); library(rmap); library(rchart)

# List of params in gcamextractor
Expand Down Expand Up @@ -78,7 +93,7 @@ regionsSelect_i = NULL
folder_i="cerf_test"

# Issue #20
paramsSelect_i = c("cerf")
paramsSelect_i = c("elec_heat_rate_BTUperkWh")

dataGCAM <- readgcam(reReadData = reReadData_i,
gcamdatabase = gcamdatabase_i,
Expand Down

0 comments on commit 3e904ba

Please sign in to comment.