rdd_to_load: Format RddFile Object to Standard Input for 'Idf$load()'...

View source: R/rdd.R

rdd_to_loadR Documentation

Format RddFile Object to Standard Input for Idf$load() Method

Description

rdd_to_load() and mdd_to_load() takes a RddFile and MddFile object respectively and format it into a data.table in acceptable format for ⁠$load()⁠ method in Idf class.

Usage

rdd_to_load(rdd, key_value, reporting_frequency)

mdd_to_load(
  mdd,
  reporting_frequency,
  class = c("Output:Meter", "Output:Meter:MeterFileOnly", "Output:Meter:Cumulative",
    "Output:Meter:Cumulative:MeterFileOnly")
)

Arguments

rdd, mdd

A RddFile object created using read_rdd() and a MddFile object created using read_mdd(), respectively.

key_value

Key value name for all variables. If not specified and the key_value column in the input RddFile object will be used. If key_value column does not exist, "*" are used for all variables.

reporting_frequency

Variable value reporting frequency for all variables. If not specified and the reporting_freqency column in the input RddFile object will be used. If reporting_freqency column does not exist, "Timestep" are used for all variables. All possible values: "Detailed", "Timestep", "Hourly", "Daily", "Monthly", "RunPeriod", "Environment", and "Annual".

class

Class name for meter output. All possible values: "Output:Meter", "Output:Meter:MeterFileOnly", "Output:Meter:Cumulative", and "Output:Meter:Cumulative:MeterFileOnly". Default: "Output:Meter".

Value

A data.table with 5 columns with an additional attribute named eplus_version extracted from the original RddFile and MddFile:

  • id: Integer type. Used to distinguish each object definition.

  • class: Character type. Class names, e.g. Output:Variable and Output:Meter.

  • index: Integer type. Field indices.

  • field: Character type. Field names.

  • value: Character type. The value of each field to be added.

Examples

## Not run: 
# read an example distributed with eplusr
path_idf <- system.file("extdata/1ZoneUncontrolled.idf", package = "eplusr")
idf <- read_idf(path_idf)

# run Design-Day-Only simulation silently
job <- idf$run(NULL, tempdir(), echo = FALSE)

# read RDD and MDD
rdd <- job$read_rdd()
mdd <- job$read_mdd()

# perform subsetting on the variables
# e.g.:
rdd_sub <- rdd[grepl("Site", variable)]
mdd_sub <- mdd[grepl("Electricity", variable)]

# use newly added helper `rdd_to_load()` and `mdd_to_load()` and `$load()` to
# add `Output:Variable` and `Output:Meter*`
idf$load(rdd_to_load(rdd_sub))
idf$load(mdd_to_load(mdd_sub))

# default `Key Value` is `"*"` and `Reporting Frequency` is `Timestep`
# can overwrite using `key_value` and `reporting_freqency` arg
rdd_to_load(rdd_sub, key_value = "Environment", reporting_frequency = "hourly")

# if input has column `key_value`, default is to use it, unless `key_value` is
# explicitly specified
rdd_to_load(rdd_sub[, key_value := "Environment"])
rdd_to_load(rdd_sub[, key_value := "Environment"], key_value = "*")

# `reporting_frequency` arg works in the same way as `key_value` arg, i.e.:
# if input has column `reporting_frequency`, use it, unless
# `reporting_frequency` is explicitly specified
rdd_to_load(rdd_sub[,  reporting_frequency := "monthly"])
rdd_to_load(rdd_sub[,  reporting_frequency := "monthly"], reporting_frequency = "detailed")

# if input has column `key_value`, default is to use it, unless `key_value` is
# explicitly specified
rdd_to_load(rdd_sub[, key_value := "Environment"])
rdd_to_load(rdd_sub[, key_value := "Environment"], key_value = "*")

# meter class can be further specified using `class` arg
mdd_to_load(mdd_sub, class = "Output:Meter:MeterFileOnly")

## End(Not run)

eplusr documentation built on Aug. 25, 2023, 5:18 p.m.