@@ -3374,13 +3374,13 @@ def test_extreme_float(self):
33743374 vals = np .ones ((len (freq ), len (dirs )))
33753375 spectrum = wr .DirectionalSpectrum (freq , dirs , vals , freq_hz = True , degrees = True )
33763376
3377- sigma = spectrum .std ()
3378- tz = spectrum .tz
3379-
33803377 T = 360 * 24 * 60.0 ** 2
33813378 q = 0.99
33823379 extreme_out = spectrum .extreme (T , q = q )
33833380
3381+ sigma = spectrum .std ()
3382+ tz = spectrum .tz
3383+
33843384 extreme_expect = sigma * np .sqrt (2.0 * np .log ((T / tz ) / np .log (1.0 / q )))
33853385
33863386 assert extreme_out == pytest .approx (extreme_expect )
@@ -3394,13 +3394,13 @@ def test_extreme_list(self):
33943394 vals = np .ones ((len (freq ), len (dirs )))
33953395 spectrum = wr .DirectionalSpectrum (freq , dirs , vals , freq_hz = True , degrees = True )
33963396
3397- sigma = spectrum .std ()
3398- tz = spectrum .tz
3399-
34003397 T = 360 * 24 * 60.0 ** 2
34013398 q = [0.1 , 0.5 , 0.99 ]
34023399 extreme_out = spectrum .extreme (T , q = q )
34033400
3401+ sigma = spectrum .std ()
3402+ tz = spectrum .tz
3403+
34043404 extreme_expect = [
34053405 sigma * np .sqrt (2.0 * np .log ((T / tz ) / np .log (1.0 / q [0 ]))),
34063406 sigma * np .sqrt (2.0 * np .log ((T / tz ) / np .log (1.0 / q [1 ]))),
@@ -3418,16 +3418,38 @@ def test_extreme_mpm(self):
34183418 vals = np .ones ((len (freq ), len (dirs )))
34193419 spectrum = wr .DirectionalSpectrum (freq , dirs , vals , freq_hz = True , degrees = True )
34203420
3421- sigma = spectrum .std ()
3422- tz = spectrum .tz
3423-
34243421 T = 360 * 24 * 60.0 ** 2
34253422 extreme_out = spectrum .extreme (T , q = 0.37 )
34263423
3424+ sigma = spectrum .std ()
3425+ tz = spectrum .tz
3426+
34273427 extreme_expect = sigma * np .sqrt (2.0 * np .log (T / tz ))
34283428
34293429 assert extreme_out == pytest .approx (extreme_expect , rel = 1e-3 )
34303430
3431+ def test_extreme_absmax (self ):
3432+ f0 = 0.0
3433+ f1 = 2.0
3434+
3435+ freq = np .linspace (f0 , f1 , 20 )
3436+ dirs = np .arange (5 , 360 , 10 )
3437+ vals = np .ones ((len (freq ), len (dirs )))
3438+ spectrum = wr .DirectionalSpectrum (freq , dirs , vals , freq_hz = True , degrees = True )
3439+
3440+ T = 360 * 24 * 60.0 ** 2
3441+ q = 0.99
3442+ extreme_out = spectrum .extreme (T , q = q , absmax = True )
3443+
3444+ sigma = spectrum .std ()
3445+ tz_absmax = spectrum .tz / 2.0
3446+
3447+ extreme_expect = sigma * np .sqrt (
3448+ 2.0 * np .log ((T / tz_absmax ) / np .log (1.0 / q ))
3449+ )
3450+
3451+ assert extreme_out == pytest .approx (extreme_expect )
3452+
34313453
34323454class Test_WaveSpectrum :
34333455 def test__init__ (self ):
0 commit comments