Skip to content

Commit

Permalink
replace unit conversion functions with madrat tool wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
fbenke-pik committed Oct 11, 2024
1 parent bde9e5b commit e956d0c
Show file tree
Hide file tree
Showing 25 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '38731616'
ValidationKey: '38753559'
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: 'mrremind: MadRat REMIND Input Data Package'
version: 0.193.6
date-released: '2024-10-10'
version: 0.193.7
date-released: '2024-10-11'
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.193.6
Date: 2024-10-10
Version: 0.193.7
Date: 2024-10-11
Authors@R: c(
person("Lavinia", "Baumstark", , "lavinia@pik-potsdam.de", role = c("aut", "cre")),
person("Renato", "Rodrigues", role = "aut"),
Expand Down Expand Up @@ -52,7 +52,7 @@ Imports:
data.table,
dplyr,
ggplot2,
GDPuc (>= 1.1.0),
GDPuc (>= 1.3.0),
Hmisc,
luscale,
magrittr,
Expand Down
2 changes: 1 addition & 1 deletion R/EDGE-Industry.R
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ calcSteel_Projections <- function(subtype = 'production',
convert = FALSE) %>%
as_tibble() %>%
select('iso3c' = 'ISO3', 'year' = 'Year', 'value') %>%
convertGDP(unit_in = 'constant 2005 US$MER',
GDPuc::toolConvertGDP(unit_in = 'constant 2005 US$MER',
unit_out = mrdrivers::toolGetUnitDollar(),
replace_NAs = 'with_USA') %>%
rename(GDPpC = 'value') %>%
Expand Down
2 changes: 1 addition & 1 deletion R/UNIDO.R
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ convertUNIDO <- function(x, subtype = 'INDSTAT2')
) %>%
# GDP conversion is only valid for monetary units
verify('$' == .data$unit) %>%
convertGDP(unit_in = 'constant 2005 US$MER',
GDPuc::toolConvertGDP(unit_in = 'constant 2005 US$MER',
unit_out = mrdrivers::toolGetUnitDollar(),
replace_NAs = 'with_USA') %>%
group_by(.data$iso3c, .data$subsector, .data$year) %>%
Expand Down
6 changes: 3 additions & 3 deletions R/calcBP.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ calcBP <- function() {

# convert price units ----

# should be from US$2023, but 'convertGDP' currently returns NA
poil <- GDPuc::convertGDP(
# should be from US$2023, but 'toolConvertGDP' currently returns NA
poil <- GDPuc::toolConvertGDP(
gdp = x[, , "Price|Primary Energy|Oil (US$2023/GJ)"],
unit_in = "constant 2022 US$MER",
unit_out = mrdrivers::toolGetUnitDollar(),
Expand All @@ -152,7 +152,7 @@ calcBP <- function() {
getNames(poil) <- gsub("\\$2023", "\\$2017", getNames(poil))

# assume these units are in current MER
pcoalgas <- GDPuc::convertGDP(
pcoalgas <- GDPuc::toolConvertGDP(
gdp = x[, , c("Price|Primary Energy|Gas (US$/GJ)", "Price|Primary Energy|Coal (US$/GJ)")],
unit_in = "current US$MER",
unit_out = mrdrivers::toolGetUnitDollar(),
Expand Down
2 changes: 1 addition & 1 deletion R/calcBiomassPrices.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ calcBiomassPrices <- function() {

# apply conversion from US$2005 to US$2017 to "a" and "b", so that the price
# calculated with these coefficients will be in US$2017
x <- GDPuc::convertGDP(
x <- GDPuc::toolConvertGDP(
gdp = x,
unit_in = "constant 2005 US$MER",
unit_out = mrdrivers::toolGetUnitDollar(),
Expand Down
2 changes: 1 addition & 1 deletion R/calcCO2Prices.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ calcCO2Prices <- function() {

# convert from $2005 to $2017

x <- GDPuc::convertGDP(
x <- GDPuc::toolConvertGDP(
gdp = x,
unit_in = "constant 2005 US$MER",
unit_out = mrdrivers::toolGetUnitDollar(),
Expand Down
2 changes: 1 addition & 1 deletion R/calcCostsTradePeFinancial.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
calcCostsTradePeFinancial <- function() {
data <- readSource("ExpertGuess", subtype = "costsTradePeFinancial")

data <- GDPuc::convertGDP(
data <- GDPuc::toolConvertGDP(
gdp = data,
unit_in = "constant 2005 US$MER",
unit_out = mrdrivers::toolGetUnitDollar(),
Expand Down
2 changes: 1 addition & 1 deletion R/calcCostsWeathering.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ calcCostsWeathering <- function() {

# convert from $2005 to $2017

x <- GDPuc::convertGDP(
x <- GDPuc::toolConvertGDP(
gdp = costs,
unit_in = "constant 2005 US$MER",
unit_out = mrdrivers::toolGetUnitDollar(),
Expand Down
2 changes: 1 addition & 1 deletion R/calcDiffInvestCosts.R
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ calcDiffInvestCosts <- function(subtype) {

# convert data from $2015 to $2017

x_new <- GDPuc::convertGDP(
x_new <- GDPuc::toolConvertGDP(
gdp = x_new,
unit_in = "constant 2015 US$MER",
unit_out = mrdrivers::toolGetUnitDollar(),
Expand Down
4 changes: 2 additions & 2 deletions R/calcEU_ReferenceScenario.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ calcEU_ReferenceScenario <- function() {
euRef2016 <- readSource("EU_ReferenceScenario", subtype = "2016")

# convert EUR2013 -> US$2017
tmp <- GDPuc::convertGDP(
tmp <- GDPuc::toolConvertGDP(
gdp = euRef2016[, , "Price|Secondary Energy|Electricity (EUR2013/GJ)"],
unit_in = "constant 2013 EUR",
unit_out = mrdrivers::toolGetUnitDollar(),
Expand All @@ -19,7 +19,7 @@ calcEU_ReferenceScenario <- function() {
euRef2020 <- readSource("EU_ReferenceScenario", subtype = "2020")

# convert EUR2015 -> US$2017
tmp <- GDPuc::convertGDP(
tmp <- GDPuc::toolConvertGDP(
gdp = euRef2020[, , "Price|Secondary Energy|Electricity (EUR2015/GJ)"],
unit_in = "constant 2015 EUR",
unit_out = mrdrivers::toolGetUnitDollar(),
Expand Down
2 changes: 1 addition & 1 deletion R/calcEconometricEmiParameter.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ calcEconometricEmiParameter <- function() {

# convert data from $2005 to $2017

p4 <- GDPuc::convertGDP(
p4 <- GDPuc::toolConvertGDP(
gdp = p4,
unit_in = "constant 2005 US$MER",
unit_out = mrdrivers::toolGetUnitDollar(),
Expand Down
2 changes: 1 addition & 1 deletion R/calcFossilExtraction.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ calcFossilExtraction <- function(subtype = "FossilExtraction") {
# (1.58 is lowest price in gas extraction data after 2015)
DIIS <- data.frame(
Res = 23000,
Price = GDPuc::convertSingle(x = 1.5, iso3c = "AUS",
Price = GDPuc::toolConvertSingle(x = 1.5, iso3c = "AUS",
unit_in = "constant 2015 LCU",
unit_out = mrdrivers::toolGetUnitDollar())
)
Expand Down
2 changes: 1 addition & 1 deletion R/calcINNOPATHS.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ calcINNOPATHS <- function() {
x <- x[, , getNames(tmp), invert = TRUE]
getNames(tmp) <- gsub("EUR2015", "US$2017", getNames(tmp))

tmp <- GDPuc::convertGDP(
tmp <- GDPuc::toolConvertGDP(
gdp = tmp,
unit_in = "constant 2015 EUR",
unit_out = mrdrivers::toolGetUnitDollar(),
Expand Down
2 changes: 1 addition & 1 deletion R/calcIndustry_EEK.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ calcIndustry_EEK <- function(kap) {
## Converting from billion 2012 to trillion 2017 dollars
EEK <- EEK %>%
dplyr::rename("value" = "EEK") %>%
GDPuc::convertGDP(unit_in = "constant 2012 US$MER",
GDPuc::toolConvertGDP(unit_in = "constant 2012 US$MER",
unit_out = mrdrivers::toolGetUnitDollar(),
replace_NAs = "with_USA") %>%
dplyr::mutate(value = .data$value * 1e-3) %>%
Expand Down
2 changes: 1 addition & 1 deletion R/calcJRC_IDEES.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ calcJRC_IDEES <- function(subtype) {
x <- x[, , getNames(tmp), invert = TRUE]
getNames(tmp) <- gsub("EUR2010", "US$2017", getNames(tmp))

tmp <- GDPuc::convertGDP(
tmp <- GDPuc::toolConvertGDP(
gdp = tmp,
unit_in = "constant 2010 EUR",
unit_out = mrdrivers::toolGetUnitDollar(),
Expand Down
2 changes: 1 addition & 1 deletion R/calcTaxConvergence.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ calcTaxConvergence <- function() {
w[, , ] <- 1

# convert data from $2005 to $2017
taxConvergence <- GDPuc::convertGDP(
taxConvergence <- GDPuc::toolConvertGDP(
gdp = taxConvergence,
unit_in = "constant 2005 US$MER",
unit_out = mrdrivers::toolGetUnitDollar(),
Expand Down
2 changes: 1 addition & 1 deletion R/calcTaxLimits.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ calcTaxLimits <- function(subtype) {
}

# convert data from $2005 to $2017
output <- GDPuc::convertGDP(
output <- GDPuc::toolConvertGDP(
gdp = output,
unit_in = "constant 2005 US$MER",
unit_out = mrdrivers::toolGetUnitDollar(),
Expand Down
2 changes: 1 addition & 1 deletion R/calcTaxXport.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ calcTaxXport <- function() {
weight[, , ] <- 1

# convert data from $2005 to $2017
x <- GDPuc::convertGDP(
x <- GDPuc::toolConvertGDP(
gdp = x,
unit_in = "constant 2005 US$MER",
unit_out = mrdrivers::toolGetUnitDollar(),
Expand Down
2 changes: 1 addition & 1 deletion R/convertDylanAusGasCost.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ convertDylanAusGasCost <- function(x) {

x %>%
# Converting from constant 2015 Australian dollars to constant 2017 US$MER
GDPuc::convertGDP(unit_in = "constant 2015 LCU", unit_out = mrdrivers::toolGetUnitDollar()) %>%
GDPuc::toolConvertGDP(unit_in = "constant 2015 LCU", unit_out = mrdrivers::toolGetUnitDollar()) %>%
add_dimension(dim = 3.4, add = "unit", nm = "Natural Gas Extraction Cost [2017USD/GJ]") %>%
toolCountryFill(fill = 0, verbosity = 2) %>%
return()
Expand Down
2 changes: 1 addition & 1 deletion R/convertGEA2012.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ convertGEA2012 <- function(x, subtype) {
if (subtype %in% c("oil", "coal", "gas")) {

# convert T US$2005/TWa -> T US$2017/TWa for cost factors xi1 and xi2
tmp <- GDPuc::convertGDP(
tmp <- GDPuc::toolConvertGDP(
gdp = out[, , c("xi1", "xi2")],
unit_in = "constant 2005 US$MER",
unit_out = mrdrivers::toolGetUnitDollar(),
Expand Down
2 changes: 1 addition & 1 deletion R/convertIIASA_subs_taxes.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ convertIIASA_subs_taxes <- function(x, subtype) {

# convert monetary data from $2005 to $2017
if (subtype %in% c("subsidies_bulk", "tax_rate")) {
x <- GDPuc::convertGDP(
x <- GDPuc::toolConvertGDP(
gdp = x,
unit_in = "constant 2005 US$MER",
unit_out = mrdrivers::toolGetUnitDollar(),
Expand Down
2 changes: 1 addition & 1 deletion R/convertTransportSubisidies.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ convertTransportSubsidies <- function(x) {
x[is.na(x)] <- 0

# convert data from EUR 2020 to USD 2017
x <- GDPuc::convertGDP(
x <- GDPuc::toolConvertGDP(
gdp = x,
unit_in = "constant 2020 EUR",
unit_out = mrdrivers::toolGetUnitDollar(),
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MadRat REMIND Input Data Package

R package **mrremind**, version **0.193.6**
R package **mrremind**, version **0.193.7**

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

Expand Down Expand Up @@ -39,7 +39,7 @@ In case of questions / problems please contact Lavinia Baumstark <lavinia@pik-po

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

Baumstark L, Rodrigues R, Levesque A, Oeser J, Bertram C, Mouratiadou I, Malik A, Schreyer F, Soergel B, Rottoli M, Mishra A, Dirnaichner A, Pehl M, Giannousakis A, Klein D, Strefler J, Feldhaus L, Brecha R, Rauner S, Dietrich J, Bi S, Benke F, Weigmann P, Richters O, Hasse R, Fuchs S, Mandaroux R, Koch J (2024). _mrremind: MadRat REMIND Input Data Package_. R package version 0.193.6, <https://github.com/pik-piam/mrremind>.
Baumstark L, Rodrigues R, Levesque A, Oeser J, Bertram C, Mouratiadou I, Malik A, Schreyer F, Soergel B, Rottoli M, Mishra A, Dirnaichner A, Pehl M, Giannousakis A, Klein D, Strefler J, Feldhaus L, Brecha R, Rauner S, Dietrich J, Bi S, Benke F, Weigmann P, Richters O, Hasse R, Fuchs S, Mandaroux R, Koch J (2024). _mrremind: MadRat REMIND Input Data Package_. R package version 0.193.7, <https://github.com/pik-piam/mrremind>.

A BibTeX entry for LaTeX users is

Expand All @@ -48,7 +48,7 @@ A BibTeX entry for LaTeX users is
title = {mrremind: MadRat REMIND Input Data Package},
author = {Lavinia Baumstark and Renato Rodrigues and Antoine Levesque and Julian Oeser and Christoph Bertram and Ioanna Mouratiadou and Aman Malik and Felix Schreyer and Bjoern Soergel and Marianna Rottoli and Abhijeet Mishra and Alois Dirnaichner and Michaja Pehl and Anastasis Giannousakis and David Klein and Jessica Strefler and Lukas Feldhaus and Regina Brecha and Sebastian Rauner and Jan Philipp Dietrich and Stephen Bi and Falk Benke and Pascal Weigmann and Oliver Richters and Robin Hasse and Sophie Fuchs and Rahel Mandaroux and Johannes Koch},
year = {2024},
note = {R package version 0.193.6},
note = {R package version 0.193.7},
url = {https://github.com/pik-piam/mrremind},
}
```

0 comments on commit e956d0c

Please sign in to comment.