Skip to contents

Computes cross-correlations for all unique station pairs.

Usage

analyze_station_pairs(data, variable = "wave_height", max_lag = 48)

Arguments

data

Data frame with columns: time, station_id, and the variable

variable

Variable to analyze (default: "wave_height")

max_lag

Maximum lag in hours (default: 48)

Value

Data frame with one row per station pair containing:

  • station1, station2: station pair

  • distance_km: distance between stations

  • optimal_lag: lag with max correlation

  • max_correlation: correlation at optimal lag

  • expected_lag: expected lag based on wave propagation (~30 km/h)

Examples

if (FALSE) { # \dontrun{
data <- data.frame(
  time = rep(seq(as.POSIXct("2024-01-01"), by = "hour", length.out = 100), 2),
  station_id = rep(c("M2", "M3"), each = 100),
  wave_height = c(rnorm(100, 3, 1), rnorm(100, 2.5, 0.8))
)
analyze_station_pairs(data)
} # }