Skip to content

Commit

Permalink
rename buildEIOModel to buildIOModel and export; incorporate adju…
Browse files Browse the repository at this point in the history
…stment for 2r models
  • Loading branch information
bl-young committed May 17, 2024
1 parent 9fdce17 commit 98b848b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export(aggregateResultMatrix)
export(aggregateResultMatrixbyRow)
export(barplotFloworImpactFractionbyRegion)
export(barplotIndicatorScoresbySector)
export(buildIOModel)
export(buildModel)
export(buildTwoRegionModels)
export(calculateEEIOModel)
Expand Down
17 changes: 12 additions & 5 deletions R/BuildModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,13 @@ buildTwoRegionModels <- function(modelname, configpaths = NULL, validate = FALSE
return(model_ls)
}

#' Build an EIO model with economic components only.
#' Build an IO model with economic components only.
#' @param modelname Name of the model from a config file.
#' @param configpaths str vector, paths (including file name) of model configuration file
#' and optional agg/disagg configuration file(s). If NULL, built-in config files are used.
#' @return A list of EIO model with only economic components
buildEIOModel <- function(modelname, configpaths = NULL) {
#' @return A list of IO model with only economic components
#' @export
buildIOModel <- function(modelname, configpaths = NULL) {
model <- initializeModel(modelname, configpaths)
model <- loadIOData(model, configpaths)
model <- loadDemandVectors(model)
Expand All @@ -314,8 +315,14 @@ buildEIOModel <- function(modelname, configpaths = NULL) {
colnames(model$U_d) <- colnames(model$U)
model[c("U", "U_d")] <- lapply(model[c("U", "U_d")],
function(x) ifelse(is.na(x), 0, x))
model$U_n <- generateDirectRequirementsfromUse(model, domestic = FALSE) #normalized Use
model$U_d_n <- generateDirectRequirementsfromUse(model, domestic = TRUE) #normalized DomesticUse

if (model$specs$IODataSource=="stateior") {
model$U_n <- generate2RDirectRequirementsfromUseWithTrade(model, domestic = FALSE)
model$U_d_n <- generate2RDirectRequirementsfromUseWithTrade(model, domestic = TRUE)
} else {
model$U_n <- generateDirectRequirementsfromUse(model, domestic = FALSE) #normalized Use
model$U_d_n <- generateDirectRequirementsfromUse(model, domestic = TRUE) #normalized DomesticUse
}
model$q <- model$CommodityOutput
model$x <- model$IndustryOutput
model$mu <- model$InternationalTradeAdjustment
Expand Down
12 changes: 6 additions & 6 deletions man/buildEIOModel.Rd → man/buildIOModel.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions tests/test_model_build.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ printValidationResults(model)

## USEEIOv2.0.1-411 Detail model with waste disaggregation (Economic only)
m <- "USEEIOv2.0.1-411"
model <- buildEIOModel(m)
model <- buildIOModel(m)
printValidationResults(model)
writeModeltoXLSX(model, ".")

Expand Down Expand Up @@ -121,6 +121,6 @@ model <- buildModel(m, configpaths = file.path(cfg))
useeior::print2RValidationResults(model)

## StateEEIOv1.0 Two-region Summary model
model <- buildEIOModel(m, configpaths = file.path(cfg))
model <- buildIOModel(m, configpaths = file.path(cfg))
useeior::print2RValidationResults(model)
writeModeltoXLSX(model, ".")

0 comments on commit 98b848b

Please sign in to comment.