Skip to contents

Filters forecast data for wind speeds at or above the storm threshold. Threshold is resolved in order: threshold_knots parameter, then STORM_ALERT_THRESHOLD_KNOTS env var, then default of 41 knots (Beaufort 9).

Usage

detect_storm_events(forecasts, threshold_knots = NULL, use_gusts = FALSE)

Arguments

forecasts

Tibble from fetch_all_forecasts() or fetch_open_meteo_forecast().

threshold_knots

Numeric threshold in knots (default NULL, uses env var or 41).

use_gusts

Logical; if TRUE, also flag rows where gusts exceed threshold. Default FALSE — only sustained wind speed triggers alerts.

Value

Tibble with columns: station_id, time, wind_speed_kn, wind_gust_kn, beaufort, description, is_gust_driven. Empty tibble if no storms detected.

Examples

forecasts <- tibble::tibble(
  station_id = "M2",
  time = Sys.time() + 3600 * 1:3,
  wind_speed_kn = c(20, 38, 50),
  wind_gust_kn = c(25, 45, 60)
)
detect_storm_events(forecasts)
#> # A tibble: 1 × 7
#>   station_id time                wind_speed_kn wind_gust_kn beaufort description
#>   <chr>      <dttm>                      <dbl>        <dbl>    <int> <chr>      
#> 1 M2         2026-04-09 15:12:08            50           60       10 Storm      
#> # ℹ 1 more variable: is_gust_driven <lgl>