master
Per A Brodtkorb 7 years ago
parent a099f7ada7
commit 258ea054a3

@ -48,7 +48,7 @@ _wafocov_estimation = JITImport('wafo.covariance.estimation')
_wafospec = JITImport('wafo.spectrum') _wafospec = JITImport('wafo.spectrum')
__all__ = ['TimeSeries', 'LevelCrossings', 'CyclePairs', 'TurningPoints', __all__ = ['TimeSeries', 'LevelCrossings', 'CyclePairs', 'TurningPoints',
'sensortypeid', 'sensortype'] 'CycleMatrix']
def _invchi2(q, df): def _invchi2(q, df):
@ -905,7 +905,8 @@ class CyclePairs(PlotData):
# for j in range(i + 1, n): # = i+1:n # for j in range(i + 1, n): # = i+1:n
# if F[i, j] != 0: # if F[i, j] != 0:
# hi = h * _lamda[i, j] # hi = h * _lamda[i, j]
# F1 = np.exp(-1 / (2 * hi**2) * ((I - i)**2 + (J - j)**2)) # Gaussian kernel # # Gaussian kernel
# F1 = np.exp(-1 / (2 * hi**2) * ((I - i)**2 + (J - j)**2))
# F1 = F1 + F1.T # Mirror kernel in diagonal # F1 = F1 + F1.T # Mirror kernel in diagonal
# F1 = np.triu(F1, 1 + NOsubzero) # Set to zero below and on diagonal # F1 = np.triu(F1, 1 + NOsubzero) # Set to zero below and on diagonal
# F1 = F[i, j] * F1 / np.sum(F1) # Normalize # F1 = F[i, j] * F1 / np.sum(F1) # Normalize

@ -580,16 +580,16 @@ class SpecData1D(PlotData):
@freqtype.setter @freqtype.setter
def freqtype(self, freqtype): def freqtype(self, freqtype):
if self._freqtype==freqtype: if self._freqtype == freqtype:
return # do nothind return # do nothind
if freqtype=='w' and self._freqtype=='f': if freqtype == 'w' and self._freqtype == 'f':
self.args *= 2*np.pi self.args *= 2 * np.pi
self.data /= 2*np.pi self.data /= 2 * np.pi
self._freqtype = 'w' self._freqtype = 'w'
self.setlabels() self.setlabels()
elif freqtype=='f' and self._freqtype=='w': elif freqtype == 'f' and self._freqtype == 'w':
self.args /= 2*np.pi self.args /= 2 * np.pi
self.data *= 2*np.pi self.data *= 2 * np.pi
self._freqtype = 'f' self._freqtype = 'f'
self.setlabels() self.setlabels()
@ -1153,7 +1153,7 @@ class SpecData1D(PlotData):
pl = [10, 30, 50, 70, 90, 95, 99, 99.9] pl = [10, 30, 50, 70, 90, 95, 99, 99.9]
mmpdf.cl = qlevels(uvdens, pl, xi=(h, h)) mmpdf.cl = qlevels(uvdens, pl, xi=(h, h))
mmpdf.pl = pl mmpdf.pl = pl
except: except Exception:
pass pass
return mmpdf return mmpdf
@ -1642,7 +1642,7 @@ class SpecData1D(PlotData):
ftmp = np.reshape(ftmp, shape) * der0[:, :, None] / A ftmp = np.reshape(ftmp, shape) * der0[:, :, None] / A
err = np.reshape(err, shape) * der0[:, :, None] / A err = np.reshape(err, shape) * der0[:, :, None] / A
f.args[2] = t[:]*A f.args[2] = t[:] * A
_labz = 'wave length [m]' if in_space else 'period [sec]' _labz = 'wave length [m]' if in_space else 'period [sec]'
else: else:
@ -1653,15 +1653,15 @@ class SpecData1D(PlotData):
if (defnr == -1): if (defnr == -1):
ftmp0 = np.fliplr(mctp2rfc(np.fliplr(ftmp))) ftmp0 = np.fliplr(mctp2rfc(np.fliplr(ftmp)))
err = np.abs(ftmp0 - err = np.abs(ftmp0 -
np.fliplr(mctp2rfc(np.fliplr(ftmp+err)))) np.fliplr(mctp2rfc(np.fliplr(ftmp + err))))
ftmp = ftmp0 ftmp = ftmp0
elif (defnr == -2): elif (defnr == -2):
ftmp0 = np.fliplr(mctp2tc(np.fliplr(ftmp), utc, ftmp0 = np.fliplr(mctp2tc(np.fliplr(ftmp), utc,
paramu)) * sqrt(L4*L0)/L2 paramu)) * sqrt(L4 * L0) / L2
err = np.abs(ftmp0 - err = np.abs(ftmp0 -
np.fliplr(mctp2tc(np.fliplr(ftmp+err), np.fliplr(mctp2tc(np.fliplr(ftmp + err),
utc, paramu)) * utc, paramu)) *
sqrt(L4*L0)/L2) sqrt(L4 * L0) / L2)
index1 = np.flatnonzero(f.args[0] > 0) index1 = np.flatnonzero(f.args[0] > 0)
index2 = np.flatnonzero(f.args[1] < 0) index2 = np.flatnonzero(f.args[1] < 0)
ftmp = np.flipud(ftmp0[index2, index1]) ftmp = np.flipud(ftmp0[index2, index1])
@ -1673,9 +1673,9 @@ class SpecData1D(PlotData):
f.data = ftmp f.data = ftmp
f.err = err f.err = err
else: # Only time or wave length distributions wanted else: # Only time or wave length distributions wanted
f.data = ftmp/A f.data = ftmp / A
f.err = err/A f.err = err / A
f.args[0] = A*t f.args[0] = A * t
# if def_[0] == 't': # if def_[0] == 't':
# f.labx{1} = 'period [sec]' # f.labx{1} = 'period [sec]'
# else: # else:
@ -1684,7 +1684,7 @@ class SpecData1D(PlotData):
if defnr > 3: if defnr > 3:
f.data = np.reshape(f.data, [Nt, Nt]) f.data = np.reshape(f.data, [Nt, Nt])
f.err = np.reshape(f.err, [Nt, Nt]) f.err = np.reshape(f.err, [Nt, Nt])
f.args[1] = A*t f.args[1] = A * t
# if def_[0] == 't': # if def_[0] == 't':
# f.labx{2} = 'period [sec]' # f.labx{2} = 'period [sec]'
# else: # else:
@ -1696,7 +1696,7 @@ class SpecData1D(PlotData):
try: try:
f.cl, f.pl = qlevels(f.f, [10, 30, 50, 70, 90, 95, 99, 99.9], f.cl, f.pl = qlevels(f.f, [10, 30, 50, 70, 90, 95, 99, 99.9],
f.args[0], f.args[1]) f.args[0], f.args[1])
except: except Exception:
warnings.warn('Singularity likely in pdf') warnings.warn('Singularity likely in pdf')
# Test of spec2mmtpdf # Test of spec2mmtpdf
@ -4257,6 +4257,7 @@ def test_mm_pdf():
mm.plot() mm.plot()
plotbackend.show() plotbackend.show()
def test_docstrings(): def test_docstrings():
import doctest import doctest
doctest.testmod() doctest.testmod()

Loading…
Cancel
Save