View source: R/get_schaake_shuffle_dates.R
get_schaake_shuffle_dates | R Documentation |
This function identifies sequential observations that do not contain missing data and could be used in the Schaake shuffle.
get_schaake_shuffle_dates(datetime_vec, window, init_times, by = "hours", ...)
datetime_vec |
A vector of dates corresponding to all the observations. These should be in the date form of '"%Y-%m-%d %H:%M:%S"'. |
window |
The length of the forecast window. This input must be specified as a lubridate object. For example, 'hours(48)' or 'days(2)'. |
init_times |
A vector containing strings with the forecast initialisation times. For example, 'c("00")' or 'c("00", "12")'. These strings are converted to numeric variables internally by the function. |
by |
The timestep of your weather forecast, eg '"hours"', '"6 hours"', '"days"'. This argument can by any increment that can be used to step between two date objects in 'seq()'. |
When there is missing data some sequences of dates will not be suitable for use in the Schaake shuffle. Individual users may choose to interpolate the missing values. For simplicity, this function identifies suitable dates that do not contain missing values.
A vector of dates of the form '"%Y-%m-%d %H:%M:%S"' that correspond to historical dates that can be used in the Schaake shuffle.
Kate Saunders and Kirien Whan
Clark, Martyn, et al. "The Schaake shuffle: A method for reconstructing space–time variability in forecasted precipitation and temperature fields." Journal of Hydrometeorology 5.1 (2004): 243-262.
datetime_vec = seq(as.POSIXct("2023-01-01 00:00:00"), as.POSIXct("2023-01-10 12:00:00"), by = "hours")
datetime_vec[days(datetime_vec) == 5] = NA
get_schaake_shuffle_dates(datetime_vec, days(1), init_times = "00")
get_schaake_shuffle_dates(datetime_vec, days(2), init_times = "00")
get_schaake_shuffle_dates(datetime_vec, days(1), init_times = c("00", "12"))
get_schaake_shuffle_dates(datetime_vec, days(1), init_times = c("00", "12"), by = "6 hours")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.