forked from pik-piam/mrremind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalcCoolingSharesFuture.R
127 lines (111 loc) · 4.04 KB
/
calcCoolingSharesFuture.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#' Calculate Cooling Type Shares for Future Timesteps
#'
#' This function calculates REMIND input data for the shares of cooling types
#' per electricity technology and REMIND region in post-2020, using as initial
#' information the Davies (2013) data per electricity technology and GCAM
#' region. The source data provide most required information but some
#' assumptions on missing data are also made.
#'
#'
#' @return MAgPIE object on cooling type shares per elecricity technology and
#' REMIND region
#' @author Ioanna Mouratiadou
#' @seealso \code{\link{calcOutput}}, \code{\link{readDaviesCooling}},
#' \code{\link{convertDaviesCooling}},
#' \code{\link{calcCoolingSharesAll}},\code{\link{calcCoolingSharesBase}}
#' @examples
#' \dontrun{
#' a <- calcOutput("CoolingSharesFuture")
#' }
#'
calcCoolingSharesFuture <- function() {
# read in data
data <- readSource("DaviesCooling", subtype = "dataFuture")
getNames(data)[grepl("^Sea", getNames(data))] <- "Sea.NA"
# seperate data for Sea water
Sea <- data[, , "Sea"]
data <- data[, , -which(getNames(data) == "Sea.NA")]
id <- getNames(data, dim = 1)
# calculate pond
pond <- new.magpie(getRegions(data), getYears(data), id)
for (i in id) {
pond[, , i] <- 100 - dimSums(data[, , i], dim = 3.2)
}
getNames(pond) <- paste(getNames(pond), "Pond", sep = ".")
# add pond to data
data <- mbind(data, pond)
# calculate sea water
sea_new <- new.magpie(getRegions(data), getYears(data), id)
for (i in id) {
sea_new[, , i] <- data[, , paste(i, "1-thru", sep = ".")] * Sea / 100
}
getNames(sea_new) <- paste(getNames(sea_new), "Sea", sep = ".")
# correct 1-thru-data
data[, , "1-thru"] <- data[, , "1-thru"] * (1 - Sea / 100)
# add sea data to data
data <- mbind(data, sea_new)
# check if all categories sum up to 100%
check <- new.magpie(getRegions(data), getYears(data), id)
for (i in id) {
check[, , i] <- dimSums(data[, , i], dim = 3.2)
}
if (!all(check == 100)) {
stop("sum of categorie XXX is not 100%")
}
# read in mapping to REMIND technologies
map_table <- toolGetMapping(
type = "sectoral",
name = "techmappingDaviesToREMIND.csv",
where = "mrremind"
)
map <- list()
map$davies <- paste(map_table$Davies.Source.Technology, map_table$Davies.Cooling, sep = ".")
map$remind <- paste(map_table$REMIND.Technology, map_table$REMIND.Cooling, sep = ".")
# calculate REMIND input in REMIND categories
output <- new.magpie(getRegions(data), getYears(data), map$remind)
output[, , ] <- 0
for (d in 1:length(map$davies)) {
if (!map$davies[d] == "-.-") {
output[, , map$remind[d]] <- data[, , map$davies[d]]
}
}
# remove no longer used technologies pcc and pco
output <- output[, , c("pcc", "pco"), invert = TRUE]
# add assumed data
output[, , "geohdr.tower"] <- 70
output[, , "geohdr.dry"] <- 20
output[, , "geohdr.hybrid"] <- 10
output[, , "hydro.default"] <- 100
output[, , "wind.default"] <- 100
output[, , "spv.default"] <- 100
output[, , "csp.tower"] <- 70
output[, , "csp.dry"] <- 20
output[, , "csp.hybrid"] <- 10
outputFuture <- new.magpie(getRegions(output), c(2020), getNames(output))
outputFuture[, , ] <- output[, , ]
# assign aggregation weight
weight <- dimSums(calcOutput("IO", subtype = "output", aggregate = FALSE)[, 2010, c("feelb", "feeli")], dim = 3)
# set weights to zero for countries that were not contained in the GCAM2ISO mapping
weight["ALA", , ] <- 0
weight["ATA", , ] <- 0
weight["BES", , ] <- 0
weight["BLM", , ] <- 0
weight["CUW", , ] <- 0
weight["GGY", , ] <- 0
weight["IMN", , ] <- 0
weight["JEY", , ] <- 0
weight["MAF", , ] <- 0
weight["PSE", , ] <- 0
weight["SSD", , ] <- 0
weight["SXM", , ] <- 0
return(list(
x = outputFuture,
weight = weight,
unit = "% of cooling type technologies",
description = c(
"Cooling shares for different cooling technologies based on ",
"Davies et al. (2013) publication and using electricity use weights ",
"(aggregated based on IEA World Energy Balances, 2014) for regional mapping"
)
))
}