small updates

master
Per.Andreas.Brodtkorb 13 years ago
parent 596a513a78
commit 2aa3f24255

@ -21,6 +21,7 @@ src/wafo/definitions.py
src/wafo/definitions.~py
src/wafo/demo_sg.py
src/wafo/demos.py
src/wafo/fig.py
src/wafo/gaussian.py
src/wafo/graphutil.py
src/wafo/info.py
@ -38,6 +39,7 @@ src/wafo/objects.py
src/wafo/plotbackend.py
src/wafo/polynomial.py
src/wafo/polynomial_old.py
src/wafo/pychip.py
src/wafo/rindmod.pyd
src/wafo/rindmod.so
src/wafo/sg_filter.py
@ -97,7 +99,6 @@ src/wafo/source/cov2XXXpdf/bounds/cov2acdfb.f
src/wafo/source/cov2XXXpdf/bounds/cov2mmpdfb.f
src/wafo/source/cov2XXXpdf/bounds/cov2tccpdfb.f
src/wafo/source/cov2XXXpdf/bounds/cov2tthpdfb.f
src/wafo/source/mreg/build_all_.py
src/wafo/source/mreg/checkmod.mod
src/wafo/source/mreg/cov2mmpdfmod.mod
src/wafo/source/mreg/cov2mmpdfreg.f
@ -283,10 +284,8 @@ src/wafo/spectrum/test/test_specdata1d.py
src/wafo/stats/__init__.py
src/wafo/stats/core.py
src/wafo/stats/distributions.py
src/wafo/stats/distributions_juli2010.py
src/wafo/stats/estimation.py
src/wafo/stats/misc.py
src/wafo/stats/twolumps.py
src/wafo/stats/tests/test_distributions.py
src/wafo/stats/tests/test_estimation.py
src/wafo/test/__init__.py
@ -301,3 +300,6 @@ src/wafo/transform/models.~py
src/wafo/transform/test/__init__.py
src/wafo/transform/test/test_models.py
src/wafo/transform/test/test_trdata.py
src/wafo/wave_theory/__init__.py
src/wafo/wave_theory/core.py
src/wafo/wave_theory/dispersion_relation.py

@ -74,9 +74,11 @@ def setbits(bitlist):
val |= j << i
return val
if __name__ == '__main__':
def test_docstrings():
import doctest
doctest.testmod()
if __name__ == '__main__':
test_docstrings()
# t = set(np.arange(8),1,1)
# t=get(0x84,np.arange(0,8))

Binary file not shown.

Binary file not shown.

@ -3,7 +3,7 @@ from scipy.fftpack import dct as _dct
from scipy.fftpack import idct as _idct
__all__ = ['dct', 'idct', 'dctn', 'idctn']
def dct(x, type=2, n=None, axis=-1, norm='ortho'):
def dct(x, type=2, n=None, axis=-1, norm='ortho'): #@ReservedAssignment
'''
Return the Discrete Cosine Transform of arbitrary type sequence x.
@ -102,7 +102,7 @@ def dct(x, type=2, n=None, axis=-1, norm='ortho'):
return _dct(farr(x.real), type, n, axis, norm) + 1j*_dct(farr(x.imag), type, n, axis, norm)
else:
return _dct(farr(x), type, n, axis, norm)
def idct(x, type=2, n=None, axis=-1, norm='ortho'):
def idct(x, type=2, n=None, axis=-1, norm='ortho'): #@ReservedAssignment
'''
Return the Inverse Discrete Cosine Transform of an arbitrary type sequence.
@ -144,7 +144,7 @@ def idct(x, type=2, n=None, axis=-1, norm='ortho'):
return _idct(farr(x.real), type, n, axis, norm) + 1j*_idct(farr(x.imag), type, n, axis, norm)
else:
return _idct(farr(x), type, n, axis, norm)
def dctn(x, type=2, axis=None, norm='ortho'):
def dctn(x, type=2, axis=None, norm='ortho'): #@ReservedAssignment
'''
DCTN N-D discrete cosine transform.
@ -215,7 +215,7 @@ def dctn(x, type=2, axis=None, norm='ortho'):
y = _dct(y, type, norm=norm)
return y.reshape(shape0)
def idctn(x, type=2, axis=None, norm='ortho'):
def idctn(x, type=2, axis=None, norm='ortho'): #@ReservedAssignment
y = np.atleast_1d(x)
shape0 = y.shape
if axis is None:
@ -645,5 +645,5 @@ def test_docstrings():
doctest.testmod()
if __name__ == '__main__':
#test_docstrings()
test_dctn()
test_docstrings()
#test_dctn()

@ -241,7 +241,7 @@ def keep(*figs):
--------
# keep only figures 1,2,3,5 and 7
>>> import pylab as p
>>> import pyfig as fig
>>> import wafo.fig as fig
>>> for ix in range(10): f = p.figure(ix)
>>> fig.keep( range(1,4), 5, 7)
@ -283,7 +283,7 @@ def close(*figs):
Examples
--------
>>> import pylab as p
>>> import pyfig as fig
>>> import wafo.fig as fig
>>> for ix in range(5): f = p.figure(ix)
>>> fig.close(3,4) # close figure 3 and 4
>>> fig.close('all') # close all remaining figures
@ -317,7 +317,7 @@ def restore(*figs):
Examples
---------
>>> import pylab as p
>>> import pyfig as fig
>>> import wafo.fig as fig
>>> for ix in range(5): f = p.figure(ix)
>>> fig.restore('all') #Restores all figures
>>> fig.restore() #same as restore('all')
@ -350,7 +350,7 @@ def hide(*figs):
Examples:
--------
>>> import pyfig as fig
>>> import wafo.fig as fig
>>> import pylab as p
>>> for ix in range(5): f = p.figure(ix)
>>> fig.hide('all') #hides all unhidden figures
@ -385,7 +385,7 @@ def minimize(*figs):
Examples:
---------
>>> import pyfig as fig
>>> import wafo.fig as fig
>>> import pylab as p
>>> for ix in range(5): f = p.figure(ix)
>>> fig.minimize('all') #Minimizes all unhidden figures
@ -420,7 +420,7 @@ def maximize(*figs):
Examples:
---------
>>> import pylab as p
>>> import pyfig as fig
>>> import wafo.fig as fig
>>> for ix in range(5): f = p.figure(ix)
>>> fig.maximize('all') #Maximizes all unhidden figures
>>> fig.maximize() #same as maximize('all')
@ -461,7 +461,7 @@ def pile(*figs):
Example:
--------
>>> import pylab as p
>>> import pyfig as fig
>>> import wafo.fig as fig
>>> for ix in range(5): f = p.figure(ix)
>>> fig.pile() # pile all open figures
>>> fig.pile(range(1,4), 5, 7) # pile figure 1,2,3,5 and 7
@ -506,7 +506,7 @@ def stack(*figs):
Example:
--------
>>> import pylab as p
>>> import pyfig as fig
>>> import wafo.fig as fig
>>> for ix in range(5): f = p.figure(ix)
>>> fig.stack() # stack all open figures
>>> fig.stack(range(1,4), 5, 7) # stack figure 1,2,3,5 and 7
@ -568,7 +568,7 @@ def tile(*figs, **kwds):
Example:
--------
>>> import pylab as p
>>> import pyfig as fig
>>> import wafo.fig as fig
>>> for ix in range(5): f = p.figure(ix)
>>> fig.tile() # tile all open figures
>>> fig.tile( range(1,4), 5, 7) # tile figure 1,2,3,5 and 7
@ -677,7 +677,7 @@ def cycle(*figs, **kwds):
Examples:
>>> import pylab as p
>>> import pyfig as fig
>>> import wafo.fig as fig
>>> for ix in range(4): f = p.figure(ix)
fig.cycle(range(3)) #Cycle trough figure 0 to 2
@ -746,11 +746,13 @@ def cycle(*figs, **kwds):
wnds.reverse()
_show_windows(wnds, win32con.SW_SHOWNORMAL)
if __name__ == '__main__':
def test_docstrings():
import doctest
doctest.testmod()
if __name__ == '__main__':
test_docstrings()
#def _errcheck(result, func, args):
# if not result:
# raise WinError()

@ -500,7 +500,7 @@ def prbnormtndpc(rho, a, b, D=None, df=0, abseps=1e-4, IERC=0, HNC=0.24):
# Make sure integration limits are finite
A = np.clip(a - D, -100, 100)
B = np.clip(b - D, -100, 100)
return mvnprdmod.prbnormtndpc(rho, A, B, df, abseps, IERC, HNC)
return mvnprdmod.prbnormtndpc(rho, A, B, df, abseps, IERC, HNC) #@UndefinedVariable
def prbnormndpc(rho, a, b, abserr=1e-4, relerr=1e-4, usesimpson=True, usebreakpoints=False):
'''
@ -561,7 +561,7 @@ def prbnormndpc(rho, a, b, abserr=1e-4, relerr=1e-4, usesimpson=True, usebreakpo
'''
# Call fortran implementation
val, err, ier = mvnprdmod.prbnormndpc(rho, a, b, abserr, relerr, usebreakpoints, usesimpson);
val, err, ier = mvnprdmod.prbnormndpc(rho, a, b, abserr, relerr, usebreakpoints, usesimpson); #@UndefinedVariable
if ier > 0:
warnings.warn('Abnormal termination ier = %d\n\n%s' % (ier, _ERRORMESSAGE[ier]))
@ -697,7 +697,7 @@ def prbnormnd(correl, a, b, abseps=1e-4, releps=1e-3, maxpts=None, method=0):
infinity = 37
infin = np.repeat(2, n) - (B > infinity) - 2 * (A < -infinity)
err, val, inform = mvn.mvndst(A, B, infin, L, maxpts, abseps, releps)
err, val, inform = mvn.mvndst(A, B, infin, L, maxpts, abseps, releps) #@UndefinedVariable
return val, err, inform

@ -7,7 +7,7 @@ from scipy import integrate as intg
import scipy.special.orthogonal as ort
from scipy import special as sp
from wafo.plotbackend import plotbackend as plt
from scipy.integrate import simps, trapz
from scipy.integrate import simps, trapz #@UnusedImport
from wafo.misc import is_numlike
from wafo.demos import humps
@ -53,10 +53,10 @@ def dea3(v0, v1, v2):
... Ei[k] = np.trapz(np.sin(x),x)
>>> En, err = dea3(Ei[0],Ei[1],Ei[2])
>>> En, err
(array([ 1.]), array([ 0.00020081]))
(array([ 1.]), array([ 0.0002008]))
>>> TrueErr = Ei-1.
>>> TrueErr
array([ -2.00805680e-04, -5.01999079e-05, -1.25498825e-05])
array([ -2.0080568e-04, -5.0199908e-05, -1.2549882e-05])
See also
--------
@ -71,8 +71,8 @@ def dea3(v0, v1, v2):
'''
E0, E1, E2 = np.atleast_1d(v0, v1, v2)
abs = np.abs
max = np.maximum
abs = np.abs #@ReservedAssignment
max = np.maximum #@ReservedAssignment
ten = 10.0
one = ones(1)
small = np.finfo(float).eps #1.0e-16 #spacing(one)
@ -96,6 +96,8 @@ def dea3(v0, v1, v2):
k1, = (1 - converged).nonzero()
if k1.size > 0 :
with warnings.catch_warnings():
warnings.simplefilter("ignore") # ignore division by zero and overflow
ss = one / delta2[k1] - one / delta1[k1]
smallE2 = (abs(ss * E1[k1]) <= 1.0e-3).ravel()
k2 = k1[smallE2.nonzero()]
@ -253,7 +255,7 @@ def romberg(fun, a, b, releps=1e-3, abseps=1e-3):
>>> import numpy as np
>>> [q,err] = romberg(np.sqrt,0,10,0,1e-4)
>>> q,err
(array([ 21.08185107]), array([ 6.61635466e-05]))
(array([ 21.0818511]), array([ 6.6163547e-05]))
'''
h = b - a
hMin = 1.0e-9
@ -375,7 +377,7 @@ def h_roots(n, method='newton'):
L = zeros((3, len(z)))
k0 = 0
kp1 = 1
for its in xrange(max_iter):
for _its in xrange(max_iter):
#Newtons method carried out simultaneously on the roots.
L[k0, :] = 0
L[kp1, :] = PIM4
@ -475,7 +477,7 @@ def j_roots(n, alpha, beta, method='newton'):
L = zeros((3, len(z)))
k0 = 0
kp1 = 1
for its in xrange(max_iter):
for _its in xrange(max_iter):
#Newton's method carried out simultaneously on the roots.
tmp = 2 + alfbet
L[k0, :] = 1
@ -583,7 +585,7 @@ def la_roots(n, alpha=0, method='newton'):
k0 = 0
kp1 = 1
k = slice(len(z))
for its in xrange(max_iter):
for _its in xrange(max_iter):
#%Newton's method carried out simultaneously on the roots.
L[k0, k] = 0.
L[kp1, k] = 1.
@ -684,7 +686,7 @@ def p_roots(n, method='newton', a= -1, b=1):
# using the recursion relation and the Newton-Raphson method
#% Legendre-Gauss Polynomials
# Legendre-Gauss Polynomials
L = zeros((3, m))
# Derivative of LGP
@ -693,14 +695,14 @@ def p_roots(n, method='newton', a= -1, b=1):
releps = 1e-15
max_iter = 100
#% Compute the zeros of the N+1 Legendre Polynomial
#% using the recursion relation and the Newton-Raphson method
# Compute the zeros of the N+1 Legendre Polynomial
# using the recursion relation and the Newton-Raphson method
#% Iterate until new points are uniformly within epsilon of old points
# Iterate until new points are uniformly within epsilon of old points
k = slice(m)
k0 = 0
kp1 = 1
for ix in xrange(max_iter):
for _ix in xrange(max_iter):
L[k0, k] = 1
L[kp1, k] = xo[k]
@ -728,7 +730,7 @@ def p_roots(n, method='newton', a= -1, b=1):
e1 = n * (n + 1)
for j in xrange(2):
for _j in xrange(2):
pkm1 = 1
pk = xo
for k in xrange(2, n + 1):
@ -815,8 +817,8 @@ def qrule(n, wfun=1, alpha=0, beta=0):
>>> sum(bp**2*wf) # integral of exp(-x.^2)*x.^2 from a = -inf to b = inf
0.88622692545275772
>>> [bp,wf] = qrule(10,4,1,2)
>>> sum(bp*wf) # integral of (x+1)*(1-x)^2 from a = -1 to b = 1
0.26666666666666844
>>> (bp*wf).sum() # integral of (x+1)*(1-x)^2 from a = -1 to b = 1
0.26666666666666755
See also
--------
@ -927,23 +929,22 @@ def gaussq(fun, a, b, reltol=1e-3, abstol=1e-3, alpha=0, beta=0, wfun=1,
integration of x**2 from 0 to 2 and from 1 to 4
>>> from scitools import numpyutils as npt
scitools.easyviz backend is matplotlib
>>> A = [0, 1]; B = [2,4]
>>> fun = npt.wrap2callable('x**2')
>>> [val1,err1] = gaussq(fun,A,B)
>>> val1
array([ 2.66666667, 21. ])
array([ 2.6666667, 21. ])
>>> err1
array([ 1.77635684e-15, 1.06581410e-14])
array([ 1.7763568e-15, 1.0658141e-14])
Integration of x^2*exp(-x) from zero to infinity:
>>> fun2 = npt.wrap2callable('1')
>>> val2, err2 = gaussq(fun2, 0, npt.inf, wfun=3, alpha=2)
>>> val3, err3 = gaussq(lambda x: x**2,0, npt.inf, wfun=3, alpha=0)
>>> val2, err2
(array([ 2.]), array([ 6.66133815e-15]))
(array([ 2.]), array([ 6.6613381e-15]))
>>> val3, err3
(array([ 2.]), array([ 1.77635684e-15]))
(array([ 2.]), array([ 1.7763568e-15]))
Integrate humps from 0 to 2 and from 1 to 4
>>> val4, err4 = gaussq(humps,A,B)
@ -1154,7 +1155,7 @@ def quadgr(fun, a, b, abseps=1e-5):
>>> import numpy as np
>>> Q, err = quadgr(np.log,0,1)
>>> quadgr(np.exp,0,9999*1j*np.pi)
(-2.0000000000122617, 2.1933275196062141e-09)
(-2.0000000000122662, 2.1933237448479304e-09)
>>> quadgr(lambda x: np.sqrt(4-x**2),0,2,1e-12)
(3.1415926535897811, 1.5809575870662229e-13)
@ -1195,16 +1196,16 @@ def quadgr(fun, a, b, abseps=1e-5):
if ~ np.isreal(a) | ~np.isreal(b) | np.isnan(a) | np.isnan(b):
raise ValueError('Infinite intervals must be real.')
#% Change of variable
# Change of variable
if np.isfinite(a) & np.isinf(b):
#% a to inf
# a to inf
fun1 = lambda t : fun(a + t / (1 - t)) / (1 - t) ** 2
[Q, err] = quadgr(fun1, 0, 1, abseps)
elif np.isinf(a) & np.isfinite(b):
#% -inf to b
# -inf to b
fun2 = lambda t: fun(b + t / (1 + t)) / (1 + t) ** 2
[Q, err] = quadgr(fun2, -1, 0, abseps)
else: #% -inf to inf
else: # -inf to inf
fun1 = lambda t: fun(t / (1 - t)) / (1 - t) ** 2
fun2 = lambda t: fun(t / (1 + t)) / (1 + t) ** 2
[Q1, err1] = quadgr(fun1, 0, 1, abseps / 2)
@ -1212,7 +1213,7 @@ def quadgr(fun, a, b, abseps=1e-5):
Q = Q1 + Q2
err = err1 + err2
#% Reverse direction
# Reverse direction
if reverse:
Q = -Q
return Q, err
@ -1225,12 +1226,17 @@ def quadgr(fun, a, b, abseps=1e-5):
xq = np.hstack((xq, -xq))
wq = np.hstack((wq, wq))
nq = len(xq)
# iscomplex = (np.iscomplex(a) | np.iscomplex(b)).any()
# if iscomplex:
# dtype = np.complex128
# else:
dtype = np.float64
#% Initiate vectors
max_iter = 17 # Max number of iterations
Q0 = zeros(max_iter) # Quadrature
Q1 = zeros(max_iter) # First Richardson extrapolation
Q2 = zeros(max_iter) # Second Richardson extrapolation
Q0 = zeros(max_iter, dtype=dtype) # Quadrature
Q1 = zeros(max_iter, dtype=dtype) # First Richardson extrapolation
Q2 = zeros(max_iter, dtype=dtype) # Second Richardson extrapolation
# One interval
hh = (b - a) / 2 # Half interval length
@ -1270,8 +1276,8 @@ def quadgr(fun, a, b, abseps=1e-5):
j = errors.argmin()
err = errors[j]
Q = Qv[j]
if k >= 2:
val, err1 = dea3(Q0[k - 2], Q0[k - 1], Q0[k])
if k >= 2 : #and not iscomplex:
_val, err1 = dea3(Q0[k - 2], Q0[k - 1], Q0[k])
# Convergence
if (err < abseps) | ~np.isfinite(Q):
@ -1346,7 +1352,7 @@ def qdemo(f, a, b):
#true1 = quad8(f,a,b,1e-10)
#[true tol]= gaussq(f,a,b,1e-12)
#[true tol] = agakron(f,a,b,1e-13)
true_val, tol = intg.quad(f, a, b)
true_val, _tol = intg.quad(f, a, b)
print('true value = %12.8f' % (true_val,))
kmax = 9
neval = zeros(kmax, dtype=int)
@ -1449,7 +1455,7 @@ def main():
sum(w)
[x2, w2] = la_roots(11, 1, 't')
from scitools import numpyutils as npu
from scitools import numpyutils as npu #@UnresolvedImport
fun = npu.wrap2callable('x**2')
p0 = fun(0)
A = [0, 1, 1]; B = [2, 4, 3]
@ -1474,8 +1480,10 @@ def main():
q0 = np.trapz(humps(x), x)
[q, err] = romberg(humps, 0, np.pi / 2, 1e-4)
print q, err
if __name__ == '__main__':
def test_docstrings():
np.set_printoptions(precision=7)
import doctest
doctest.testmod()
if __name__ == '__main__':
test_docstrings()
#main()

@ -24,7 +24,7 @@ import polynomial as pl
__all__ = ['PPform', 'savitzky_golay', 'savitzky_golay_piecewise', 'sgolay2d','SmoothSpline',
'slopes','pchip_slopes','slopes2','stineman_interp', 'Pchip','StinemanInterp', 'CubicHermiteSpline']
'pchip_slopes','slopes','stineman_interp', 'Pchip','StinemanInterp', 'CubicHermiteSpline']
def savitzky_golay(y, window_size, order, deriv=0):
r"""Smooth (and optionally differentiate) data with a Savitzky-Golay filter.
@ -63,10 +63,10 @@ def savitzky_golay(y, window_size, order, deriv=0):
>>> y = np.exp( -t**2 ) + np.random.normal(0, 0.05, t.shape)
>>> ysg = savitzky_golay(y, window_size=31, order=4)
>>> import matplotlib.pyplot as plt
>>> plt.plot(t, y, label='Noisy signal')
>>> plt.plot(t, np.exp(-t**2), 'k', lw=1.5, label='Original signal')
>>> plt.plot(t, ysg, 'r', label='Filtered signal')
>>> plt.legend()
>>> h=plt.plot(t, y, label='Noisy signal')
>>> h=plt.plot(t, np.exp(-t**2), 'k', lw=1.5, label='Original signal')
>>> h=plt.plot(t, ysg, 'r', label='Filtered signal')
>>> h=plt.legend()
>>> plt.show()
References
@ -81,7 +81,7 @@ def savitzky_golay(y, window_size, order, deriv=0):
try:
window_size = np.abs(np.int(window_size))
order = np.abs(np.int(order))
except ValueError, msg:
except ValueError:
raise ValueError("window_size and order have to be of type int")
if window_size % 2 != 1 or window_size < 1:
raise TypeError("window_size size must be a positive odd number")
@ -110,6 +110,8 @@ def savitzky_golay_piecewise(xvals, data, kernel=11, order =4):
Example
-------
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> n = 1e3
>>> x = np.linspace(0, 25, n)
>>> y = np.round(sin(x))
@ -118,9 +120,9 @@ def savitzky_golay_piecewise(xvals, data, kernel=11, order =4):
# As an example, this figure shows the effect of an additive noise with a variance
# of 0.2 (original signal (black), noisy signal (red) and filtered signal (blue dots)).
>>> yn = y + sqrt(0.2)*np.random.randn(*x.shape)
>>> yn = y + np.sqrt(0.2)*np.random.randn(*x.shape)
>>> yr = savitzky_golay_piecewise(x, yn, kernel=11, order=4)
>>> plt.plot(x, yn, 'r', x, y, 'k', x, yr, 'b.')
>>> h=plt.plot(x, yn, 'r', x, y, 'k', x, yr, 'b.')
'''
turnpoint=0
last=len(xvals)
@ -173,9 +175,9 @@ def sgolay2d ( z, window_size, order, derivative=None):
# do some plotting
>>> import matplotlib.pyplot as plt
>>> plt.matshow(Z)
>>> plt.matshow(Zn)
>>> plt.matshow(Zf)
>>> h=plt.matshow(Z)
>>> h=plt.matshow(Zn)
>>> h=plt.matshow(Zf)
"""
# number of terms in the polynomial expression
n_terms = (order + 1) * (order + 2) / 2.0
@ -263,13 +265,14 @@ class PPform(object):
Example
-------
>>> import matplotlib.pyplot as plt
>>> coef = np.array([[1,1]]) # unit step function
>>> coef = np.array([[1,1],[0,1]]) # linear from 0 to 2
>>> coef = np.array([[1,1],[1,1],[0,2]]) # linear from 0 to 2
>>> breaks = [0,1,2]
>>> self = PPform(coef, breaks)
>>> x = linspace(-1,3)
>>> plot(x,self(x))
>>> h=plt.plot(x,self(x))
"""
def __init__(self, coeffs, breaks, fill=0.0, sort=False, a=None, b=None):
if sort:
@ -450,11 +453,12 @@ class SmoothSpline(PPform):
Example
-------
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> x = np.linspace(0,1)
>>> y = exp(x)+1e-1*np.random.randn(x.shape)
>>> y = np.exp(x)+1e-1*np.random.randn(x.size)
>>> pp9 = SmoothSpline(x, y, p=.9)
>>> pp99 = SmoothSpline(x, y, p=.99, var=0.01)
>>> plot(x,y, x,pp99(x),'g', x,pp9(x),'k', x,exp(x),'r')
>>> h=plt.plot(x,y, x,pp99(x),'g', x,pp9(x),'k', x,np.exp(x),'r')
See also
--------
@ -604,7 +608,7 @@ def pchip_slopes(x, y):
dk[-1] = _edge_case(mk[-1],dk[-2])
return dk
def slopes2(x,y, method='parabola', tension=0, monotone=True):
def slopes(x,y, method='parabola', tension=0, monotone=False):
'''
Return estimated slopes y'(x)
@ -647,7 +651,7 @@ def slopes2(x,y, method='parabola', tension=0, monotone=True):
dydx = (y[1:] - y[:-1]) / dx
method = method.lower()
if method.startswith('parabola'):
if method.startswith('p'): #parabola'):
yp[1:-1] = (dydx[:-1] * dx[1:] + dydx[1:] * dx[:-1]) / (dx[1:] + dx[:-1])
yp[0] = 2.0 * dydx[0] - yp[1]
yp[-1] = 2.0 * dydx[-1] - yp[-2]
@ -655,12 +659,12 @@ def slopes2(x,y, method='parabola', tension=0, monotone=True):
# At the endpoints - use one-sided differences
yp[0] = dydx[0]
yp[-1] = dydx[-1]
if method.startswith('secant'):
if method.startswith('s'): #secant'):
# In the middle - use the average of the secants
yp[1:-1] = (dydx[:-1] + dydx[1:]) / 2.0
else: # Cardinal or Catmull-Rom method
yp[1:-1] = (y[2:] - y[:-2]) / (x[2:] - x[:-2])
if method.startswith('cardinal'):
if method.startswith('car'): #cardinal'):
yp = (1-tension) * yp
if monotone:
@ -689,45 +693,11 @@ def slopes2(x,y, method='parabola', tension=0, monotone=True):
return yp
def slopes(x, y):
"""
:func:`slopes` calculates the slope *y*'(*x*)
The slope is estimated using the slope obtained from that of a
parabola through any three consecutive points.
This method should be superior to that described in the appendix
of A CONSISTENTLY WELL BEHAVED METHOD OF INTERPOLATION by Russel
W. Stineman (Creative Computing July 1980) in at least one aspect:
Circles for interpolation demand a known aspect ratio between
*x*- and *y*-values. For many functions, however, the abscissa
are given in different dimensions, so an aspect ratio is
completely arbitrary.
The parabola method gives very similar results to the circle
method for most regular cases but behaves much better in special
cases.
Norbert Nemec, Institute of Theoretical Physics, University or
Regensburg, April 2006 Norbert.Nemec at physik.uni-regensburg.de
(inspired by a original implementation by Halldor Bjornsson,
Icelandic Meteorological Office, March 2006 halldor at vedur.is)
"""
# Cast key variables as float.
x = np.asarray(x, np.float_)
y = np.asarray(y, np.float_)
yp = np.zeros(y.shape, np.float_)
dx = x[1:] - x[:-1]
dy = y[1:] - y[:-1]
dydx = dy / dx
yp[1:-1] = (dydx[:-1] * dx[1:] + dydx[1:] * dx[:-1]) / (dx[1:] + dx[:-1])
yp[0] = 2.0 * dy[0] / dx[0] - yp[1]
yp[-1] = 2.0 * dy[-1] / dx[-1] - yp[-2]
return yp
class StinemanInterp2(PiecewisePolynomial):
def __init__(self, x, y, yp=None, method='parabola', monotone=False):
if yp is None:
yp = slopes(x, y, method, monotone=monotone)
super(StinemanInterp,self).__init__(x, zip(y,yp))
class StinemanInterp(object):
'''
@ -773,16 +743,18 @@ class StinemanInterp(object):
Examples
--------
>>> import wafo.interpolate as wi
>>> x = linspace(0,2*pi,20)
>>> y = sin(x); yp = cos(x)
>>> xi = linspace(0,2*pi,40);
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> x = np.linspace(0,2*pi,20)
>>> y = np.sin(x); yp = np.cos(x)
>>> xi = np.linspace(0,2*pi,40);
>>> yi = wi.StinemanInterp(x,y)(xi)
>>> yi1 = wi.CubicHermiteSpline(x,y, yp)(xi)
>>> yi2 = wi.Pchip(x,y, method='parabola')(xi)
>>> plt.subplot(211)
>>> plt.plot(x,y,'o',xi,yi,'r', xi,yi1, 'g', xi,yi1, 'b')
>>> plt.subplot(212)
>>> plt.plot(xi,np.abs(sin(xi)-yi), 'r', xi, np.abs(sin(xi)-yi1), 'g', xi, np.abs(sin(xi)-yi2), 'b')
>>> h=plt.subplot(211)
>>> h=plt.plot(x,y,'o',xi,yi,'r', xi,yi1, 'g', xi,yi1, 'b')
>>> h=plt.subplot(212)
>>> h=plt.plot(xi,np.abs(sin(xi)-yi), 'r', xi, np.abs(sin(xi)-yi1), 'g', xi, np.abs(sin(xi)-yi2), 'b')
References
----------
@ -792,9 +764,9 @@ class StinemanInterp(object):
--------
slopes, Pchip
'''
def __init__(self, x,y,yp=None,method='parabola'):
def __init__(self, x,y,yp=None,method='parabola', monotone=False):
if yp is None:
yp = slopes2(x, y, method)
yp = slopes(x, y, method, monotone)
self.x = np.asarray(x, np.float_)
self.y = np.asarray(y, np.float_)
self.yp = np.asarray(yp, np.float_)
@ -940,7 +912,7 @@ class CubicHermiteSpline(PiecewisePolynomial):
'''
def __init__(self, x, y, yp=None, method='Catmull-Rom'):
if yp is None:
yp = slopes2(x, y, method, monotone=False)
yp = slopes(x, y, method, monotone=False)
super(CubicHermiteSpline, self).__init__(x, zip(y,yp), orders=3)
class Pchip(PiecewisePolynomial):
@ -972,6 +944,7 @@ class Pchip(PiecewisePolynomial):
Example
-------
>>> import wafo.interpolate as wi
# Create a step function (will demonstrate monotonicity)
>>> x = np.arange(7.0) - 3.0
>>> y = np.array([-1.0, -1,-1,0,1,1,1])
@ -992,24 +965,25 @@ class Pchip(PiecewisePolynomial):
>>> yvec3 = wi.StinemanInterp(x, y)(xvec)
# Plot the results
>>> plt.plot(x, y, 'ro')
>>> plt.plot(xvec, yvec, 'b')
>>> plt.plot(xvec, yvec1, 'k')
>>> plt.plot(xvec, yvec2, 'g')
>>> plt.plot(xvec, yvec3, 'm')
>>> plt.title("pchip() step function test")
>>> plt.xlabel("X")
>>> plt.ylabel("Y")
>>> plt.title("Comparing pypchip() vs. Scipy interp1d() vs. non-monotonic CHS")
>>> import matplotlib.pyplot as plt
>>> h=plt.plot(x, y, 'ro')
>>> h=plt.plot(xvec, yvec, 'b')
>>> h=plt.plot(xvec, yvec1, 'k')
>>> h=plt.plot(xvec, yvec2, 'g')
>>> h=plt.plot(xvec, yvec3, 'm')
>>> h=plt.title("pchip() step function test")
>>> h=plt.xlabel("X")
>>> h=plt.ylabel("Y")
>>> h=plt.title("Comparing pypchip() vs. Scipy interp1d() vs. non-monotonic CHS")
>>> legends = ["Data", "pypchip()", "interp1d","CHS", 'SI']
>>> plt.legend(legends, loc="upper left")
>>> h=plt.legend(legends, loc="upper left")
>>> plt.show()
"""
def __init__(self, x, y, yp=None, method='secant'):
if yp is None:
yp = slopes2(x, y, method=method, monotone=True)
yp = slopes(x, y, method=method, monotone=True)
super(Pchip, self).__init__(x, zip(y,yp), orders=3)
def test_smoothing_spline():
@ -1023,13 +997,98 @@ def test_smoothing_spline():
dy1 = pp1(x1)
y01 = pp0(x1)
#dy = y-y1
import pylab as plb
import matplotlib.pyplot as plb
plb.plot(x, y, x1, y1, '.', x1, dy1, 'ro', x1, y01, 'r-')
plb.show()
pass
#tck = interpolate.splrep(x, y, s=len(x))
def compare_methods():
############################################################
# Sine wave test
############################################################
# Create a example vector containing a sine wave.
x = np.arange(30.0)/10.
y = np.sin(x)
# Interpolate the data above to the grid defined by "xvec"
xvec = np.arange(250.)/100.
# Initialize the interpolator slopes
# Create the pchip slopes
m = slopes(x, y, method='parabola', monotone=True)
m1 = slopes(x, y, method='parabola', monotone=False)
m2 = slopes(x, y, method='catmul', monotone=False)
m3 = pchip_slopes(x, y)
# Call the monotonic piece-wise Hermite cubic interpolator
yvec = Pchip(x, y, m)(xvec)
yvec1 = Pchip(x, y, m1)(xvec)
yvec2 = Pchip(x, y, m2)(xvec)
yvec3 = Pchip(x, y, m3)(xvec)
import matplotlib.pyplot as plt
plt.figure()
plt.plot(x,y, 'r.')
plt.title("pchip() Sin test code")
# Plot the interpolated points
plt.plot(xvec, yvec, xvec, yvec1, xvec, yvec2,'go',xvec, yvec3)
plt.legend(['true','parbola_monoton','parabola','catmul','pchip'], frameon=False, loc=0)
plt.ioff()
plt.show()
def demo_monoticity():
# Step function test...
import matplotlib.pyplot as plt
plt.figure(2)
plt.title("pchip() step function test")
# Create a step function (will demonstrate monotonicity)
x = np.arange(7.0) - 3.0
y = np.array([-1.0, -1,-1,0,1,1,1])
# Interpolate using monotonic piecewise Hermite cubic spline
xvec = np.arange(599.)/100. - 3.0
# Create the pchip slopes
m = slopes(x,y, monotone=True)
# m1 = slopes(x, y, monotone=False)
# m2 = slopes(x,y,method='catmul',monotone=False)
m3 = pchip_slopes(x, y)
# Interpolate...
yvec = Pchip(x, y, m)(xvec)
# Call the Scipy cubic spline interpolator
from scipy.interpolate import interpolate as ip
function = ip.interp1d(x, y, kind='cubic')
yvec2 = function(xvec)
# Non-montonic cubic Hermite spline interpolator using
# Catmul-Rom method for computing slopes...
yvec3 = CubicHermiteSpline(x,y)(xvec)
yvec4 = StinemanInterp(x, y)(xvec)
yvec5 = Pchip(x, y, m3)(xvec) #@UnusedVariable
# Plot the results
plt.plot(x, y, 'ro', label='Data')
plt.plot(xvec, yvec, 'b', label='Pchip')
plt.plot(xvec, yvec2, 'k', label='interp1d')
plt.plot(xvec, yvec3, 'g', label='CHS')
plt.plot(xvec, yvec4, 'm', label='Stineman')
#plt.plot(xvec, yvec5, 'yo', label='Pchip2')
plt.xlabel("X")
plt.ylabel("Y")
plt.title("Comparing Pchip() vs. Scipy interp1d() vs. non-monotonic CHS")
# legends = ["Data", "Pchip()", "interp1d","CHS", 'Stineman']
plt.legend(loc="upper left", frameon=False)
plt.ioff()
plt.show()
def main():
from scipy import interpolate
import matplotlib.pyplot as plt
@ -1041,7 +1100,7 @@ def main():
breaks = [0, 1, 2]
pp = PPform(coef, breaks, a= -100, b=100)
x = linspace(-1, 3, 20)
y = pp(x)
y = pp(x) #@UnusedVariable
x = linspace(0, 2 * pi + pi / 4, 20)
y = x + np.random.randn(x.size)
@ -1059,7 +1118,7 @@ def main():
t = np.arange(0, 1.1, .1)
x = np.sin(2 * np.pi * t)
y = np.cos(2 * np.pi * t)
tck1, u = interpolate.splprep([t, y], s=0)
tck1, u = interpolate.splprep([t, y], s=0) #@UnusedVariable
tck2 = interpolate.splrep(t, y, s=len(t), task=0)
#interpolate.spl
tck = interpolate.splmake(t, y, order=3, kind='smoothest', conds=None)
@ -1068,12 +1127,11 @@ def main():
pass
def test_pp():
import polynomial as pl
coef = np.array([[1, 1], [0, 0]]) # linear from 0 to 2
coef = np.array([[1, 1], [0, 0]]) # linear from 0 to 2 @UnusedVariable
coef = np.array([[1, 1], [1, 1], [0, 2]]) # quadratic from 0 to 1 and 1 to 2.
dc = pl.polyder(coef, 1)
c2 = pl.polyint(dc, 1)
c2 = pl.polyint(dc, 1) #@UnusedVariable
breaks = [0, 1, 2]
pp = PPform(coef, breaks)
pp(0.5)
@ -1086,8 +1144,14 @@ def test_pp():
plb.show()
def test_docstrings():
import doctest
doctest.testmod()
if __name__ == '__main__':
test_docstrings()
#main()
test_smoothing_spline()
#test_smoothing_spline()
# compare_methods()
# demo_monoticity()

@ -136,7 +136,7 @@ class KDEgauss(object):
for i in ind.tolist(): #
h[i] = get_smoothing(self.dataset[i])
deth = h.prod()
self.inv_hs = linalg.diag(1.0 / h)
self.inv_hs = np.diag(1.0 / h)
else: #fully general smoothing matrix
deth = linalg.det(h)
if deth <= 0:
@ -835,7 +835,7 @@ class KDE(_KDE):
for i in ind.tolist(): #
h[i] = get_smoothing(self.dataset[i])
deth = h.prod()
self.inv_hs = linalg.diag(1.0 / h)
self.inv_hs = np.diag(1.0 / h)
else: #fully general smoothing matrix
deth = linalg.det(h)
if deth <= 0:
@ -1024,7 +1024,7 @@ class KRegression(_KDE):
>>> y = 2*np.exp(-x**2/(2*0.3**2))+3*np.exp(-(x-1)**2/(2*0.7**2)) + ei
>>> kreg = wk.KRegression(x, y)
>>> f = kreg(output='plotobj', title='Kernel regression', plotflag=1)
>>> f.plot(label='p=0')
>>> h=f.plot(label='p=0')
"""
def __init__(self, data, y, p=0, hs=None, kernel=None, alpha=0.0, xmin=None, xmax=None, inc=128, L2=None):
@ -2365,7 +2365,7 @@ def qlevels2(data, p=(10,30,50,70,90, 95, 99, 99.9), method=1):
>>> PL = np.r_[10:90:20, 90, 95, 99, 99.9]
>>> xs = ws.norm.rvs(size=2500000)
>>> np.round(qlevels2(ws.norm.pdf(xs), p=PL), decimals=3)
array([ 0.396, 0.37 , 0.318, 0.233, 0.103, 0.058, 0.014, 0.002])
array([ 0.396, 0.37 , 0.318, 0.233, 0.103, 0.059, 0.014, 0.002])
# compared with the exact values
>>> ws.norm.pdf(ws.norm.ppf((100-PL)/200))
@ -2800,6 +2800,7 @@ def evar(y):
>>> var0 = 0.02 # noise variance
>>> yn = y + sqrt(var0)*np.random.randn(*y.shape)
>>> evar(yn) #estimated variance
0.020018619214933957
2D function
>>> xp = np.linspace(0,1,50)
@ -2807,7 +2808,8 @@ def evar(y):
>>> f = np.exp(x+y) + np.sin((x-2*y)*3)
>>> var0 = 0.04 # noise variance
>>> fn = f + sqrt(var0)*np.random.randn(*f.shape)
>>> evar(fn) estimated variance
>>> evar(fn) # estimated variance
0.022806636928561375
3D function
>>> yp = np.linspace(-2,2,50)
@ -2815,7 +2817,8 @@ def evar(y):
>>> f = x*exp(-x**2-y**2-z**2)
>>> var0 = 0.5 # noise variance
>>> fn = f + sqrt(var0)*np.random.randn(*f.shape)
>>> evar(fn) estimated variance
>>> evar(fn) # estimated variance
0.47375136534336421
Other example
-------------
@ -2907,27 +2910,27 @@ def smoothn(data, s=None, weight=None, robust=False, z0=None, tolz=1e-3, maxiter
1-D example
>>> import matplotlib.pyplot as plt
>>> x = np.linspace(0,100,2**8)
>>> y = cos(x/10)+(x/50)**2 + np.random.randn(x.shape)/10
>>> y = np.cos(x/10)+(x/50)**2 + np.random.randn(x.size)/10
>>> y[np.r_[70, 75, 80]] = np.array([5.5, 5, 6])
>>> z = smoothn(y) # Regular smoothing
>>> zr = smoothn(y,robust=True) # Robust smoothing
>>> plt.subplot(121),
>>> h = plt.plot(x,y,'r.',x,z,'k',LineWidth=2)
>>> plt.title('Regular smoothing')
>>> plt.subplot(122)
>>> plt.plot(x,y,'r.',x,zr,'k',LineWidth=2)
>>> plt.title('Robust smoothing')
>>> h=plt.subplot(121),
>>> h = plt.plot(x,y,'r.',x,z,'k',linewidth=2)
>>> h=plt.title('Regular smoothing')
>>> h=plt.subplot(122)
>>> h=plt.plot(x,y,'r.',x,zr,'k',linewidth=2)
>>> h=plt.title('Robust smoothing')
2-D example
>>> xp = np.r_[0:1:.02]
>>> [x,y] = np.meshgrid(xp,xp)
>>> f = np.exp(x+y) + np.sin((x-2*y)*3);
>>> fn = f + randn(size(f))*0.5;
>>> fn = f + np.random.randn(*f.shape)*0.5;
>>> fs = smoothn(fn);
>>> plt.subplot(121),
>>> plt.contourf(xp,xp,fn)
>>> plt.subplot(122)
>>> plt.contourf(xp,xp,fs)
>>> h=plt.subplot(121),
>>> h=plt.contourf(xp,xp,fn)
>>> h=plt.subplot(122)
>>> h=plt.contourf(xp,xp,fs)
2-D example with missing data
n = 256;
@ -3228,7 +3231,7 @@ def test_smoothn_2d():
[x,y] = np.meshgrid(xp,xp)
f = np.exp(x+y) + np.sin((x-2*y)*3)
fn = f + np.random.randn(*f.shape)*0.5
fs, s = smoothn(fn, fulloutput=True)
fs, s = smoothn(fn, fulloutput=True) #@UnusedVariable
fs2 = smoothn(fn,s=2*s)
plt.subplot(131),
plt.contourf(xp,xp,fn)
@ -3519,13 +3522,13 @@ def regressionbin(x,y):
y : arraylike
of 0 and 1
'''
hopt1, h1,h2 = _get_regression_smooting(x,y,fun='hos')
hopt2, h1,h2 = _get_regression_smooting(x,y,fun='hste')
hopt1, h1,h2 = _get_regression_smooting(x,y,fun='hos') #@UnusedVariable
hopt2, h1,h2 = _get_regression_smooting(x,y,fun='hste') #@UnusedVariable
hopt = sqrt(hopt1*hopt2)
fbest = kreg_demo4(x, y, hopt2+0.1, hopt)
for fun in ['hste']: # , 'hisj', 'hns', 'hstt'
hsmax, hs1, hs2 =_get_regression_smooting(x,y,fun=fun)
hsmax, hs1, hs2 =_get_regression_smooting(x,y,fun=fun) #@UnusedVariable
for hi in np.linspace(hsmax*0.1,hsmax,55):
f = kreg_demo4(x, y, hi, hopt)
if f.aicc<=fbest.aicc:
@ -3625,8 +3628,8 @@ def kreg_demo3(x,y, fun1, hs=None, fun='hisj', plotlog=False):
# ref Casella and Berger (1990) "Statistical inference" pp444
a = 2*pi + z0**2/(ciii+1e-16)
b = 2*(1+z0**2/(ciii+1e-16))
plo2 = ((a-sqrt(a**2-2*pi**2*b))/b).clip(min=0,max=1)
pup2 = ((a+sqrt(a**2-2*pi**2*b))/b).clip(min=0,max=1)
plo2 = ((a-sqrt(a**2-2*pi**2*b))/b).clip(min=0,max=1) #@UnusedVariable
pup2 = ((a+sqrt(a**2-2*pi**2*b))/b).clip(min=0,max=1) #@UnusedVariable
# Jeffreys intervall a=b=0.5
#st.beta.isf(alpha/2, x+a, n-x+b)
@ -3682,12 +3685,12 @@ def check_kreg_demo3():
plt.ion()
k = 0
for i, n in enumerate([50, 100,300,600, 4000]):
for i, n in enumerate([50, 100,300,600, 4000]): #@UnusedVariable
x,y, fun1 = _get_data(n, symmetric=True,loc1=1.0, scale1=0.6, scale2=1.25)
k0 = k
for j, fun in enumerate(['hste']):
hsmax, hs1, hs2 =_get_regression_smooting(x,y,fun=fun)
for j, fun in enumerate(['hste']): #@UnusedVariable
hsmax, hs1, hs2 =_get_regression_smooting(x,y,fun=fun) #@UnusedVariable
for hi in np.linspace(hsmax*0.25,hsmax,9):
plt.figure(k)
k +=1
@ -3706,15 +3709,15 @@ def check_kreg_demo4():
#kde_gauss_demo()
#kreg_demo2(n=120,symmetric=True,fun='hste', plotlog=True)
k = 0
for i, n in enumerate([100,300,600,4000]):
for i, n in enumerate([100,300,600,4000]): #@UnusedVariable
x,y, fun1 = _get_data(n, symmetric=True,loc1=0.1, scale1=0.6, scale2=0.75)
k0 = k
hopt1, h1,h2 = _get_regression_smooting(x,y,fun='hos')
hopt2, h1,h2 = _get_regression_smooting(x,y,fun='hste')
k0 = k #@UnusedVariable
hopt1, h1,h2 = _get_regression_smooting(x,y,fun='hos') #@UnusedVariable
hopt2, h1,h2 = _get_regression_smooting(x,y,fun='hste') #@UnusedVariable
hopt = sqrt(hopt1*hopt2)
#hopt = _get_regression_smooting(x,y,fun='hos')[0]
for j, fun in enumerate(['hste']): # , 'hisj', 'hns', 'hstt'
hsmax, hs1, hs2 =_get_regression_smooting(x,y,fun=fun)
for j, fun in enumerate(['hste']): # , 'hisj', 'hns', 'hstt' @UnusedVariable
hsmax, hs1, hs2 =_get_regression_smooting(x,y,fun=fun) #@UnusedVariable
fmax = kreg_demo4(x, y, hsmax+0.1, hopt)
for hi in np.linspace(hsmax*0.1,hsmax,55):
@ -3735,7 +3738,7 @@ def empirical_bin_prb(x,y, hopt):
'''
Returns empirical binomial probabiltity
'''
n = x.size
# n = x.size
xmin, xmax = x.min(), x.max()
ni = max(2*int((xmax-xmin)/hopt)+3,5)
@ -3834,7 +3837,7 @@ def kde_gauss_demo(n=50):
#dist = st.norm
dist = st.expon
data = dist.rvs(loc=0, scale=1.0, size=n)
d, N = np.atleast_2d(data).shape
d, N = np.atleast_2d(data).shape #@UnusedVariable
if d==1:
plot_options = [dict(color='red'), dict(color='green'), dict(color='black')]
@ -3873,12 +3876,12 @@ def test_docstrings():
if __name__ == '__main__':
#check_kreg_demo3()
check_kreg_demo4()
# check_kreg_demo4()
#test_smoothn_2d()
#test_smoothn_cardioid()
#test_docstrings()
test_docstrings()
#kde_demo2()
#kreg_demo1(fast=True)
#kde_gauss_demo()

@ -6,7 +6,7 @@ from __future__ import division
import sys
import fractions
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, #@UnusedImport
array, asarray, broadcast_arrays, ceil, floor, frexp, hypot,
sqrt, arctan2, sin, cos, exp, log, mod, diff, empty_like,
finfo, inf, pi, interp, isnan, isscalar, zeros, ones, linalg,
@ -93,7 +93,7 @@ class Bunch(object):
def update(self, ** kwargs):
self.__dict__.update(kwargs)
def printf(format, *args):
def printf(format, *args): #@ReservedAssignment
sys.stdout.write(format % args)
@ -1452,7 +1452,7 @@ def stirlerr(n):
return y
def getshipchar(value, property="max_deadweight"):
def getshipchar(value, property="max_deadweight"): #@ReservedAssignment
'''
Return ship characteristics from value of one ship-property
@ -1485,19 +1485,20 @@ def getshipchar(value, property="max_deadweight"):
Example
---------
>>> import wafo.misc as wm
>>> wm.getshipchar(10,'service_speed')
{'beam': 29.0,
'beamSTD': 2.9000000000000004,
'draught': 9.5999999999999996,
'draughtSTD': 2.1120000000000001,
'length': 216.0,
'lengthSTD': 2.0113098831942762,
'max_deadweight': 30969.0,
'max_deadweightSTD': 3096.9000000000001,
'propeller_diameter': 6.761165385916601,
'propeller_diameterSTD': 0.20267047566705432,
'service_speed': 10.0,
'service_speedSTD': 0}
>>> sc = wm.getshipchar(10,'service_speed')
>>> for key in sorted(sc): key, sc[key]
('beam', 29.0)
('beamSTD', 2.9000000000000004)
('draught', 9.6)
('draughtSTD', 2.112)
('length', 216.0)
('lengthSTD', 2.011309883194276)
('max_deadweight', 30969.0)
('max_deadweightSTD', 3096.9)
('propeller_diameter', 6.761165385916601)
('propeller_diameterSTD', 0.20267047566705432)
('service_speed', 10.0)
('service_speedSTD', 0)
Other units: 1 ft = 0.3048 m and 1 knot = 0.5144 m/s
@ -2142,7 +2143,7 @@ def tranproc(x, f, x0, *xi):
if N > 4:
warnings.warn('Transformation of derivatives of order>4 not supported.')
return y #y0,y1,y2,y3,y4
def good_bins(data=None, range=None, num_bins=None, num_data=None, odd=False, loose=True):
def good_bins(data=None, range=None, num_bins=None, num_data=None, odd=False, loose=True): #@ReservedAssignment
''' Return good bins for histogram
Parameters
@ -2195,7 +2196,7 @@ def good_bins(data=None, range=None, num_bins=None, num_data=None, odd=False, lo
limits = np.arange(mn, mx + d / 2, d)
return limits
def plot_histgrm(data, bins=None, range=None, normed=False, weights=None, lintype='b-'):
def plot_histgrm(data, bins=None, range=None, normed=False, weights=None, lintype='b-'): #@ReservedAssignment
'''
Plot histogram
@ -2405,7 +2406,7 @@ def fourier(data, t=None, T=None, m=None, n=None, method='trapz'):
def _test_find_cross():
t = findcross([0, 0, 1, -1, 1], 0)
t = findcross([0, 0, 1, -1, 1], 0) #@UnusedVariable
def _test_common_shape():
@ -2454,7 +2455,7 @@ def _test_tranproc():
tr = wtm.TrHermite()
x = linspace(-5, 5, 501)
g = tr(x)
gder = tranproc(x, g, x, ones(g.size))
gder = tranproc(x, g, x, ones(g.size)) #@UnusedVariable
pass
#>>> gder(:,1) = g(:,1)
#>>> plot(g(:,1),[g(:,2),gder(:,2)])
@ -2476,7 +2477,7 @@ def _test_extrema():
ind = findextrema(x)
ti, tp = t[ind], x[ind]
plot(t, x, '.', ti, tp, 'r.')
ind1 = findrfc(tp, 0.3)
ind1 = findrfc(tp, 0.3) #@UnusedVariable

Binary file not shown.

Binary file not shown.

@ -27,7 +27,7 @@ from scipy.special import ndtr as cdfnorm, ndtri as invnorm
import warnings
import numpy as np
from numpy import (inf, pi, zeros, ones, sqrt, where, log, exp, cos, sin, arcsin, mod, finfo, interp, #@UnresolvedImport
from numpy import (inf, pi, zeros, ones, sqrt, where, log, exp, cos, sin, arcsin, mod, interp, #@UnresolvedImport
linspace, arange, sort, all, abs, vstack, hstack, atleast_1d, sign, expm1, #@UnresolvedImport
finfo, polyfit, r_, nonzero, cumsum, ravel, size, isnan, nan, ceil, diff, array) #@UnresolvedImport
from numpy.fft import fft
@ -290,11 +290,11 @@ class LevelCrossings(WafoData):
elif dist.startswith('ray') or dist.startswith('trun'):
phat = distributions.truncrayleigh.fit2(x, floc=0, method=method)
SF = phat.sf(xF)
if False:
n = len(x)
Sx = sum((x + offset) ** 2 - offset ** 2)
s = sqrt(Sx / n); # Shape parameter
F = -np.expm1(-((xF + offset) ** 2 - offset ** 2) / s ** 2)
# if False:
# n = len(x)
# Sx = sum((x + offset) ** 2 - offset ** 2)
# s = sqrt(Sx / n); # Shape parameter
# F = -np.expm1(-((xF + offset) ** 2 - offset ** 2) / s ** 2)
lcEst = np.vstack((xF + u, lcu * (SF))).T
else:
raise ValueError()
@ -661,7 +661,7 @@ def test_levelcrossings_extrapolate():
lc = mm.level_crossings()
s = x[:,1].std()
lc_gpd = lc.extrapolate(-2*s, 2*s, dist='rayleigh')
lc_gpd = lc.extrapolate(-2*s, 2*s, dist='rayleigh') #@UnusedVariable
class CyclePairs(WafoData):
'''
@ -1360,7 +1360,7 @@ class TimeSeries(WafoData):
if alpha is not None :
#% Confidence interval constants
CI = [v / _invchi2(1 - alpha / 2 , v), v / _invchi2(alpha / 2 , v)];
spec.CI = [v / _invchi2(1 - alpha / 2 , v), v / _invchi2(alpha / 2 , v)];
spec.tr = tr
spec.L = L
@ -2126,9 +2126,9 @@ class TimeSeries(WafoData):
Ns = int(n / (nfig * nsub))
ind = r_[0:Ns]
if all(xn >= 0):
vscale = [0, 2 * sigma * vfact]
vscale = [0, 2 * sigma * vfact] #@UnusedVariable
else:
vscale = array([-1, 1]) * vfact * sigma
vscale = array([-1, 1]) * vfact * sigma #@UnusedVariable
XlblTxt = 'Time [sec]'
@ -2800,7 +2800,7 @@ def main():
mm = tp.cycle_pairs()
lc = mm.level_crossings()
lc.plot()
T = ts.wave_periods(vh=0.0, pdef='c2c')
T = ts.wave_periods(vh=0.0, pdef='c2c') #@UnusedVariable
@ -2810,7 +2810,7 @@ def main():
S = Sj.tospecdata()
R = S.tocovdata()
x = R.sim(ns=1000, dt=0.2)
x = R.sim(ns=1000, dt=0.2) #@UnusedVariable
S.characteristic(['hm0', 'tm02'])
ns = 1000
dt = .2
@ -2840,8 +2840,8 @@ def test_docstrings():
doctest.testmod()
if __name__ == '__main__':
test_levelcrossings_extrapolate()
test_docstrings()
# test_levelcrossings_extrapolate()
# if True: #False : #
# import doctest

@ -17,12 +17,12 @@
#-------------------------------------------------------------------------------
#!/usr/bin/env python
import warnings
import pylab as plb
import warnings #@UnusedImport
import matplotlib.pyplot as plt
import numpy as np
from numpy.fft import fft, ifft
from numpy import (zeros, ones, zeros_like, atleast_1d, array, asarray, newaxis, arange, #@UnresolvedImport
logical_or, abs, any, pi, cos, round, diff, all, r_, exp, hstack, trim_zeros, #@UnresolvedImport
from numpy import (zeros, ones, zeros_like, atleast_1d, array, asarray, newaxis, arange, #@UnresolvedImport @UnusedImport
logical_or, abs, any, pi, cos, round, diff, all, r_, exp, hstack, trim_zeros, #@UnresolvedImport @UnusedImport
where, extract, dot, linalg, sign, concatenate, floor, isreal, conj, remainder, #@UnresolvedImport
linspace) #@UnresolvedImport
from numpy.lib.polynomial import * #@UnusedWildImport
@ -358,7 +358,7 @@ def unfinished_orthofit(x,y,n):
# Reshape
x = x.ravel()
siz0 = y.shape
# siz0 = y.shape
y = y.ravel()
# Coefficients of the orthogonal polynomials
@ -1095,7 +1095,7 @@ def chebfit(fun, n=10, a= -1, b=1, trace=False):
x = map_to_interval(chebroot(n), a, b)
f = fun(x);
if trace:
plb.plot(x, f, '+')
plt.plot(x, f, '+')
else:
f = fun
n = len(f)
@ -1731,8 +1731,7 @@ def padefitlsq(fun, m, k, a= -1, b=1, trace=False, x=None, end_points=True):
warnings.warn('Check the result! Number of function values should be at least: %d' % npt)
if trace:
import pylab as plb
plb.plot(x, fs, '+')
plt.plot(x, fs, '+')
wt = ones((npt))
ee = ones((npt))
@ -1741,17 +1740,17 @@ def padefitlsq(fun, m, k, a= -1, b=1, trace=False, x=None, end_points=True):
u = zeros((npt, ncof))
for ix in xrange(MAXIT):
#% Set up design matrix for least squares fit.
pow = wt
bb = pow * (fs + abs(mad) * sign(ee))
pow_ = wt
bb = pow_ * (fs + abs(mad) * sign(ee))
for jx in xrange(m + 1):
u[:, jx] = pow
pow = pow * x
u[:, jx] = pow_
pow_ = pow_ * x
pow = -bb
pow_ = -bb
for jx in xrange(m + 1, ncof):
pow = pow * x
u[:, jx] = pow
pow_ = pow_ * x
u[:, jx] = pow_
[u1, w, v] = linalg.svd(u, full_matrices=False)
@ -1772,7 +1771,7 @@ def padefitlsq(fun, m, k, a= -1, b=1, trace=False, x=None, end_points=True):
if trace:
print('Iteration=%d, max error=%g' % (ix, devmax))
plb.plot(x, fs, x, ee + fs)
plt.plot(x, fs, x, ee + fs)
#c1=c1(:)
#c2=c2(:)
return poly1d(c1), poly1d(c2)
@ -1786,42 +1785,42 @@ def main():
[c1, c2] = padefitlsq(exp, 3, 3, 0, 2)
x = linspace(0, 4)
plb.plot(x, polyval(c1, x) / polyval(c2, x), 'g')
plb.plot(x, exp(x), 'r')
plt.plot(x, polyval(c1, x) / polyval(c2, x), 'g')
plt.plot(x, exp(x), 'r')
import scipy.special as sp
p = [[1, 1, 1], [2, 2, 2]]
pi = polyint(p, 1)
pr = polyreloc(p, 2)
pd = polyder(p)
st = poly2str(p)
c = poly1d(1. / sp.gamma(plb.r_[6 + 1:0:-1])) #polynomial coeff exponential function
pr = polyreloc(p, 2) #@UnusedVariable
pd = polyder(p) #@UnusedVariable
st = poly2str(p) #@UnusedVariable
c = poly1d(1. / sp.gamma(np.r_[6 + 1:0:-1])) #polynomial coeff exponential function
[p, q] = padefit(c)
x = linspace(0, 4);
plb.plot(x, c(x), x, p(x) / q(x), 'g-', x, exp(x), 'r.')
plb.close()
plt.plot(x, c(x), x, p(x) / q(x), 'g-', x, exp(x), 'r.')
plt.close()
x = arange(4)
dx = dct(x)
idx = idct(dx)
idx = idct(dx) #@UnusedVariable
a = 0;
b = 2;
ck = chebfit(exp, 6, a, b);
t = chebval(0, ck, a, b)
t = chebval(0, ck, a, b) #@UnusedVariable
x = linspace(0, 2, 6);
plb.plot(x, exp(x), 'r', x, chebval(x, ck, a, b), 'g.')
plt.plot(x, exp(x), 'r', x, chebval(x, ck, a, b), 'g.')
#x1 = chebroot(9).'*(b-a)/2+(b+a)/2 ;
#ck1 =chebfit([x1 exp(x1)],9,a,b);
#plot(x,exp(x),'r'), hold on
#plot(x,chebval(x,ck1,a,b),'g'), hold off
t = poly2hstr([1, 1, 2])
t = poly2hstr([1, 1, 2]) #@UnusedVariable
py = [1, 0]
px = polyshift(py, 0, 5);
t1 = polyval(px, [0, 2.5, 5]) #% This is the same as the line below
t2 = polyval(py, [-1, 0, 1 ])
t1 = polyval(px, [0, 2.5, 5]) #% This is the same as the line below @UnusedVariable
t2 = polyval(py, [-1, 0, 1 ]) #@UnusedVariable
px = [1, 0]
py = polyishift(px, 0, 5);
@ -1829,9 +1828,12 @@ def main():
t2 = polyval(py, [-1, 0, 1 ])
print(t1, t2)
if __name__ == '__main__':
if False:
main()
else:
def test_docstrings():
import doctest
doctest.testmod()
if __name__ == '__main__':
test_docstrings()
# main()

@ -1,350 +0,0 @@
'''
pychip.py
chris.michalski@gmail.com
20090818
Piecewise cubic Hermite interpolation (monotonic...) in Python
References:
Wikipedia: Monotone cubic interpolation
Cubic Hermite spline
A cubic Hermite spline is a third degree spline with each polynomial of the spline
in Hermite form. The Hermite form consists of two control points and two control
tangents for each polynomial. Each interpolation is performed on one sub-interval
at a time (piece-wise). A monotone cubic interpolation is a variant of cubic
interpolation that preserves monotonicity of the data to be interpolated (in other
words, it controls overshoot). Monotonicity is preserved by linear interpolation
but not by cubic interpolation.
Use:
There are two separate calls, the first call, pchip_slopes(), computes the slopes that
the interpolator needs. If there are a large number of points to compute,
it is more efficient to compute the slopes once, rather than for every point
being evaluated. The second call, pchip_eval(), takes the slopes computed by
pchip_slopes() along with X, Y, and a vector of desired "xnew"s and computes a vector
of "ynew"s. If only a handful of points is needed, pchip() is a third function
which combines a call to pchip_slopes() followed by pchip_eval().
'''
import warnings
import numpy as np
from matplotlib import pyplot as plt
from interpolate import slopes2, slopes, stineman_interp
from scipy.interpolate import PiecewisePolynomial
#=========================================================
def pchip(x, y, xnew):
# Compute the slopes used by the piecewise cubic Hermite interpolator
m = pchip_slopes(x, y)
# Use these slopes (along with the Hermite basis function) to interpolate
ynew = pchip_eval(x, y, m, xnew)
return ynew
#=========================================================
def x_is_okay(x,xvec):
# Make sure "x" and "xvec" satisfy the conditions for
# running the pchip interpolator
n = len(x)
m = len(xvec)
# Make sure "x" is in sorted order (brute force, but works...)
xx = x.copy()
xx.sort()
total_matches = (xx == x).sum()
if total_matches != n:
warnings.warn( "x values weren't in sorted order --- aborting")
return False
# Make sure 'x' doesn't have any repeated values
delta = x[1:] - x[:-1]
if (delta == 0.0).any():
warnings.warn( "x values weren't monotonic--- aborting")
return False
# Check for in-range xvec values (beyond upper edge)
check = xvec > x[-1]
if check.any():
print "*" * 50
print "x_is_okay()"
print "Certain 'xvec' values are beyond the upper end of 'x'"
print "x_max = ", x[-1]
indices = np.compress(check, range(m))
print "out-of-range xvec's = ", xvec[indices]
print "out-of-range xvec indices = ", indices
return False
# Second - check for in-range xvec values (beyond lower edge)
check = xvec< x[0]
if check.any():
print "*" * 50
print "x_is_okay()"
print "Certain 'xvec' values are beyond the lower end of 'x'"
print "x_min = ", x[0]
indices = np.compress(check, range(m))
print "out-of-range xvec's = ", xvec[indices]
print "out-of-range xvec indices = ", indices
return False
return True
#=========================================================
def pchip_eval(x, y, m, xvec):
'''
Evaluate the piecewise cubic Hermite interpolant with monoticity preserved
x = array containing the x-data
y = array containing the y-data
m = slopes at each (x,y) point [computed to preserve monotonicity]
xnew = new "x" value where the interpolation is desired
x must be sorted low to high... (no repeats)
y can have repeated values
This works with either a scalar or vector of "xvec"
'''
############################
# Make sure there aren't problems with the input data
############################
if not x_is_okay(x, xvec):
print "pchip_eval2() - ill formed 'x' vector!!!!!!!!!!!!!"
# Cause a hard crash...
return #STOP_pchip_eval2
# Find the indices "k" such that x[k] < xvec < x[k+1]
k = np.searchsorted(x[1:-1], xvec)
# Create the Hermite coefficients
h = x[k+1] - x[k]
t = (xvec - x[k]) / h[k]
# Hermite basis functions
h00 = (2 * t**3) - (3 * t**2) + 1
h10 = t**3 - (2 * t**2) + t
h01 = (-2* t**3) + (3 * t**2)
h11 = t**3 - t**2
# Compute the interpolated value of "y"
ynew = h00*y[k] + h10*h*m[k] + h01*y[k+1] + h11*h*m[k+1]
return ynew
#=========================================================
def pchip_slopes(x,y, method='secant', tension=0, monotone=True):
'''
Return estimated slopes y'(x)
Parameters
----------
x, y : array-like
array containing the x- and y-data, respectively.
x must be sorted low to high... (no repeats) while
y can have repeated values.
method : string
defining method of estimation for yp. Valid options are:
'secant' average secants
yp = 0.5*((y[k+1]-y[k])/(x[k+1]-x[k]) + (y[k]-y[k-1])/(x[k]-x[k-1]))
'Catmull-Rom' yp = (y[k+1]-y[k-1])/(x[k+1]-x[k-1])
'Cardinal' yp = (1-tension) * (y[k+1]-y[k-1])/(x[k+1]-x[k-1])
tension : real scalar between 0 and 1.
tension parameter used in Cardinal method
monotone : bool
If True modifies yp to preserve monoticity
x input conditioning is assumed but not checked
'''
n = len(x)
# Compute the slopes of the secant lines between successive points
delta = (y[1:] - y[:-1]) / (x[1:] - x[:-1])
# Initialize the tangents at every points as the average of the secants
m = np.zeros(n, dtype='d')
# At the endpoints - use one-sided differences
m[0] = delta[0]
m[n-1] = delta[-1]
method = method.lower()
if method.startswith('secant'):
# In the middle - use the average of the secants
m[1:-1] = (delta[:-1] + delta[1:]) / 2.0
else: # Cardinal or Catmull-Rom method
m[1:-1] = (y[2:] - y[:-2]) / (x[2:] - x[:-2])
if method.startswith('cardinal'):
m = (1-tension) * m
if monotone:
# Special case: intervals where y[k] == y[k+1]
# Setting these slopes to zero guarantees the spline connecting
# these points will be flat which preserves monotonicity
ii, = (delta == 0.0).nonzero()
m[ii] = 0.0
m[ii+1] = 0.0
alpha = m[:-1]/delta
beta = m[1:]/delta
dist = alpha**2 + beta**2
tau = 3.0 / np.sqrt(dist)
# To prevent overshoot or undershoot, restrict the position vector
# (alpha, beta) to a circle of radius 3. If (alpha**2 + beta**2)>9,
# then set m[k] = tau[k]alpha[k]delta[k] and m[k+1] = tau[k]beta[b]delta[k]
# where tau = 3/sqrt(alpha**2 + beta**2).
# Find the indices that need adjustment
indices_to_fix, = (dist > 9.0).nonzero()
for ii in indices_to_fix:
m[ii] = tau[ii] * alpha[ii] * delta[ii]
m[ii+1] = tau[ii] * beta[ii] * delta[ii]
return m
def _edge_case(m0, d1):
return np.where((d1==0) | (m0==0), 0.0, 1.0/(1.0/m0+1.0/d1))
def pchip_slopes2(x, y):
# Determine the derivatives at the points y_k, d_k, by using
# PCHIP algorithm is:
# We choose the derivatives at the point x_k by
# Let m_k be the slope of the kth segment (between k and k+1)
# If m_k=0 or m_{k-1}=0 or sgn(m_k) != sgn(m_{k-1}) then d_k == 0
# else use weighted harmonic mean:
# w_1 = 2h_k + h_{k-1}, w_2 = h_k + 2h_{k-1}
# 1/d_k = 1/(w_1 + w_2)*(w_1 / m_k + w_2 / m_{k-1})
# where h_k is the spacing between x_k and x_{k+1}
hk = x[1:] - x[:-1]
mk = (y[1:] - y[:-1]) / hk
smk = np.sign(mk)
condition = ((smk[1:] != smk[:-1]) | (mk[1:]==0) | (mk[:-1]==0))
w1 = 2*hk[1:] + hk[:-1]
w2 = hk[1:] + 2*hk[:-1]
whmean = 1.0/(w1+w2)*(w1/mk[1:] + w2/mk[:-1])
dk = np.zeros_like(y)
dk[1:-1][condition] = 0.0
dk[1:-1][~condition] = 1.0/whmean[~condition]
# For end-points choose d_0 so that 1/d_0 = 1/m_0 + 1/d_1 unless
# one of d_1 or m_0 is 0, then choose d_0 = 0
dk[0] = _edge_case(mk[0],dk[1])
dk[-1] = _edge_case(mk[-1],dk[-2])
return dk
class StinemanInterp(PiecewisePolynomial):
def __init__(self, x, y, yp=None, method='parabola'):
if yp is None:
yp = slopes2(x, y, method)
super(StinemanInterp,self).__init__(x, zip(y,yp))
def CubicHermiteSpline2(x, y, xnew):
'''
Piecewise Cubic Hermite Interpolation using Catmull-Rom
method for computing the slopes.
'''
# Non-montonic cubic Hermite spline interpolator using
# Catmul-Rom method for computing slopes...
m = pchip_slopes(x, y, method='catmull', monotone=False)
# Use these slopes (along with the Hermite basis function) to interpolate
ynew = pchip_eval(x, y, m, xnew)
return ynew
#==============================================================
def main():
############################################################
# Sine wave test
############################################################
# Create a example vector containing a sine wave.
x = np.arange(30.0)/10.
y = np.sin(x)
# Interpolate the data above to the grid defined by "xvec"
xvec = np.arange(250.)/100.
# Initialize the interpolator slopes
m = pchip_slopes(x,y)
m1 = slopes(x, y)
m2 = pchip_slopes(x,y,method='catmul',monotone=False)
m3 = pchip_slopes2(x, y)
# Call the monotonic piece-wise Hermite cubic interpolator
yvec = pchip_eval(x, y, m, xvec)
yvec1 = pchip_eval(x, y, m1, xvec)
yvec2 = pchip_eval(x, y, m2, xvec)
yvec3 = pchip_eval(x, y, m3, xvec)
plt.figure(1)
plt.plot(x,y, 'ro')
plt.title("pchip() Sin test code")
# Plot the interpolated points
plt.plot(xvec, yvec, xvec, yvec1, xvec, yvec2,xvec, yvec3, )
plt.legend(['true','m0','m1','m2','m3'])
# Step function test...
plt.figure(2)
plt.title("pchip() step function test")
# Create a step function (will demonstrate monotonicity)
x = np.arange(7.0) - 3.0
y = np.array([-1.0, -1,-1,0,1,1,1])
# Interpolate using monotonic piecewise Hermite cubic spline
xvec = np.arange(599.)/100. - 3.0
# Create the pchip slopes
m = pchip_slopes(x,y)
m1 = slopes(x, y)
m2 = pchip_slopes(x,y,method='catmul',monotone=False)
m3 = pchip_slopes2(x, y)
# Interpolate...
yvec = pchip_eval(x, y, m, xvec)
# Call the Scipy cubic spline interpolator
from scipy.interpolate import interpolate
function = interpolate.interp1d(x, y, kind='cubic')
yvec2 = function(xvec)
# Non-montonic cubic Hermite spline interpolator using
# Catmul-Rom method for computing slopes...
yvec3 = CubicHermiteSpline(x,y)(xvec)
yvec4 = StinemanInterp(x, y)(xvec)
#yvec4 = stineman_interp(xvec, x, y, m)
yvec5 = pchip_eval(x, y, m3, xvec)
# Plot the results
plt.plot(x, y, 'ro')
plt.plot(xvec, yvec, 'b')
plt.plot(xvec, yvec2, 'k')
plt.plot(xvec, yvec3, 'g')
plt.plot(xvec, yvec4, 'm')
#plt.plot(xvec, yvec5, 'y')
plt.xlabel("X")
plt.ylabel("Y")
plt.title("Comparing pypchip() vs. Scipy interp1d() vs. non-monotonic CHS")
legends = ["Data", "pypchip()", "interp1d","CHS", 'SI']
plt.legend(legends, loc="upper left")
plt.ioff()
plt.show()
if __name__ == '__main__':
###################################################################
main()

Binary file not shown.

@ -98,10 +98,10 @@ class SavitzkyGolay(object):
>>> y = np.exp( -t**2 ) + np.random.normal(0, 0.05, t.shape)
>>> ysg = SavitzkyGolay(n=15, degree=4).smooth(y)
>>> import matplotlib.pyplot as plt
>>> plt.plot(t, y, label='Noisy signal')
>>> plt.plot(t, np.exp(-t**2), 'k', lw=1.5, label='Original signal')
>>> plt.plot(t, ysg, 'r', label='Filtered signal')
>>> plt.legend()
>>> hy = plt.plot(t, y, label='Noisy signal')
>>> h = plt.plot(t, np.exp(-t**2), 'k', lw=1.5, label='Original signal')
>>> h = plt.plot(t, ysg, 'r', label='Filtered signal')
>>> h = plt.legend()
>>> plt.show()
References
@ -300,8 +300,8 @@ class Kalman(object):
>>> hz = plt.plot(z,'r.', label='observations')
>>> hx = plt.plot(x,'b-', label='Kalman output') # a-posteriori state estimates:
>>> ht = plt.plot(truth,'g-', label='true voltage')
>>> plt.legend()
>>> plt.title('Automobile Voltimeter Example')
>>> h = plt.legend()
>>> h = plt.title('Automobile Voltimeter Example')
'''
@ -400,9 +400,9 @@ def test_kalman():
x[i] = filt(zi) # perform a Kalman filter iteration
import matplotlib.pyplot as plt
hz = plt.plot(z, 'r.', label='observations')
hx = plt.plot(x, 'b-', label='Kalman output') # a-posteriori state estimates:
ht = plt.plot(truth, 'g-', label='true voltage')
_hz = plt.plot(z, 'r.', label='observations')
_hx = plt.plot(x, 'b-', label='Kalman output') # a-posteriori state estimates:
_ht = plt.plot(truth, 'g-', label='true voltage')
plt.legend()
plt.title('Automobile Voltimeter Example')
plt.show()
@ -417,7 +417,12 @@ def test_smooth():
plt.plot(t, y, t, ysg, '--')
plt.show()
def test_docstrings():
import doctest
doctest.testmod()
if __name__ == '__main__':
test_kalman()
test_docstrings()
#test_kalman()
#test_smooth()

@ -1,5 +1,5 @@
GFORTRAN module version '4' created from mregmodule.f on Tue Mar 27 09:05:04 2012
MD5:73d0040f77005ab6be34b297552c2c19 -- If you edit this, you'll get what you deserve.
GFORTRAN module version '4' created from mregmodule.f on Sat May 05 23:15:24 2012
MD5:591d9e50f69bfbecf5b2775f3e32febf -- If you edit this, you'll get what you deserve.
(() () () () () () () () () () () () () () () () () () () () () () ()
() () () ())
@ -23,15 +23,23 @@ UNKNOWN 0 0 SUBROUTINE GENERIC) (UNKNOWN 0 0 0 UNKNOWN ()) 7 0 (8 9 10
3 'rind' 'mregmod' 'rind' 1 ((PROCEDURE UNKNOWN-INTENT MODULE-PROC DECL
UNKNOWN 0 0 SUBROUTINE GENERIC) (UNKNOWN 0 0 0 UNKNOWN ()) 21 0 (22 23
24 25 26 27 28 29 30 31) () 0 () () () 0 0)
26 'db' '' 'db' 21 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
22 'xind' '' 'xind' 21 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
23 'r' '' 'r' 21 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 EXPLICIT (CONSTANT (
INTEGER 4 0 0 INTEGER ()) 0 '1') (CONSTANT (INTEGER 4 0 0 INTEGER ()) 0
'40401')) 0 () () () 0 0)
24 'bu' '' 'bu' 21 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 EXPLICIT (CONSTANT (
INTEGER 4 0 0 INTEGER ()) 0 '1') (CONSTANT (INTEGER 4 0 0 INTEGER ()) 0
'201')) 0 () () () 0 0)
27 'sq' '' 'sq' 21 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
25 'dbun' '' 'dbun' 21 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
26 'db' '' 'db' 21 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 EXPLICIT (CONSTANT (
INTEGER 4 0 0 INTEGER ()) 0 '1') (CONSTANT (INTEGER 4 0 0 INTEGER ()) 0
'201')) 0 () () () 0 0)
24 'bu' '' 'bu' 21 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
27 'sq' '' 'sq' 21 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 EXPLICIT (CONSTANT (
INTEGER 4 0 0 INTEGER ()) 0 '1') (CONSTANT (INTEGER 4 0 0 INTEGER ()) 0
'201')) 0 () () () 0 0)
@ -39,14 +47,6 @@ INTEGER 4 0 0 INTEGER ()) 0 '1') (CONSTANT (INTEGER 4 0 0 INTEGER ()) 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
29 'nit' '' 'nit' 21 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
22 'xind' '' 'xind' 21 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
23 'r' '' 'r' 21 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 EXPLICIT (CONSTANT (
INTEGER 4 0 0 INTEGER ()) 0 '1') (CONSTANT (INTEGER 4 0 0 INTEGER ()) 0
'40401')) 0 () () () 0 0)
25 'dbun' '' 'dbun' 21 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
30 'n' '' 'n' 21 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
31 'infr' '' 'infr' 21 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
@ -63,8 +63,6 @@ INTEGER 4 0 0 INTEGER ()) 0 '1') (CONSTANT (INTEGER 4 0 0 INTEGER ()) 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 EXPLICIT (CONSTANT (
INTEGER 4 0 0 INTEGER ()) 0 '1') (CONSTANT (INTEGER 4 0 0 INTEGER ()) 0
'201')) 0 () () () 0 0)
18 'n' '' 'n' 7 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
11 'db' '' 'db' 7 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 EXPLICIT (CONSTANT (
INTEGER 4 0 0 INTEGER ()) 0 '1') (CONSTANT (INTEGER 4 0 0 INTEGER ()) 0
@ -78,14 +76,10 @@ INTEGER 4 0 0 INTEGER ()) 0 '1') (CONSTANT (INTEGER 4 0 0 INTEGER ()) 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 EXPLICIT (CONSTANT (
INTEGER 4 0 0 INTEGER ()) 0 '1') (CONSTANT (INTEGER 4 0 0 INTEGER ()) 0
'7')) 0 () () () 0 0)
19 'nit' '' 'nit' 7 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
14 'a' '' 'a' 7 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 EXPLICIT (CONSTANT (
INTEGER 4 0 0 INTEGER ()) 0 '1') (CONSTANT (INTEGER 4 0 0 INTEGER ()) 0
'1407')) 0 () () () 0 0)
20 'infr' '' 'infr' 7 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
15 'da' '' 'da' 7 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 EXPLICIT (CONSTANT (
INTEGER 4 0 0 INTEGER ()) 0 '1') (CONSTANT (INTEGER 4 0 0 INTEGER ()) 0
@ -94,6 +88,12 @@ INTEGER 4 0 0 INTEGER ()) 0 '1') (CONSTANT (INTEGER 4 0 0 INTEGER ()) 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
17 'm' '' 'm' 7 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
18 'n' '' 'n' 7 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
19 'nit' '' 'nit' 7 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
20 'infr' '' 'infr' 7 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
)
('fi' 0 2 'mreg' 0 4 'rind' 0 3)

@ -1,5 +1,5 @@
GFORTRAN module version '4' created from dsvdc.f on Tue Mar 27 09:05:01 2012
MD5:324936151a800ce072449221cf8c2383 -- If you edit this, you'll get what you deserve.
GFORTRAN module version '4' created from dsvdc.f on Sat May 05 23:15:23 2012
MD5:09a15038d4562b84946981936b0bee73 -- If you edit this, you'll get what you deserve.
(() () () () () () () () () () () () () () () () () () () () () () () ()
() () ())
@ -34,16 +34,14 @@ PROCEDURE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 FUNCTION) (
UNKNOWN 0 0 0 UNKNOWN ()) 0 0 () () 32 () () () 0 0)
33 'svd' 'svd' 'svd' 1 ((MODULE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
UNKNOWN 0 0) (UNKNOWN 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 0)
29 'n' '' 'n' 28 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
30 'dx' '' 'dx' 28 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 ASSUMED_SIZE (CONSTANT (
INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
31 'dy' '' 'dy' 28 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 ASSUMED_SIZE (CONSTANT (
INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
8 'c' '' 'c' 4 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
9 's' '' 's' 4 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
5 'n' '' 'n' 4 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
6 'dx' '' 'dx' 4 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
@ -52,6 +50,18 @@ INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
7 'dy' '' 'dy' 4 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 ASSUMED_SIZE (CONSTANT (
INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
8 'c' '' 'c' 4 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
9 's' '' 's' 4 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
18 'x' '' 'x' 17 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (2 ASSUMED_SHAPE (CONSTANT
(INTEGER 4 0 0 INTEGER ()) 0 '1') () (CONSTANT (INTEGER 4 0 0 INTEGER ())
0 '1') ()) 0 () () () 0 0)
19 'n' '' 'n' 17 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
20 'p' '' 'p' 17 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
21 's' '' 's' 17 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 ASSUMED_SHAPE (CONSTANT
(INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
@ -68,26 +78,16 @@ DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (2 ASSUMED_SHAPE (CONSTANT
0 '1') ()) 0 () () () 0 0)
25 'job' '' 'job' 17 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
26 'info' '' 'info' 17 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
18 'x' '' 'x' 17 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (2 ASSUMED_SHAPE (CONSTANT
(INTEGER 4 0 0 INTEGER ()) 0 '1') () (CONSTANT (INTEGER 4 0 0 INTEGER ())
0 '1') ()) 0 () () () 0 0)
19 'n' '' 'n' 17 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
20 'p' '' 'p' 17 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
15 'ds' '' 'ds' 11 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
12 'da' '' 'da' 11 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
13 'db' '' 'db' 11 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
14 'dc' '' 'dc' 11 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
29 'n' '' 'n' 28 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
15 'ds' '' 'ds' 11 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
26 'info' '' 'info' 17 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
)
('dp' 0 2 'drot1' 0 3 'drotg' 0 10 'dsvdc' 0 16 'dswap1' 0 27

@ -1,5 +1,5 @@
GFORTRAN module version '4' created from mvnprodcorrprb.f on Tue Mar 27 09:05:10 2012
MD5:3c74315b2657777cdd2d82ef024b4aea -- If you edit this, you'll get what you deserve.
GFORTRAN module version '4' created from mvnprodcorrprb.f on Sat May 05 23:15:35 2012
MD5:e14dcbae790def5a44b530dc6eb0aba5 -- If you edit this, you'll get what you deserve.
(() () () () () () () () () () () () () () () () () () () () () () () ()
() () ())
@ -30,6 +30,12 @@ MODULE-PROC DECL UNKNOWN 0 0 FUNCTION GENERIC) (REAL 8 0 0 REAL ()) 16 0
19 'erfcoremod' 'erfcoremod' 'erfcoremod' 1 ((MODULE UNKNOWN-INTENT
UNKNOWN-PROC UNKNOWN UNKNOWN 0 0) (UNKNOWN 0 0 0 UNKNOWN ()) 0 0 () () 0
() () () 0 0)
7 'arg' '' 'arg' 6 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
8 'result' '' 'result' 6 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
9 'jint' '' 'jint' 6 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
11 'x' '' 'x' 10 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
12 'value' '' 'value' 10 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
@ -42,12 +48,6 @@ UNKNOWN 0 0 RESULT) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
18 'value' '' 'value' 16 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
UNKNOWN 0 0 RESULT) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
7 'arg' '' 'arg' 6 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
8 'result' '' 'result' 6 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
9 'jint' '' 'jint' 6 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
)
('calerf' 0 3 'derf' 0 2 'derfc' 0 5 'derfcx' 0 4 'erfcoremod' 0 19)

@ -1,5 +1,5 @@
GFORTRAN module version '4' created from intmodule.f on Tue Mar 27 09:05:12 2012
MD5:cabeafe3b4601bcca29abefe46d04288 -- If you edit this, you'll get what you deserve.
GFORTRAN module version '4' created from intmodule.f on Sat May 05 23:15:40 2012
MD5:53fb950b8a79cff14291a70f77ea6928 -- If you edit this, you'll get what you deserve.
(() () () () () () () () () () () () () () () () () () () () () () () ()
() () ())
@ -20,15 +20,15 @@ DECL UNKNOWN 0 0 SUBROUTINE GENERIC) (UNKNOWN 0 0 0 UNKNOWN ()) 4 0 (5 6
3 'sadapt' 'adaptmod' 'sadapt' 1 ((PROCEDURE UNKNOWN-INTENT MODULE-PROC
DECL UNKNOWN 0 0 SUBROUTINE GENERIC) (UNKNOWN 0 0 0 UNKNOWN ()) 14 0 (
15 16 17 18 19 20 21 22) () 0 () () () 0 0)
18 'abseps' '' 'abseps' 14 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
19 'releps' '' 'releps' 14 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
20 'error' '' 'error' 14 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
9 'absreq' '' 'absreq' 4 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
21 'value' '' 'value' 14 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
10 'relreq' '' 'relreq' 4 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
22 'inform' '' 'inform' 14 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0
11 'absest' '' 'absest' 4 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
12 'finest' '' 'finest' 4 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
13 'inform' '' 'inform' 4 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
15 'n' '' 'n' 14 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
@ -37,30 +37,30 @@ INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
17 'functn' '' 'functn' 14 ((PROCEDURE UNKNOWN-INTENT UNKNOWN-PROC BODY
UNKNOWN 0 0 DUMMY FUNCTION ALWAYS_EXPLICIT) (REAL 8 0 0 REAL ()) 23 0 (
24 25) () 17 () () () 0 0)
18 'abseps' '' 'abseps' 14 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
19 'releps' '' 'releps' 14 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
20 'error' '' 'error' 14 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
21 'value' '' 'value' 14 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
22 'inform' '' 'inform' 14 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
24 'n' '' 'n' 23 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
25 'z' '' 'z' 23 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 ASSUMED_SHAPE (CONSTANT
(INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
8 'functn' '' 'functn' 4 ((PROCEDURE UNKNOWN-INTENT UNKNOWN-PROC BODY
UNKNOWN 0 0 DUMMY FUNCTION ALWAYS_EXPLICIT) (REAL 8 0 0 REAL ()) 26 0 (
27 28) () 8 () () () 0 0)
9 'absreq' '' 'absreq' 4 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
10 'relreq' '' 'relreq' 4 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
11 'absest' '' 'absest' 4 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
12 'finest' '' 'finest' 4 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
13 'inform' '' 'inform' 4 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
5 'ndim' '' 'ndim' 4 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
6 'mincls' '' 'mincls' 4 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
7 'maxcls' '' 'maxcls' 4 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
8 'functn' '' 'functn' 4 ((PROCEDURE UNKNOWN-INTENT UNKNOWN-PROC BODY
UNKNOWN 0 0 DUMMY FUNCTION ALWAYS_EXPLICIT) (REAL 8 0 0 REAL ()) 26 0 (
27 28) () 8 () () () 0 0)
27 'n' '' 'n' 26 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
28 'z' '' 'z' 26 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0

@ -1,5 +1,5 @@
GFORTRAN module version '4' created from rind71mod.f on Tue Mar 27 09:05:15 2012
MD5:03dc18351a9cdc1dd505edc7a8479944 -- If you edit this, you'll get what you deserve.
GFORTRAN module version '4' created from rind71mod.f on Sat May 05 23:15:45 2012
MD5:86f10ef51b48ccdfff196b6e4d5d27c8 -- If you edit this, you'll get what you deserve.
(() () () () () () () () () () () () () () () () () () () () () () ()
() () () ())
@ -22,9 +22,9 @@ UNKNOWN UNKNOWN 0 0) (UNKNOWN 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 0)
6 'cm' '' 'cm' 3 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 ASSUMED_SHAPE (CONSTANT
(INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
9 'ind' '' 'ind' 3 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () (1 ASSUMED_SHAPE (
CONSTANT (INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
7 'b1' '' 'b1' 3 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 ASSUMED_SHAPE (CONSTANT
(INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
5 'c2' '' 'c2' 3 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
8 'sq' '' 'sq' 3 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
@ -32,9 +32,9 @@ DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 ASSUMED_SHAPE (CONSTANT
(INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
4 'c1' '' 'c1' 3 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
7 'b1' '' 'b1' 3 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 ASSUMED_SHAPE (CONSTANT
(INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
9 'ind' '' 'ind' 3 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () (1 ASSUMED_SHAPE (
CONSTANT (INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
)
('c1c2' 0 2 'c1c2mod' 0 10)

@ -1,5 +1,5 @@
GFORTRAN module version '4' created from intmodule.f on Tue Mar 27 09:05:13 2012
MD5:99db0c86db329df2a1ee0bbf67b9ec99 -- If you edit this, you'll get what you deserve.
GFORTRAN module version '4' created from intmodule.f on Sat May 05 23:15:41 2012
MD5:eb0327a40d874f78d04c89aa93e323f2 -- If you edit this, you'll get what you deserve.
(() () () () () () () () () () () () () () () () () () () () () () () ()
() () ())
@ -17,30 +17,30 @@ MD5:99db0c86db329df2a1ee0bbf67b9ec99 -- If you edit this, you'll get what you de
(2 'krobov' 'krobovmod' 'krobov' 1 ((PROCEDURE UNKNOWN-INTENT
MODULE-PROC DECL UNKNOWN 0 0 SUBROUTINE GENERIC) (UNKNOWN 0 0 0 UNKNOWN
()) 3 0 (4 5 6 7 8 9 10 11 12) () 0 () () () 0 0)
4 'ndim' '' 'ndim' 3 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
7 'functn' '' 'functn' 3 ((PROCEDURE UNKNOWN-INTENT UNKNOWN-PROC BODY
UNKNOWN 0 0 DUMMY FUNCTION ALWAYS_EXPLICIT) (REAL 8 0 0 REAL ()) 13 0 (
14 15) () 7 () () () 0 0)
5 'minvls' '' 'minvls' 3 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
8 'abseps' '' 'abseps' 3 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
6 'maxvls' '' 'maxvls' 3 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
9 'releps' '' 'releps' 3 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
11 'finest' '' 'finest' 3 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
12 'inform' '' 'inform' 3 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
5 'minvls' '' 'minvls' 3 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
10 'abserr' '' 'abserr' 3 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
7 'functn' '' 'functn' 3 ((PROCEDURE UNKNOWN-INTENT UNKNOWN-PROC BODY
UNKNOWN 0 0 DUMMY FUNCTION ALWAYS_EXPLICIT) (REAL 8 0 0 REAL ()) 13 0 (
14 15) () 7 () () () 0 0)
11 'finest' '' 'finest' 3 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
4 'ndim' '' 'ndim' 3 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
9 'releps' '' 'releps' 3 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
6 'maxvls' '' 'maxvls' 3 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
14 'n' '' 'n' 13 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
15 'z' '' 'z' 13 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 ASSUMED_SHAPE (CONSTANT
(INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
14 'n' '' 'n' 13 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
)
('krobov' 0 2)

@ -1,5 +1,5 @@
GFORTRAN module version '4' created from rind71mod.f on Tue Mar 27 09:05:15 2012
MD5:f25fedb5e90d06a4555a8d917fc02de3 -- If you edit this, you'll get what you deserve.
GFORTRAN module version '4' created from rind71mod.f on Sat May 05 23:15:45 2012
MD5:0b1982321203177ab8efc0aefe21c275 -- If you edit this, you'll get what you deserve.
(() () () () () () () () () () () () () () () () () () () () () () ()
() () () ())
@ -193,11 +193,10 @@ DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 ASSUMED_SHAPE (CONSTANT
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
35 'xma' '' 'xma' 30 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
24 'n' '' 'n' 23 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
48 'xma' '' 'xma' 43 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
49 'n0' '' 'n0' 43 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
25 'wfout' '' 'wfout' 23 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 ASSUMED_SHAPE (CONSTANT
(INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
26 'bpout' '' 'bpout' 23 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 ASSUMED_SHAPE (CONSTANT
(INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
@ -221,6 +220,11 @@ DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
42 'n0' '' 'n0' 36 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
24 'n' '' 'n' 23 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
25 'wfout' '' 'wfout' 23 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 ASSUMED_SHAPE (CONSTANT
(INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
10 'n' '' 'n' 9 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
11 'wfout' '' 'wfout' 9 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
@ -259,10 +263,6 @@ DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 ASSUMED_SHAPE (CONSTANT
(INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
47 'xmi' '' 'xmi' 43 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
48 'xma' '' 'xma' 43 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
49 'n0' '' 'n0' 43 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
)
('__convert_r4_r8' 0 8 'gausshe0' 0 2 'gaussla0' 0 7 'gaussle0' 0 3

@ -1,5 +1,5 @@
GFORTRAN module version '4' created from intmodule.f on Tue Mar 27 09:05:12 2012
MD5:c88c5a15c480306fb971bd1e5ced587e -- If you edit this, you'll get what you deserve.
GFORTRAN module version '4' created from intmodule.f on Sat May 05 23:15:40 2012
MD5:f628260304c0d5215e1ef95941599430 -- If you edit this, you'll get what you deserve.
(() () () () () () () () () () () () () () () () () () () () () () () ()
() () ())
@ -17,14 +17,6 @@ MD5:c88c5a15c480306fb971bd1e5ced587e -- If you edit this, you'll get what you de
(2 'ranmc' 'rcrudemod' 'ranmc' 1 ((PROCEDURE UNKNOWN-INTENT MODULE-PROC
DECL UNKNOWN 0 0 SUBROUTINE GENERIC) (UNKNOWN 0 0 0 UNKNOWN ()) 3 0 (4 5
6 7 8 9 10 11) () 0 () () () 0 0)
8 'releps' '' 'releps' 3 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
UNKNOWN 0 0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
9 'error' '' 'error' 3 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
UNKNOWN 0 0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
10 'value' '' 'value' 3 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
UNKNOWN 0 0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
11 'inform' '' 'inform' 3 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
UNKNOWN 0 0 DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
4 'n' '' 'n' 3 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
5 'maxpts' '' 'maxpts' 3 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
@ -34,6 +26,14 @@ UNKNOWN 0 0 DUMMY FUNCTION ALWAYS_EXPLICIT) (REAL 8 0 0 REAL ()) 12 0 (
13 14) () 6 () () () 0 0)
7 'abseps' '' 'abseps' 3 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
UNKNOWN 0 0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
8 'releps' '' 'releps' 3 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
UNKNOWN 0 0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
9 'error' '' 'error' 3 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
UNKNOWN 0 0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
10 'value' '' 'value' 3 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
UNKNOWN 0 0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
11 'inform' '' 'inform' 3 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
UNKNOWN 0 0 DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
13 'n' '' 'n' 12 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY) (
INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
14 'z' '' 'z' 12 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0

@ -1,5 +1,5 @@
GFORTRAN module version '4' created from rind71mod.f on Tue Mar 27 09:05:16 2012
MD5:c563cb41c58c08f015ddd93b31235450 -- If you edit this, you'll get what you deserve.
GFORTRAN module version '4' created from rind71mod.f on Sat May 05 23:15:48 2012
MD5:39a52091a6c81f0056e400b137f29e11 -- If you edit this, you'll get what you deserve.
(() () () () () () () () () () () () () () () () () () () () () () ()
() () () ())
@ -27,30 +27,30 @@ UNKNOWN ()) 10 0 (11 12 13 14 15 16 17 18) () 0 () () () 0 0)
4 'setdata' 'rind71mod' 'setdata' 1 ((PROCEDURE UNKNOWN-INTENT
MODULE-PROC DECL UNKNOWN 0 0 SUBROUTINE GENERIC) (UNKNOWN 0 0 0 UNKNOWN
()) 19 0 (20 21 22 23 24 25 26 27 28) () 0 () () () 0 0)
22 'depss' '' 'depss' 19 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
23 'dreps' '' 'dreps' 19 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
28 'dxsplt' '' 'dxsplt' 19 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
24 'deps2' '' 'deps2' 19 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
25 'dnit' '' 'dnit' 19 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
24 'deps2' '' 'deps2' 19 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
26 'dxc' '' 'dxc' 19 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
27 'dnint' '' 'dnint' 19 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
28 'dxsplt' '' 'dxsplt' 19 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
9 'speed' '' 'speed' 8 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
20 'method' '' 'method' 19 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
21 'scale' '' 'scale' 19 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
22 'depss' '' 'depss' 19 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
23 'dreps' '' 'dreps' 19 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
7 'array' '' 'array' 6 ((VARIABLE UNKNOWN-INTENT UNKNOWN-PROC UNKNOWN
UNKNOWN 0 0 DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (2
ASSUMED_SHAPE (CONSTANT (INTEGER 4 0 0 INTEGER ()) 0 '1') () (CONSTANT (
INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)
9 'speed' '' 'speed' 8 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
11 'fxind' '' 'fxind' 10 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 ASSUMED_SHAPE (CONSTANT
(INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)

@ -1,5 +1,5 @@
GFORTRAN module version '4' created from rindmod.f on Tue Mar 27 09:05:14 2012
MD5:dcdbb9dedca21469ecd6ba2a3e2bf880 -- If you edit this, you'll get what you deserve.
GFORTRAN module version '4' created from rindmod.f on Sat May 05 23:15:44 2012
MD5:27b48943ab247880a4203cf14574fba3 -- If you edit this, you'll get what you deserve.
(() () () () () () () () () () () () () () () () () () () () () () ()
() () () ())
@ -52,6 +52,12 @@ UNKNOWN ()) 15 0 (16 17 18 19 20 21 22 23 24 25 26) () 0 () () () 0 0)
MODULE-PROC DECL UNKNOWN 0 0 SUBROUTINE GENERIC ALWAYS_EXPLICIT) (
UNKNOWN 0 0 0 UNKNOWN ()) 27 0 (28 29 30 31 32 33 34 35 36 37) () 0 () ()
() 0 0)
28 'method' '' 'method' 27 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 OPTIONAL DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
29 'xcscale' '' 'xcscale' 27 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN
0 0 OPTIONAL DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
30 'abseps' '' 'abseps' 27 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 OPTIONAL DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
31 'releps' '' 'releps' 27 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 OPTIONAL DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
32 'coveps' '' 'coveps' 27 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0
@ -66,12 +72,6 @@ OPTIONAL DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
0 0 OPTIONAL DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
37 'nc1c2' '' 'nc1c2' 27 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
OPTIONAL DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
28 'method' '' 'method' 27 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 OPTIONAL DUMMY) (INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
29 'xcscale' '' 'xcscale' 27 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN
0 0 OPTIONAL DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
30 'abseps' '' 'abseps' 27 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN 0
0 OPTIONAL DUMMY) (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
16 'vals' '' 'vals' 15 ((VARIABLE OUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0
DIMENSION DUMMY) (REAL 8 0 0 REAL ()) 0 0 () (1 ASSUMED_SHAPE (CONSTANT
(INTEGER 4 0 0 INTEGER ()) 0 '1') ()) 0 () () () 0 0)

@ -1,5 +1,5 @@
GFORTRAN module version '4' created from swapmod.f on Tue Mar 27 09:05:13 2012
MD5:d3f134c81002cd5f6cec09ebff3e336f -- If you edit this, you'll get what you deserve.
GFORTRAN module version '4' created from swapmod.f on Sat May 05 23:15:42 2012
MD5:52275e19413dc7ab9d6082dbb7b7af80 -- If you edit this, you'll get what you deserve.
(() () () () () () () () () () () () () () () () () () () () () () () ()
() () ())
@ -25,12 +25,6 @@ DECL UNKNOWN 0 0 SUBROUTINE) (UNKNOWN 0 0 0 UNKNOWN ()) 11 0 (12 13) ()
0 () () () 0 0)
14 'swapmod' 'swapmod' 'swapmod' 1 ((MODULE UNKNOWN-INTENT UNKNOWN-PROC
UNKNOWN UNKNOWN 0 0) (UNKNOWN 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 0)
12 'a' '' 'a' 11 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
13 'b' '' 'b' 11 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
9 'a' '' 'a' 8 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
10 'b' '' 'b' 8 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
6 'a' '' 'a' 5 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
@ -39,6 +33,12 @@ UNKNOWN UNKNOWN 0 0) (UNKNOWN 0 0 0 UNKNOWN ()) 0 0 () () 0 () () () 0 0)
7 'b' '' 'b' 5 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(CHARACTER 1 0 0 CHARACTER ((CONSTANT (INTEGER 4 0 0 INTEGER ()) 0 '1')))
0 0 () () 0 () () () 0 0)
12 'a' '' 'a' 11 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
13 'b' '' 'b' 11 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0)
9 'a' '' 'a' 8 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 0 0 DUMMY)
(INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0)
)
('swap_c' 0 2 'swap_i' 0 3 'swap_r' 0 4 'swapmod' 0 14)

@ -52,7 +52,7 @@ from numpy import (inf, atleast_1d, newaxis, any, minimum, maximum, array, #@Unr
asarray, exp, log, sqrt, where, pi, arange, linspace, sin, cos, abs, sinh, #@UnresolvedImport
isfinite, mod, expm1, tanh, cosh, finfo, ones, ones_like, isnan, #@UnresolvedImport
zeros_like, flatnonzero, sinc, hstack, vstack, real, flipud, clip) #@UnresolvedImport
from dispersion_relation import w2k, k2w
from dispersion_relation import w2k, k2w #@UnusedImport
from wafo.spectrum import SpecData1D, SpecData2D
sech = lambda x: 1.0 / cosh(x)
@ -362,13 +362,13 @@ def jonswap_seastate(u10, fetch=150000., method='lewis', g=9.81, output='dict'):
>>> import wafo.spectrum.models as wsm
>>> fetch = 10000; u10 = 10
>>> ss = wsm.jonswap_seastate(u10, fetch, output='dict')
>>> ss
{'Ag': 0.016257903375341734,
'Hm0': 0.51083679198275533,
'Tp': 2.7727680999585265,
'gamma': 2.4824142635861119,
'sigmaA': 0.075317331395172021,
'sigmaB': 0.091912084512251344}
>>> for key in sorted(ss.keys()): key, ss[key]
('Ag', 0.016257903375341734)
('Hm0', 0.51083679198275533)
('Tp', 2.7727680999585265)
('gamma', 2.4824142635861119)
('sigmaA', 0.07531733139517202)
('sigmaB', 0.09191208451225134)
>>> S = wsm.Jonswap(**ss)
>>> S.Hm0
0.51083679198275533
@ -660,7 +660,7 @@ def phi1(wi, h, g=9.81):
Transform a JONSWAP spectrum to a spectrum for waterdepth = 30 m
>>> import wafo.spectrum.models as wsm
>>> S = wsm.Jonswap()
>>> w = range(3.0)
>>> w = np.arange(3.0)
>>> S(w)*wsm.phi1(w,30.0)
array([ 0. , 1.0358056 , 0.03796281])
@ -894,8 +894,8 @@ class Torsethaugen(ModelSpectrum):
Tp = self.Tp
gravity1 = self.gravity # m/s**2
min = minimum
max = maximum
min = minimum #@ReservedAssignment
max = maximum #@ReservedAssignment
# The parameter values below are found comparing the
# model to average measured spectra for the Statfjord Field
@ -1476,7 +1476,7 @@ class Spreading(object):
##% By es, jr 1999.11.25
def __init__(self, type='cos2s', theta0=0, method='mitsuyasu', s_a=15., s_b=15., m_a=5., m_b= -2.5, wn_lo=0.0, wn_c=1., wn_up=inf):
def __init__(self, type='cos2s', theta0=0, method='mitsuyasu', s_a=15., s_b=15., m_a=5., m_b= -2.5, wn_lo=0.0, wn_c=1., wn_up=inf): #@ReservedAssignment
self.type = type
self.theta0 = theta0
@ -2003,11 +2003,11 @@ def _test_some_spectra():
import pylab as plb
#import pylab as plb
#w = plb.linspace(0,3)
w, th = plb.ogrid[0:4, 0:6]
k, k2 = w2k(w, th)
k1, k12 = w2k(w, th, h=20)
#k1, k12 = w2k(w, th, h=20)
plb.plot(w, k, w, k2)
plb.show()
@ -2050,7 +2050,7 @@ def _test_spreading():
theta0 = lambda w: w * plb.pi / 6.0
D2 = Spreading('cos2s', theta0=theta0)
d1 = D2(theta, w)[0]
t = plb.contour(d1.squeeze())
_t = plb.contour(d1.squeeze())
pi = plb.pi
D = Spreading('wrap_norm', s_a=10.0)
@ -2061,12 +2061,15 @@ def _test_spreading():
plb.contour(d1[0])
plb.show()
def test_docstrings():
import doctest
doctest.testmod()
def main():
if False: # True: #
_test_some_spectra()
else:
import doctest
doctest.testmod()
test_docstrings()
if __name__ == '__main__':
main()

@ -4,7 +4,7 @@ Created on 19. juli 2010
@author: pab
'''
from wafo.spectrum.dispersion_relation import w2k,k2w
from wafo.spectrum.dispersion_relation import w2k,k2w #@UnusedImport
def test_k2w():
'''

@ -113,8 +113,8 @@ class WafoData(object):
>>> d = WafoData(np.sin(x),x)
>>> xi = np.linspace(0,5,60)
>>> di = WafoData(d.eval_points(xi, method='cubic'),xi)
>>> d.plot('.')
>>> di.plot()
>>> h = d.plot('.')
>>> hi = di.plot()
'''
if isinstance(self.args, (list, tuple)): # Multidimensional data
@ -136,6 +136,7 @@ class WafoData(object):
>>> x = np.linspace(0,5,60)
>>> d = WafoData(np.sin(x), x)
>>> d.integrate(0,np.pi/2)
0.99940054759302188
'''
method = kwds.pop('method','trapz')
@ -507,7 +508,8 @@ def main():
pass
if __name__ == '__main__':
test_integrate()
#test_integrate()
#test_eval_points()
#test_docstrings()
test_docstrings()
#main()

Loading…
Cancel
Save