Skip to content

Commit

Permalink
fix calculating industry/subsectors input for SSP2_lowEn (pik-piam#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q authored Sep 30, 2021
1 parent a239e8e commit 6a5e9a9
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '14816816'
ValidationKey: '14836500'
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": "mrremind: MadRat REMIND Input Data Package",
"version": "0.78.4",
"version": "0.78.5",
"description": "<p>The mrremind packages contains data preprocessing for the REMIND model.<\/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: mrremind
Type: Package
Title: MadRat REMIND Input Data Package
Version: 0.78.4
Date: 2021-09-29
Version: 0.78.5
Date: 2021-09-30
Authors@R: c(person("Lavinia", "Baumstark", email = "[email protected]", role = c("aut","cre")),
person("Renato", "Rodrigues", role = "aut"),
person("Antoine", "Levesque", role = "aut"),
Expand Down
40 changes: 25 additions & 15 deletions R/calcFEdemand.R
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ calcFEdemand <- function(subtype = "FE") {
scenario = paste0('gdp_', .data$Data1),
item = paste0('ue_', sub('_(production|VA)$', '', .data$Data2))) %>%
select('Region', 'year', 'scenario', 'item', 'Value') %>%
filter(.data$year %in% unique(getYears(reminditems))) %>%
filter(.data$year %in% unique(getYears(reminditems))) %>%
as.magpie(tidy = TRUE)

## Steel activity ----
Expand All @@ -716,33 +716,43 @@ calcFEdemand <- function(subtype = "FE") {
# t * 1e-9 Gt/t = t
value = .data$Value * 1e-9) %>%
select('Region', 'year', 'scenario', 'item', 'value') %>%
filter(.data$year %in% unique(getYears(reminditems))) %>%
filter(.data$year %in% unique(getYears(reminditems))) %>%
as.magpie(tidy = TRUE)

## extend to SSP2_lowEn ----
# SSP2_lowEn is described as "per capita energy demands similar to SDP, also
# tech assumptions as in SDP", so that's what we do ...
foo_pop <- calcOutput('Population', aggregate = FALSE, FiveYearSteps = FALSE)

industry_subsectors_ue_SSP2_lowEn <- (
dimSums(industry_subsectors_ue[,,'gdp_SDP'], dim = 3.1) %>%
`/`(dimSums(foo_pop[,getYears(industry_subsectors_ue),'pop_SDP'])) %>%
`*`(dimSums(foo_pop[,getYears(industry_subsectors_ue),'pop_SSP2']))
)

getNames(industry_subsectors_ue_SSP2_lowEn) <- paste(
'gdp_SSP2_lowEn', getNames(industry_subsectors_ue_SSP2_lowEn), sep = '.')

industry_subsectors_ue <- mbind(
industry_subsectors_ue,

dimSums(industry_subsectors_ue[,,'gdp_SDP'], dim = 3.1) %>%
`/`(dimSums(foo_pop[,getYears(industry_subsectors_ue),'pop_SDP'])) %>%
`*`(dimSums(foo_pop[,getYears(industry_subsectors_ue),'pop_SSP2'])) %>%
setNames(paste('gdp_SSP2_lowEn', getNames(.data), sep = '.'))
industry_subsectors_ue,
industry_subsectors_ue_SSP2_lowEn
)

industry_steel_SSP2_lowEn <- (
dimSums(industry_steel[,,'gdp_SDP'], dim = 3.1)
/ dimSums(foo_pop[,getYears(industry_steel),'pop_SDP'])
* dimSums(foo_pop[,getYears(industry_steel),'pop_SSP2'])
)

getNames(industry_steel_SSP2_lowEn) <- paste(
'gdp_SSP2_lowEn', getNames(industry_steel_SSP2_lowEn), sep = '.')

industry_steel <- mbind(
industry_steel,

dimSums(industry_steel[,,'gdp_SDP'], dim = 3.1) %>%
`/`(dimSums(foo_pop[,getYears(industry_steel),'pop_SDP'])) %>%
`*`(dimSums(foo_pop[,getYears(industry_steel),'pop_SSP2'])) %>%
setNames(paste('gdp_SSP2_lowEn', getNames(.data), sep = '.'))
industry_steel,
industry_steel_SSP2_lowEn
)

rm(foo_pop)
rm(foo_pop, industry_subsectors_ue_SSP2_lowEn, industry_steel_SSP2_lowEn)

industry_subsectors_en <- calcOutput(
type = 'IO', subtype = 'output_Industry_subsectors', round = 8,
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.78.4**
R package **mrremind**, version **0.78.5**

[![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://codecov.io/gh/pik-piam/mrremind) [![r-universe](https://pik-piam.r-universe.dev/badges/mrremind)](https://pik-piam.r-universe.dev/ui#builds)

Expand Down Expand Up @@ -38,7 +38,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 (2021). _mrremind: MadRat REMIND Input Data Package_. R package version 0.78.4.
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 (2021). _mrremind: MadRat REMIND Input Data Package_. R package version 0.78.5.

A BibTeX entry for LaTeX users is

Expand All @@ -47,7 +47,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},
year = {2021},
note = {R package version 0.78.4},
note = {R package version 0.78.5},
}
```

0 comments on commit 6a5e9a9

Please sign in to comment.