Skip to content

Commit

Permalink
Merge pull request #311 from 0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q/dev/cal…
Browse files Browse the repository at this point in the history
…cCement

 add calcCement(), combining data from readvanRuijven2016() and readUSGS(cement)
  • Loading branch information
0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q authored Aug 24, 2022
2 parents 847adc3 + 8382ea6 commit d06a453
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '27181322'
ValidationKey: '27302340'
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.141.4",
"version": "0.142.0",
"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.141.4
Date: 2022-08-19
Version: 0.142.0
Date: 2022-08-23
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 @@ -2,6 +2,7 @@

export(calcAGEB)
export(calcBP)
export(calcCement)
export(calcCementShare)
export(calcChemicalFeedstocksShare)
export(calcClinker_to_cement_ratio)
Expand Down
61 changes: 61 additions & 0 deletions R/calcCement.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#' Calculate Historic Cement Production
#'
#' Combines cement production data from [`readvanRuijven2016()`] and
#' [`readUSGS(cement)`][readUSGS] into a single data set, using USGS data from
#' 2005 on.
#'
#' @md
#' @return A list with a [`magpie`][magclass::magclass] object `x` with
#' country-level cement production in tonnes, `weight`, `unit`, `description`,
#' and `min` fields.
#'
#' @author Michaja Pehl
#'
#' @seealso [calcOutput]
#'
#' @importFrom assertr verify
#' @importFrom dplyr anti_join arrange bind_rows filter group_by select ungroup
#' @importFrom magclass as.magpie
#' @importFrom magrittr %>%
#' @importFrom quitte madrat_mule
#' @importFrom rlang .data syms

#' @export
calcCement <- function() {
transition_year <- 2005
. <- NULL

d_vanRuijvan2016 <- readSource('vanRuijven2016', convert = FALSE) %>%
madrat_mule()

d_USGS_cement <- readSource('USGS', 'cement', convert = FALSE) %>%
madrat_mule() %>%
group_by(!!!syms(c('iso3c', 'year'))) %>%
filter(max(.data$reporting.year) == .data$reporting.year) %>%
ungroup() %>%
select(-'reporting.year')

d <- d_USGS_cement %>%
filter(transition_year <= .data$year)

d <- bind_rows(
d,

d_vanRuijvan2016 %>%
anti_join(d, c('iso3c', 'year'))
) %>%
group_by(!!!syms(c('iso3c', 'year'))) %>%
mutate(count = n()) %>%
verify(1 == .data$count,
description = 'only one data point per country/year') %>%
select(-'count') %>%
arrange(!!!syms(c('iso3c', 'year')))

return(list(x = d %>%
as.magpie(spatial = 1, temporal = 2, data = ncol(.)) %>%
toolCountryFill(verbosity = 2),
weight = NULL,
description = 'historical cement production',
unit = 'tonnes of cement',
min = 0))
}
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.141.4**
R package **mrremind**, version **0.142.0**

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

0 comments on commit d06a453

Please sign in to comment.