Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Commit

Permalink
magclass 6 compatibility fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tscheypidi committed Sep 3, 2021
1 parent ff061da commit 9d44bfb
Show file tree
Hide file tree
Showing 81 changed files with 2,199 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '6827766519'
ValidationKey: '6829232796'
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 .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "remind: The REMIND R Package",
"version": "36.185.1",
"version": "36.185.2",
"description": "<p>Contains the REMIND-specific routines for data and model output manipulation.<\/p>",
"creators": [
{
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: remind
Type: Package
Title: The REMIND R Package
Version: 36.185.1
Date: 2021-08-30
Version: 36.185.2
Date: 2021-09-03
Authors@R: c(
person("Anastasis", "Giannousakis", email="giannou@pik-potsdam.de", role=c("aut","cre")),
person("Michaja", "Pehl", role=c("aut")))
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ importFrom(lusweave,swtable)
importFrom(madrat,calcOutput)
importFrom(madrat,toolGetMapping)
importFrom(madrat,toolNAreplace)
importFrom(magclass,"getItems<-")
importFrom(magclass,"getNames<-")
importFrom(magclass,"getRegions<-")
importFrom(magclass,"getSets<-")
Expand All @@ -184,6 +185,7 @@ importFrom(magclass,collapseNames)
importFrom(magclass,complete_magpie)
importFrom(magclass,dimReduce)
importFrom(magclass,dimSums)
importFrom(magclass,getItems)
importFrom(magclass,getNames)
importFrom(magclass,getRegions)
importFrom(magclass,getSets)
Expand Down
6 changes: 3 additions & 3 deletions R/calcFEprices.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ calcFEprices <- function(gdx) {
mbind(
q_febal.m[,,c("fepet", "fedie")] * vm_prodFe.l[,,c("fepet", "fedie")],
q_balfinen.m[,,"fehos"] * vm_prodFe.l[,,"fehos"])),
dims = 3
dim = 3
)
/ dimSums(vm_prodFe.l, dims = 3)
/ (abs(dimSums(qm_budget.m, dims = 3)) + 1e-10)
/ dimSums(vm_prodFe.l, dim = 3)
/ (abs(dimSums(qm_budget.m, dim = 3)) + 1e-10)
* 1000
/ TWa_2_EJ
) -> liquids.p
Expand Down
1 change: 1 addition & 0 deletions R/compareScenarios.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ compareScenarios <- function(mif, hist,
y_bar=c(2010,2030,2050,2100),
reg=NULL, mainReg="GLO", fileName="CompareScenarios.pdf",
sr15marker_RCP=NULL) {
unit <- NULL

lineplots_perCap <- function(data, vars, percap_factor, ylabstr,
global=FALSE, per_gdp=FALSE, histdata=NULL){
Expand Down
38 changes: 38 additions & 0 deletions R/dimSums.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#' dimSums
#'
#' Slightly modified version of the \code{dimSums} function of the magclass package.
#' It will expand magclass objects of length 0 by adding an element in the dimension
#' over which \code{dimSumsSpecial} is applied and set all values to 0 and it
#' will name the spatial dimension "GLO" if summation over this dimension happens.
#'
#' @param x A MAgPIE-object
#' @param dim The dimensions(s) to sum over. A vector of dimension codes or dimension names.
#' See \code{\link{dimCode}} for more information
#' @param na.rm logical. Should missing values (including NaN) be omitted from
#' the calculations?
#' @return A MAgPIE object with values summed over the specified dimensions
#' @importFrom magclass getItems<- getItems new.magpie
#' @author Jan Philipp Dietrich
dimSums <- function(x, dim = 3, na.rm = FALSE) { # nolint
if (is.null(x)) return(x)
if (length(x) == 0) {
elem <- list()
for (i in 1:3) {
if (dim(x)[i] == 0) elem[[i]] <- "dummy"
else elem[[i]] <- getItems(x, dim = i)
}
out <- new.magpie(elem[[1]], elem[[2]], elem[[3]], fill = 0)
if (dim(x)[1] == 0) getItems(out, dim = 1) <- "GLO"
if (dim(x)[2] == 0) getItems(out, dim = 2) <- NULL
if (dim(x)[3] == 0) getItems(out, dim = 3) <- NULL
return(out)
}
out <- magclass::dimSums(x, dim = dim, na.rm = na.rm)
if (1 %in% dim) getItems(out, dim = 1) <- "GLO"
return(out)
}

"getRegions<-" <- function(x, value) { #nolint
getItems(x, dim = 1) <- value
return(x)
}
1 change: 1 addition & 0 deletions R/plotLCOE.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

plotLCOE <- function(LCOEfile, gdx, y=c(2015,2020,2030,2040,2050,2060),reg="all_regi",fileName="LCOE_plots.pdf") {

unit <- NULL

df.LCOE.in <- read.csv(LCOEfile, sep = ";")

Expand Down
1 change: 0 additions & 1 deletion R/readSupplycurveBio.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#' @importFrom magclass mbind collapseNames add_dimension getSets
#' @importFrom remulator calc_supplycurve
#' @author David Klein
#' @seealso \code{\link[remulator]{emulator}} \code{\link{calc_supplycurve}}
#' @export

readSupplycurveBio <- function(outputdirs, userfun = function(param,x) {return(param[[1]] + param[[2]] * x)}, mult_on = "all") {
Expand Down
3 changes: 2 additions & 1 deletion R/reportEDGETransport.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

reportEDGETransport <- function(output_folder=".",
remind_root=NULL) {

unit <- NULL

if(is.null(remind_root)){
remind_root <- file.path(output_folder, "../..")
}
Expand Down
2 changes: 2 additions & 0 deletions R/reportLCOE.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

reportLCOE <- function(gdx, output.type = "both"){

unit <- NULL

# test whether output.type defined
if (!output.type %in% c("marginal", "average", "both", "marginal detail")) {
print("Unknown output type. Please choose either marginal, average, both or marginal detail.")
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# The REMIND R Package

R package **remind**, version **36.185.1**
R package **remind**, version **36.185.2**

[![CRAN status](https://www.r-pkg.org/badges/version/remind)](https://cran.r-project.org/package=remind)
[![CRAN status](https://www.r-pkg.org/badges/version/remind)](https://cran.r-project.org/package=remind) [![r-universe](https://pik-piam.r-universe.dev/badges/remind)](https://pik-piam.r-universe.dev/ui#builds)

## Purpose and Functionality

Expand Down Expand Up @@ -46,7 +46,7 @@ In case of questions / problems please contact Anastasis Giannousakis <giannou@p

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

Giannousakis A, Pehl M (2021). _remind: The REMIND R Package_. R package version 36.185.1.
Giannousakis A, Pehl M (2021). _remind: The REMIND R Package_. R package version 36.185.2.

A BibTeX entry for LaTeX users is

Expand All @@ -55,7 +55,7 @@ A BibTeX entry for LaTeX users is
title = {remind: The REMIND R Package},
author = {Anastasis Giannousakis and Michaja Pehl},
year = {2021},
note = {R package version 36.185.1},
note = {R package version 36.185.2},
}
```

1 change: 0 additions & 1 deletion man/.gitignore

This file was deleted.

24 changes: 24 additions & 0 deletions man/calcFEprices.Rd

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

32 changes: 32 additions & 0 deletions man/calcKayaDecomp.Rd

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

36 changes: 36 additions & 0 deletions man/calcNetTrade.Rd

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

36 changes: 36 additions & 0 deletions man/calcNetTradeValue.Rd

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

38 changes: 38 additions & 0 deletions man/calcPrice.Rd

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

30 changes: 30 additions & 0 deletions man/calc_CES_marginals.Rd

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

26 changes: 26 additions & 0 deletions man/calc_regionSubset_sums.Rd

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

Loading

0 comments on commit 9d44bfb

Please sign in to comment.