Skip to content

Commit

Permalink
mrdownscale output script
Browse files Browse the repository at this point in the history
  • Loading branch information
pascal-sauer committed Aug 7, 2024
1 parent 001e999 commit c22704e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions scripts/output/extra/disaggregation_mrdownscale.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# | (C) 2008-2024 Potsdam Institute for Climate Impact Research (PIK)
# | authors, and contributors see CITATION.cff file. This file is part
# | of MAgPIE and licensed under AGPL-3.0-or-later. Under Section 7 of
# | AGPL-3.0, you are granted additional permissions described in the
# | MAgPIE License Exception, version 1.0 (see LICENSE file).
# | Contact: [email protected]

# ------------------------------------------------------------------------------------------------
# description: Downscale MAgPIE results to 0.25 degree resolution in LUH2 format for ESMs
# comparison script: FALSE
# ------------------------------------------------------------------------------------------------
library(mrdownscale)

outputdir <- normalizePath(outputdir)

clustermap <- Sys.glob(file.path(outputdir, "clustermap_*.rds"))
gdx <- file.path(outputdir, "fulldata.gdx")
stopifnot(file.exists(gdx), length(clustermap) == 1)

scenario <- gsub("_", "-", sub("-mag-[0-9]+$", "", basename(outputdir)))

local({ # redirectSource is local by default, running it in the global environment does not work
redirectSource("MagpieFulldataGdx", c(clustermap, gdx), linkOthers = FALSE)
stopifnot(length(getConfig("redirections")) >= 1)
retrieveData("ESM", rev = format(Sys.time(), "%Y-%m-%d"), scenario = scenario, progress = FALSE,
outputfolder = outputdir)
})

0 comments on commit c22704e

Please sign in to comment.