Example #1
0
plt.subplot(122),
mM.plot()
plt.title('min-max cycle pairs')
plt.subplot(121),
mM_rfc.plot()
plt.title('Rainflow filtered cycles')
plt.show()

#! Min-max and rainflow cycle distributions
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import wafo.misc as wm
ampmM_sea = mM.amplitudes()
ampRFC_sea = mM_rfc.amplitudes()
plt.clf()
plt.subplot(121)
wm.plot_histgrm(ampmM_sea, 25)
ylim = plt.gca().get_ylim()
plt.title('min-max amplitude distribution')
plt.subplot(122)
wm.plot_histgrm(ampRFC_sea, 25)
plt.gca().set_ylim(ylim)
plt.title('Rainflow amplitude distribution')
plt.show()

#!#! Section 4.3.3 Simulation of rainflow cycles
#!#! Simulation of cycles in a Markov model
# n = 41
# param_m = [-1, 1, n]
# param_D = [1, n, n]
# u_markov=levels(param_m);
# G_markov=mktestmat(param_m,[-0.2, 0.2],0.15,1);
Example #2
0
# Min-max and rainflow cycle distributions
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# import wafo.misc as wm
ampmM_sea = mM.amplitudes()
ampRFC_sea = mM_rfc.amplitudes()
plt.figure()
title = "s_n_curve"
set_windows_title(title)
S = np.linspace(1e6, 1000e6)
plt.loglog(S, damage_vs_S(S, beta, K1))
plt.figure()
plt.subplot(121)
stress_range = (1, 1e9)
n_bins = 100
wm.plot_histgrm(ampmM_sea, bins=n_bins, range=stress_range)
plt.xlim(stress_range)
ylim = plt.gca().get_ylim()
plt.title('min-max amplitude distribution')
plt.subplot(122)
if sig_cp is not None:
    wm.plot_histgrm(sig_cp[:, 0], bins=n_bins, range=stress_range)
    plt.gca().set_ylim(ylim)
    title = 'Rainflow amplitude distribution'
    plt.title(title)
    plt.semilogy
    set_windows_title(title)

    hist, bin_edges = np.histogram(sig_cp[:, 0],
                                   bins=n_bins,
                                   range=stress_range)
Example #3
0
mM.plot()
title("min-max cycle pairs")
subplot(121),
mM_rfc.plot()
title("Rainflow filtered cycles")
show()

#! Min-max and rainflow cycle distributions
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import wafo.misc as wm

ampmM_sea = mM.amplitudes()
ampRFC_sea = mM_rfc.amplitudes()
clf()
subplot(121)
wm.plot_histgrm(ampmM_sea, 25)
ylim = gca().get_ylim()
title("min-max amplitude distribution")
subplot(122)
wm.plot_histgrm(ampRFC_sea, 25)
gca().set_ylim(ylim)
title("Rainflow amplitude distribution")
show()

#!#! Section 4.3.3 Simulation of rainflow cycles
#!#! Simulation of cycles in a Markov model
n = 41
param_m = [-1, 1, n]
param_D = [1, n, n]
u_markov = levels(param_m)
G_markov = mktestmat(param_m, [-0.2, 0.2], 0.15, 1)
Example #4
0
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.')
plt.show()

#! Does the highest wave contradict a transformed Gaussian model?
Example #5
0
#! Section 1.4.2 Probability distributions of wave characteristics.
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#! Probability distribution of wave trough period:
#! WAFO gives the possibility of computing the exact probability
#! distributions for a number of characteristics given a spectral density.
#! In the following example we study the trough period extracted from the
#! time series and compared with the theoretical density computed with exact
#! spectrum, S1, and the estimated spectrum, Sest.
clf()
import wafo.misc as wm
dtyex = S1.to_t_pdf(pdef='Tt', paramt=(0, 10, 51), nit=3)
dtyest = Sest.to_t_pdf(pdef='Tt', paramt=(0, 10, 51), nit=3)

T, index = ts.wave_periods(vh=0, pdef='d2u')
bins = wm.good_bins(T, num_bins=25, odd=True)
wm.plot_histgrm(T, bins=bins, normed=True)

dtyex.plot()
dtyest.plot('-.')
axis([0, 10, 0, 0.35])
show()

#! Section 1.4.3 Directional spectra
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#! Here are a few lines of code, which produce directional spectra 
#! with frequency independent and frequency dependent spreading.
clf()
plotflag = 1
Nt = 101;   # number of angles
th0 = pi / 2; # primary direction of waves
Sp = 15;   # spreading parameter
Example #6
0
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.')
plt.show()

#! Does the highest wave contradict a transformed Gaussian model?
Example #7
0
#! Section 1.4.2 Probability distributions of wave characteristics.
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#! Probability distribution of wave trough period:
#! WAFO gives the possibility of computing the exact probability
#! distributions for a number of characteristics given a spectral density.
#! In the following example we study the trough period extracted from the
#! time series and compared with the theoretical density computed with exact
#! spectrum, S1, and the estimated spectrum, Sest.
plt.clf()
import wafo.misc as wm
dtyex = S1.to_t_pdf(pdef='Tt', paramt=(0, 10, 51), nit=3)
dtyest = Sest.to_t_pdf(pdef='Tt', paramt=(0, 10, 51), nit=3)

T, index = ts.wave_periods(vh=0, pdef='d2u')
bins = wm.good_bins(T, num_bins=25, odd=True)
wm.plot_histgrm(T, bins=bins, normed=True)

dtyex.plot()
dtyest.plot('-.')
plt.axis([0, 10, 0, 0.35])
plt.show()

#! Section 1.4.3 Directional spectra
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#! Here are a few lines of code, which produce directional spectra
#! with frequency independent and frequency dependent spreading.
plt.clf()
plotflag = 1
Nt = 101      # number of angles
th0 = np.pi / 2  # primary direction of waves
Sp = 15       # spreading parameter
Example #8
0
# Min-max and rainflow cycle distributions
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# import wafo.misc as wm
ampmM_sea = mM.amplitudes()
ampRFC_sea = mM_rfc.amplitudes()
plt.figure()
title = "s_n_curve"
set_windows_title(title)
S = np.linspace(1e6, 1000e6)
plt.loglog(S, damage_vs_S(S, beta, K1))
plt.figure()
plt.subplot(121)
stress_range = (1, 1e9)
n_bins = 100
wm.plot_histgrm(ampmM_sea, bins=n_bins, range=stress_range)
plt.xlim(stress_range)
ylim = plt.gca().get_ylim()
plt.title('min-max amplitude distribution')
plt.subplot(122)
if sig_cp is not None:
    wm.plot_histgrm(sig_cp[:, 0], bins=n_bins, range=stress_range)
    plt.gca().set_ylim(ylim)
    title = 'Rainflow amplitude distribution'
    plt.title(title)
    plt.semilogy
    set_windows_title(title)

    hist, bin_edges = np.histogram(
        sig_cp[
            :, 0], bins=n_bins, range=stress_range)