You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.2 KiB
Python
29 lines
1.2 KiB
Python
10 years ago
|
from numpy.testing import (run_module_suite, assert_equal,
|
||
10 years ago
|
assert_array_almost_equal)
|
||
|
# assert_almost_equal, assert_array_equal)
|
||
10 years ago
|
import wafo.spectrum.models as sm
|
||
10 years ago
|
# from wafo.covariance import CovData1D
|
||
|
|
||
10 years ago
|
|
||
|
def test_covariance():
|
||
|
Sj = sm.Jonswap()
|
||
10 years ago
|
S = Sj.tospecdata() # Make spec
|
||
10 years ago
|
R = S.tocovdata()
|
||
10 years ago
|
dt = R.sampling_period()
|
||
|
assert_equal(dt, 1.0471975511965976)
|
||
|
S1 = R.tospecdata()
|
||
|
assert_array_almost_equal(S.data[:10], S1.data[:10], 11)
|
||
|
x = R.sim(ns=1000, dt=0.2, iseed=0)
|
||
|
assert_array_almost_equal(x[:10, 0], [0.0, 1.04719755, 2.0943951,
|
||
|
3.14159265, 4.1887902, 5.23598776,
|
||
|
6.28318531, 7.33038286, 8.37758041,
|
||
|
9.42477796], decimal=3)
|
||
|
assert_array_almost_equal(x[:10, 1], [0.22155905, 1.21207066, 1.95670282,
|
||
|
2.11634902, 1.57967273, 0.2665005,
|
||
|
-0.79630253, -1.31908028,
|
||
|
-2.20056021, -1.84451748], decimal=3)
|
||
|
|
||
10 years ago
|
|
||
|
if __name__ == '__main__':
|
||
|
run_module_suite()
|