Skip to content

Commit

Permalink
in checkProjectSummations, use skipUnits=TRUE
Browse files Browse the repository at this point in the history
  • Loading branch information
orichters committed Mar 13, 2024
1 parent a414292 commit a545df2
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions scripts/output/single/checkProjectSummations.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,18 @@ mifdata <- as.quitte(mif)

stopmessage <- NULL

options(width = 160)

absDiff <- 0.00001
relDiff <- 0.01

# to be skipped for regional aggregation as they are no extensive variables
varGrep <- paste0("^Tech|CES Price|^Price|^Internal|[Pp]er[- ][Cc]apita|per-GDP|Specific|Interest Rate|",
"Intensity|Productivity|Average Extraction Costs|^PVP|Other Fossil Adjusted|Projected|[Ss]hare")
unitList <- c("%", "Percent", "percent", "% pa", "1", "share", "USD/capita", "index", "kcal/cap/day",
"cm/capita", "kcal/capita/day", "unitless", "kcal/kcal", "m3/ha", "tC/tC", "tC/ha", "years",
"share of total land", "tDM/capita/yr", "US$05 PPP/cap/yr", "t DM/ha/yr", "US$2010/kW", "US$2010/kW/yr")

# emi variables where bunkers are added only to the World level
gases <- c("BC", "CO", "CO2", "Kyoto Gases", "NOx", "OC", "Sulfur", "VOC")
vars <- c("", "|Energy", "|Energy Demand|Transportation", "|Energy and Industrial Processes",
"|Energy|Demand", "|Energy|Demand|Transportation")
gasvars <- expand.grid(gases, vars, stringsAsFactors = FALSE)
bunkervars <- unique(sort(paste0("Emissions|", gasvars$Var1, gasvars$Var2)))


# failing <- mif %>%
# checkSummations(dataDumpFile = NULL, outputDirectory = NULL, summationsFile = "extractVariableGroups",
# absDiff = 5e-7, relDiff = 1e-8) %>%
# filter(abs(diff) >= 5e-7, abs(reldiff) >= 1e-8) %>%
# df_variation() %>%
# droplevels()
# if (nrow(failing) > 0) stopmessage <- c(stopmessage, "extractVariableGroups")

for (template in c("AR6", "NAVIGATE")) {
message("\n### Check project summations for ", template)
d <- generateIIASASubmission(mifdata, outputDirectory = NULL, logFile = NULL,
Expand All @@ -52,8 +38,7 @@ for (template in c("AR6", "NAVIGATE")) {
droplevels()

csregi <- d %>%
filter(! .data$unit %in% unitList, ! grepl(varGrep, .data$variable)) %>%
checkSummationsRegional() %>%
checkSummationsRegional(skipUnits = TRUE) %>%
rename(World = "total") %>%
droplevels()
checkyear <- 2050
Expand All @@ -64,7 +49,6 @@ for (template in c("AR6", "NAVIGATE")) {
if (nrow(failregi) > 0) {
message("For those ", template, " variables, the sum of regional values does not match the World value in 2050:")
failregi %>% piamInterfaces::niceround() %>% print(n = 1000)
print(paste0(failregi$variable, collapse = ", "))
} else {
message("Regional summation checks are fine.")
}
Expand Down

0 comments on commit a545df2

Please sign in to comment.