Description Usage Arguments Details Value See Also Examples
View source: R/sliding_window.R
This function allows to expand the time data series to include adjacent time steps and days, using a sliding window. The procedure is used to shift the variable generation time series, so calculations are not limited to the observed load and variable generation pairs. The objective is to further explore how the variable behaviour of these generators affect reliability calculations.
1 2 | sliding_window(time.data, win.h.size = NULL, win.h.weight = NULL,
win.d.size = NULL, win.d.weight = NULL)
|
time.data |
Time series data formatted with |
win.h.size |
Vector to determine the size of the window for adjacent time steps |
win.h.weight |
Weights associated with adjacent hours |
win.d.size |
Vector to determine the size of the window for adjacent days |
win.d.weight |
Weights associated with adjacent days |
The sliding window can include adjacent time steps (typically adjacent hours) and/or adjacent days. Table 1 shows and example, with the current hour being hour 6 in day 5. If an hour is withing the extent of the sliding window it is marked with an x.
Table 1: Example of sliding window
| H1 | H2 | H3 | H4 | H5 | H6 | H7 | H8 | H9 | H10 | |
| Day 1 | ||||||||||
| Day 2 | ||||||||||
| Day 3 | x | x | x | x | x | x | x | |||
| Day 4 | x | x | x | x | x | x | x | |||
| Day 5 | x | x | x | Current | x | x | x | |||
| Day 6 | x | x | x | x | x | x | x | |||
| Day 7 | x | x | x | x | x | x | x | |||
| Day 8 | ||||||||||
| Day 9 |
win.h.size determines how many adjacent time steps are included in the sliding window. By default, the window
only includes the current hour. If specified, win.h.size must be a numeric vector with 2 values.
Similarly, win.d.size determines how many adjacent days are used in the window and defaults to the current day.
If defined, it must be a vector with 2 integers.
For example, to reproduce the window in Table 1 set:
win.h.size = c(-3, 3)
win.d.size = c(-2, 2)
By default, all the data points in the sliding window are given the same probability in the calculations. It is possible
to provide different weights to adjacent hours and adjacent days. This is achieved by using the wind.h.weight and
wind.d.weight parameters, respectively. The lengths of these needs to be consistent with the corresponding sizes
parameters. Table 2 shows an example of how the final weights are calculated, by
setting:
wind.h.weight = c(0.1, 0.1, 0.2, 0.2, 0.2, 0.1, 0.1)
wind.d.weight = c(0.1, 0.2, 0.4, 0.2 0.1)
Figure 2: Example of sliding window with different weights
| H1 | H2 | H3 | H4 | H5 | H6 | H7 | H8 | H9 | H10 | Day weight | |
| Day 1 | |||||||||||
| Day 2 | |||||||||||
| Day 3 | 0.01 | 0.01 | 0.02 | 0.02 | 0.02 | 0.01 | 0.01 | 0.1 | |||
| Day 4 | 0.02 | 0.02 | 0.04 | 0.04 | 0.04 | 0.02 | 0.02 | 0.2 | |||
| Day 5 | 0.04 | 0.04 | 0.08 | 0.08 | 0.08 | 0.04 | 0.04 | 0.4 | |||
| Day 6 | 0.02 | 0.02 | 0.04 | 0.04 | 0.04 | 0.02 | 0.02 | 0.2 | |||
| Day 7 | 0.01 | 0.01 | 0.02 | 0.02 | 0.02 | 0.01 | 0.01 | 0.1 | |||
| Day 8 | |||||||||||
| Day 9 | |||||||||||
| Hour weight | 0.1 | 0.1 | 0.2 | 0.2 | 0.2 | 0.1 | 0.1 |
Use of a sliding window is currently an open area of research. The authors suggest to use it as a sensitivitiy tool, especially when only a few years of data is available. Special care should be taken with solar data. Because of its daily pattern, a window with too many adjacent hours could return erroneous results.
A vignette in the package presents some additional examples and graphs for the use of this function. It can
be accessed with browseVignettes("sliding_window").
An expanded data frame with the same format as data.time, but with a sliding window applied to the
variable generation columns
format_timedata to create the time.data object
This function is called from calculate_metrics and calculate_elcc
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # Create time data object
tdata <- data.frame(Area = c(rep("A", 48), rep("B", 48)),
Time = 1:48,
Load = c(runif(48, 200, 250), runif(48, 400, 450)),
Wind = c(runif(48, 20, 25), runif(48, 40, 45)))
td <- format_timedata(tdata)
head(td)
# If no data is provided, results remain intact
td2 <- sliding_window(td)
# Expand data for adjacent time steps (with equal and different weights)
td3 <- sliding_window(td, win.h.size = c(-1, 1))
td4 <- sliding_window(td, win.h.size = c(-1, 1), win.h.weight = c(1, 2, 1))
# Expand data for ajdacent days
td5 <- sliding_window(td, win.d.size = c(0, 1))
# Expand data for both adjacent times and days
td6 <- sliding_window(td, win.h.size = c(-1, 1), win.d.size = c(0, 1))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.