diff --git a/CHANGELOG.md b/CHANGELOG.md index 51efe188b..76dee2104 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - ### removed -- +- **scripts** Drop the `gdxrrw`/`gdx` R dependency from REMIND scripts; GDX writes now use `gamstransfer`-based `quitte::write.gdx` + [[#2485](https://github.com/remindmodel/remind/pull/2485)] ### fixed - **scripts** Fix call to harmonization and infilling console entry point in `climateAssessmentInterimRun.R` diff --git a/DESCRIPTION b/DESCRIPTION index d62671fbd..d261ca6c1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -24,7 +24,6 @@ Imports: GDPuc, gdx2, gdxdt, - gdxrrw, ggplot2, glue, gms (>= 0.33.4), diff --git a/README.md b/README.md index 44b84c432..4f119faac 100644 --- a/README.md +++ b/README.md @@ -94,8 +94,8 @@ so! Model dependencies **must be publicly available** and should be Open Source. Development aim is to rather minimize than expand dependencies on non-free and/or non open source software. That means that besides currently existing -dependencies on GAMS, the `gdxrrw` R package and the corresponding solvers there -should be no additional dependencies of this kind and that these existing +dependencies on GAMS and the corresponding solvers there should be no +additional dependencies of this kind and that these existing dependencies should be resolved in the future if possible. If a new R package is added as dependency this package should fulfill the diff --git a/scripts/input/climateAssessmentImpulseResponse.R b/scripts/input/climateAssessmentImpulseResponse.R index 37a37b8aa..43acdff79 100644 --- a/scripts/input/climateAssessmentImpulseResponse.R +++ b/scripts/input/climateAssessmentImpulseResponse.R @@ -6,7 +6,6 @@ # | Contact: remind@pik-potsdam.de # !/bin/bash library(dplyr) -require(gdxrrw) # Needs an environmental variable to be set, see below library(lucode2) library(magrittr) library(piamInterfaces) @@ -234,18 +233,15 @@ oupt <- oupt %>% runTimes <- c(runTimes, "postprocessing end" = Sys.time()) runTimes <- c(runTimes, "write_gdx start" = Sys.time()) -writeToGdx <- function(file = "pm_magicc_temperatureImpulseResponse", df) { - df$tall <- factor(df$tall) - df$tall1 <- factor(df$tall1) - attr(df, which = "symName") <- "pm_temperatureImpulseResponse" - attr(df, which = "domains") <- c("tall", "tall") - attr(df, which = "domInfo") <- "full" - - wgdx.lst(file, df, squeeze = FALSE) -} - -# write to GDX: -writeToGdx("pm_magicc_temperatureImpulseResponse", oupt) +# write to GDX +oupt %>% + rename(value = tirf) %>% + mutate(variable = "pm_temperatureImpulseResponse") %>% + write.gdx( + "pm_magicc_temperatureImpulseResponse.gdx", + varmap = c("pm_temperatureImpulseResponse" = "pm_temperatureImpulseResponse"), + dimCols = c("tall", "tall1") + ) cat(date(), "climateAssessmentImpulseResponse.R: Wrote results to 'pm_magicc_temperatureImpulseResponse.gdx'\n") runTimes <- c(runTimes, "write_gdx end" = Sys.time()) diff --git a/scripts/input/climateAssessmentInterimRun.R b/scripts/input/climateAssessmentInterimRun.R index 4c7a95824..4a5bc8b1c 100644 --- a/scripts/input/climateAssessmentInterimRun.R +++ b/scripts/input/climateAssessmentInterimRun.R @@ -6,7 +6,6 @@ # | Contact: remind@pik-potsdam.de # !/bin/bash library(dplyr) -require(gdxrrw) # Needs an environmental variable to be set, see below library(lucode2) library(magrittr) library(piamInterfaces) diff --git a/scripts/input/run_KotzWenz_damages.R b/scripts/input/run_KotzWenz_damages.R index 038920fe7..1562f15c0 100644 --- a/scripts/input/run_KotzWenz_damages.R +++ b/scripts/input/run_KotzWenz_damages.R @@ -8,9 +8,7 @@ # FP print("Calculating damages and marginal damages for SCC ") require(dplyr) -require(gdxrrw) require(quitte) -igdx(system("dirname $( which gams )", intern = TRUE)) beta1 <- read.csv("../../modules/50_damages/KotzWenz/input/f50_KLW_df_beta1.cs4r",skip=4,header=FALSE) %>% rename(iso=V1,realization=V2,value=V3) beta2 <- read.csv("../../modules/50_damages/KotzWenz/input/f50_KLW_df_beta2.cs4r",skip=4,header=FALSE) %>% rename(iso=V1,realization=V2,value=V3) @@ -56,23 +54,18 @@ for(i in countries){ alldam_marg <- rbind(alldam_marg,rename(select(dam_q,c("iso","period","low_marg","med_marg","mean_marg","high_marg")),tall=period)) } -writeToGdx = function(file,df,name){ - df$tall = factor(df$tall) - df$iso = factor(df$iso) - df$percentile = factor(df$percentile) - attr(df,which = 'symName') = name - attr(df,which = 'domains') = c('tall','iso','percentile') - attr(df,which = 'domInfo') = 'full' - - wgdx.lst(file,df,squeeze = F) -} - alldam <- reshape2::melt(alldam,id.vars=c("tall","iso")) %>% rename(percentile=variable) alldam_marg <- reshape2::melt(rename(alldam_marg,low=low_marg,med=med_marg,mean=mean_marg,high=high_marg),id.vars=c("tall","iso")) %>% rename(percentile=variable) -# write to GDX: -writeToGdx('pm_KotzWenz_damageIso',alldam,'pm_damageIso') -writeToGdx('pm_KotzWenz_damageMarginalIso',alldam_marg,'pm_damageMarginalIso') +# write to GDX +alldam %>% + mutate(variable = "pm_damageIso") %>% + write.gdx("pm_KotzWenz_damageIso.gdx", + varmap = c(pm_damageIso = "pm_damageIso"), dimCols = c("tall", "iso", "percentile")) +alldam_marg %>% + mutate(variable = "pm_damageMarginalIso") %>% + write.gdx("pm_KotzWenz_damageMarginalIso.gdx", + varmap = c(pm_damageMarginalIso = "pm_damageMarginalIso"), dimCols = c("tall", "iso", "percentile")) print("...done.") diff --git a/scripts/output/comparison/checkClimatePercentiles.R b/scripts/output/comparison/checkClimatePercentiles.R index b60cf104e..929dcd875 100644 --- a/scripts/output/comparison/checkClimatePercentiles.R +++ b/scripts/output/comparison/checkClimatePercentiles.R @@ -19,7 +19,6 @@ # require(tidyverse) require(quitte) -require(gdx) require(yaml) cat("===================== STARTING checkClimatePercentiles.R", "\n") diff --git a/scripts/start/prepare.R b/scripts/start/prepare.R index 320407059..d913e35c6 100644 --- a/scripts/start/prepare.R +++ b/scripts/start/prepare.R @@ -52,7 +52,7 @@ prepare <- function() { # list all packages of interest alphabetically here tribble( ~Package, "data.table", "devtools", "dplyr", "edgeTransport", - "flexdashboard", "gdx2", "gdxdt", "gdxrrw", "ggplot2", "gtools", + "flexdashboard", "gdx2", "gdxdt", "ggplot2", "gtools", "lucode2", "luplot", "luscale", "magclass", "magpie4", "methods", "mip", "mrtransport", "optparse", "parallel", "plotly", "remind2", "reporttransport", "reticulate", "rlang", diff --git a/scripts/start/prepareAndRun.R b/scripts/start/prepareAndRun.R index 16a48c1cd..d42a1c449 100644 --- a/scripts/start/prepareAndRun.R +++ b/scripts/start/prepareAndRun.R @@ -8,7 +8,6 @@ library(gms, quietly = TRUE,warn.conflicts =FALSE) library(lucode2, quietly = TRUE,warn.conflicts =FALSE) library(dplyr, quietly = TRUE,warn.conflicts =FALSE) library(yaml, quietly = TRUE,warn.conflicts=FALSE) -require(gdx) # Call prepare() and run() without cfg, because cfg is read from results folder, where it has been