Skip to content

Schedules and Profiles

Housing Stock Energy Hub edited this page Nov 13, 2019 · 2 revisions

The algorithm employed to generate profiles is further described in


Example

The following example selects a device and generates its corresponding profile multiple times.

In brief, the comparison is made to understand how the generated values may be different, but with similar distribution.

.

Firstly, in addition to the standard EnHub set-up, some extra variables are defined:

  path.Store <- <folder-path>   # Folder to store the outputs of the example (eg. "~/Desktop/")
  noProfiles <- 6               # Number of profiles/days to compare
 itemProfile <- "kitchenapps"   # Chosen device for the comparison

Then, a previously generated schedule is loaded, which is located in myData/UKHEFF.

Additionally, the function fnUsrIntensity is used to potentially scale the referential profile, which increases or decreases its corresponding intensity.

tbl_ScheduleFixed_UKHEFF <-
  read.csv("myData/UKHEFF/tbl_ScheduleFixed_UKHEFF.csv")
tbl_ScheduleFixed_UKHEFF$X <- NULL
tbl_ScheduleFixed_UKHEFF[,2:26] <-
  data.frame(mapply(`*`,tbl_ScheduleFixed_UKHEFF[,2:26],
                    fnUsrIntensity(.is.EUIntensity)))

For the example, we want to extract only one profile in one single period. Therefore, we combine dtaGetOneColumn and lapply to perform such a double iteration. The result is similar to employing a double for loop, but faster.

dtaGetOneColumn <- function(i, dataFromList, period, column) {
  dtalist <- dataFromList[[i]][period, column]
  return(dtalist)
}

dtaDemonstration <- lapply(1:noProfiles,
                           dtaGetOneColumn,
                           lapply(1:noProfiles,
                                  fnMakeScheduleHighResolution),
                                  1:(24 * 7),
                                  itemProfile)

dtaDemonstration <- ldply(dtaDemonstration, data.frame)
colnames(dtaDemonstration) <- c("value")
dtaDemonstration$group <- rep(1:noProfiles, each = (24 * 7))
dtaDemonstration$time <- tbl.EnHub.Period$Hour[1:(24 * 7)]

This is the resulting dataset:

          value group                time
     1: 0.03915     1 2014-01-01 00:00:00
     2: 0.03951     1 2014-01-01 01:00:00
     3: 0.04337     1 2014-01-01 02:00:00
     4: 0.04356     1 2014-01-01 03:00:00
     5: 0.04356     1 2014-01-01 04:00:00
    ---                                  
  1004: 0.04356     6 2014-01-07 19:00:00
  1005: 0.04337     6 2014-01-07 20:00:00
  1006: 0.04246     6 2014-01-07 21:00:00
  1007: 0.03915     6 2014-01-07 22:00:00
  1008: 0.03915     6 2014-01-07 23:00:00

For clarity, we generate a couple of graphics:

g1 <- ggplot(dtaDemonstration,
                aes(x = time, y = value, colour = group, group = group)) +
             geom_line(size = 0.4) + facet_wrap(~group) +
             theme_minimal() + scale_color_distiller(palette = "RdBu") +
             theme(legend.position = "none", axis.title.x = element_blank())

g2 <- ggplot(dtaDemonstration,
                aes(x = value, fill = as.factor(group))) +
             geom_density(aes(y = ..count..), alpha=0.75) +
             theme_minimal() + scale_fill_brewer(palette = "RdBu") +
             theme(legend.position="none", axis.title.x=element_blank())