Skip to content

Commit

Permalink
Merge pull request #740 from flohump/f_fixreport
Browse files Browse the repository at this point in the history
hotfix for rds_report.R output script: fix units in "report.rds" file
  • Loading branch information
pascal-sauer authored Nov 1, 2024
2 parents 8ca3f86 + 02fdf50 commit dd71fec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion scripts/output/rds_report.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ resultsarchive <- "/p/projects/rd3mod/models/results/magpie"
report <- getReport(gdx, scenario = cfg$title, dir = outputdir)

for (mapping in c("AR6", "NAVIGATE", "SHAPE", "AR6_MAgPIE")) {
missingVariables <- sort(setdiff(unique(deletePlus(getMappingVariables(mapping,"M"))),unique(deletePlus(getNames(report,dim="variable")))))
missingVariables <- sort(setdiff(unique(deletePlus(getMappingVariables(mapping, "M"))), unique(deletePlus(getNames(report, dim = "variable")))))
if (length(missingVariables) > 0) {
warning("# The following ", length(missingVariables), " variables are expected in the piamInterfaces package ",
"for mapping ", mapping, ", but cannot be found in the MAgPIE report.\nPlease either fix in magpie4 or adjust the mapping in piamInterfaces.\n- ",
Expand All @@ -48,6 +48,7 @@ for (mapping in c("AR6", "NAVIGATE", "SHAPE", "AR6_MAgPIE")) {
}

write.report(report, file = mif)
report <- read.report(file = mif, as.list = FALSE)

q <- as.quitte(report)
# as.quitte converts "World" into "GLO". But we want to keep "World" and therefore undo these changes
Expand Down
4 changes: 4 additions & 0 deletions scripts/output/rds_report_iso.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ rds_iso <- paste0(outputdir, "/report_iso.rds")

report <- getReportIso(gdx, scenario = cfg$title, dir = outputdir)

mif <- sub(".rds",".mif",rds_iso)
write.report(report, file = mif, scenario = cfg$title)
report <- read.report(file = mif, as.list = FALSE)

q <- as.quitte(report)
# as.quitte converts "World" into "GLO". But we want to keep "World" and therefore undo these changes
q <- droplevels(q)
Expand Down

0 comments on commit dd71fec

Please sign in to comment.