From dc63fd2124e7630f62f29588163989274689043c Mon Sep 17 00:00:00 2001 From: Ben Young Date: Wed, 13 Sep 2023 16:15:29 -0400 Subject: [PATCH] Convert factors from basic to producer price --- R/LoadExternalImportFactors.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/R/LoadExternalImportFactors.R b/R/LoadExternalImportFactors.R index 9fa3a39c..345ea6a6 100644 --- a/R/LoadExternalImportFactors.R +++ b/R/LoadExternalImportFactors.R @@ -26,7 +26,13 @@ loadExternalImportFactors <- function(model, configpaths = NULL) { # Format IFTable to match model$M IFTable['Flow'] <- paste(IFTable$Flowable, IFTable$Context, IFTable$Unit, sep = "/") - #TODO: Convert from basic to producer price using TAU if possible + # Convert from basic to producer price using TAU of CurrencyYear + Tau <- model$Tau[, as.character(meta$CurrencyYear)] + names(Tau) <- gsub("/.*","",names(Tau)) + IFTable <- merge(IFTable, as.data.frame(Tau), by.x = 'Sector', by.y = 0, all.y = FALSE) + IFTable['FlowAmount'] <- IFTable['FlowAmount'] / IFTable['Tau'] + IFTable['PriceType'] <- 'Producer' + IFTable['CurrencyYear'] <- model$specs$IOYear if(model$specs$IODataSource =="stateior") { #TODO