-
Notifications
You must be signed in to change notification settings - Fork 47
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 #451 from katarkow/EW_costs
Migrate enhanced weathering costs from REMIND
- Loading branch information
Showing
12 changed files
with
154 additions
and
22 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
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,23 @@ | ||
#' Calculate costs of transport of enahnced weathering | ||
#' | ||
#' @return transport costs of spreading rock on the fields | ||
#' @seealso \code{\link{calcOutput}} | ||
#' @examples | ||
#' | ||
#' \dontrun{ | ||
#' calcOutput("CostsWeathering") | ||
#' } | ||
#' | ||
|
||
calcCostsWeathering <- function() { | ||
|
||
costs <- readSource("Strefler", subtype = "weathering_costs") | ||
weight <- costs # get the same dimensions of the data | ||
weight[, , ] <- 1 # this will take the average of the countries to get the regional resolution | ||
|
||
return(list(x = costs, | ||
weight = weight, | ||
unit = "T$/Gt stone", | ||
description = "Transport costs for spreading rocks on the fields. The first rlf corresponds to climate regions (1 - warm, 2 - temperate). The second rlf are the distances of fields from the sources of the material." | ||
)) | ||
} |
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,7 +1,25 @@ | ||
convertStrefler <- function(x) { | ||
|
||
w <- calcOutput("FAOLand",aggregate=FALSE)[,,"6620",pmatch = TRUE][,2005,] | ||
y <- toolAggregate(x, "regionmappingGEC.csv", weight=w) | ||
|
||
#' @title convertStrefler | ||
#' @description Converts data on enhanced weathering | ||
#' @param x unconverted magpie object from read-script | ||
#' | ||
#' @return magpie object with a completed dataset | ||
#' | ||
|
||
convertStrefler <- function(x, subtype) { | ||
|
||
if (subtype == "weathering_graderegi") { | ||
w <- calcOutput("FAOLand", aggregate = FALSE)[, , "6620", pmatch = TRUE][, 2005, ] | ||
y <- toolAggregate(x, "regionmappingGEC.csv", weight = w) | ||
return(y) | ||
} | ||
|
||
if (subtype == "weathering_costs") { | ||
reg_rel <- toolGetMapping("regionmappingH12.csv", type = "regional", | ||
where = "mappingfolder") # get H12 regionmapping | ||
# assign the same cost for each country in a given region | ||
y <- toolAggregate(x, reg_rel) | ||
return(y) | ||
} | ||
|
||
stop("Not a valid subtype in convertStrefler") | ||
} |
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,32 @@ | ||
readStrefler <- function(){ | ||
x <- read.csv("f33_data_weathering_graderegi.csv", sep=";", header=TRUE, row.names = 1) | ||
x <- as.magpie(x,spatial=1) | ||
getSets(x)[1] <- "region" | ||
getSets(x)[2] <- "year" | ||
getSets(x)[3] <- "data1" | ||
return(x) | ||
#' Get data on enhanced weathering | ||
#' | ||
#' @param subtype type of data, one of "weathering_graderegi", "weathering_costs" | ||
#' @return magpie object of region dependent data | ||
#' @seealso \code{\link{readSource}} | ||
#' @examples | ||
#' | ||
#' \dontrun{ | ||
#' a <- readSource(type="Strefler", subtype="weathering_graderegi") | ||
#' } | ||
|
||
readStrefler <- function(subtype) { | ||
|
||
# weathering potential | ||
if (subtype == "weathering_graderegi") { | ||
x <- read.csv("f33_data_weathering_graderegi.csv", sep = ";", header = TRUE, row.names = 1) | ||
x <- as.magpie(x, spatial = 1) | ||
getSets(x)[1] <- "region" | ||
getSets(x)[2] <- "year" | ||
getSets(x)[3] <- "data1" | ||
return(x) | ||
} | ||
|
||
# transport costs of spreading rock for weathering on the fields | ||
if (subtype == "weathering_costs") { | ||
x <- read.csv("p33_weathering_transport_costs.csv", sep = ";", header = TRUE) | ||
x <- as.magpie(x, tidy = "true") | ||
return(x) | ||
} | ||
|
||
stop("Not a valid subtype provided to readStrefler") | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.