Skip to content

Commit

Permalink
find stateior objects via alias
Browse files Browse the repository at this point in the history
  • Loading branch information
bl-young committed Dec 17, 2024
1 parent 1dc20e8 commit 5d64cea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion R/StateiorFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
#' @return A list of two-region IO data of model iolevel and year.
getTwoRegionIOData <- function(model, dataname) {
# Define state, year and iolevel
alias <- ifelse(!is.na(model$specs$alias), model$specs$alias, NULL)
if(!"US-DC" %in% model$specs$ModelRegionAcronyms) {
state <- state.name[state.abb == gsub(".*-", "", model$specs$ModelRegionAcronyms[1])]
} else {
state <- "District of Columbia"
}
# Define data file name
filename <- paste(lapply(c("TwoRegion", model$specs$BaseIOLevel, dataname,
model$specs$DisaggregationSpecs, model$specs$IOYear,
alias, model$specs$IOYear,
model$specs$IODataVersion),
function(x) x[!is.na(x)]), collapse = "_")
# Adjust filename to fit what is on the Data Commons
Expand All @@ -33,6 +34,7 @@ getTwoRegionIOData <- function(model, dataname) {
filename <- gsub(dataname, "UsewithTrade", filename)
}
# Load data
logging::loginfo(paste0("Loading ", filename))
TwoRegionIOData <- readRDS(loadDataCommonsfile(paste0("stateio/", filename, ".rds")))
# Keep SoI and RoUS only
TwoRegionIOData <- TwoRegionIOData[[state]]
Expand Down
7 changes: 4 additions & 3 deletions tests/test_model_build.R
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,11 @@ printValidationResults(model)
testCalculationFunctions(model)
testVisualizationFunctions(model)

# ## StateEEIOv1.0 Two-region Summary model with "standard" Utility disaggregation
# model <- useeior:::initializeModel(m, configpaths = file.path(cfg))
# model$specs$Model <- "GAEEIOv1.0-75-GHG-19"
# ## StateEEIOv1.2 Two-region Summary model with "standard" Utility disaggregation
# model <- useeior:::initializeModel(m)
# model$specs$Model <- "GAEEIOv1.2-milkbar-19"
# model$specs$IODataVersion <- "0.3.0" # required for disaggregation
# model$specs$alias <- "milkbar"
# model$specs$DisaggregationSpecs <- "UtilityDisaggregation"
# model <- useeior:::loadIOData(model, file.path(cfg))
# model <- useeior:::loadandbuildSatelliteTables(model)
Expand Down

0 comments on commit 5d64cea

Please sign in to comment.