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
)

Arguments

observations

A 3-dimensional array for observations.

observation.times

The time of each observation. The length of times should equal the thrid dimension of observations.

forecast.times

The initial time for forecasts that you want to align observations with.

flts

The offset time in seconds that you want to align observations with.

return.na.index

Whether to return the NA index.

show.progress

A logical for whether to show the progress bar.

silent

No printing warning messages.

Value

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.

Details

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.

Author

Weiming Hu weiming@psu.edu