Skip to content

Commit

Permalink
Merge pull request pik-piam#343 from 0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q…
Browse files Browse the repository at this point in the history
…/fix/NEN_steel_glut

fix exploding specific FE demand for primary steel for NEN (and therefore NEU)
  • Loading branch information
0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q authored Jan 13, 2023
2 parents 4787a61 + 218e537 commit 6d5b00a
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '29341005'
ValidationKey: '29364920'
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.151.5",
"version": "0.151.6",
"description": "<p>The mrremind packages contains data preprocessing for the\n 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 @@
Type: Package
Package: mrremind
Title: MadRat REMIND Input Data Package
Version: 0.151.5
Date: 2023-01-10
Version: 0.151.6
Date: 2023-01-13
Authors@R: c(
person("Lavinia", "Baumstark", , "[email protected]", role = c("aut", "cre")),
person("Renato", "Rodrigues", role = "aut"),
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ importFrom(magclass,setYears)
importFrom(magclass,time_interpolate)
importFrom(magclass,where)
importFrom(magclass,write.magpie)
importFrom(magrittr,"%<>%")
importFrom(magrittr,"%>%")
importFrom(mgsub,mgsub)
importFrom(nnls,nnls)
Expand Down
25 changes: 23 additions & 2 deletions R/calcFEdemand.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @param subtype Final energy (FE) or Energy service (ES) or Useful/Final Energy items from EDGEv3 corresponding to REMIND FE items (UE_for_Eff,FE_for_Eff)
#' @importFrom assertr verify
#' @importFrom rlang .data sym syms
#' @importFrom magrittr %>%
#' @importFrom magrittr %<>% %>%
#' @importFrom data.table data.table tstrsplit setnames CJ setkey as.data.table :=
#' @importFrom stats approx
#' @importFrom dplyr arrange as_tibble between bind_rows count filter first last
Expand Down Expand Up @@ -1749,6 +1749,27 @@ calcFEdemand <- function(subtype = "FE") {
verify(expr = 0 < .data$specific.energy,
description = 'All specific energy factors above 0')

# replace absurdly high specific energy (e.g. primary steel NEN after IEA
# 2021 data update) with EUR averages (considered peer-countries to NEN –
# CHE, GRL, ISL, LIE, NOR, SJM).
industry_subsectors_specific_energy %<>%
filter('steel_primary' == .data$subsector,
100 < .data$specific.energy) %>%
select(-'specific.energy') %>%
left_join(
industry_subsectors_specific_energy %>%
filter('steel_primary' == .data$subsector,
.data$region %in% c('DEU', 'ECE', 'ECS', 'ENC', 'ESC', 'ESW',
'EWN', 'FRA', 'UKI')) %>%
group_by(.data$scenario, .data$year, .data$subsector) %>%
summarise(specific.energy = mean(.data$specific.energy),
.groups = 'drop'),

c('scenario', 'year', 'subsector')
) %>%
overwrite(industry_subsectors_specific_energy,
except = 'specific.energy')

# extend time horizon
industry_subsectors_specific_energy <-
industry_subsectors_specific_energy %>%
Expand Down Expand Up @@ -1910,7 +1931,7 @@ calcFEdemand <- function(subtype = "FE") {
) %>%
mutate(value = .data$level * .data$specific.energy) %>%
select('scenario', 'iso3c', 'year', 'subsector', 'value') %>%
assert(is.finite, .data$value) %>%
assert(is.finite, 'value') %>%
inner_join(
industry_subsectors_en_shares %>%
full_join(region_mapping_21, 'region') %>%
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.151.5**
R package **mrremind**, version **0.151.6**

[![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/ui#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 (2023). _mrremind: MadRat REMIND Input Data Package_. R package version 0.151.5, <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 (2023). _mrremind: MadRat REMIND Input Data Package_. R package version 0.151.6, <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},
year = {2023},
note = {R package version 0.151.5},
note = {R package version 0.151.6},
url = {https://github.com/pik-piam/mrremind},
}
```

0 comments on commit 6d5b00a

Please sign in to comment.