From 66d970854653e243ec9c7fb41d1eea170d9797d3 Mon Sep 17 00:00:00 2001 From: Michaja Pehl Date: Wed, 9 Oct 2024 15:06:59 +0200 Subject: [PATCH 1/3] fix cement production estimates by adjusting filtered regression data --- R/EDGE-Industry.R | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/R/EDGE-Industry.R b/R/EDGE-Industry.R index 6668d454..dc14f1a0 100644 --- a/R/EDGE-Industry.R +++ b/R/EDGE-Industry.R @@ -1730,19 +1730,35 @@ calcIndustry_Value_Added <- function(subtype = 'physical', ) %>% filter(!is.na(.data$cement.production)) + ### censor nonsensical data ---- + cement_censor <- list_to_data_frame(list( + BDI = 1980:2010, # zero cement production + CIV = 1990:1993, # cement VA 100 times higher than before and after + NAM = 2007:2010, # zero cement production + HKG = 1973:1979, # no data for CHN prior to 1980 + IRQ = 1992:1997, # cement VA 100 times higher than before and after + RUS = 1970:1990, # exclude data from Soviet period which biases + # projections up + NULL), + 'iso3c', 'year') %>% + mutate(censored = TRUE) + + regression_data_cement <- regression_data_cement %>% + anti_join(cement_censor, c('iso3c', 'year')) + ### compute regional and World aggregates ---- regression_data_cement <- regression_data_cement %>% inner_join( population %>% - group_by(.data$iso3c, .data$year) %>% - summarise(population = calc_mode(.data$population), .groups = 'drop'), + filter('SSP2' == .data$scenario) %>% # TODO: define default scenario + select(-'scenario'), c('iso3c', 'year') ) %>% inner_join( GDP %>% - group_by(.data$iso3c, .data$year) %>% - summarise(GDP = calc_mode(.data$GDP), .groups = 'drop'), + filter('SSP2' == .data$scenario) %>% # TODO: define default scenario + select(-'scenario'), c('iso3c', 'year') ) %>% From 297ea6d0529dd2acfccc4b35df6dab7c869b091b Mon Sep 17 00:00:00 2001 From: Michaja Pehl Date: Wed, 9 Oct 2024 15:07:34 +0200 Subject: [PATCH 2/3] clean default scenario selection TODO: define default scenario --- R/EDGE-Industry.R | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/R/EDGE-Industry.R b/R/EDGE-Industry.R index dc14f1a0..8ec3f9c5 100644 --- a/R/EDGE-Industry.R +++ b/R/EDGE-Industry.R @@ -39,7 +39,7 @@ #' geom_line geom_path geom_point ggplot ggsave guide_legend labs #' scale_colour_manual scale_fill_discrete scale_fill_manual #' scale_linetype_manual scale_shape_manual theme theme_minimal -#' @importFrom quitte calc_mode character.data.frame df_populate_range duplicate +#' @importFrom quitte character.data.frame df_populate_range duplicate #' list_to_data_frame madrat_mule magclass_to_tibble order.levels #' seq_range sum_total_ #' @importFrom readr write_rds @@ -1380,16 +1380,16 @@ calcIndustry_Value_Added <- function(subtype = 'physical', inner_join( GDP %>% filter(max(INDSTAT$year) >= .data$year) %>% - group_by(.data$iso3c, .data$year) %>% - summarise(GDP = calc_mode(.data$GDP), .groups = 'drop'), + filter('SSP2' == .data$scenario) %>% # TODO: define default scenario + select(-'scenario'), c('iso3c', 'year') ) %>% inner_join( population %>% filter(max(INDSTAT$year) >= .data$year) %>% - group_by(.data$iso3c, .data$year) %>% - summarise(population = calc_mode(.data$population), .groups = 'drop'), + filter('SSP2' == .data$scenario) %>% # TODO: define default scenario + select(-'scenario'), c('iso3c', 'year') ) @@ -1487,15 +1487,15 @@ calcIndustry_Value_Added <- function(subtype = 'physical', regression_data_steel <- regression_data_steel %>% inner_join( population %>% - group_by(.data$iso3c, .data$year) %>% - summarise(population = calc_mode(.data$population), .groups = 'drop'), + filter('SSP2' == .data$scenario) %>% # TODO: define default scenario + select(-'scenario'), c('iso3c', 'year') ) %>% inner_join( GDP %>% - group_by(.data$iso3c, .data$year) %>% - summarise(GDP = calc_mode(.data$GDP), .groups = 'drop'), + filter('SSP2' == .data$scenario) %>% # TODO: define default scenario + select(-'scenario'), c('iso3c', 'year') ) %>% From 62165806d474f72002bcfd369b2d0147e9aff26b Mon Sep 17 00:00:00 2001 From: Michaja Pehl Date: Wed, 9 Oct 2024 15:21:50 +0200 Subject: [PATCH 3/3] lucode hubbub --- .buildlibrary | 2 +- CITATION.cff | 2 +- DESCRIPTION | 2 +- NAMESPACE | 1 - README.md | 6 +++--- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 9d197690..23eefd69 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '38689670' +ValidationKey: '38709675' AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' - 'Warning: namespace ''.*'' is not available and has been replaced' diff --git a/CITATION.cff b/CITATION.cff index 8555b35f..996aff9c 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,7 +2,7 @@ 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.4 +version: 0.193.5 date-released: '2024-10-09' abstract: The mrremind packages contains data preprocessing for the REMIND model. authors: diff --git a/DESCRIPTION b/DESCRIPTION index f9f826e8..4fe13022 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: mrremind Title: MadRat REMIND Input Data Package -Version: 0.193.4 +Version: 0.193.5 Date: 2024-10-09 Authors@R: c( person("Lavinia", "Baumstark", , "lavinia@pik-potsdam.de", role = c("aut", "cre")), diff --git a/NAMESPACE b/NAMESPACE index 67649ef6..504e02a8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -160,7 +160,6 @@ importFrom(magrittr,"%>%") importFrom(quitte,add_countrycode_) importFrom(quitte,as.quitte) importFrom(quitte,calc_addVariable) -importFrom(quitte,calc_mode) importFrom(quitte,cartesian) importFrom(quitte,character.data.frame) importFrom(quitte,df_populate_range) diff --git a/README.md b/README.md index d24bdf32..51735ddf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # MadRat REMIND Input Data Package -R package **mrremind**, version **0.193.4** +R package **mrremind**, version **0.193.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://app.codecov.io/gh/pik-piam/mrremind) [![r-universe](https://pik-piam.r-universe.dev/badges/mrremind)](https://pik-piam.r-universe.dev/builds) @@ -39,7 +39,7 @@ In case of questions / problems please contact Lavinia Baumstark . +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.5, . A BibTeX entry for LaTeX users is @@ -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.4}, + note = {R package version 0.193.5}, url = {https://github.com/pik-piam/mrremind}, } ```