RAnEnExtra::plotAnalogTimeSeries plots forecasts and observations for comparison over time.

plotAnalogTimeSeries(
  start.time,
  end.time,
  i.station,
  obs.id = NULL,
  obs.times = NULL,
  obs.data = NULL,
  anen.times,
  anen.flts,
  anen.data,
  fcst.id = NULL,
  fcst.times = NULL,
  fcst.flts = NULL,
  fcst.data = NULL,
  max.flt = 82800,
  origin = "1970-01-01",
  tz = "UTC",
  y.lab = "",
  return.data = F,
  legend.names = c(anen = "AnEn median", obs = "Observations", fcst = "Forecasts"),
  color.func.line = ggplot2::scale_color_brewer("", palette = "Dark2"),
  color.func.shade = ggplot2::scale_fill_manual("", values = c(`AnEn range` =
    "lightgrey", `AnEn 25% ~ 75%` = "lightblue"))
)

Arguments

start.time

A POSIXct for the start time.

end.time

A POSIXct for the end time.

i.station

The station index to visualize. This can be a single scalar so that the same station index for observations, AnEn, and forecasts is used; or it can be a named vector like this: i.station = c('obs' = 4, 'anen' = 15, 'fcst' = 10) or i.station = c('obs' = 4, 'anen' = 15).

obs.id

The observation parameter ID.

obs.times

A vector for observation times. Usually this is observations$Times.

obs.data

An array for observation data. Usually this is observations$Data.

anen.times

A vector for AnEn test times.

anen.flts

A vector for AnEn flts.

anen.data

An 4-dimensional array for analogs.

fcst.id

The forecast parameter ID.

fcst.times

A vector for forecast times. Usually this is forecasts$Times.

fcst.flts

A vector for forecast flts. Usually this is forecasts$flts.

fcst.data

An array for forecast data. Usually this is forecasts$Data.

max.flt

The cut off point value for both forecasts and AnEn lead times.

origin

The origin for as.POSIXct

tz

The tz for as.POSIXct

y.lab

The variable name to be shown on figures.

return.data

Whether to return the plot data so that you can generate your own plots. This will suppress plotting the figure inside this function.

legend.names

The names to use in the legend. It must be a named vector.

color.func.line

The ggplot function to use for coloring lines.

color.func.shade

The ggplot function to use for coloring shades.

Value

If return.data is TRUE, a list with two data frames is returned; otherwise, it returns a ggplot object.

Details

Sometimes, it is helpful to plot forecasts and observations for a long time series. However, this is always limited by forecast lead times because the lead times are usually for several days. What if we want to plot a time series that spans longer than that?

This function generates a plot for that purpose. It simply stacks forecasts from different days and all forecasts lead times. Overlapping lead times will be cut off and earlier lead times will be preferred and kept.