Skip to content

Commit

Permalink
increment version
Browse files Browse the repository at this point in the history
  • Loading branch information
fbenke-pik committed Mar 8, 2024
1 parent 5ebd6c3 commit e815803
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '224749174'
ValidationKey: '2248124229790'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ cff-version: 1.2.0
message: If you use this software, please cite it using the metadata from this file.
type: software
title: 'remind2: The REMIND R package (2nd generation)'
version: 1.135.9
date-released: '2024-03-04'
version: 1.135.9.9001
date-released: '2024-03-08'
abstract: Contains the REMIND-specific routines for data and model output manipulation.
authors:
- family-names: Rodrigues
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: remind2
Title: The REMIND R package (2nd generation)
Version: 1.135.9
Date: 2024-03-04
Version: 1.135.9.9001
Date: 2024-03-08
Authors@R: c(
person("Renato", "Rodrigues", , "[email protected]", role = c("aut", "cre")),
person("Lavinia", "Baumstark", role = "aut"),
Expand Down
3 changes: 2 additions & 1 deletion R/reportEmi.R
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ reportEmi <- function(gdx, output = NULL, regionSubsetList = NULL, t = c(seq(200
}

# Read-in plastic-related variables
v37_plasticsCarbon <- readGDX(gdx, "v37_plasticsCarbon", field = "l", restore_zeros = FALSE, react = "silent")[,t,]
v37_plasticsCarbon <- readGDX(gdx, "v37_plasticsCarbon", field = "l", temporal = 1, spatial = 2,
restore_zeros = FALSE, react = "silent")[,t,]
if (length(v37_plasticsCarbon) == 0) {
v37_plasticsCarbon <- NULL
}
Expand Down
135 changes: 135 additions & 0 deletions R/validateEfficiency.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# | (C) 2006-2023 Potsdam Institute for Climate Impact Research (PIK)
# | authors, and contributors see CITATION.cff file. This file is part
# | of REMIND and licensed under AGPL-3.0-or-later. Under Section 7 of
# | AGPL-3.0, you are granted additional permissions described in the
# | REMIND License Exception, version 1.0 (see LICENSE file).
# | Contact: [email protected]

library(magclass)
library(remind2)
library(lucode2)
library(gms)
library(methods)
library(edgeTransport)
library(quitte)
############################# BASIC CONFIGURATION #############################
gdx_name <- "fulldata.gdx" # name of the gdx
gdx_ref_name <- "input_ref.gdx" # name of the ref for < cm_startyear
gdx_refpolicycost_name <- "input_refpolicycost.gdx" # name of the reference gdx (for policy cost calculation)


if(!exists("source_include")) {
# Define arguments that can be read from command line
outputdir <- "."
readArgs("outputdir", "gdx_name", "gdx_ref_name", "gdx_refpolicycost_name")
}

gdx <- file.path(outputdir, gdx_name)
gdx_ref <- file.path(outputdir, gdx_ref_name)
gdx_refpolicycost <- file.path(outputdir, gdx_refpolicycost_name)
if (! file.exists(gdx_ref)) gdx_ref <- NULL
if (! file.exists(gdx_refpolicycost)) gdx_refpolicycost <- NULL
scenario <- getScenNames(outputdir)
###############################################################################
# paths of the reporting files
remind_reporting_file <- file.path(outputdir,paste0("REMIND_generic_", scenario,".mif"))
magicc_reporting_file <- file.path(outputdir,paste0("REMIND_climate_", scenario, ".mif"))
LCOE_reporting_file <- file.path(outputdir,paste0("REMIND_LCOE_", scenario, ".csv"))

remind_policy_reporting_file <- file.path(outputdir,paste0("REMIND_generic_",scenario,"_adjustedPolicyCosts.mif"))
remind_policy_reporting_file <- remind_policy_reporting_file[file.exists(remind_policy_reporting_file)]
if (length(remind_policy_reporting_file) > 0) {
unlink(remind_policy_reporting_file)
message("\n", paste(basename(remind_policy_reporting_file), collapse = ", "), " deleted.")
message(paste(basename(remind_reporting_file), collapse = ", "), " will contain policy costs based on input_refpolicycost.gdx.")
}

configfile <- file.path(outputdir, "config.Rdata")
envir <- new.env()
load(configfile, envir = envir)

# produce REMIND reporting *.mif based on gdx information
message("\n### start generation of mif files at ", Sys.time())
convGDX2MIF(gdx, gdx_refpolicycost = gdx_refpolicycost, file = remind_reporting_file,
scenario = scenario, gdx_ref = gdx_ref)

# MAGICC code not working with REMIND-EU
# generate MAGICC reporting and append to REMIND reporting
if (0 == nchar(Sys.getenv('MAGICC_BINARY'))) {
warning('Can\'t find magicc executable under environment variable MAGICC_BINARY')
} else {
message("Generate ", basename(magicc_reporting_file))
system(paste("cd ",outputdir ,"/magicc; ",
"pwd;",
"sed -f modify_MAGCFG_USER_CFG.sed -i MAGCFG_USER.CFG; ",
Sys.getenv('MAGICC_BINARY'), '; ',
"awk -f MAGICC_reporting.awk -v c_expname=\"", scenario, "\"",
" < climate_reporting_template.txt ",
" > ","../../../", magicc_reporting_file,"; ",
"sed -i 's/;glob;/;World;/g' ","../../../", magicc_reporting_file, "; ",
"cat ", "../../../",magicc_reporting_file, " >> ", "../../../",remind_reporting_file, "; ",
sep = ""))
}


## generate EDGE-T reporting if it is needed
## the reporting is appended to REMIND_generic_<scenario>.MIF
## REMIND_generic_<scenario>_withoutPlus.MIF is replaced.

edgetOutputDir <- file.path(outputdir, "EDGE-T")
if(file.exists(edgetOutputDir)) {
if (! file.exists(file.path(edgetOutputDir, "demandF_plot_pkm.RDS"))) {
message("EDGE-T reporting files are missing, probably because the run was killed.")
message("Rerunning toolIterativeEDGETransport(reporting = TRUE).")
savewd <- getwd()
setwd(outputdir)
edgeTransport::toolIterativeEDGETransport(reporting = TRUE)
setwd(savewd)
}
message("start generation of EDGE-T reporting")
EDGET_output <- toolReportEDGET(edgetOutputDir,
extendedReporting = FALSE,
scenario_title = scenario, model_name = "REMIND",
gdx = file.path(outputdir, "fulldata.gdx"))

write.mif(EDGET_output, remind_reporting_file, append = TRUE)
deletePlus(remind_reporting_file, writemif = TRUE)

message("end generation of EDGE-T reporting")
}

magpie_reporting_file <- envir$cfg$pathToMagpieReport
if (! is.null(magpie_reporting_file) && file.exists(magpie_reporting_file)) {
message("add MAgPIE reporting from ", magpie_reporting_file)
tmp_rem <- quitte::as.quitte(remind_reporting_file)
tmp_mag <- dplyr::filter(quitte::as.quitte(magpie_reporting_file), .data$period %in% unique(tmp_rem$period))
# remove population from magpie reporting to avoid duplication (units "million" vs. "million people")
sharedvariables <- intersect(tmp_mag$variable, tmp_rem$variable)
if (length(sharedvariables) > 0) {
message("The following variables will be dropped from MAgPIE reporting because they are in REMIND reporting: ", paste(sharedvariables, collapse = ", "))
tmp_mag <- dplyr::filter(tmp_mag, ! .data$variable %in% sharedvariables)
}
# harmonize scenario name from -mag-xx to -rem-xx
tmp_mag$scenario <- paste0(scenario)
tmp_rem_mag <- rbind(tmp_rem, tmp_mag)
quitte::write.mif(tmp_rem_mag, path = remind_reporting_file)
deletePlus(remind_reporting_file, writemif = TRUE)
}

message("### end generation of mif files at ", Sys.time())

## produce REMIND LCOE reporting *.csv based on gdx information
message("### start generation of LCOE reporting at ", Sys.time())
tmp <- try(convGDX2CSV_LCOE(gdx,file=LCOE_reporting_file,scen=scenario)) # execute convGDX2MIF_LCOE
message("### end generation of LCOE reporting at ", Sys.time())

## generate DIETER reporting if it is needed
## the reporting is appended to REMIND_generic_<scenario>.MIF in "DIETER" Sub Directory
DIETERGDX <- "report_DIETER.gdx"
if(file.exists(file.path(outputdir, DIETERGDX))){
message("start generation of DIETER reporting at ", Sys.time())
remind2::reportDIETER(DIETERGDX,outputdir)
message("end generation of DIETER reporting at ", Sys.time())
}

message("### reporting finished.")
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# The REMIND R package (2nd generation)

R package **remind2**, version **1.135.9**
R package **remind2**, version **1.135.9.9001**

[![CRAN status](https://www.r-pkg.org/badges/version/remind2)](https://cran.r-project.org/package=remind2) [![R build status](https://github.com/pik-piam/remind2/workflows/check/badge.svg)](https://github.com/pik-piam/remind2/actions) [![codecov](https://codecov.io/gh/pik-piam/remind2/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/remind2) [![r-universe](https://pik-piam.r-universe.dev/badges/remind2)](https://pik-piam.r-universe.dev/builds)

Expand Down Expand Up @@ -49,7 +49,7 @@ In case of questions / problems please contact Renato Rodrigues <renato.rodrigue

To cite package **remind2** in publications use:

Rodrigues R, Baumstark L, Benke F, Dietrich J, Dirnaichner A, Duerrwaechter J, Führlich P, Giannousakis A, Hasse R, Hilaire J, Klein D, Koch J, Kowalczyk K, Levesque A, Malik A, Merfort A, Merfort L, Morena-Leiva S, Pehl M, Pietzcker R, Rauner S, Richters O, Rottoli M, Schötz C, Schreyer F, Siala K, Sörgel B, Spahr M, Strefler J, Verpoort P, Weigmann P (2024). _remind2: The REMIND R package (2nd generation)_. R package version 1.135.9, <URL: https://github.com/pik-piam/remind2>.
Rodrigues R, Baumstark L, Benke F, Dietrich J, Dirnaichner A, Duerrwaechter J, Führlich P, Giannousakis A, Hasse R, Hilaire J, Klein D, Koch J, Kowalczyk K, Levesque A, Malik A, Merfort A, Merfort L, Morena-Leiva S, Pehl M, Pietzcker R, Rauner S, Richters O, Rottoli M, Schötz C, Schreyer F, Siala K, Sörgel B, Spahr M, Strefler J, Verpoort P, Weigmann P (2024). _remind2: The REMIND R package (2nd generation)_. R package version 1.135.9.9001, <https://github.com/pik-piam/remind2>.

A BibTeX entry for LaTeX users is

Expand All @@ -58,7 +58,7 @@ A BibTeX entry for LaTeX users is
title = {remind2: The REMIND R package (2nd generation)},
author = {Renato Rodrigues and Lavinia Baumstark and Falk Benke and Jan Philipp Dietrich and Alois Dirnaichner and Jakob Duerrwaechter and Pascal Führlich and Anastasis Giannousakis and Robin Hasse and Jérome Hilaire and David Klein and Johannes Koch and Katarzyna Kowalczyk and Antoine Levesque and Aman Malik and Anne Merfort and Leon Merfort and Simón Morena-Leiva and Michaja Pehl and Robert Pietzcker and Sebastian Rauner and Oliver Richters and Marianna Rottoli and Christof Schötz and Felix Schreyer and Kais Siala and Björn Sörgel and Mike Spahr and Jessica Strefler and Philipp Verpoort and Pascal Weigmann},
year = {2024},
note = {R package version 1.135.9},
note = {R package version 1.135.9.9001},
url = {https://github.com/pik-piam/remind2},
}
```
1 change: 0 additions & 1 deletion man/remind2-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e815803

Please sign in to comment.