Skip to content

Commit

Permalink
Refactor fullRemind in line with new gdp and pop GAMS sets
Browse files Browse the repository at this point in the history
Add SSP2IndiaDEA scenarios to mrdriver calls in fullREMIND and remove SSP2EU scenario.
Move readIEA_WEIO_2014 to mrindustry, fixes #624.
Add scenario specification for all calcGDP, calcGDPpc and calcPopulation calls, in anticipation of mrdrivers changes.
Clean up NAMESPACE file by removing importFrom statements and adding :: calls for select functions.
  • Loading branch information
johanneskoch94 committed Feb 3, 2025
1 parent 0ddd1d4 commit 5d2a29c
Show file tree
Hide file tree
Showing 107 changed files with 908 additions and 1,275 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '43050380'
ValidationKey: '430792199830'
AcceptedWarnings:
- Invalid URL: .*
- 'Warning: package ''.*'' was built under R version'
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: 'mrremind: MadRat REMIND Input Data Package'
version: 0.214.0
date-released: '2025-01-29'
version: 0.214.0.9015
date-released: '2025-02-03'
abstract: The mrremind packages contains data preprocessing for the REMIND model.
authors:
- family-names: Baumstark
Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: mrremind
Title: MadRat REMIND Input Data Package
Version: 0.214.0
Date: 2025-01-29
Version: 0.214.0.9015
Date: 2025-02-03
Authors@R: c(
person("Lavinia", "Baumstark", , "lavinia@pik-potsdam.de", role = c("aut", "cre")),
person("Renato", "Rodrigues", role = "aut"),
Expand Down Expand Up @@ -40,7 +40,6 @@ URL: https://github.com/pik-piam/mrremind
Depends:
R (>= 2.10.0)
Imports:
assertr,
countrycode,
data.table,
dplyr,
Expand All @@ -53,6 +52,7 @@ Imports:
magrittr,
mrcommons (>= 1.44.12),
mrdrivers (>= 6.0.0),
mrfaocore,
mrindustry (>= 0.4.0),
nnls,
purrr,
Expand Down
77 changes: 2 additions & 75 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export(calcIEA_ETP)
export(calcIEA_EVOutlook)
export(calcIEA_WorldEnergyOutlook)
export(calcIRENA)
export(calcMacroInvestments)
export(calcOtherFossilInElectricity)
export(calcPlasticsEoL)
export(calcProjectPipelines)
Expand All @@ -32,6 +33,7 @@ export(convertIEA_CCUS)
export(convertIEA_ETP)
export(convertUBA)
export(convertUNFCCC)
export(fullREMIND)
export(fullTHRESHOLDS)
export(readAGEB)
export(readAR6GWP)
Expand All @@ -43,7 +45,6 @@ export(readHRE)
export(readIAEA_PRIS)
export(readIEA_CCUS)
export(readIEA_HSMR)
export(readIEA_WEIO_2014)
export(readUBA)
export(readUNFCCC)
export(toolAggregateTimeSteps)
Expand All @@ -54,105 +55,31 @@ export(toolFillEU34Countries)
export(toolSolarFunctionAggregate)
import(madrat)
import(magclass)
importFrom(assertr,verify)
importFrom(data.table,":=")
importFrom(data.table,data.table)
importFrom(data.table,rbindlist)
importFrom(data.table,setDT)
importFrom(data.table,setkeyv)
importFrom(data.table,setnames)
importFrom(dplyr,"%>%")
importFrom(dplyr,across)
importFrom(dplyr,all_of)
importFrom(dplyr,anti_join)
importFrom(dplyr,arrange)
importFrom(dplyr,bind_cols)
importFrom(dplyr,bind_rows)
importFrom(dplyr,desc)
importFrom(dplyr,distinct)
importFrom(dplyr,everything)
importFrom(dplyr,filter)
importFrom(dplyr,full_join)
importFrom(dplyr,group_by)
importFrom(dplyr,if_any)
importFrom(dplyr,lag)
importFrom(dplyr,left_join)
importFrom(dplyr,matches)
importFrom(dplyr,min_rank)
importFrom(dplyr,mutate)
importFrom(dplyr,n)
importFrom(dplyr,pull)
importFrom(dplyr,recode)
importFrom(dplyr,relocate)
importFrom(dplyr,rename)
importFrom(dplyr,rename_all)
importFrom(dplyr,select)
importFrom(dplyr,starts_with)
importFrom(dplyr,summarise)
importFrom(dplyr,summarize)
importFrom(dplyr,tribble)
importFrom(dplyr,ungroup)
importFrom(madrat,calcOutput)
importFrom(madrat,madratAttach)
importFrom(madrat,readSource)
importFrom(madrat,toolAggregate)
importFrom(madrat,toolGetMapping)
importFrom(magclass,"getItems<-")
importFrom(magclass,collapseDim)
importFrom(magclass,dimSums)
importFrom(magclass,getItems)
importFrom(magclass,matchDim)
importFrom(magclass,mbind)
importFrom(magclass,mselect)
importFrom(magclass,time_interpolate)
importFrom(magrittr,"%>%")
importFrom(quitte,add_countrycode_)
importFrom(quitte,as.quitte)
importFrom(quitte,calc_addVariable)
importFrom(quitte,cartesian)
importFrom(quitte,inline.data.frame)
importFrom(quitte,interpolate_missing_periods)
importFrom(quitte,madrat_mule)
importFrom(quitte,removeColNa)
importFrom(readr,read_csv)
importFrom(readxl,excel_sheets)
importFrom(readxl,read_excel)
importFrom(readxl,read_xlsx)
importFrom(rlang,"!!!")
importFrom(rlang,"!!")
importFrom(rlang,.data)
importFrom(rlang,is_empty)
importFrom(rlang,sym)
importFrom(rlang,syms)
importFrom(stats,aggregate)
importFrom(stats,coef)
importFrom(stats,complete.cases)
importFrom(stats,lm)
importFrom(stats,na.exclude)
importFrom(stats,na.omit)
importFrom(stats,na.pass)
importFrom(stats,weighted.mean)
importFrom(tibble,as_tibble)
importFrom(tibble,tibble)
importFrom(tidyr,complete)
importFrom(tidyr,drop_na)
importFrom(tidyr,expand_grid)
importFrom(tidyr,extract)
importFrom(tidyr,gather)
importFrom(tidyr,nest)
importFrom(tidyr,nesting)
importFrom(tidyr,pivot_longer)
importFrom(tidyr,pivot_wider)
importFrom(tidyr,separate)
importFrom(tidyr,spread)
importFrom(tidyr,unite)
importFrom(tidyr,unnest)
importFrom(tidyselect,all_of)
importFrom(utils,download.file)
importFrom(utils,head)
importFrom(utils,packageVersion)
importFrom(utils,read.csv)
importFrom(utils,read.csv2)
importFrom(utils,read.table)
importFrom(utils,tail)
importFrom(utils,unzip)
3 changes: 1 addition & 2 deletions R/calcAGEB.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#' @param subtype data subtype. Either "balances" ("Auswertungstabellen zur Energiebilanz Deutschland") or
#' "electricity" ("Bruttostromerzeugung in Deutschland nach Energieträgern")
#' @importFrom dplyr select mutate left_join
#' @importFrom stats aggregate
#' @export
calcAGEB <- function(subtype = "balances") {
ageb <- readSource("AGEB", subtype = subtype)
Expand Down Expand Up @@ -36,7 +35,7 @@ calcAGEB <- function(subtype = "balances") {
) %>%
select("variable" = "REMIND_variable", "region", "year", "value")

x <- aggregate(value ~ variable + region + year, x, sum) %>%
x <- stats::aggregate(value ~ variable + region + year, x, sum) %>%
as.magpie() %>%
toolCountryFill(fill = NA, verbosity = 2)

Expand Down
4 changes: 1 addition & 3 deletions R/calcBP.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#' Calculate REMIND variables from historical BP values
#'
#' @author Falk Benke
#' @importFrom magclass matchDim
#' @importFrom quitte interpolate_missing_periods
#'
#' @export
#'
Expand Down Expand Up @@ -36,7 +34,7 @@ calcBP <- function() {
data.frame(period = 2050, value = 0.45)
)

efficiencyFactors <- interpolate_missing_periods(efficiencyFactors, method = "linear") %>%
efficiencyFactors <- quitte::interpolate_missing_periods(efficiencyFactors, method = "linear") %>%
as.magpie() %>%
dimReduce()

Expand Down
12 changes: 6 additions & 6 deletions R/calcBiomassPrices.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ calcBiomassPrices <- function() {
x <- readSource("MAgPIE", subtype = "supplyCurve_magpie_40")

# add supply curves for SDP-MC-SSP1-PkBudg1000 copying SDP-MC-SSP1-PkBudg650
tmp <- x[, , "SDP-MC-SSP1-PkBudg650"]
tmp <- x[, , "SDP-MC-SSP1-PkBudg650"]
getNames(tmp) <- gsub("SDP-MC-SSP1-PkBudg650", "SDP-MC-SSP1-PkBudg1000", getNames(tmp))
x <- mbind(x, tmp)

Expand Down Expand Up @@ -37,9 +37,9 @@ calcBiomassPrices <- function() {
x[, , "a"][is.na(x[, , "a"])] <- 1
x[, , "b"][is.na(x[, , "b"])] <- 0.1

return(list(x = x,
weight = calcOutput("FAOLand", aggregate = FALSE)[, , "6610", pmatch = TRUE][, "y2010", ],
unit = "none",
description = "coefficients for the bioenergy supplycurve",
aggregationFunction = toolBiomassSupplyAggregate))
list(x = x,
weight = calcOutput("FAOLand", aggregate = FALSE)[, , "6610", pmatch = TRUE][, "y2010", ],
unit = "none",
description = "coefficients for the bioenergy supplycurve",
aggregationFunction = toolBiomassSupplyAggregate)
}
5 changes: 2 additions & 3 deletions R/calcCapacity.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#'
#' @param subtype data subtype. Either "capacityByTech" or "capacityByPE"
#' @return magpie object of capacity data
#' @importFrom dplyr tribble
#' @author Renato Rodrigues, Stephen Bi
#' @examples
#' \dontrun{
Expand Down Expand Up @@ -90,7 +89,7 @@ calcCapacity <- function(subtype) {
# *** for 2018-2022, take 90GW, 90GW*0.5=50GW ngt, the rest is split between ngcc and gaschp 70:30 (from IEA EB energy output)

CHA.2020.GasData <- as.magpie(
tribble(
tibble::tribble(
~region, ~year, ~data, ~value,
"CHN", 2010, "gaschp", 0.004,
"CHN", 2015, "gaschp", 0.011,
Expand All @@ -107,7 +106,7 @@ calcCapacity <- function(subtype) {
# so it should be roughly ok as upper bound. (don't use as lower bound!)

USA.2025.PVData <- as.magpie(
tribble(
tibble::tribble(
~region, ~year, ~data, ~value,
"USA", 2025, "spv", 0.265))

Expand Down
Loading

0 comments on commit 5d2a29c

Please sign in to comment.