-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
512 lines (512 loc) · 23.7 KB
/
.Rhistory
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
library(gplots)
library(RColorBrewer)
source('evaluate_pi.R')
var_x_all = c('Environment:Site Direct Solar Radiation Rate per Area',
'Environment:Site Outdoor Air Drybulb Temperature',
'Environment:Site Outdoor Air Relative Humidity',
'People Occupant Count',
'Zone Mean Air Temperature')
var_y = c('Electricity:Building')
var_y = c('Electricity:Building')
var_x <- combinations[,c]
x_str <- paste(var_x, collapse = '_')
var_x<-var_x_all
var_x <- combinations[,c]
x_str <- paste(var_x, collapse = '_')
x_str <- str_replace_all(x_str, ":", " ")
y_str <- str_replace_all(var_y, ":", " ")
out_fname <- paste("results", y_str, x_str, sep='-')
out_fname <- str_replace_all(out_fname, 'Environment|Site|Outdoor|Rate per Area|Direct|People','')
out_fname <- gsub("\\s+", "", str_trim(out_fname))
load(paste(out_fname,'RData',sep='.'))
print(eval$plot_boxplot)
var_x_all = c('Environment:Site Direct Solar Radiation Rate per Area',
'Environment:Site Outdoor Air Drybulb Temperature',
'Environment:Site Outdoor Air Relative Humidity',
#'People Occupant Count',
'Zone Mean Air Temperature')
var_x<-var_x_all
x_str <- paste(var_x, collapse = '_')
x_str <- str_replace_all(x_str, ":", " ")
y_str <- str_replace_all(var_y, ":", " ")
out_fname <- paste("results", y_str, x_str, sep='-')
out_fname <- str_replace_all(out_fname, 'Environment|Site|Outdoor|Rate per Area|Direct|People','')
out_fname <- gsub("\\s+", "", str_trim(out_fname))
load(paste(out_fname,'RData',sep='.'))
print(eval$plot_errorbars)
print(eval$plot_boxplot)
print(eval$plot_errorbars)
var_x_all = c('Environment:Site Direct Solar Radiation Rate per Area',
'Environment:Site Outdoor Air Drybulb Temperature',
'Environment:Site Outdoor Air Relative Humidity',
'People Occupant Count',
'Zone Mean Air Temperature')
var_x<-var_x_all
x_str <- paste(var_x, collapse = '_')
x_str <- str_replace_all(x_str, ":", " ")
y_str <- str_replace_all(var_y, ":", " ")
out_fname <- paste("results", y_str, x_str, sep='-')
out_fname <- str_replace_all(out_fname, 'Environment|Site|Outdoor|Rate per Area|Direct|People','')
out_fname <- gsub("\\s+", "", str_trim(out_fname))
load(paste(out_fname,'RData',sep='.'))
print(eval$plot_errorbars)
var_x_all = c('Environment:Site Direct Solar Radiation Rate per Area',
'Environment:Site Outdoor Air Drybulb Temperature',
'Environment:Site Outdoor Air Relative Humidity',
#'People Occupant Count',
'Zone Mean Air Temperature')
var_y = c('Electricity:Building')
var_x<-var_x_all
x_str <- paste(var_x, collapse = '_')
x_str <- str_replace_all(x_str, ":", " ")
y_str <- str_replace_all(var_y, ":", " ")
out_fname <- paste("results", y_str, x_str, sep='-')
out_fname <- str_replace_all(out_fname, 'Environment|Site|Outdoor|Rate per Area|Direct|People','')
out_fname <- gsub("\\s+", "", str_trim(out_fname))
load(paste(out_fname,'RData',sep='.'))
print(eval$plot_boxplot)
var_x_all = c('Environment:Site Direct Solar Radiation Rate per Area',
'Environment:Site Outdoor Air Drybulb Temperature',
#'Environment:Site Outdoor Air Relative Humidity',
'People Occupant Count')
x_str <- paste(var_x, collapse = '_')
x_str <- str_replace_all(x_str, ":", " ")
y_str <- str_replace_all(var_y, ":", " ")
out_fname <- paste("results", y_str, x_str, sep='-')
out_fname <- str_replace_all(out_fname, 'Environment|Site|Outdoor|Rate per Area|Direct|People','')
out_fname <- gsub("\\s+", "", str_trim(out_fname))
load(paste(out_fname,'RData',sep='.'))
print(eval$plot_boxplot)
var_x<-var_x_all
x_str <- paste(var_x, collapse = '_')
x_str <- str_replace_all(x_str, ":", " ")
y_str <- str_replace_all(var_y, ":", " ")
out_fname <- paste("results", y_str, x_str, sep='-')
out_fname <- str_replace_all(out_fname, 'Environment|Site|Outdoor|Rate per Area|Direct|People','')
out_fname <- gsub("\\s+", "", str_trim(out_fname))
load(paste(out_fname,'RData',sep='.'))
print(eval$plot_boxplot)
################################################################################
# Evaluate occupancy by resolution
types = c('space', 'floor', 'single')
var_x = c('Environment:Site Direct Solar Radiation Rate per Area',
'Environment:Site Outdoor Air Drybulb Temperature',
'People Occupant Count')
var_y = c('Electricity:Building')
dat_ppl <- as.data.frame(matrix(nrow = 0, ncol = 4))
colnames(dat_ppl) <- c('picp', 'nrpiw','cvrmse','cwc')
for (i in (1:5)) {
for (type in types) {
x_str <- paste(var_x, collapse = '_')
x_str <- str_replace_all(x_str, ":", " ")
y_str <- str_replace_all(var_y, ":", " ")
out_fname <- paste("results", i, type, y_str, x_str, sep='-')
out_fname <- str_replace_all(out_fname, 'Environment|Site|Outdoor|Rate per Area|Direct|People','')
out_fname <- gsub("\\s+", "", str_trim(out_fname))
load(paste(out_fname,'.RData'))
temp = data.frame(picp=eval$picp, nrpiw=eval$nrpiw,
cvrmse=eval$cvrmse, cwc=eval$cwc)
rownames(temp) <- paste(type,i,sep='_')
dat_ppl <- rbind(dat_ppl,temp)
}
}
View(dat_ppl)
View(dat_ppl)
library(stringr)
library(graphics)
library(grDevices)
library(gplots)
library(RColorBrewer)
source('evaluate_pi.R')
################################################################################
# Evaluate occupancy by resolution
types = c('space', 'floor', 'single')
var_x = c('Environment:Site Direct Solar Radiation Rate per Area',
'Environment:Site Outdoor Air Drybulb Temperature',
'People Occupant Count')
var_y = c('Electricity:Building')
dat_ppl <- as.data.frame(matrix(nrow = 0, ncol = 6))
colnames(dat_ppl) <- c('run','resolution','picp', 'nrpiw','cvrmse','cwc')
for (i in (1:5)) {
for (type in types) {
x_str <- paste(var_x, collapse = '_')
x_str <- str_replace_all(x_str, ":", " ")
y_str <- str_replace_all(var_y, ":", " ")
out_fname <- paste("results", i, type, y_str, x_str, sep='-')
out_fname <- str_replace_all(out_fname, 'Environment|Site|Outdoor|Rate per Area|Direct|People','')
out_fname <- gsub("\\s+", "", str_trim(out_fname))
load(paste(out_fname,'.RData'))
temp = data.frame(run=i,resolution=type,
picp=eval$picp, nrpiw=eval$nrpiw,
cvrmse=eval$cvrmse, cwc=eval$cwc)
dat_ppl <- rbind(dat_ppl,temp)
}
}
ggplot(data=dat_ppl, aes(x=run, y=cvrmse, group=resolution, colour=resolution)) +
geom_line() +
geom_point()
ggplot(data=dat_ppl, aes(x=run, y=cvrmse, group=resolution, colour=resolution)) +
geom_bar()
ggplot(data=dat_ppl, aes(x=run, y=cvrmse, fill=resolution)) +
geom_bar()
ggplot(data=dat_ppl, aes(x=run, y=cvrmse, fill=resolution)) +
geom_bar(stat="identity", position=position_dodge())
ggplot(data=dat_ppl, aes(x=run, y=picp, fill=resolution)) +
geom_bar(stat="identity", position=position_dodge())
ggplot(data=dat_ppl, aes(x=run, y=picp, fill=resolution)) +
geom_bar(stat="identity", position=position_dodge(), colour="black")
ggplot(data=dat_ppl, aes(x=run, y=cvrmse, fill=resolution)) +
geom_bar(stat="identity", position=position_dodge(), colour="black") +
ylab('CVRMSE [%]')
ggplot(data=dat_ppl, aes(x=run, y=picp, fill=resolution)) +
geom_bar(stat="identity", position=position_dodge(), colour="black") +
ylab('Prediction Interval Coverage Probability')
ggplot(data=dat_ppl, aes(x=run, y=nrpiw, fill=resolution)) +
geom_bar(stat="identity", position=position_dodge(), colour="black") +
ylab('Prediction Interval Coverage Probability (PICP)')
ggplot(data=dat_ppl, aes(x=run, y=nrpiw, fill=resolution)) +
geom_bar(stat="identity", position=position_dodge(), colour="black") +
ylab('NRPIW')
ggplot(data=dat_ppl, aes(x=run, y=nrpiw, fill=resolution)) +
geom_bar(stat="identity", position=position_dodge(), colour="black") +
ylab('Normalized Root Mean Squared Prediction Interval Width (NRPIW)')
ggplot(data=dat_ppl, aes(x=run, y=picp, fill=resolution)) +
geom_bar(stat="identity", position=position_dodge(), colour="black") +
ylab('Prediction Interval Coverage Probability (PICP)')
ggplot(data=dat_ppl, aes(x=run, y=nrpiw, fill=resolution)) +
geom_bar(stat="identity", position=position_dodge(), colour="black") +
ylab('Normalized Root Mean Squared Prediction Interval Width (NRPIW)')
ggplot(data=dat_ppl, aes(x=run, y=cvrmse, fill=resolution)) +
geom_bar(stat="identity", position=position_dodge(), colour="black") +
ylab('Mean Posterior CVRMSE [%]')
ggplot(data=dat_ppl, aes(x=run, y=cvrmse, fill=resolution)) +
geom_bar(stat="identity", position=position_dodge(), colour="black") +
ylab('Mean Posterior CVRMSE [%]') +
theme(plot.axis=element_text(size=20))
?theme
ggplot(data=dat_ppl, aes(x=run, y=cvrmse, fill=resolution)) +
geom_bar(stat="identity", position=position_dodge(), colour="black") +
ylab('Mean Posterior CVRMSE [%]') +
theme(axis.text=element_text(size=20))
ggplot(data=dat_ppl, aes(x=run, y=cvrmse, fill=resolution)) +
geom_bar(stat="identity", position=position_dodge(), colour="black") +
ylab('Mean Posterior CVRMSE [%]') +
theme(text=element_text(size=20))
ggplot(data=dat_ppl, aes(x=run, y=picp, fill=resolution)) +
geom_bar(stat="identity", position=position_dodge(), colour="black") +
ylab('Prediction Interval Coverage Probability (PICP)') +
theme(text=element_text(size=20))
ggplot(data=dat_ppl, aes(x=run, y=nrpiw, fill=resolution)) +
geom_bar(stat="identity", position=position_dodge(), colour="black") +
ylab('Normalized Root Mean Squared Prediction Interval Width (NRPIW)')+
theme(text=element_text(size=20))
ggplot(data=dat_ppl, aes(x=run, y=nrpiw, fill=resolution)) +
geom_bar(stat="identity", position=position_dodge(), colour="black") +
ylab('Normalized RMS Prediction Interval Width (NRPIW)')+
theme(text=element_text(size=20))
ggplot(data=dat_ppl, aes(x=run, y=cvrmse, fill=resolution)) +
geom_bar(stat="identity", position=position_dodge(), colour="black") +
ylab('Mean Posterior CVRMSE [%]') +
theme(text=element_text(size=20))
run_num=5
load(paste('bc_data_byZone_',run_num,'.RData',sep=''))
# run different combinations
type = 'space' # options: c('single', 'floor', 'space')
var_y = c('Electricity:Building')
library(eplusr)
library(rstan)
source('functions_eplusr.R')
source('gp_utility.R')
source('evaluate_pi.R')
# Occupant Count ##########################################
ppl_all <- select_x(xf, xc, xpred, 'people')
ppl_basement <- select_x(xf, xc, xpred, 'BASEMENT.*people')
ppl_bot <- select_x(xf, xc, xpred, 'BOT.*people')
ppl_mid <- select_x(xf, xc, xpred, 'MID.*people')
ppl_top <- select_x(xf, xc, xpred, 'TOP.*people')
ppl_openOfc <- select_x(xf, xc, xpred, 'ZN_1.*people|ZN_3.*people')
ppl_privateOfc <- select_x(xf, xc, xpred, 'ZN_2.*people')
ppl_meeting <- select_x(xf, xc, xpred, 'ZN_4.*people')
ppl_corridor <- select_x(xf, xc, xpred, 'CORE.*people')
ppl_aux <- select_x(xf, xc, xpred, 'BASEMENT.*people')
# remove all people from xf, xc and xpred
xf_sub <- xf[,!grepl('people',names(xf),ignore.case = TRUE),with=FALSE]
xc_sub <- xc[,!grepl('people',names(xc),ignore.case = TRUE),with=FALSE]
xpred_sub <- xpred[,!grepl('people',names(xpred),ignore.case = TRUE),with=FALSE]
yf<-bc_data_sub$yf$`Electricity:Building [J](Hourly)`
# remove all people from xf, xc and xpred
xf_sub <- xf[,!grepl('people',names(xf),ignore.case = TRUE),with=FALSE]
xc_sub <- xc[,!grepl('people',names(xc),ignore.case = TRUE),with=FALSE]
xpred_sub <- xpred[,!grepl('people',names(xpred),ignore.case = TRUE),with=FALSE]
# seperate by floor
xf_sub$`Basement People Occupant Count` <- rowSums(ppl_basement$xf_sub)
xf_sub$`Bot People Occupant Count` <- rowSums(ppl_bot$xf_sub)
xf_sub$`Mid People Occupant Count` <- rowSums(ppl_mid$xf_sub)
xf_sub$`Top People Occupant Count` <- rowSums(ppl_top$xf_sub)
# seperate by space type
xf_sub$`Open Office People Occupant Count` <- rowSums(ppl_openOfc$xf_sub)
`Open Office People Occupant Count` <- rowSums(ppl_openOfc$xf_sub)
`Open Office People Occupant Count` <- rowSums(ppl_openOfc$xf_sub)
# seperate by space type
xf_sub$`Open Office People Occupant Count` <- rowSums(ppl_openOfc$xf_sub)
xf_sub$`Private Office People Occupant Count` <- rowSums(ppl_privateOfc$xf_sub)
xf_sub$`Meeting People Occupant Count` <- rowSums(ppl_meeting$xf_sub)
xf_sub$`Corridor People Occupant Count` <- rowSums(ppl_corridor$xf_sub)
xf_sub$`Auxiliary People Occupant Count` <- rowSums(ppl_aux$xf_sub)
plot(xf_sub$`Mid People Occupant Count`,yf)
library(eplusr)
library(rstan)
source('functions_eplusr.R')
source('gp_utility.R')
source('evaluate_pi.R')
load('bc_data_occSimulator.RData')
# sample size
n_train <- 150
n_test_train <- 0
n_test_outOfSample <- 100
n_com <- 150
n_iter <- 300
run_num <- 1
var_y = c('Electricity:Building')
# set x used for BC
var_x = c('Environment:Site Direct Solar Radiation Rate per Area',
'Environment:Site Outdoor Air Drybulb Temperature',
'People Occupant Count')
var_t = c("ZoneInfiltration",
"Lights",
"ElectricEquipment",
"Chiller")
tf_distr <- list('beta_shape_a'=rep(1,5),
'beta_shape_b'=rep(1,5))
bc_data <- get_system_data(var_y = var_y,
var_x = var_x,
var_t = var_t,
obs_field, obs_com, param_values)
xf<-bc_data$xf;xc<-bc_data$xc
bc_data_non_zero <- subset_bc_data(bc_data, num_sim, which(bc_data$yf != 0))
field_idx <- seq_len(nrow(bc_data_non_zero$yf))
subset_field_idx <- sample(field_idx, n_train)
subset_test_idx <- c(sample(subset_field_idx,n_test_train),
sample(setdiff(field_idx,subset_field_idx), n_test_outOfSample))
bc_test <- list(y_true = bc_data_non_zero$yf[subset_test_idx,],
x_pred = bc_data_non_zero$xf[subset_test_idx,])
xpred<-bc_test$x_pred
# Occupant Count ##########################################
ppl_all <- select_x(xf, xc, xpred, 'people')
ppl_basement <- select_x(xf, xc, xpred, 'BASEMENT.*people')
ppl_bot <- select_x(xf, xc, xpred, 'BOT.*people')
ppl_mid <- select_x(xf, xc, xpred, 'MID.*people')
ppl_top <- select_x(xf, xc, xpred, 'TOP.*people')
ppl_openOfc <- select_x(xf, xc, xpred, 'ZN_1.*people|ZN_3.*people')
ppl_privateOfc <- select_x(xf, xc, xpred, 'ZN_2.*people')
ppl_meeting <- select_x(xf, xc, xpred, 'ZN_4.*people')
ppl_corridor <- select_x(xf, xc, xpred, 'CORE.*people')
ppl_aux <- select_x(xf, xc, xpred, 'BASEMENT.*people')
# remove all people from xf, xc and xpred
xf_sub <- xf[,!grepl('people',names(xf),ignore.case = TRUE),with=FALSE]
xc_sub <- xc[,!grepl('people',names(xc),ignore.case = TRUE),with=FALSE]
xpred_sub <- xpred[,!grepl('people',names(xpred),ignore.case = TRUE),with=FALSE]
# sum as single X
xf_sub$`Total People Occupant Count` <- rowSums(ppl_all$xf_sub)
xc_sub$`Total People Occupant Count` <- rowSums(ppl_all$xc_sub)
xpred_sub$`Total People Occupant Count` <- rowSums(ppl_all$xpred_sub)
# seperate by floor
xf_sub$`Basement People Occupant Count` <- rowSums(ppl_basement$xf_sub)
xf_sub$`Bot People Occupant Count` <- rowSums(ppl_bot$xf_sub)
xf_sub$`Mid People Occupant Count` <- rowSums(ppl_mid$xf_sub)
xf_sub$`Top People Occupant Count` <- rowSums(ppl_top$xf_sub)
# seperate by space type
xf_sub$`Open Office People Occupant Count` <- rowSums(ppl_openOfc$xf_sub)
xf_sub$`Private Office People Occupant Count` <- rowSums(ppl_privateOfc$xf_sub)
xf_sub$`Meeting People Occupant Count` <- rowSums(ppl_meeting$xf_sub)
xf_sub$`Corridor People Occupant Count` <- rowSums(ppl_corridor$xf_sub)
xf_sub$`Auxiliary People Occupant Count` <- rowSums(ppl_aux$xf_sub)
plot(xf_sub$`Mid People Occupant Count`,bc_data$yf)
plot(xf_sub$`Mid People Occupant Count`,bc_data$yf$`Electricity:Building [J](Hourly)`)
plot(xf_sub$`Private Office People Occupant Count`,bc_data$yf$`Electricity:Building [J](Hourly)`)
plot(xf_sub$`Meeting People Occupant Count`,bc_data$yf$`Electricity:Building [J](Hourly)`)
setwd("~/Documents/GitHub/occupant-calibration")
install.packages("tidyverse")
library(tidyverse)
wifi <- paste(folder,"AS2_WIFI_2018.csv",sep='/')
folder <- "data"
wifi <- paste(folder,"AS2_WIFI_2018.csv",sep='/')
wifi <- read_csv(paste(folder,"AS2_WIFI_2018.csv",sep='/'))
View(wifi)
wifi <- read_csv(paste('data/AS2','WIFI','2018.csv',sep='_'))
btu <- read_csv(paste('data/AS2','BTU','2018.csv',sep='_'))
elec <- read_csv(paste('data/AS2','KWH','2018.csv',sep='_'))
View(wifi)
parse_date(wifi$X1)
parse_date(as.character(wifi$X1))
?gather
wifi_df <- gather(wifi,key = 'hour', value = "value")
View(wifi_df)
View(wifi)
wifi_df <- gather(wifi,key = 'hour', value = "value", `0`, `1`, `2`)
View(wifi_df)
wifi_df <- gather(wifi,key = 'hour', value = "value", seq(0,23))
seq(0,23)
wifi_df <- gather(wifi,key = 'hour', value = "value", 2:ncol(wifi))
View(wifi_df)
kwh <- read_csv(paste('data/AS2','KWH','2018.csv',sep='_'))
elec_tidy <- gather(kwh, key = 'hour', value = 'kwh', 2:ncol(kwh))
kwh <- read_csv(paste('data/AS2','KWH','2018.csv',sep='_'))
kwh <- read_csv(paste('resources/data/AS2','KWH','2018.csv',sep='_'))
wifi <- read_csv(paste('resources/data/AS2','WIFI','2018.csv',sep='_'))
btu <- read_csv(paste('resources/data/AS2','BTU','2018.csv',sep='_'))
kwh <- read_csv(paste('resources/data/AS2','KWH','2018.csv',sep='_'))
wifi <- read_csv(paste('resources/data/AS2','WIFI','2018.csv',sep='_'))
View(btu)
wifi <- read_csv(paste('resources/data/AS2','WIFI','2018.csv',sep='_'))
btu <- read_csv(paste('resources/data/AS2','BTU','2018.csv',sep='_'))
kwh <- read_csv(paste('resources/data/AS2','KWH','2018.csv',sep='_'))
?read_csv
View(btu)
spec(...)
wifi_tidy <- gather(wifi,key = 'hour', value = "count", 2:ncol(wifi))
btu_tidy <- gather(btu, key = 'hour', value = "btu", 2:ncol(btu))
elec_tidy <- gather(kwh, key = 'hour', value = 'kwh', 2:ncol(kwh))
kwh_tidy <- gather(kwh, key = 'hour', value = 'kwh', 2:ncol(kwh))
library(tidyverse)
folder <- "data"
wifi <- read_csv(paste('resources/data/AS2','WIFI','2018.csv',sep='_'))
btu <- read_csv(paste('resources/data/AS2','BTU','2018.csv',sep='_'))
kwh <- read_csv(paste('resources/data/AS2','KWH','2018.csv',sep='_'))
wifi_tidy <- gather(wifi,key = 'hour', value = "count", 2:ncol(wifi))
btu_tidy <- gather(btu, key = 'hour', value = "btu", 2:ncol(btu))
kwh_tidy <- gather(kwh, key = 'hour', value = 'kwh', 2:ncol(kwh))
paste(kwh_tidy$date,kwh_tidy$hour)
library(tidyverse)
parse_datetime(paste(kwh_tidy$date,kwh_tidy$hour), "d m y h")
parse_date_time(paste(kwh_tidy$date,kwh_tidy$hour), "d m y h")
library(lubridate)
parse_date_time(paste(kwh_tidy$date,kwh_tidy$hour), "d m y h")
parse_date_time(paste(kwh_tidy$date,kwh_tidy$hour), "d m y H")
paste(kwh_tidy$date,kwh_tidy$hour)
View(kwh_tidy)
?gather
cooling_df <- data.frame(timestep=parse_date_time(paste(cooling_tidy$date,cooling_tidy$hour), "d m y H"),
cooling_btu = btu_tidy$btu)
wifi <- read_csv(paste('resources/data/AS2','WIFI','2018.csv',sep='_'))
cooling <- read_csv(paste('resources/data/AS2','BTU','2018.csv',sep='_'))
electricity <- read_csv(paste('resources/data/AS2','KWH','2018.csv',sep='_'))
wifi_tidy <- gather(wifi,key = 'hour', value = "count", 2:ncol(wifi))
cooling_tidy <- gather(btu, key = 'hour', value = "btu", 2:ncol(btu))
electricity_tidy <- gather(kwh, key = 'hour', value = 'kwh', 2:ncol(kwh))
wifi_df <- data.frame(timestep=parse_date_time(paste(wifi_tidy$date, wifi_tidy$hour), "d m y H"),
wifi_count = wifi_tidy$count)
cooling_df <- data.frame(timestep=parse_date_time(paste(cooling_tidy$date,cooling_tidy$hour), "d m y H"),
cooling_btu = btu_tidy$btu)
View(cooling_tidy)
View(cooling_df)
cooling_df <- data.frame(timestep=parse_date_time(paste(cooling_tidy$date,cooling_tidy$hour), "d m y H"),
cooling_btu = cooling_tidy$btu)
View(wifi_df)
parse_date_time(paste(wifi_tidy$date, wifi_tidy$hour), "d m y H")
wifi_df$timestep
wifi_df$timestep[1]
x=paste(wifi_tidy$date, wifi_tidy$hour)
View(x)
x<-parse_date_time(x)
x<-parse_date_time(x, 'd m y H')
View(x)
x[1]
print(x[1])
x
order(x)
x_sorted <- x[order(x)]
x_sorted
dat <- bind_rows(electricity_df, cooling_df, wifi_df, id='timestep')
wifi <- read_csv(paste('resources/data/AS2','WIFI','2018.csv',sep='_'))
cooling <- read_csv(paste('resources/data/AS2','BTU','2018.csv',sep='_'))
electricity <- read_csv(paste('resources/data/AS2','KWH','2018.csv',sep='_'))
wifi_tidy <- gather(wifi,key = 'hour', value = "count", 2:ncol(wifi))
cooling_tidy <- gather(btu, key = 'hour', value = "btu", 2:ncol(btu))
electricity_tidy <- gather(kwh, key = 'hour', value = 'kwh', 2:ncol(kwh))
wifi_df <- data.frame(timestep=parse_date_time(paste(wifi_tidy$date, wifi_tidy$hour), "d m y H"),
wifi_count = wifi_tidy$count)
cooling_df <- data.frame(timestep=parse_date_time(paste(cooling_tidy$date,cooling_tidy$hour), "d m y H"),
cooling_btu = cooling_tidy$btu)
electricity_df <- data.frame(timestep=parse_date_time(paste(electricity_tidy$date,electricity_tidy$hour), "d m y H"),
electricity_kwh = electricity_tidy$kwh)
dat <- bind_rows(electricity_df, cooling_df, wifi_df, id='timestep')
dat <- bind_rows(list(electricity_df, cooling_df, wifi_df), id='timestep')
wifi <- read_csv(paste('resources/data/AS2','WIFI','2018.csv',sep='_'))
cooling <- read_csv(paste('resources/data/AS2','BTU','2018.csv',sep='_'))
electricity <- read_csv(paste('resources/data/AS2','KWH','2018.csv',sep='_'))
wifi_tidy <- gather(wifi,key = 'hour', value = "count", 2:ncol(wifi))
cooling_tidy <- gather(btu, key = 'hour', value = "btu", 2:ncol(btu))
electricity_tidy <- gather(kwh, key = 'hour', value = 'kwh', 2:ncol(kwh))
wifi_df <- data.frame(timestep=parse_date_time(paste(wifi_tidy$date, wifi_tidy$hour), "d m y H"),
wifi_count = wifi_tidy$count)
cooling_df <- data.frame(timestep=parse_date_time(paste(cooling_tidy$date,cooling_tidy$hour), "d m y H"),
cooling_btu = cooling_tidy$btu)
electricity_df <- data.frame(timestep=parse_date_time(paste(electricity_tidy$date,electricity_tidy$hour), "d m y H"),
electricity_kwh = electricity_tidy$kwh)
dat <- bind_rows(electricity_df, cooling_df, wifi_df)
View(dat)
View(electricity_df)
View(elec_tidy)
View(wifi_df)
View(wifi_tidy)
paste(wifi_tidy$date, wifi_tidy$hour+1)
paste(wifi_tidy$date, as.numeric(wifi_tidy$hour)+1)
wifi_df <- data.frame(timestep=parse_date_time(paste(wifi_tidy$date, as.numeric(wifi_tidy$hour)+1), "d m y H"),
wifi_count = wifi_tidy$count)
View(wifi_df)
library(tidyverse)
library(lubridate)
folder <- "data"
wifi <- read_csv(paste('resources/data/AS2','WIFI','2018.csv',sep='_'))
cooling <- read_csv(paste('resources/data/AS2','BTU','2018.csv',sep='_'))
electricity <- read_csv(paste('resources/data/AS2','KWH','2018.csv',sep='_'))
wifi_tidy <- gather(wifi,key = 'hour', value = "count", 2:ncol(wifi))
cooling_tidy <- gather(btu, key = 'hour', value = "btu", 2:ncol(btu))
electricity_tidy <- gather(kwh, key = 'hour', value = 'kwh', 2:ncol(kwh))
wifi_df <- data.frame(timestep=parse_date_time(paste(wifi_tidy$date, as.numeric(wifi_tidy$hour)+1), "d m y H"),
wifi_count = wifi_tidy$count)
cooling_df <- data.frame(timestep=parse_date_time(paste(cooling_tidy$date,as.numeric(cooling_tidy$hour)+1), "d m y H"),
cooling_btu = cooling_tidy$btu)
electricity_df <- data.frame(timestep=parse_date_time(paste(electricity_tidy$date,as.numeric(electricity_tidy$hour)+1), "d m y H"),
electricity_kwh = electricity_tidy$kwh)
dat <- bind_rows(electricity_df, cooling_df, wifi_df, id='timestep')
dat <- bind_rows(electricity_df, cooling_df, wifi_df)
View(dat)
one <- mtcars[1:4, ]
two <- mtcars[11:14, ]
View(one)
View(two)
bind_rows(one, two)
one
two
dat <- bind_cols(electricity_df, cooling_df, wifi_df, id='timestep')
dat <- full_join(electricity_df, cooling_df, wifi_df, id='timestep')
dat <- full_join(electricity_df, cooling_df, wifi_df, by='timestep')
View(dat)
dat <- full_join(list(electricity_df, cooling_df, wifi_df), by='timestep')
dat <- full_join(list(electricity_df, cooling_df, wifi_df), by='timestep', type='full')
library(plyr)
dat <- full_join(list(electricity_df, cooling_df, wifi_df), by='timestep', type='full')
dat <- join_all(list(electricity_df, cooling_df, wifi_df), by='timestep', type='full')
View(dat)
dat <- dat[order(dat$timestep),]
View(dat)
setwd("~/Documents/GitHub/occupant-calibration")
library(eplusr)
path_resources <- paste(getwd(), "resources","idf", sep = '/')
# idf for large reference building with occupancy schedule based on LBNL occupancy simulator
path_idf <- file.path(path_resources, "AS2.idf")
library(eplusr)
path_resources <- paste(getwd(), "resources","idf", sep = '/')
# idf for large reference building with occupancy schedule based on LBNL occupancy simulator
path_idf <- file.path(path_resources, "AS2.idf")
path_idf
source('~/Documents/GitHub/occupant-calibration/run_sim.R', echo=TRUE)
idf <- read_idf(path_idf)
path_idf
path_resources <- paste(getwd(), "resources", sep = '/')
# idf for large reference building with occupancy schedule based on LBNL occupancy simulator
path_idf <- file.path(path_resources, "idf/AS2.idf")
idf <- read_idf(path_idf)
epw <- read_epw(path_epw)