From 5cd7f2053f29a8d6a66b2eeda3ecc003ca4a7d4a Mon Sep 17 00:00:00 2001 From: Alexander Barth Date: Thu, 4 Jul 2024 09:38:29 +0200 Subject: [PATCH] add PhysOcean.rayleigh_criterion --- src/tides.jl | 27 +++++++++++++++++++++++++++ test/test_tides.jl | 12 ++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/tides.jl b/src/tides.jl index 564065e..d5070a8 100644 --- a/src/tides.jl +++ b/src/tides.jl @@ -99,3 +99,30 @@ function ep2ap(semimajor, eccentricity, inclination, phase) end export ep2ap + +""" + Tmin = PhysOcean.rayleigh_criterion(f1,f2) + +Compute the minimum duration `Tmin` to separate the frequency `f1` and `f2` +following the Rayleigh criterion. +`Tmin` has the inverse of the units of `f1` and `f2`. + +For example to resolve the M2 and S2 tides, the duration of the time series has +to be at least 14.765 days: + +``` +using PhysOcean +f_M2 = 12.4206 # h⁻¹ +f_S2 = 12 # h⁻¹ +Tmin = PhysOcean.rayleigh_criterion(f_M2,f_S2) +Tmin/24 +# output 14.765 +``` + +Reference: + +Bruce B. Parker, [Tidal Analysis and Prediction](https://web.archive.org/web/20240626033634/https://tidesandcurrents.noaa.gov/publications/Tidal_Analysis_and_Predictions.pdf), NOAA Special Publication NOS CO-OPS 3, page 84 +""" +function rayleigh_criterion(f₁,f₂) + 1/abs(1/f₁-1/f₂) +end diff --git a/test/test_tides.jl b/test/test_tides.jl index a4d393f..d85453f 100644 --- a/test/test_tides.jl +++ b/test/test_tides.jl @@ -32,3 +32,15 @@ amplitude_u2,phase_u2,amplitude_v2,phase_v2 = ep2ap(semimajor, eccentricity, inc @test amplitude_v ≈ amplitude_v2 @test phase_u ≈ phase_u2 @test phase_v ≈ phase_v2 + + + +# page 82 from +# https://web.archive.org/web/20240626033634/https://tidesandcurrents.noaa.gov/publications/Tidal_Analysis_and_Predictions.pdf + +f_M2 = 12.4206 +f_S2 = 12 +Tmin = PhysOcean.rayleigh_criterion(f_M2,f_S2) + +# Table 3.1 +@test Tmin/24 ≈ 14.765 atol=0.001