Created
March 15, 2022 02:08
-
-
Save hongyuanjia/ff4960c3fce9ad344f84f2a384eca19f to your computer and use it in GitHub Desktop.
Construct an EnergyPlus `Schedule:Day:List` object using external CSV
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
library(eplusr) | |
# construct a fake schedule CSV file with 15 min interval and random values | |
interval <- 15 | |
fake_data <- data.frame( | |
time = seq( | |
as.POSIXct("2020-03-15 00:15:00"), | |
by = "15 mins", | |
length.out = 24 * (60 / interval) | |
), | |
value = round(runif(24 * (60 / interval)), 2) | |
) | |
path_csv <- tempfile(fileext = ".csv") | |
write.csv(fake_data, path_csv, row.names = FALSE) | |
# read the CSV in | |
data <- read.csv(path_csv) | |
# use the example model distributed with EnergyPlus v8.8 for illustration | |
path <- path_eplus_example(8.8, "1ZoneUncontrolled.idf") | |
idf <- read_idf(path) | |
# add an empty Schedule:Day:List object | |
sch <- idf$add(Schedule_Day_List = list("MySchedule", "Fraction", ..4 = interval))[[1]] | |
# extract the values of 1-4 fields into a list | |
val <- sch$value(1:4) | |
# combine the original field values together with your schedule data | |
sch$set(c(val, data$val)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment