Пример #1
0
 def test1_TKDE1D(self):
     data = self.data
     x = np.linspace(0.01, max(data) + 1, 10)
     kde = wk.TKDE(data, hs=0.5, L2=0.5)
     f = kde(x)
     assert_allclose(f, [
         1.03982714, 0.45839018, 0.39514782, 0.32860602, 0.26433318,
         0.20717946, 0.15907684, 0.1201074, 0.08941027, 0.06574882
     ])
     f = kde.eval_points(x)
     assert_allclose(f, [
         1.03982714, 0.45839018, 0.39514782, 0.32860602, 0.26433318,
         0.20717946, 0.15907684, 0.1201074, 0.08941027, 0.06574882
     ])
     f = kde.eval_grid(x)
     assert_allclose(f, [
         1.03982714, 0.45839018, 0.39514782, 0.32860602, 0.26433318,
         0.20717946, 0.15907684, 0.1201074, 0.08941027, 0.06574882
     ])
     assert_allclose(np.trapz(f, x), 0.94787730659349068)
     f = kde.eval_grid_fast(x)
     assert_allclose(f, [
         1.0401892415290148, 0.45838973393693677, 0.39514689240671547,
         0.32860531818532457, 0.2643330110605783, 0.20717975528556506,
         0.15907696844388747, 0.12010770443337843, 0.08941129458260941,
         0.06574899139165799
     ])
     assert_allclose(np.trapz(f, x), 0.9479438058416647)
Пример #2
0
plt.show()
#disp('Block = 4'),pause(pstate)

## Section 5.2 Generalized Pareto and Extreme Value distributions
## Section 5.2.1 Generalized Extreme Value distribution

# Empirical distribution of significant wave-height with estimated
# Generalized Extreme Value distribution,
gev = ws.genextreme.fit2(Hs)
gev.plotfitsummary()
# wafostamp([],'(ER)')
# disp('Block = 5a'),pause(pstate)

plt.clf()
x = np.linspace(0, 14, 200)
kde = wk.TKDE(Hs, L2=0.5)(x, output='plot')
kde.plot()
plt.hold(True)
plt.plot(x, gev.pdf(x), '--')
# disp('Block = 5b'),pause(pstate)

# Analysis of yura87 wave data.
# Wave data interpolated (spline) and organized in 5-minute intervals
# Normalized to mean 0 and std = 1 to get stationary conditions.
# maximum level over each 5-minute interval analysed by GEV
xn = wd.yura87()
XI = np.r_[1:len(xn):0.25] - .99
N = len(XI)
N = N - np.mod(N, 4 * 60 * 5)

YI = si.interp1d(xn[:, 0], xn[:, 1], kind='linear')(XI)
Пример #3
0
import wafo.spectrum.models as wsm
xx = wd.sea()
xx[:, 1] = ss.detrend(xx[:, 1])
ts = wo.mat2timeseries(xx)
Tcrcr, ix = ts.wave_periods(vh=0, pdef='c2c', wdef='tw', rate=8)
Tc, ixc = ts.wave_periods(vh=0, pdef='u2d', wdef='tw', rate=8)

#! Histogram of crestperiod compared to the kernel density estimate
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import wafo.kdetools as wk
plt.clf()
print(Tc.mean())
print(Tc.max())

t = np.linspace(0.01, 8, 200)
ftc = wk.TKDE(Tc, L2=0, inc=128)

plt.plot(t, ftc.eval_grid(t), t, ftc.eval_grid_fast(t), '-.')
wm.plot_histgrm(Tc, normed=True)
plt.title('Kernel Density Estimates')
plt.xlabel('Tc [s]')
plt.axis([0, 8, 0, 0.5])
plt.show()

#! Extreme waves - model check: the highest and steepest wave
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
plt.clf()
S, H = ts.wave_height_steepness(kind=0)
indS = S.argmax()
indH = H.argmax()
ts.plot_sp_wave([indH, indS], 'k.')
Пример #4
0
import wafo.objects as wo
xx = wd.sea() 
xx[:,1] = wm.detrend(xx[:,1])
ts = wo.mat2timeseries(xx)
Tcrcr, ix = ts.wave_periods(vh=0, pdef='c2c', wdef='tw', rate=8)
Tc, ixc = ts.wave_periods(vh=0, pdef='u2d', wdef='tw', rate=8)
 
#! Histogram of crestperiod compared to the kernel density estimate
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import wafo.kdetools as wk
clf()
print(Tc.mean())
print(Tc.max())

t = linspace(0.01,8,200);
ftc = wk.TKDE(Tc, L2=0, inc=128)

plot(t,ftc.eval_grid(t), t, ftc.eval_grid_fast(t),'-.') 
wm.plot_histgrm(Tc,normed=True)
title('Kernel Density Estimates')
axis([0, 8, 0, 0.5])
show() 
 
#! Extreme waves - model check: the highest and steepest wave
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clf()
S, H = ts.wave_height_steepness(method=0)
indS = S.argmax()
indH = H.argmax()
ts.plot_sp_wave([indH, indS],'k.')
show()