Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pik-piam/remind2 into Car…
Browse files Browse the repository at this point in the history
…bonStorageDetail
  • Loading branch information
tabeado committed Jan 31, 2024
1 parent b42c2ff commit f06b1a6
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 111 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '223338570'
ValidationKey: '223160847'
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
- 'Warning: namespace ''.*'' is not available and has been replaced'
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
- id: mixed-line-ending

- repo: https://github.com/lorenzwalthert/precommit
rev: v0.3.2.9025
rev: v0.3.2.9027
hooks:
- id: parsable-R
- id: deps-in-desc
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ 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.131.0
version: 1.130.1
date-released: '2024-01-25'
abstract: Contains the REMIND-specific routines for data and model output manipulation.
authors:
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: remind2
Title: The REMIND R package (2nd generation)
Version: 1.131.0
Version: 1.130.1
Date: 2024-01-25
Authors@R: c(
person("Renato", "Rodrigues", , "[email protected]", role = c("aut", "cre")),
Expand Down Expand Up @@ -89,6 +89,6 @@ Suggests:
VignetteBuilder:
knitr
Encoding: UTF-8
RoxygenNote: 7.3.0
RoxygenNote: 7.3.1
Config/testthat/parallel: true
Config/testthat/edition: 3
44 changes: 26 additions & 18 deletions R/loadModeltest.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#' @importFrom utils globalVariables
globalVariables(".")
globalVariables(".") # nolint


getProjectPath <- function(project = "remind") {
possibleProjectLocations <- file.path(c("//clusterfs.pik-potsdam.de", "/p/projects"), project)
possibleProjectLocations <- file.path(c("//clusterfs.pik-potsdam.de", "/p/projects"), project) # nolint
sel <- which(file.exists(possibleProjectLocations))[1]
if (is.na(sel)) stop("Cannot determine a path to projects on the cluster.")
possibleProjectLocations[sel]
Expand All @@ -13,14 +13,15 @@ getProjectPath <- function(project = "remind") {
#' @importFrom dplyr bind_cols
getNewsestModeltests <- function(namePattern, requireMif) {

modeltestOutPath <- file.path(getProjectPath(), "modeltests/output")
modeltestOutPath <- file.path(getProjectPath(), "modeltests", "remind", "output")
entries <- dir(modeltestOutPath)
allRunNames <-
entries %>%
grep(
x = .,
pattern = "^[a-zA-Z0-9-]+_\\d{4}-\\d{2}-\\d{2}_\\d{2}\\.\\d{2}\\.\\d{2}$",
value = TRUE)
value = TRUE
)
allRuns <-
allRunNames %>%
strsplit("_", fixed = TRUE) %>%
Expand All @@ -31,6 +32,8 @@ getNewsestModeltests <- function(namePattern, requireMif) {
bind_cols(runName = allRunNames) %>%
mutate(date = as.Date(.data$date)) %>%
mutate(path = file.path(.env$modeltestOutPath, .data$runName)) %>%
filter(date >= max(.data$date) - 180) %>% # limit to half a year
filter(file.exists(file.path(.data$path, "config.Rdata"))) %>%
mutate(mifScen = getMifScenPath(.data$path))
selectedRuns <-
allRuns %>%
Expand All @@ -57,11 +60,11 @@ getNewsestModeltests <- function(namePattern, requireMif) {
#' }
#' @export
loadCs2Data <- function(
mifScen,
mifHist,
cfgScen = NULL,
cfgDefault = NULL,
envir = globalenv()
mifScen,
mifHist,
cfgScen = NULL,
cfgDefault = NULL,
envir = globalenv()
) {

folder <- tempdir()
Expand All @@ -76,7 +79,8 @@ loadCs2Data <- function(
outputFile = outputFile,
sections = NULL,
envir = envir,
quiet = TRUE)
quiet = TRUE
)
file.remove(file.path(folder, paste0(outputFile, ".pdf")))
return(invisible(NULL))
}
Expand Down Expand Up @@ -112,15 +116,15 @@ cs2InputPaths <- function(outputDirs) {
#' ssp1 <- new.env()
#' ssp2eu <- new.env()
#' loadModeltest(ssp1, "^SSP1-AMT-")
#' loadModeltest(ssp2eu, "^SSP2EU-AMT-")
#' loadModeltest(ssp2eu, "^SSP2EU-.*-AMT$")
#' ssp1$data
#' ssp2eu$data
#' }
#' @export
loadModeltest <- function(
envir = globalenv(),
namePattern = "^SSP2EU-AMT-",
folder = tempdir()
envir = globalenv(),
namePattern = "^SSP2EU-.*-AMT$",
folder = tempdir()
) {

stopifnot(is.environment(envir))
Expand All @@ -143,7 +147,8 @@ loadModeltest <- function(
mifScen = file.path(folder, paste0(modeltests$name, ".mif")),
mifHist = file.path(folder, "historical.mif"),
cfgScen = file.path(folder, paste0(modeltests$name, ".Rdata")),
cfgDefault = file.path(folder, "default.cfg"))
cfgDefault = file.path(folder, "default.cfg")
)

copyFile <- function(from, to) {
cat("Copying\n ", paste(from, collapse = "\n "),
Expand All @@ -155,7 +160,8 @@ loadModeltest <- function(
warning(
"failed copying following files\n",
paste(from[!success], collapse = "\n"),
immediate. = TRUE)
immediate. = TRUE
)
}

copyFile(path$mifScen, tmpPath$mifScen)
Expand All @@ -169,14 +175,16 @@ loadModeltest <- function(
"user specified environment"
else
environmentName(envir),
".\n", sep = "")
".\n", sep = ""
)

loadCs2Data(
mifScen = tmpPath$mifScen,
mifHist = tmpPath$mifHist,
cfgScen = tmpPath$cfgScen,
cfgDefault = tmpPath$cfgDefault,
envir = envir)
envir = envir
)

cat("Done.\n")

Expand Down
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.131.0**
R package **remind2**, version **1.130.1**

[![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.131.0, <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.130.1, <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.131.0},
note = {R package version 1.130.1},
url = {https://github.com/pik-piam/remind2},
}
```
Loading

0 comments on commit f06b1a6

Please sign in to comment.