|
|
@ -6,7 +6,8 @@ from __future__ import division
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
import fractions
|
|
|
|
import fractions
|
|
|
|
import numpy as np
|
|
|
|
import numpy as np
|
|
|
|
from numpy import (abs, amax, any, logical_and, arange, linspace, atleast_1d, #atleast_2d,
|
|
|
|
from numpy import (
|
|
|
|
|
|
|
|
abs, amax, any, logical_and, arange, linspace, atleast_1d, # atleast_2d,
|
|
|
|
array, asarray, broadcast_arrays, ceil, floor, frexp, hypot,
|
|
|
|
array, asarray, broadcast_arrays, ceil, floor, frexp, hypot,
|
|
|
|
sqrt, arctan2, sin, cos, exp, log, mod, diff, empty_like,
|
|
|
|
sqrt, arctan2, sin, cos, exp, log, mod, diff, empty_like,
|
|
|
|
finfo, inf, pi, interp, isnan, isscalar, zeros, ones, linalg,
|
|
|
|
finfo, inf, pi, interp, isnan, isscalar, zeros, ones, linalg,
|
|
|
@ -25,7 +26,8 @@ except:
|
|
|
|
floatinfo = finfo(float)
|
|
|
|
floatinfo = finfo(float)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__all__ = ['is_numlike', 'JITImport', 'DotDict', 'Bunch', 'printf', 'sub_dict_select',
|
|
|
|
__all__ = [
|
|
|
|
|
|
|
|
'is_numlike', 'JITImport', 'DotDict', 'Bunch', 'printf', 'sub_dict_select',
|
|
|
|
'parse_kwargs', 'detrendma', 'ecross', 'findcross',
|
|
|
|
'parse_kwargs', 'detrendma', 'ecross', 'findcross',
|
|
|
|
'findextrema', 'findpeaks', 'findrfc', 'rfcfilter', 'findtp', 'findtc',
|
|
|
|
'findextrema', 'findpeaks', 'findrfc', 'rfcfilter', 'findtp', 'findtc',
|
|
|
|
'findoutliers', 'common_shape', 'argsreduce',
|
|
|
|
'findoutliers', 'common_shape', 'argsreduce',
|
|
|
@ -43,7 +45,9 @@ def is_numlike(obj):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class JITImport(object):
|
|
|
|
class JITImport(object):
|
|
|
|
|
|
|
|
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Just In Time Import of module
|
|
|
|
Just In Time Import of module
|
|
|
|
|
|
|
|
|
|
|
@ -53,9 +57,11 @@ class JITImport(object):
|
|
|
|
>>> np.exp(0)==1.0
|
|
|
|
>>> np.exp(0)==1.0
|
|
|
|
True
|
|
|
|
True
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, module_name):
|
|
|
|
def __init__(self, module_name):
|
|
|
|
self._module_name = module_name
|
|
|
|
self._module_name = module_name
|
|
|
|
self._module = None
|
|
|
|
self._module = None
|
|
|
|
|
|
|
|
|
|
|
|
def __getattr__(self, attr):
|
|
|
|
def __getattr__(self, attr):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
return getattr(self._module, attr)
|
|
|
|
return getattr(self._module, attr)
|
|
|
@ -67,7 +73,9 @@ class JITImport(object):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
raise
|
|
|
|
raise
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DotDict(dict):
|
|
|
|
class DotDict(dict):
|
|
|
|
|
|
|
|
|
|
|
|
''' Implement dot access to dict values
|
|
|
|
''' Implement dot access to dict values
|
|
|
|
|
|
|
|
|
|
|
|
Example
|
|
|
|
Example
|
|
|
@ -78,7 +86,9 @@ class DotDict(dict):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
__getattr__ = dict.__getitem__
|
|
|
|
__getattr__ = dict.__getitem__
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Bunch(object):
|
|
|
|
class Bunch(object):
|
|
|
|
|
|
|
|
|
|
|
|
''' Implement keyword argument initialization of class
|
|
|
|
''' Implement keyword argument initialization of class
|
|
|
|
|
|
|
|
|
|
|
|
Example
|
|
|
|
Example
|
|
|
@ -87,13 +97,17 @@ class Bunch(object):
|
|
|
|
>>> d.test1
|
|
|
|
>>> d.test1
|
|
|
|
1
|
|
|
|
1
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, **kwargs):
|
|
|
|
def __init__(self, **kwargs):
|
|
|
|
self.__dict__.update(kwargs)
|
|
|
|
self.__dict__.update(kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
def keys(self):
|
|
|
|
def keys(self):
|
|
|
|
return self.__dict__.keys()
|
|
|
|
return self.__dict__.keys()
|
|
|
|
|
|
|
|
|
|
|
|
def update(self, ** kwargs):
|
|
|
|
def update(self, ** kwargs):
|
|
|
|
self.__dict__.update(kwargs)
|
|
|
|
self.__dict__.update(kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def printf(format, *args): # @ReservedAssignment
|
|
|
|
def printf(format, *args): # @ReservedAssignment
|
|
|
|
sys.stdout.write(format % args)
|
|
|
|
sys.stdout.write(format % args)
|
|
|
|
|
|
|
|
|
|
|
@ -122,7 +136,7 @@ def sub_dict_select(somedict, somekeys):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def parse_kwargs(options, **kwargs):
|
|
|
|
def parse_kwargs(options, **kwargs):
|
|
|
|
''' Update options dict from keyword arguments if the keyword exists in options
|
|
|
|
''' Update options dict from keyword arguments if it exists in options
|
|
|
|
|
|
|
|
|
|
|
|
Example
|
|
|
|
Example
|
|
|
|
>>> opt = dict(arg1=2, arg2=3)
|
|
|
|
>>> opt = dict(arg1=2, arg2=3)
|
|
|
@ -140,13 +154,16 @@ def parse_kwargs(options, **kwargs):
|
|
|
|
options.update(newopts)
|
|
|
|
options.update(newopts)
|
|
|
|
return options
|
|
|
|
return options
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def testfun(*args, **kwargs):
|
|
|
|
def testfun(*args, **kwargs):
|
|
|
|
opts = dict(opt1=1, opt2=2)
|
|
|
|
opts = dict(opt1=1, opt2=2)
|
|
|
|
if len(args) == 1 and len(kwargs) == 0 and type(args[0]) is str and args[0].startswith('default'):
|
|
|
|
if (len(args) == 1 and len(kwargs) == 0 and type(args[0]) is str and
|
|
|
|
|
|
|
|
args[0].startswith('default')):
|
|
|
|
return opts
|
|
|
|
return opts
|
|
|
|
opts = parse_kwargs(opts, **kwargs)
|
|
|
|
opts = parse_kwargs(opts, **kwargs)
|
|
|
|
return opts
|
|
|
|
return opts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def detrendma(x, L):
|
|
|
|
def detrendma(x, L):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Removes a trend from data using a moving average
|
|
|
|
Removes a trend from data using a moving average
|
|
|
@ -194,7 +211,6 @@ def detrendma(x, L):
|
|
|
|
if n < 2 * L + 1: # only able to remove the mean
|
|
|
|
if n < 2 * L + 1: # only able to remove the mean
|
|
|
|
return x1 - x1.mean(axis=0)
|
|
|
|
return x1 - x1.mean(axis=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mn = x1[0:2 * L + 1].mean(axis=0)
|
|
|
|
mn = x1[0:2 * L + 1].mean(axis=0)
|
|
|
|
y = empty_like(x1)
|
|
|
|
y = empty_like(x1)
|
|
|
|
y[0:L] = x1[0:L] - mn
|
|
|
|
y[0:L] = x1[0:L] - mn
|
|
|
@ -205,6 +221,7 @@ def detrendma(x, L):
|
|
|
|
y[n - L::] = x1[n - L::] - trend[-1]
|
|
|
|
y[n - L::] = x1[n - L::] - trend[-1]
|
|
|
|
return y
|
|
|
|
return y
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def ecross(t, f, ind, v=0):
|
|
|
|
def ecross(t, f, ind, v=0):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Extracts exact level v crossings
|
|
|
|
Extracts exact level v crossings
|
|
|
@ -252,7 +269,9 @@ def ecross(t, f, ind, v=0):
|
|
|
|
# Tested on: Python 2.5
|
|
|
|
# Tested on: Python 2.5
|
|
|
|
# revised pab Feb2004
|
|
|
|
# revised pab Feb2004
|
|
|
|
# By pab 18.06.2001
|
|
|
|
# By pab 18.06.2001
|
|
|
|
return t[ind] + (v - f[ind]) * (t[ind + 1] - t[ind]) / (f[ind + 1] - f[ind])
|
|
|
|
return (t[ind] + (v - f[ind]) * (t[ind + 1] - t[ind]) /
|
|
|
|
|
|
|
|
(f[ind + 1] - f[ind]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _findcross(xn):
|
|
|
|
def _findcross(xn):
|
|
|
|
'''Return indices to zero up and downcrossings of a vector
|
|
|
|
'''Return indices to zero up and downcrossings of a vector
|
|
|
@ -288,6 +307,7 @@ def _findcross(xn):
|
|
|
|
ind, = (xn[:n - 1] * xn[1:] < 0).nonzero()
|
|
|
|
ind, = (xn[:n - 1] * xn[1:] < 0).nonzero()
|
|
|
|
return ind
|
|
|
|
return ind
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def findcross(x, v=0.0, kind=None):
|
|
|
|
def findcross(x, v=0.0, kind=None):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Return indices to level v up and/or downcrossings of a vector
|
|
|
|
Return indices to level v up and/or downcrossings of a vector
|
|
|
@ -352,10 +372,11 @@ def findcross(x, v=0.0, kind=None):
|
|
|
|
t_0 = int(xn[ind[0] + 1] < 0)
|
|
|
|
t_0 = int(xn[ind[0] + 1] < 0)
|
|
|
|
ind = ind[t_0::2]
|
|
|
|
ind = ind[t_0::2]
|
|
|
|
elif kind in ('dw', 'uw', 'tw', 'cw'):
|
|
|
|
elif kind in ('dw', 'uw', 'tw', 'cw'):
|
|
|
|
#make sure that the first is a level v down-crossing if wdef=='dw'
|
|
|
|
# make sure the first is a level v down-crossing if wdef=='dw'
|
|
|
|
#or make sure that the first is a level v up-crossing if wdef=='uw'
|
|
|
|
# or make sure the first is a level v up-crossing if wdef=='uw'
|
|
|
|
#make sure that the first is a level v down-crossing if wdef=='tw'
|
|
|
|
# make sure the first is a level v down-crossing if wdef=='tw'
|
|
|
|
#or make sure that the first is a level v up-crossing if wdef=='cw'
|
|
|
|
# or make sure the first is a level v up-crossing if
|
|
|
|
|
|
|
|
# wdef=='cw'
|
|
|
|
xor = lambda a, b: a ^ b
|
|
|
|
xor = lambda a, b: a ^ b
|
|
|
|
first_is_down_crossing = int(xn[ind[0]] > xn[ind[0] + 1])
|
|
|
|
first_is_down_crossing = int(xn[ind[0]] > xn[ind[0] + 1])
|
|
|
|
if xor(first_is_down_crossing, kind in ('dw', 'tw')):
|
|
|
|
if xor(first_is_down_crossing, kind in ('dw', 'tw')):
|
|
|
@ -372,6 +393,7 @@ def findcross(x, v=0.0, kind=None):
|
|
|
|
raise ValueError('Unknown wave/crossing definition!')
|
|
|
|
raise ValueError('Unknown wave/crossing definition!')
|
|
|
|
return ind
|
|
|
|
return ind
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def findextrema(x):
|
|
|
|
def findextrema(x):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Return indices to minima and maxima of a vector
|
|
|
|
Return indices to minima and maxima of a vector
|
|
|
@ -402,6 +424,8 @@ def findextrema(x):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
xn = atleast_1d(x).ravel()
|
|
|
|
xn = atleast_1d(x).ravel()
|
|
|
|
return findcross(diff(xn), 0.0) + 1
|
|
|
|
return findcross(diff(xn), 0.0) + 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def findpeaks(data, n=2, min_h=None, min_p=0.0):
|
|
|
|
def findpeaks(data, n=2, min_h=None, min_p=0.0):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Find peaks of vector or matrix possibly rainflow filtered
|
|
|
|
Find peaks of vector or matrix possibly rainflow filtered
|
|
|
@ -461,7 +485,8 @@ def findpeaks(data, n=2, min_h=None, min_p=0.0):
|
|
|
|
elif iy == nrows - 1:
|
|
|
|
elif iy == nrows - 1:
|
|
|
|
ind2 = np.flatnonzero(S[iy, ind] > S[iy - 1, ind])
|
|
|
|
ind2 = np.flatnonzero(S[iy, ind] > S[iy - 1, ind])
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
ind2 = np.flatnonzero((S[iy, ind] > S[iy - 1, ind]) & (S[iy, ind] > S[iy + 1, ind]))
|
|
|
|
ind2 = np.flatnonzero((S[iy, ind] > S[iy - 1, ind]) &
|
|
|
|
|
|
|
|
(S[iy, ind] > S[iy + 1, ind]))
|
|
|
|
|
|
|
|
|
|
|
|
if len(ind2):
|
|
|
|
if len(ind2):
|
|
|
|
indP.append((ind[ind2] + iy * mcols))
|
|
|
|
indP.append((ind[ind2] + iy * mcols))
|
|
|
@ -474,16 +499,17 @@ def findpeaks(data, n=2, min_h=None, min_p=0.0):
|
|
|
|
peaks = S.take(ind)
|
|
|
|
peaks = S.take(ind)
|
|
|
|
ind2 = peaks.argsort()[::-1]
|
|
|
|
ind2 = peaks.argsort()[::-1]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# keeping only the Np most significant peak frequencies.
|
|
|
|
# keeping only the Np most significant peak frequencies.
|
|
|
|
nmax = min(n, len(ind))
|
|
|
|
nmax = min(n, len(ind))
|
|
|
|
ind = ind[ind2[:nmax]]
|
|
|
|
ind = ind[ind2[:nmax]]
|
|
|
|
if (min_p > 0):
|
|
|
|
if (min_p > 0):
|
|
|
|
# Keeping only peaks larger than min_p percent relative to the maximum peak
|
|
|
|
# Keeping only peaks larger than min_p percent relative to the maximum
|
|
|
|
|
|
|
|
# peak
|
|
|
|
ind = ind[(S.take(ind) > min_p * smax)]
|
|
|
|
ind = ind[(S.take(ind) > min_p * smax)]
|
|
|
|
|
|
|
|
|
|
|
|
return ind
|
|
|
|
return ind
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def findrfc_astm(tp):
|
|
|
|
def findrfc_astm(tp):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Return rainflow counted cycles
|
|
|
|
Return rainflow counted cycles
|
|
|
@ -514,6 +540,7 @@ def findrfc_astm(tp):
|
|
|
|
# sig_rfc holds the actual rainflow counted cycles, not the indices
|
|
|
|
# sig_rfc holds the actual rainflow counted cycles, not the indices
|
|
|
|
return sig_rfc
|
|
|
|
return sig_rfc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def findrfc(tp, h=0.0, method='clib'):
|
|
|
|
def findrfc(tp, h=0.0, method='clib'):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Return indices to rainflow cycles of a sequence of TP.
|
|
|
|
Return indices to rainflow cycles of a sequence of TP.
|
|
|
@ -624,7 +651,6 @@ def findrfc(tp, h=0.0, method='clib'):
|
|
|
|
#iy = i
|
|
|
|
#iy = i
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# goto L180
|
|
|
|
# goto L180
|
|
|
|
# L170:
|
|
|
|
# L170:
|
|
|
|
if (xplus <= xminus):
|
|
|
|
if (xplus <= xminus):
|
|
|
@ -646,9 +672,11 @@ def findrfc(tp, h=0.0, method='clib'):
|
|
|
|
ind, ix = clib.findrfc(y, h)
|
|
|
|
ind, ix = clib.findrfc(y, h)
|
|
|
|
return np.sort(ind[:ix])
|
|
|
|
return np.sort(ind[:ix])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def mctp2rfc(fmM, fMm=None):
|
|
|
|
def mctp2rfc(fmM, fMm=None):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Return Rainflow matrix given a Markov matrix of a Markov chain of turning points
|
|
|
|
Return Rainflow matrix given a Markov matrix of a Markov chain
|
|
|
|
|
|
|
|
of turning points
|
|
|
|
|
|
|
|
|
|
|
|
computes f_rfc = f_mM + F_mct(f_mM).
|
|
|
|
computes f_rfc = f_mM + F_mct(f_mM).
|
|
|
|
|
|
|
|
|
|
|
@ -707,7 +735,8 @@ def mctp2rfc(fmM, fMm=None):
|
|
|
|
SRA = RAA.sum()
|
|
|
|
SRA = RAA.sum()
|
|
|
|
|
|
|
|
|
|
|
|
DRFC = SA - SRA
|
|
|
|
DRFC = SA - SRA
|
|
|
|
NT = min(mA[0] - sum(RAA[:, 0]), MA[0] - sum(RAA[0, :])) # ?? check
|
|
|
|
# ?? check
|
|
|
|
|
|
|
|
NT = min(mA[0] - sum(RAA[:, 0]), MA[0] - sum(RAA[0, :]))
|
|
|
|
NT = max(NT, 0) # ??check
|
|
|
|
NT = max(NT, 0) # ??check
|
|
|
|
|
|
|
|
|
|
|
|
if NT > 1e-6 * max(MA[0], mA[0]):
|
|
|
|
if NT > 1e-6 * max(MA[0], mA[0]):
|
|
|
@ -722,13 +751,14 @@ def mctp2rfc(fmM, fMm=None):
|
|
|
|
e[j] = e[j] / norm
|
|
|
|
e[j] = e[j] / norm
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
fx = 0.0;
|
|
|
|
fx = 0.0
|
|
|
|
if max(abs(e)) > 1e-6 and max(abs(NN)) > 1e-6 * max(MA[0], mA[0]):
|
|
|
|
if (max(abs(e)) > 1e-6 and
|
|
|
|
|
|
|
|
max(abs(NN)) > 1e-6 * max(MA[0], mA[0])):
|
|
|
|
PMm = AA1.copy()
|
|
|
|
PMm = AA1.copy()
|
|
|
|
for j in range(nA):
|
|
|
|
for j in range(nA):
|
|
|
|
norm = MA[j]
|
|
|
|
norm = MA[j]
|
|
|
|
if norm != 0:
|
|
|
|
if norm != 0:
|
|
|
|
PMm[j, :] = PMm[j, :] / norm;
|
|
|
|
PMm[j, :] = PMm[j, :] / norm
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
PMm = np.fliplr(PMm)
|
|
|
|
PMm = np.fliplr(PMm)
|
|
|
@ -740,7 +770,8 @@ def mctp2rfc(fmM, fMm=None):
|
|
|
|
fx = NN * (A / (1 - B * A) * e)
|
|
|
|
fx = NN * (A / (1 - B * A) * e)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
rh = np.eye(A.shape[0]) - np.dot(B, A)
|
|
|
|
rh = np.eye(A.shape[0]) - np.dot(B, A)
|
|
|
|
fx = np.dot(NN, np.dot(A, linalg.solve(rh, e))) #least squares
|
|
|
|
#least squares
|
|
|
|
|
|
|
|
fx = np.dot(NN, np.dot(A, linalg.solve(rh, e)))
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
f_rfc[N - 1 - k, k - i] = fx + DRFC
|
|
|
|
f_rfc[N - 1 - k, k - i] = fx + DRFC
|
|
|
@ -758,8 +789,8 @@ def mctp2rfc(fmM, fMm=None):
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
|
|
for k in range(1, N):
|
|
|
|
for k in range(1, N):
|
|
|
|
M0 = max(0, f_max[0] - np.sum(f_rfc[0, N - k:N]));
|
|
|
|
M0 = max(0, f_max[0] - np.sum(f_rfc[0, N - k:N]))
|
|
|
|
m0 = max(0, f_min[N - 1 - k] - np.sum(f_rfc[1:k+1, N - 1 - k]));
|
|
|
|
m0 = max(0, f_min[N - 1 - k] - np.sum(f_rfc[1:k + 1, N - 1 - k]))
|
|
|
|
f_rfc[0, N - 1 - k] = min(m0, M0)
|
|
|
|
f_rfc[0, N - 1 - k] = min(m0, M0)
|
|
|
|
# end
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
|
@ -781,7 +812,6 @@ def mctp2rfc(fmM, fMm=None):
|
|
|
|
return f_rfc
|
|
|
|
return f_rfc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def rfcfilter(x, h, method=0):
|
|
|
|
def rfcfilter(x, h, method=0):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Rainflow filter a signal.
|
|
|
|
Rainflow filter a signal.
|
|
|
@ -866,9 +896,11 @@ def rfcfilter(x, h, method=0):
|
|
|
|
z1 = 0
|
|
|
|
z1 = 0
|
|
|
|
t1, y1 = (t0, y0) if z1 == 0 else (ti, yi)
|
|
|
|
t1, y1 = (t0, y0) if z1 == 0 else (ti, yi)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if (((z0 == +1) & cmpfun1(yi, fmi)) | ((z0 == -1) & cmpfun2(yi, fpi))):
|
|
|
|
if (((z0 == +1) & cmpfun1(yi, fmi)) |
|
|
|
|
|
|
|
|
((z0 == -1) & cmpfun2(yi, fpi))):
|
|
|
|
z1 = -1
|
|
|
|
z1 = -1
|
|
|
|
elif (((z0 == +1) & cmpfun2(fmi, yi)) | ((z0 == -1) & cmpfun1(fpi, yi))):
|
|
|
|
elif (((z0 == +1) & cmpfun2(fmi, yi)) |
|
|
|
|
|
|
|
|
((z0 == -1) & cmpfun1(fpi, yi))):
|
|
|
|
z1 = +1
|
|
|
|
z1 = +1
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
warnings.warn('Something wrong, i=%d' % tim1)
|
|
|
|
warnings.warn('Something wrong, i=%d' % tim1)
|
|
|
@ -898,6 +930,7 @@ def rfcfilter(x, h, method=0):
|
|
|
|
t[j] = t0
|
|
|
|
t[j] = t0
|
|
|
|
return y[t[:j + 1]]
|
|
|
|
return y[t[:j + 1]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def findtp(x, h=0.0, kind=None):
|
|
|
|
def findtp(x, h=0.0, kind=None):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Return indices to turning points (tp) of data, optionally rainflowfiltered.
|
|
|
|
Return indices to turning points (tp) of data, optionally rainflowfiltered.
|
|
|
@ -936,7 +969,9 @@ def findtp(x, h=0.0, kind=None):
|
|
|
|
>>> itph = wm.findtp(x1[:,1],0.3,'Mw')
|
|
|
|
>>> itph = wm.findtp(x1[:,1],0.3,'Mw')
|
|
|
|
>>> tp = x1[itp,:]
|
|
|
|
>>> tp = x1[itp,:]
|
|
|
|
>>> tph = x1[itph,:]
|
|
|
|
>>> tph = x1[itph,:]
|
|
|
|
>>> a = plb.plot(x1[:,0],x1[:,1],tp[:,0],tp[:,1],'ro',tph[:,1],tph[:,1],'k.')
|
|
|
|
>>> a = plb.plot(x1[:,0],x1[:,1],
|
|
|
|
|
|
|
|
... tp[:,0],tp[:,1],'ro',
|
|
|
|
|
|
|
|
... tph[:,1],tph[:,1],'k.')
|
|
|
|
>>> plb.close('all')
|
|
|
|
>>> plb.close('all')
|
|
|
|
>>> itp
|
|
|
|
>>> itp
|
|
|
|
array([ 11, 21, 22, 24, 26, 28, 31, 39, 43, 45, 47, 51, 56,
|
|
|
|
array([ 11, 21, 22, 24, 26, 28, 31, 39, 43, 45, 47, 51, 56,
|
|
|
@ -970,7 +1005,8 @@ def findtp(x, h=0.0, kind=None):
|
|
|
|
if kind == 'astm':
|
|
|
|
if kind == 'astm':
|
|
|
|
# the Nieslony approach always put the first loading point as the first
|
|
|
|
# the Nieslony approach always put the first loading point as the first
|
|
|
|
# turning point.
|
|
|
|
# turning point.
|
|
|
|
if x[ind[0]] != x[0]: # add the first turning point is the first of the signal
|
|
|
|
# add the first turning point is the first of the signal
|
|
|
|
|
|
|
|
if x[ind[0]] != x[0]:
|
|
|
|
ind = np.r_[0, ind, n - 1]
|
|
|
|
ind = np.r_[0, ind, n - 1]
|
|
|
|
else: # only add the last point of the signal
|
|
|
|
else: # only add the last point of the signal
|
|
|
|
ind = np.r_[ind, n - 1]
|
|
|
|
ind = np.r_[ind, n - 1]
|
|
|
@ -1000,6 +1036,7 @@ def findtp(x, h=0.0, kind=None):
|
|
|
|
ind = ind[:-1]
|
|
|
|
ind = ind[:-1]
|
|
|
|
return ind
|
|
|
|
return ind
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def findtc(x_in, v=None, kind=None):
|
|
|
|
def findtc(x_in, v=None, kind=None):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Return indices to troughs and crests of data.
|
|
|
|
Return indices to troughs and crests of data.
|
|
|
@ -1092,6 +1129,7 @@ def findtc(x_in, v=None, kind=None):
|
|
|
|
|
|
|
|
|
|
|
|
return v_ind[:n_c - 1] + ind + 1, v_ind
|
|
|
|
return v_ind[:n_c - 1] + ind + 1, v_ind
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def findoutliers(x, zcrit=0.0, dcrit=None, ddcrit=None, verbose=False):
|
|
|
|
def findoutliers(x, zcrit=0.0, dcrit=None, ddcrit=None, verbose=False):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Return indices to spurious points of data
|
|
|
|
Return indices to spurious points of data
|
|
|
@ -1120,7 +1158,8 @@ def findoutliers(x, zcrit=0.0, dcrit=None, ddcrit=None, verbose=False):
|
|
|
|
-----
|
|
|
|
-----
|
|
|
|
Consecutive points less than zcrit apart are considered as spurious.
|
|
|
|
Consecutive points less than zcrit apart are considered as spurious.
|
|
|
|
The point immediately after and before are also removed. Jumps greater than
|
|
|
|
The point immediately after and before are also removed. Jumps greater than
|
|
|
|
dcrit in Dxn and greater than ddcrit in D^2xn are also considered as spurious.
|
|
|
|
dcrit in Dxn and greater than ddcrit in D^2xn are also considered as
|
|
|
|
|
|
|
|
spurious.
|
|
|
|
(All distances to be interpreted in the vertical direction.)
|
|
|
|
(All distances to be interpreted in the vertical direction.)
|
|
|
|
Another good choice for dcrit and ddcrit are:
|
|
|
|
Another good choice for dcrit and ddcrit are:
|
|
|
|
|
|
|
|
|
|
|
@ -1153,7 +1192,6 @@ def findoutliers(x, zcrit=0.0, dcrit=None, ddcrit=None, verbose=False):
|
|
|
|
waveplot, reconstruct
|
|
|
|
waveplot, reconstruct
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# finding outliers
|
|
|
|
# finding outliers
|
|
|
|
findjumpsDx = True # find jumps in Dx
|
|
|
|
findjumpsDx = True # find jumps in Dx
|
|
|
|
# two point spikes and Spikes dcrit above/under the
|
|
|
|
# two point spikes and Spikes dcrit above/under the
|
|
|
@ -1168,7 +1206,6 @@ def findoutliers(x, zcrit=0.0, dcrit=None, ddcrit=None, verbose=False):
|
|
|
|
if xn.size < 2:
|
|
|
|
if xn.size < 2:
|
|
|
|
raise ValueError('The vector must have more than 2 elements!')
|
|
|
|
raise ValueError('The vector must have more than 2 elements!')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ind = zeros(0, dtype=int)
|
|
|
|
ind = zeros(0, dtype=int)
|
|
|
|
# indg=[]
|
|
|
|
# indg=[]
|
|
|
|
indmiss = isnan(xn)
|
|
|
|
indmiss = isnan(xn)
|
|
|
@ -1249,7 +1286,8 @@ def findoutliers(x, zcrit=0.0, dcrit=None, ddcrit=None, verbose=False):
|
|
|
|
indtr, = nonzero((diff(indzeros)))
|
|
|
|
indtr, = nonzero((diff(indzeros)))
|
|
|
|
indtr = indtr + 1
|
|
|
|
indtr = indtr + 1
|
|
|
|
#%indices to consecutive equal points
|
|
|
|
#%indices to consecutive equal points
|
|
|
|
if True: # removing the point before + all equal points + the point after
|
|
|
|
# removing the point before + all equal points + the point after
|
|
|
|
|
|
|
|
if True:
|
|
|
|
ind = hstack((ind, indtr - 1, indz, indtr, indtr + 1))
|
|
|
|
ind = hstack((ind, indtr - 1, indz, indtr, indtr + 1))
|
|
|
|
else: # % removing all points + the point after
|
|
|
|
else: # % removing all points + the point after
|
|
|
|
ind = hstack((ind, indz, indtr, indtr + 1))
|
|
|
|
ind = hstack((ind, indz, indtr, indtr + 1))
|
|
|
@ -1258,7 +1296,8 @@ def findoutliers(x, zcrit=0.0, dcrit=None, ddcrit=None, verbose=False):
|
|
|
|
if zcrit == 0.:
|
|
|
|
if zcrit == 0.:
|
|
|
|
print('Found %d consecutive equal values' % indz.size)
|
|
|
|
print('Found %d consecutive equal values' % indz.size)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
print('Found %d consecutive values less than %g apart.' % (indz.size, zcrit))
|
|
|
|
print('Found %d consecutive values less than %g apart.' %
|
|
|
|
|
|
|
|
(indz.size, zcrit))
|
|
|
|
indg = ones(xn.size, dtype=bool)
|
|
|
|
indg = ones(xn.size, dtype=bool)
|
|
|
|
|
|
|
|
|
|
|
|
if ind.size > 1:
|
|
|
|
if ind.size > 1:
|
|
|
@ -1271,6 +1310,7 @@ def findoutliers(x, zcrit=0.0, dcrit=None, ddcrit=None, verbose=False):
|
|
|
|
|
|
|
|
|
|
|
|
return ind, indg
|
|
|
|
return ind, indg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def common_shape(*args, ** kwds):
|
|
|
|
def common_shape(*args, ** kwds):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Return the common shape of a sequence of arrays
|
|
|
|
Return the common shape of a sequence of arrays
|
|
|
@ -1339,8 +1379,8 @@ def common_shape(*args, ** kwds):
|
|
|
|
raise ValueError("shape mismatch: two or more arrays have "
|
|
|
|
raise ValueError("shape mismatch: two or more arrays have "
|
|
|
|
"incompatible dimensions on axis %r." % (axis,))
|
|
|
|
"incompatible dimensions on axis %r." % (axis,))
|
|
|
|
elif len(unique) == 2:
|
|
|
|
elif len(unique) == 2:
|
|
|
|
# There is exactly one non-1 length. The common shape will take this
|
|
|
|
# There is exactly one non-1 length.
|
|
|
|
# value.
|
|
|
|
# The common shape will take this value.
|
|
|
|
unique.remove(1)
|
|
|
|
unique.remove(1)
|
|
|
|
new_length = unique.pop()
|
|
|
|
new_length = unique.pop()
|
|
|
|
c_shape.append(new_length)
|
|
|
|
c_shape.append(new_length)
|
|
|
@ -1351,6 +1391,7 @@ def common_shape(*args, ** kwds):
|
|
|
|
|
|
|
|
|
|
|
|
return tuple(c_shape)
|
|
|
|
return tuple(c_shape)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def argsreduce(condition, * args):
|
|
|
|
def argsreduce(condition, * args):
|
|
|
|
""" Return the elements of each input array that satisfy some condition.
|
|
|
|
""" Return the elements of each input array that satisfy some condition.
|
|
|
|
|
|
|
|
|
|
|
@ -1399,7 +1440,8 @@ def argsreduce(condition, * args):
|
|
|
|
|
|
|
|
|
|
|
|
def stirlerr(n):
|
|
|
|
def stirlerr(n):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Return error of Stirling approximation, i.e., log(n!) - log( sqrt(2*pi*n)*(n/exp(1))**n )
|
|
|
|
Return error of Stirling approximation,
|
|
|
|
|
|
|
|
i.e., log(n!) - log( sqrt(2*pi*n)*(n/exp(1))**n )
|
|
|
|
|
|
|
|
|
|
|
|
Example
|
|
|
|
Example
|
|
|
|
-------
|
|
|
|
-------
|
|
|
@ -1430,7 +1472,6 @@ def stirlerr(n):
|
|
|
|
|
|
|
|
|
|
|
|
y = gammaln(n1 + 1) - log(sqrt(2 * pi * n1) * (n1 / exp(1)) ** n1)
|
|
|
|
y = gammaln(n1 + 1) - log(sqrt(2 * pi * n1) * (n1 / exp(1)) ** n1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nn = n1 * n1
|
|
|
|
nn = n1 * n1
|
|
|
|
|
|
|
|
|
|
|
|
n500 = 500 < n1
|
|
|
|
n500 = 500 < n1
|
|
|
@ -1446,11 +1487,16 @@ def stirlerr(n):
|
|
|
|
n15 = logical_and(15 < n1, n1 <= 35)
|
|
|
|
n15 = logical_and(15 < n1, n1 <= 35)
|
|
|
|
if any(n15):
|
|
|
|
if any(n15):
|
|
|
|
nn15 = nn[n15]
|
|
|
|
nn15 = nn[n15]
|
|
|
|
y[n15] = (S0 - (S1 - (S2 - (S3 - S4 / nn15) / nn15) / nn15) / nn15) / n1[n15]
|
|
|
|
y[n15] = (
|
|
|
|
|
|
|
|
S0 - (S1 - (S2 - (S3 - S4 / nn15) / nn15) / nn15) / nn15) / n1[n15]
|
|
|
|
|
|
|
|
|
|
|
|
return y
|
|
|
|
return y
|
|
|
|
|
|
|
|
|
|
|
|
def getshipchar(value=None, property="max_deadweight", **kwds): #@ReservedAssignment
|
|
|
|
#@ReservedAssignment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def getshipchar(value=None, property="max_deadweight", # @ReservedAssignment
|
|
|
|
|
|
|
|
**kwds):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Return ship characteristics from value of one ship-property
|
|
|
|
Return ship characteristics from value of one ship-property
|
|
|
|
|
|
|
|
|
|
|
@ -1464,15 +1510,16 @@ def getshipchar(value=None, property="max_deadweight", **kwds): #@ReservedAssign
|
|
|
|
'propeller_diameter'.
|
|
|
|
'propeller_diameter'.
|
|
|
|
The length was found from statistics of 40 vessels of size 85 to
|
|
|
|
The length was found from statistics of 40 vessels of size 85 to
|
|
|
|
100000 tonn. An exponential curve through 0 was selected, and the
|
|
|
|
100000 tonn. An exponential curve through 0 was selected, and the
|
|
|
|
factor and exponent that minimized the standard deviation of the relative
|
|
|
|
factor and exponent that minimized the standard deviation of the
|
|
|
|
error was selected. (The error returned is the same for any ship.) The
|
|
|
|
relative error was selected. (The error returned is the same for
|
|
|
|
servicespeed was found for ships above 1000 tonns only.
|
|
|
|
any ship.) The servicespeed was found for ships above 1000 tonns
|
|
|
|
The propeller diameter formula is from [1]_.
|
|
|
|
only. The propeller diameter formula is from [1]_.
|
|
|
|
|
|
|
|
|
|
|
|
Returns
|
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
-------
|
|
|
|
sc : dict
|
|
|
|
sc : dict
|
|
|
|
containing estimated mean values and standard-deviations of ship characteristics:
|
|
|
|
containing estimated mean values and standard-deviations of ship
|
|
|
|
|
|
|
|
characteristics:
|
|
|
|
max_deadweight [kkg], (weight of cargo, fuel etc.)
|
|
|
|
max_deadweight [kkg], (weight of cargo, fuel etc.)
|
|
|
|
length [m]
|
|
|
|
length [m]
|
|
|
|
beam [m]
|
|
|
|
beam [m]
|
|
|
@ -1504,8 +1551,8 @@ def getshipchar(value=None, property="max_deadweight", **kwds): #@ReservedAssign
|
|
|
|
Reference
|
|
|
|
Reference
|
|
|
|
---------
|
|
|
|
---------
|
|
|
|
.. [1] Gray and Greeley, (1978),
|
|
|
|
.. [1] Gray and Greeley, (1978),
|
|
|
|
"Source level model for propeller blade rate radiation for the world's merchant
|
|
|
|
"Source level model for propeller blade rate radiation for the world's
|
|
|
|
fleet", Bolt Beranek and Newman Technical Memorandum No. 458.
|
|
|
|
merchant fleet", Bolt Beranek and Newman Technical Memorandum No. 458.
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
if value is None:
|
|
|
|
if value is None:
|
|
|
|
names = kwds.keys()
|
|
|
|
names = kwds.keys()
|
|
|
@ -1522,7 +1569,8 @@ def getshipchar(value=None, property="max_deadweight", **kwds): #@ReservedAssign
|
|
|
|
beam=lambda x: ((x / 1.78) ** (1 / 0.27)),
|
|
|
|
beam=lambda x: ((x / 1.78) ** (1 / 0.27)),
|
|
|
|
draught=lambda x: ((x / 0.8) ** (1 / 0.24)),
|
|
|
|
draught=lambda x: ((x / 0.8) ** (1 / 0.24)),
|
|
|
|
service_speed=lambda x: ((x / 1.14) ** (1 / 0.21)),
|
|
|
|
service_speed=lambda x: ((x / 1.14) ** (1 / 0.21)),
|
|
|
|
propeller_diameter=lambda x: (((x / 0.12) ** (4 / 3) / 3.45) ** (2.5)))
|
|
|
|
propeller_diameter=lambda x: (((x / 0.12) ** (4 / 3) /
|
|
|
|
|
|
|
|
3.45) ** (2.5)))
|
|
|
|
|
|
|
|
|
|
|
|
max_deadweight = prop2max_dw.get(prop, lambda x: x)(value)
|
|
|
|
max_deadweight = prop2max_dw.get(prop, lambda x: x)(value)
|
|
|
|
propertySTD = prop + 'STD'
|
|
|
|
propertySTD = prop + 'STD'
|
|
|
@ -1540,7 +1588,6 @@ def getshipchar(value=None, property="max_deadweight", **kwds): #@ReservedAssign
|
|
|
|
speed = round(1.14 * max_deadweight ** 0.21 * 10) / 10
|
|
|
|
speed = round(1.14 * max_deadweight ** 0.21 * 10) / 10
|
|
|
|
speed_err = speed * 0.10
|
|
|
|
speed_err = speed * 0.10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
p_diam = 0.12 * length ** (3.0 / 4.0)
|
|
|
|
p_diam = 0.12 * length ** (3.0 / 4.0)
|
|
|
|
p_diam_err = 0.12 * length_err ** (3.0 / 4.0)
|
|
|
|
p_diam_err = 0.12 * length_err ** (3.0 / 4.0)
|
|
|
|
|
|
|
|
|
|
|
@ -1550,13 +1597,16 @@ def getshipchar(value=None, property="max_deadweight", **kwds): #@ReservedAssign
|
|
|
|
shipchar = OrderedDict(beam=beam, beamSTD=beam_err,
|
|
|
|
shipchar = OrderedDict(beam=beam, beamSTD=beam_err,
|
|
|
|
draught=draught, draughtSTD=draught_err,
|
|
|
|
draught=draught, draughtSTD=draught_err,
|
|
|
|
length=length, lengthSTD=length_err,
|
|
|
|
length=length, lengthSTD=length_err,
|
|
|
|
max_deadweight=max_deadweight, max_deadweightSTD=max_deadweightSTD,
|
|
|
|
max_deadweight=max_deadweight,
|
|
|
|
propeller_diameter=p_diam, propeller_diameterSTD=p_diam_err,
|
|
|
|
max_deadweightSTD=max_deadweightSTD,
|
|
|
|
|
|
|
|
propeller_diameter=p_diam,
|
|
|
|
|
|
|
|
propeller_diameterSTD=p_diam_err,
|
|
|
|
service_speed=speed, service_speedSTD=speed_err)
|
|
|
|
service_speed=speed, service_speedSTD=speed_err)
|
|
|
|
|
|
|
|
|
|
|
|
shipchar[propertySTD] = 0
|
|
|
|
shipchar[propertySTD] = 0
|
|
|
|
return shipchar
|
|
|
|
return shipchar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def betaloge(z, w):
|
|
|
|
def betaloge(z, w):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Natural Logarithm of beta function.
|
|
|
|
Natural Logarithm of beta function.
|
|
|
@ -1595,6 +1645,7 @@ def betaloge(z, w):
|
|
|
|
# (-(zpw-0.5).*log(zpw) +(w-0.5).*log(w)+(z-0.5).*log(z) +0.5*log(2*pi))
|
|
|
|
# (-(zpw-0.5).*log(zpw) +(w-0.5).*log(w)+(z-0.5).*log(z) +0.5*log(2*pi))
|
|
|
|
# return y
|
|
|
|
# return y
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def gravity(phi=45):
|
|
|
|
def gravity(phi=45):
|
|
|
|
''' Returns the constant acceleration of gravity
|
|
|
|
''' Returns the constant acceleration of gravity
|
|
|
|
|
|
|
|
|
|
|
@ -1638,7 +1689,9 @@ def gravity(phi=45):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
phir = phi * pi / 180. # change from degrees to radians
|
|
|
|
phir = phi * pi / 180. # change from degrees to radians
|
|
|
|
return 9.78049 * (1. + 0.0052884 * sin(phir) ** 2. - 0.0000059 * sin(2 * phir) ** 2.)
|
|
|
|
return 9.78049 * (1. + 0.0052884 * sin(phir) ** 2. -
|
|
|
|
|
|
|
|
0.0000059 * sin(2 * phir) ** 2.)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def nextpow2(x):
|
|
|
|
def nextpow2(x):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
@ -1662,6 +1715,7 @@ def nextpow2(x):
|
|
|
|
n = n - 1
|
|
|
|
n = n - 1
|
|
|
|
return n
|
|
|
|
return n
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def discretize(fun, a, b, tol=0.005, n=5, method='linear'):
|
|
|
|
def discretize(fun, a, b, tol=0.005, n=5, method='linear'):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Automatic discretization of function
|
|
|
|
Automatic discretization of function
|
|
|
@ -1702,13 +1756,13 @@ def discretize(fun, a, b, tol=0.005, n=5, method='linear'):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
return _discretize_linear(fun, a, b, tol, n)
|
|
|
|
return _discretize_linear(fun, a, b, tol, n)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _discretize_linear(fun, a, b, tol=0.005, n=5):
|
|
|
|
def _discretize_linear(fun, a, b, tol=0.005, n=5):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Automatic discretization of function, linear gridding
|
|
|
|
Automatic discretization of function, linear gridding
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
tiny = floatinfo.tiny
|
|
|
|
tiny = floatinfo.tiny
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
x = linspace(a, b, n)
|
|
|
|
x = linspace(a, b, n)
|
|
|
|
y = fun(x)
|
|
|
|
y = fun(x)
|
|
|
|
|
|
|
|
|
|
|
@ -1726,6 +1780,7 @@ def _discretize_linear(fun, a, b, tol=0.005, n=5):
|
|
|
|
err = 0.5 * amax(abs((y00 - y) / (abs(y00 + y) + tiny)))
|
|
|
|
err = 0.5 * amax(abs((y00 - y) / (abs(y00 + y) + tiny)))
|
|
|
|
return x, y
|
|
|
|
return x, y
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _discretize_adaptive(fun, a, b, tol=0.005, n=5):
|
|
|
|
def _discretize_adaptive(fun, a, b, tol=0.005, n=5):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Automatic discretization of function, adaptive gridding.
|
|
|
|
Automatic discretization of function, adaptive gridding.
|
|
|
@ -1747,7 +1802,8 @@ def _discretize_adaptive(fun, a, b, tol=0.005, n=5):
|
|
|
|
|
|
|
|
|
|
|
|
I, = where(erri > tol)
|
|
|
|
I, = where(erri > tol)
|
|
|
|
# double the sample rate in intervals with the most error
|
|
|
|
# double the sample rate in intervals with the most error
|
|
|
|
y = (vstack(((x[I] + x[I - 1]) / 2, (x[I + 1] + x[I]) / 2)).T).ravel()
|
|
|
|
y = (vstack(((x[I] + x[I - 1]) / 2,
|
|
|
|
|
|
|
|
(x[I + 1] + x[I]) / 2)).T).ravel()
|
|
|
|
fy = fun(y)
|
|
|
|
fy = fun(y)
|
|
|
|
|
|
|
|
|
|
|
|
fy0 = interp(y, x, fx)
|
|
|
|
fy0 = interp(y, x, fx)
|
|
|
@ -1903,10 +1959,10 @@ def meshgrid(*xi, **kwargs):
|
|
|
|
sparse = kwargs.get('sparse', False)
|
|
|
|
sparse = kwargs.get('sparse', False)
|
|
|
|
indexing = kwargs.get('indexing', 'xy') # 'ij'
|
|
|
|
indexing = kwargs.get('indexing', 'xy') # 'ij'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ndim = len(args)
|
|
|
|
ndim = len(args)
|
|
|
|
s0 = (1,) * ndim
|
|
|
|
s0 = (1,) * ndim
|
|
|
|
output = [x.reshape(s0[:i] + (-1,) + s0[i + 1::]) for i, x in enumerate(args)]
|
|
|
|
output = [x.reshape(s0[:i] + (-1,) + s0[i + 1::])
|
|
|
|
|
|
|
|
for i, x in enumerate(args)]
|
|
|
|
|
|
|
|
|
|
|
|
shape = [x.size for x in output]
|
|
|
|
shape = [x.size for x in output]
|
|
|
|
|
|
|
|
|
|
|
@ -1938,6 +1994,7 @@ def ndgrid(*args, **kwargs):
|
|
|
|
kwargs['indexing'] = 'ij'
|
|
|
|
kwargs['indexing'] = 'ij'
|
|
|
|
return meshgrid(*args, ** kwargs)
|
|
|
|
return meshgrid(*args, ** kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def trangood(x, f, min_n=None, min_x=None, max_x=None, max_n=inf):
|
|
|
|
def trangood(x, f, min_n=None, min_x=None, max_x=None, max_n=inf):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Make sure transformation is efficient.
|
|
|
|
Make sure transformation is efficient.
|
|
|
@ -2004,10 +2061,10 @@ def trangood(x, f, min_n=None, min_x=None, max_x=None, max_n=inf):
|
|
|
|
L = float(xn - x0)
|
|
|
|
L = float(xn - x0)
|
|
|
|
eps = floatinfo.eps
|
|
|
|
eps = floatinfo.eps
|
|
|
|
if ((nf < min_n) or (max_n < nf) or any(abs(ddx) > 10 * eps * (L))):
|
|
|
|
if ((nf < min_n) or (max_n < nf) or any(abs(ddx) > 10 * eps * (L))):
|
|
|
|
## % pab 07.01.2001: Always choose the stepsize df so that
|
|
|
|
# % pab 07.01.2001: Always choose the stepsize df so that
|
|
|
|
## % it is an exactly representable number.
|
|
|
|
# % it is an exactly representable number.
|
|
|
|
## % This is important when calculating numerical derivatives and is
|
|
|
|
# % This is important when calculating numerical derivatives and is
|
|
|
|
## % accomplished by the following.
|
|
|
|
# % accomplished by the following.
|
|
|
|
dx = L / (min(min_n, max_n) - 1)
|
|
|
|
dx = L / (min(min_n, max_n) - 1)
|
|
|
|
dx = (dx + 2.) - 2.
|
|
|
|
dx = (dx + 2.) - 2.
|
|
|
|
xi = arange(x0, xn + dx / 2., dx)
|
|
|
|
xi = arange(x0, xn + dx / 2., dx)
|
|
|
@ -2033,6 +2090,7 @@ def trangood(x, f, min_n=None, min_x=None, max_x=None, max_n=inf):
|
|
|
|
|
|
|
|
|
|
|
|
return xo, fo
|
|
|
|
return xo, fo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def tranproc(x, f, x0, *xi):
|
|
|
|
def tranproc(x, f, x0, *xi):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Transforms process X and up to four derivatives
|
|
|
|
Transforms process X and up to four derivatives
|
|
|
@ -2108,16 +2166,17 @@ def tranproc(x, f, x0, *xi):
|
|
|
|
y = [y0]
|
|
|
|
y = [y0]
|
|
|
|
hn = xo[1] - xo[0]
|
|
|
|
hn = xo[1] - xo[0]
|
|
|
|
if hn ** N < sqrt(eps):
|
|
|
|
if hn ** N < sqrt(eps):
|
|
|
|
print('Numerical problems may occur for the derivatives in tranproc.')
|
|
|
|
msg = ('Numerical problems may occur for the derivatives in ' +
|
|
|
|
warnings.warn('The sampling of the transformation may be too small.')
|
|
|
|
'tranproc.\nThe sampling of the transformation may be too small.')
|
|
|
|
|
|
|
|
warnings.warn(msg)
|
|
|
|
|
|
|
|
|
|
|
|
#% Transform X with the derivatives of f.
|
|
|
|
# Transform X with the derivatives of f.
|
|
|
|
fxder = zeros((N, x0.size))
|
|
|
|
fxder = zeros((N, x0.size))
|
|
|
|
fder = vstack((xo, fo))
|
|
|
|
fder = vstack((xo, fo))
|
|
|
|
for k in range(N): #% Derivation of f(x) using a difference method.
|
|
|
|
for k in range(N): # Derivation of f(x) using a difference method.
|
|
|
|
n = fder.shape[-1]
|
|
|
|
n = fder.shape[-1]
|
|
|
|
#%fder = [(fder(1:n-1,1)+fder(2:n,1))/2 diff(fder(:,2))./diff(fder(:,1))]
|
|
|
|
fder = vstack([(fder[0, 0:n - 1] + fder[0, 1:n]) / 2,
|
|
|
|
fder = vstack([(fder[0, 0:n - 1] + fder[0, 1:n]) / 2, diff(fder[1, :]) / hn])
|
|
|
|
diff(fder[1, :]) / hn])
|
|
|
|
fxder[k] = tranproc(fder[0], fder[1], x0)
|
|
|
|
fxder[k] = tranproc(fder[0], fder[1], x0)
|
|
|
|
|
|
|
|
|
|
|
|
# Calculate the transforms of the derivatives of X.
|
|
|
|
# Calculate the transforms of the derivatives of X.
|
|
|
@ -2141,14 +2200,18 @@ def tranproc(x, f, x0, *xi):
|
|
|
|
# Fourth time derivative of y:
|
|
|
|
# Fourth time derivative of y:
|
|
|
|
# y4 = f''''(x)*x1.^4+f'(x)*x4
|
|
|
|
# y4 = f''''(x)*x1.^4+f'(x)*x4
|
|
|
|
# +6*f'''(x)*x1^2*x2+f''(x)*(3*x2^2+4x1*x3)
|
|
|
|
# +6*f'''(x)*x1^2*x2+f''(x)*(3*x2^2+4x1*x3)
|
|
|
|
y4 = (fxder[3] * xi[0] ** 4. + fxder[0] * xi[3] + \
|
|
|
|
y4 = (fxder[3] * xi[0] ** 4. + fxder[0] * xi[3] +
|
|
|
|
6. * fxder[2] * xi[0] ** 2. * xi[1] + \
|
|
|
|
6. * fxder[2] * xi[0] ** 2. * xi[1] +
|
|
|
|
fxder[1] * (3. * xi[1] ** 2. + 4. * xi[0] * xi[1]))
|
|
|
|
fxder[1] * (3. * xi[1] ** 2. + 4. * xi[0] * xi[1]))
|
|
|
|
y.append(y4)
|
|
|
|
y.append(y4)
|
|
|
|
if N > 4:
|
|
|
|
if N > 4:
|
|
|
|
warnings.warn('Transformation of derivatives of order>4 not supported.')
|
|
|
|
warnings.warn('Transformation of derivatives of ' +
|
|
|
|
|
|
|
|
'order>4 not supported.')
|
|
|
|
return y # y0,y1,y2,y3,y4
|
|
|
|
return y # y0,y1,y2,y3,y4
|
|
|
|
def good_bins(data=None, range=None, num_bins=None, num_data=None, odd=False, loose=True): #@ReservedAssignment
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def good_bins(data=None, range=None, num_bins=None, # @ReservedAssignment
|
|
|
|
|
|
|
|
num_data=None, odd=False, loose=True):
|
|
|
|
''' Return good bins for histogram
|
|
|
|
''' Return good bins for histogram
|
|
|
|
|
|
|
|
|
|
|
|
Parameters
|
|
|
|
Parameters
|
|
|
@ -2158,7 +2221,8 @@ def good_bins(data=None, range=None, num_bins=None, num_data=None, odd=False, lo
|
|
|
|
range : (float, float)
|
|
|
|
range : (float, float)
|
|
|
|
minimum and maximum range of bins (default data.min(), data.max())
|
|
|
|
minimum and maximum range of bins (default data.min(), data.max())
|
|
|
|
num_bins : scalar integer
|
|
|
|
num_bins : scalar integer
|
|
|
|
approximate number of bins wanted (default depending on num_data=len(data))
|
|
|
|
approximate number of bins wanted
|
|
|
|
|
|
|
|
(default depending on num_data=len(data))
|
|
|
|
odd : bool
|
|
|
|
odd : bool
|
|
|
|
placement of bins (0 or 1) (default 0)
|
|
|
|
placement of bins (0 or 1) (default 0)
|
|
|
|
loose : bool
|
|
|
|
loose : bool
|
|
|
@ -2188,7 +2252,7 @@ def good_bins(data=None, range=None, num_bins=None, num_data=None, odd=False, lo
|
|
|
|
num_bins = np.ceil(4 * np.sqrt(np.sqrt(num_data)))
|
|
|
|
num_bins = np.ceil(4 * np.sqrt(np.sqrt(num_data)))
|
|
|
|
|
|
|
|
|
|
|
|
d = float(mx - mn) / num_bins * 2
|
|
|
|
d = float(mx - mn) / num_bins * 2
|
|
|
|
e = np.floor(np.log(d) / np.log(10));
|
|
|
|
e = np.floor(np.log(d) / np.log(10))
|
|
|
|
m = np.floor(d / 10 ** e)
|
|
|
|
m = np.floor(d / 10 ** e)
|
|
|
|
if m > 5:
|
|
|
|
if m > 5:
|
|
|
|
m = 5
|
|
|
|
m = 5
|
|
|
@ -2201,7 +2265,9 @@ def good_bins(data=None, range=None, num_bins=None, num_data=None, odd=False, lo
|
|
|
|
limits = np.arange(mn, mx + d / 2, d)
|
|
|
|
limits = np.arange(mn, mx + d / 2, d)
|
|
|
|
return limits
|
|
|
|
return limits
|
|
|
|
|
|
|
|
|
|
|
|
def plot_histgrm(data, bins=None, range=None, normed=False, weights=None, lintype='b-'): #@ReservedAssignment
|
|
|
|
|
|
|
|
|
|
|
|
def plot_histgrm(data, bins=None, range=None, # @ReservedAssignment
|
|
|
|
|
|
|
|
normed=False, weights=None, lintype='b-'):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Plot histogram
|
|
|
|
Plot histogram
|
|
|
|
|
|
|
|
|
|
|
@ -2254,7 +2320,9 @@ def plot_histgrm(data, bins=None, range=None, normed=False, weights=None, lintyp
|
|
|
|
if bins is None:
|
|
|
|
if bins is None:
|
|
|
|
bins = np.ceil(4 * np.sqrt(np.sqrt(len(x))))
|
|
|
|
bins = np.ceil(4 * np.sqrt(np.sqrt(len(x))))
|
|
|
|
|
|
|
|
|
|
|
|
bin_, limits = np.histogram(data, bins=bins, normed=normed, weights=weights) #, new=True)
|
|
|
|
#, new=True)
|
|
|
|
|
|
|
|
bin_, limits = np.histogram(
|
|
|
|
|
|
|
|
data, bins=bins, normed=normed, weights=weights)
|
|
|
|
limits.shape = (-1, 1)
|
|
|
|
limits.shape = (-1, 1)
|
|
|
|
xx = limits.repeat(3, axis=1)
|
|
|
|
xx = limits.repeat(3, axis=1)
|
|
|
|
xx.shape = (-1,)
|
|
|
|
xx.shape = (-1,)
|
|
|
@ -2267,6 +2335,7 @@ def plot_histgrm(data, bins=None, range=None, normed=False, weights=None, lintyp
|
|
|
|
yy = np.hstack((yy, 0.0))
|
|
|
|
yy = np.hstack((yy, 0.0))
|
|
|
|
return plotbackend.plot(xx, yy, lintype, limits, limits * 0)
|
|
|
|
return plotbackend.plot(xx, yy, lintype, limits, limits * 0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def num2pistr(x, n=3):
|
|
|
|
def num2pistr(x, n=3):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Convert a scalar to a text string in fractions of pi
|
|
|
|
Convert a scalar to a text string in fractions of pi
|
|
|
@ -2303,6 +2372,7 @@ def num2pistr(x, n=3):
|
|
|
|
xtxt = format % x
|
|
|
|
xtxt = format % x
|
|
|
|
return xtxt
|
|
|
|
return xtxt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def fourier(data, t=None, T=None, m=None, n=None, method='trapz'):
|
|
|
|
def fourier(data, t=None, T=None, m=None, n=None, method='trapz'):
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
Returns Fourier coefficients.
|
|
|
|
Returns Fourier coefficients.
|
|
|
@ -2314,7 +2384,8 @@ def fourier(data, t=None, T=None, m=None, n=None, method='trapz'):
|
|
|
|
t : array-like
|
|
|
|
t : array-like
|
|
|
|
vector with n values indexed from 1 to N.
|
|
|
|
vector with n values indexed from 1 to N.
|
|
|
|
T : real scalar
|
|
|
|
T : real scalar
|
|
|
|
primitive period of signal, i.e., smallest period. (default T = t[-1]-t[0]
|
|
|
|
primitive period of signal, i.e., smallest period.
|
|
|
|
|
|
|
|
(default T = t[-1]-t[0]
|
|
|
|
m : scalar integer
|
|
|
|
m : scalar integer
|
|
|
|
defines no of harmonics desired (default M = N)
|
|
|
|
defines no of harmonics desired (default M = N)
|
|
|
|
n : scalar integer
|
|
|
|
n : scalar integer
|
|
|
@ -2398,7 +2469,7 @@ def fourier(data, t=None, T=None, m=None, n=None, method='trapz'):
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# # Fourier coefficients by fft
|
|
|
|
# Fourier coefficients by fft
|
|
|
|
# Fcof1 = 2*ifft(x(1:N1,:),[],1);
|
|
|
|
# Fcof1 = 2*ifft(x(1:N1,:),[],1);
|
|
|
|
# Pcor = [1; exp(sqrt(-1)*(1:M-1).'*t(1))]; % correction term to get
|
|
|
|
# Pcor = [1; exp(sqrt(-1)*(1:M-1).'*t(1))]; % correction term to get
|
|
|
|
# % the correct integration limits
|
|
|
|
# % the correct integration limits
|
|
|
@ -2409,10 +2480,10 @@ def fourier(data, t=None, T=None, m=None, n=None, method='trapz'):
|
|
|
|
return a, b
|
|
|
|
return a, b
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _test_find_cross():
|
|
|
|
def _test_find_cross():
|
|
|
|
t = findcross([0, 0, 1, -1, 1], 0) # @UnusedVariable
|
|
|
|
t = findcross([0, 0, 1, -1, 1], 0) # @UnusedVariable
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _test_common_shape():
|
|
|
|
def _test_common_shape():
|
|
|
|
|
|
|
|
|
|
|
|
A = ones((4, 1))
|
|
|
|
A = ones((4, 1))
|
|
|
@ -2443,18 +2514,20 @@ def _test_meshgrid():
|
|
|
|
yv[0, 0] = 10
|
|
|
|
yv[0, 0] = 10
|
|
|
|
print(xv)
|
|
|
|
print(xv)
|
|
|
|
print(yv)
|
|
|
|
print(yv)
|
|
|
|
## >>> xv
|
|
|
|
# >>> xv
|
|
|
|
## array([[ 0. , 0.5, 1. ]])
|
|
|
|
## array([[ 0. , 0.5, 1. ]])
|
|
|
|
## >>> yv
|
|
|
|
# >>> yv
|
|
|
|
## array([[ 0.],
|
|
|
|
# array([[ 0.],
|
|
|
|
## [ 1.]])
|
|
|
|
# [ 1.]])
|
|
|
|
## array([[-1. , -0.5, 1. , 4. , 5. ],
|
|
|
|
# array([[-1. , -0.5, 1. , 4. , 5. ],
|
|
|
|
## [-1. , -0.5, 1. , 4. , 5. ],
|
|
|
|
## [-1. , -0.5, 1. , 4. , 5. ],
|
|
|
|
## [-1. , -0.5, 1. , 4. , 5. ]])
|
|
|
|
# [-1. , -0.5, 1. , 4. , 5. ]])
|
|
|
|
##
|
|
|
|
#
|
|
|
|
## array([[ 0., 0., 0., 0., 0.],
|
|
|
|
# array([[ 0., 0., 0., 0., 0.],
|
|
|
|
## [-2., -2., -2., -2., -2.],
|
|
|
|
## [-2., -2., -2., -2., -2.],
|
|
|
|
## [-5., -5., -5., -5., -5.]])
|
|
|
|
# [-5., -5., -5., -5., -5.]])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _test_tranproc():
|
|
|
|
def _test_tranproc():
|
|
|
|
import wafo.transform.models as wtm
|
|
|
|
import wafo.transform.models as wtm
|
|
|
|
tr = wtm.TrHermite()
|
|
|
|
tr = wtm.TrHermite()
|
|
|
@ -2466,14 +2539,19 @@ def _test_tranproc():
|
|
|
|
#>>> plot(g(:,1),[g(:,2),gder(:,2)])
|
|
|
|
#>>> plot(g(:,1),[g(:,2),gder(:,2)])
|
|
|
|
#>>> plot(g(:,1),pdfnorm(g(:,2)).*gder(:,2),g(:,1),pdfnorm(g(:,1)))
|
|
|
|
#>>> plot(g(:,1),pdfnorm(g(:,2)).*gder(:,2),g(:,1),pdfnorm(g(:,1)))
|
|
|
|
#>>> legend('Transformed model','Gaussian model')
|
|
|
|
#>>> legend('Transformed model','Gaussian model')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _test_detrend():
|
|
|
|
def _test_detrend():
|
|
|
|
import pylab as plb
|
|
|
|
import pylab as plb
|
|
|
|
cos = plb.cos;randn = plb.randn
|
|
|
|
cos = plb.cos
|
|
|
|
|
|
|
|
randn = plb.randn
|
|
|
|
x = linspace(0, 1, 200)
|
|
|
|
x = linspace(0, 1, 200)
|
|
|
|
y = exp(x) + cos(5 * 2 * pi * x) + 1e-1 * randn(x.size)
|
|
|
|
y = exp(x) + cos(5 * 2 * pi * x) + 1e-1 * randn(x.size)
|
|
|
|
y0 = detrendma(y, 20);tr = y - y0
|
|
|
|
y0 = detrendma(y, 20)
|
|
|
|
|
|
|
|
tr = y - y0
|
|
|
|
plb.plot(x, y, x, y0, 'r', x, exp(x), 'k', x, tr, 'm')
|
|
|
|
plb.plot(x, y, x, y0, 'r', x, exp(x), 'k', x, tr, 'm')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _test_extrema():
|
|
|
|
def _test_extrema():
|
|
|
|
import pylab as pb
|
|
|
|
import pylab as pb
|
|
|
|
from pylab import plot
|
|
|
|
from pylab import plot
|
|
|
@ -2485,7 +2563,6 @@ def _test_extrema():
|
|
|
|
_ind1 = findrfc(tp, 0.3)
|
|
|
|
_ind1 = findrfc(tp, 0.3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _test_discretize():
|
|
|
|
def _test_discretize():
|
|
|
|
import pylab as plb
|
|
|
|
import pylab as plb
|
|
|
|
x, y = discretize(cos, 0, pi)
|
|
|
|
x, y = discretize(cos, 0, pi)
|
|
|
@ -2501,6 +2578,7 @@ def _test_stirlerr():
|
|
|
|
print getshipchar(1000)
|
|
|
|
print getshipchar(1000)
|
|
|
|
print betaloge(3, 2)
|
|
|
|
print betaloge(3, 2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _test_parse_kwargs():
|
|
|
|
def _test_parse_kwargs():
|
|
|
|
opt = dict(arg1=1, arg2=3)
|
|
|
|
opt = dict(arg1=1, arg2=3)
|
|
|
|
print opt
|
|
|
|
print opt
|
|
|
@ -2519,6 +2597,7 @@ def _test_parse_kwargs():
|
|
|
|
out1 = testfun(opt0['opt1'], **opt0)
|
|
|
|
out1 = testfun(opt0['opt1'], **opt0)
|
|
|
|
print out1
|
|
|
|
print out1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_docstrings():
|
|
|
|
def test_docstrings():
|
|
|
|
import doctest
|
|
|
|
import doctest
|
|
|
|
doctest.testmod()
|
|
|
|
doctest.testmod()
|
|
|
|