generated from IMMM-SFA/metarepo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile_sim_result.R
59 lines (58 loc) · 2.28 KB
/
compile_sim_result.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
compile.sim.result <- function(result.path, df.prototype.area) {
folders <- list.files(result.path)
result <- lapply(folders, function(folder) {
df <- readr::read_csv(sprintf("%s/%s/eplusout.csv", result.path, folder)) %>%
dplyr::mutate(energy.elec = `Electricity:Facility [J](Hourly)`) %>%
dplyr::mutate(energy.overall = energy.elec) %>%
{.}
if ("NaturalGas:Facility [J](Hourly)" %in% names(df)) {
df <- df %>%
dplyr::mutate(energy.gas = `NaturalGas:Facility [J](Hourly)`) %>%
dplyr::mutate(energy.overall = energy.elec + energy.gas)
}
df %>%
dplyr::select(starts_with("energy")) %>%
dplyr::summarise_if(is.numeric, sum) %>%
dplyr::mutate(idf.kw = folder) %>%
{.}
}) %>%
dplyr::bind_rows() %>%
dplyr::mutate(energy.GJ = energy.overall * 1e-9) %>%
dplyr::select(idf.kw, energy.GJ) %>%
dplyr::left_join(df.prototype.area, by="idf.kw") %>%
dplyr::mutate(EUI.GJ.per.m2 = energy.GJ / prototype.m2) %>%
tidyr::separate(idf.kw, into=letters[1:6], sep="\\-") %>%
dplyr::rename(type = a) %>%
{.}
result
}
compile.sim.result.elec.gas <- function(result.path, df.prototype.area) {
folders <- list.files(result.path)
result <- lapply(folders, function(folder) {
df <- readr::read_csv(sprintf("%s/%s/eplusout.csv", result.path, folder)) %>%
dplyr::mutate(energy.elec = `Electricity:Facility [J](Hourly)`) %>%
dplyr::mutate(energy.overall = energy.elec) %>%
{.}
if ("NaturalGas:Facility [J](Hourly)" %in% names(df)) {
df <- df %>%
dplyr::mutate(energy.gas = `NaturalGas:Facility [J](Hourly)`) %>%
dplyr::mutate(energy.overall = energy.elec + energy.gas)
}
df %>%
dplyr::select(starts_with("energy")) %>%
dplyr::summarise_if(is.numeric, sum) %>%
dplyr::mutate(idf.kw = folder) %>%
{.}
}) %>%
dplyr::bind_rows() %>%
dplyr::mutate(elec = energy.elec * 1e-9) %>%
dplyr::mutate(gas = energy.gas * 1e-9) %>%
dplyr::select(idf.kw, elec, gas) %>%
dplyr::left_join(df.prototype.area, by="idf.kw") %>%
tidyr::gather(variable, energy.GJ, elec:gas) %>%
dplyr::mutate(EUI.GJ.per.m2 = energy.GJ / prototype.m2) %>%
tidyr::separate(idf.kw, into=letters[1:6], sep="\\-") %>%
dplyr::rename(type = a) %>%
{.}
result
}