-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #311 from 0UmfHxcvx5J7JoaOhFSs5mncnisTJJ6q/dev/cal…
…cCement add calcCement(), combining data from readvanRuijven2016() and readUSGS(cement)
- Loading branch information
Showing
6 changed files
with
69 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters