This is a helper function that aligns the observations with the dimension format of a forecast for convenience of statistical analysis.
alignObservations(
observations,
observation.times,
forecast.times,
flts,
return.na.index = F,
show.progress = F,
silent = T
)
A 3-dimensional array for observations.
The time of each observation. The length of times should equal the thrid dimension of observations.
The initial time for forecasts that you want to align observations with.
The offset time in seconds that you want to align observations with.
Whether to return the NA index.
A logical for whether to show the progress bar.
No printing warning messages.
If return.na.index is false, by default, it retuns the aligned observations; otherwise, it returns a list with the aligned observations and a index matrix for which pair of forecast time/FLT could not be found in observation times provided.
For example, forecasts are usually 4-dimensional and observations are only 3-dimensional. Forecasts have one extra dimension, FLTs, than observations. This function converts the dimensions of observations to forecasts and artificially add the FLTs dimension to observations by replicating values in observations.
Imagine the following sequence of observation times
00h 06h 12h 18h 24h 30h 36h 42h 48h 54h
After the alignment with the daily forecasts with 6 FLTs, the aligned observations will be
00h 06h 12h 18h 24h 30h
24h 30h 36h 42h 48h 54h
You note that there will be duplicates in observations which cannot be avoided in this format.