updated __all__ attributes in modules

master
Per.Andreas.Brodtkorb 14 years ago
parent 5dbc448368
commit bb7b1de823

@ -9,6 +9,7 @@ import transform
import definitions import definitions
import polynomial import polynomial
import stats import stats
import interpolate
try: try:
from wafo.version import version as __version__ from wafo.version import version as __version__

@ -2,6 +2,6 @@
Covariance package in WAFO Toolbox. Covariance package in WAFO Toolbox.
""" """
from core import CovData1D from core import * #CovData1D
#import models #import models
#import dispersion_relation #import dispersion_relation

@ -2,14 +2,15 @@ from numpy import r_, minimum, maximum, atleast_1d, atleast_2d, mod, ones, floor
random, eye, nonzero, where, repeat, sqrt, exp, inf, diag, zeros, sin, arcsin, nan #@UnresolvedImport random, eye, nonzero, where, repeat, sqrt, exp, inf, diag, zeros, sin, arcsin, nan #@UnresolvedImport
from numpy import triu #@UnresolvedImport from numpy import triu #@UnresolvedImport
from scipy.special import ndtr as cdfnorm, ndtri as invnorm from scipy.special import ndtr as cdfnorm, ndtri as invnorm
from scipy.special import erfc
from wafo import mvn from wafo import mvn
import numpy as np import numpy as np
import wafo.mvnprdmod as mvnprdmod import wafo.mvnprdmod as mvnprdmod
import wafo.rindmod as rindmod import wafo.rindmod as rindmod
import warnings import warnings
from wafo.misc import common_shape from wafo.misc import common_shape
from scipy.stats.stats import erfc
__all__ = ['Rind', 'rindmod', 'mvnprdmod', 'mvn', 'cdflomax' , 'prbnormtndpc', 'prbnormndpc', 'prbnormnd', 'cdfnornd2', 'prbnorm2d','cdfnorm','invnorm']
class Rind(object): class Rind(object):
''' '''
RIND Computes multivariate normal expectations RIND Computes multivariate normal expectations
@ -595,7 +596,6 @@ _ERRORMESSAGE[6] = '''the input is invalid because:
def prbnormnd(correl, a, b, abseps=1e-4, releps=1e-3, maxpts=None, method=0): def prbnormnd(correl, a, b, abseps=1e-4, releps=1e-3, maxpts=None, method=0):
''' '''
Multivariate Normal probability by Genz' algorithm. Multivariate Normal probability by Genz' algorithm.

@ -11,6 +11,9 @@ from wafo.misc import meshgrid
_POINTS_AND_WEIGHTS = {} _POINTS_AND_WEIGHTS = {}
__all__ = ['peaks', 'humps', 'is_numlike', 'dea3', 'clencurt', 'romberg',
'h_roots','j_roots', 'la_roots','p_roots','qrule',
'gaussq', 'richardson', 'quadgr', 'qdemo']
def peaks(x=None, y=None, n=51): def peaks(x=None, y=None, n=51):
''' '''
Return the "well" known MatLab (R) peaks function Return the "well" known MatLab (R) peaks function
@ -20,7 +23,7 @@ def peaks(x=None, y=None, n=51):
------- -------
>>> import pylab as plt >>> import pylab as plt
>>> x,y,z = peaks() >>> x,y,z = peaks()
>>> plt.contourf(x,y,z) >>> h = plt.contourf(x,y,z)
''' '''
if x is None: if x is None:
@ -1164,7 +1167,8 @@ def gaussq(fun, a, b, reltol=1e-3, abstol=1e-3, alpha=0, beta=0, wfun=1,
return val, abserr return val, abserr
def richardson(Q, k): def richardson(Q, k):
#% Richardson extrapolation with parameter estimation # license BSD
# Richardson extrapolation with parameter estimation
c = np.real((Q[k - 1] - Q[k - 2]) / (Q[k] - Q[k - 1])) - 1. c = np.real((Q[k - 1] - Q[k - 2]) / (Q[k] - Q[k - 1])) - 1.
#% The lower bound 0.07 admits the singularity x.^-0.9 #% The lower bound 0.07 admits the singularity x.^-0.9
c = max(c, 0.07) c = max(c, 0.07)
@ -1212,9 +1216,7 @@ def quadgr(fun, a, b, abseps=1e-5):
QUAD, QUAD,
QUADGK QUADGK
''' '''
#% Author: jonas.lundgren@saabgroup.com, 2009. # Author: jonas.lundgren@saabgroup.com, 2009. license BSD
# Order limits (required if infinite limits) # Order limits (required if infinite limits)
if a == b: if a == b:
Q = b - a Q = b - a

@ -19,6 +19,8 @@ from numpy.lib.shape_base import vstack
from numpy.lib.function_base import linspace from numpy.lib.function_base import linspace
import polynomial as pl import polynomial as pl
__all__ =['PPform','SmoothSpline']
class PPform(object): class PPform(object):
"""The ppform of the piecewise polynomials is given in terms of coefficients """The ppform of the piecewise polynomials is given in terms of coefficients
and breaks. The polynomial in the ith interval is and breaks. The polynomial in the ith interval is

@ -12,7 +12,7 @@
from __future__ import division from __future__ import division
from itertools import product from itertools import product
from misc import tranproc #, trangood from misc import tranproc #, trangood
from numpy import pi, sqrt, atleast_2d, exp, newaxis, array #@UnresolvedImport from numpy import pi, sqrt, atleast_2d, exp, newaxis #@UnresolvedImport
from scipy import interpolate, linalg from scipy import interpolate, linalg
from scipy.special import gamma from scipy.special import gamma
from wafo.misc import meshgrid from wafo.misc import meshgrid
@ -32,8 +32,8 @@ _stats_lapl = (2, 1. / 4, np.inf)
_stats_logi = (pi ** 2 / 3, 1. / 6, 1 / 42) _stats_logi = (pi ** 2 / 3, 1. / 6, 1 / 42)
_stats_gaus = (1, 1. / (2 * sqrt(pi)), 3. / (8 * sqrt(pi))) _stats_gaus = (1, 1. / (2 * sqrt(pi)), 3. / (8 * sqrt(pi)))
__all__ =['sphere_volume','TKDE', 'KDE', 'Kernel', 'accum', 'qlevels',
'iqrange', 'gridcount', 'kde_demo1', 'kde_demo2']
def sphere_volume(d, r=1.0): def sphere_volume(d, r=1.0):
""" """
Returns volume of d-dimensional sphere with radius r Returns volume of d-dimensional sphere with radius r

@ -24,10 +24,12 @@ floatinfo = finfo(float)
__all__ = ['JITImport', 'DotDict', 'Bunch', 'printf', 'sub_dict_select', __all__ = ['JITImport', 'DotDict', 'Bunch', 'printf', 'sub_dict_select',
'parse_kwargs', 'ecross', 'findtc', 'findtp', 'findcross', 'parse_kwargs', 'detrendma', 'ecross', 'findcross',
'findextrema', 'findrfc', 'rfcfilter', 'common_shape', 'argsreduce', 'findextrema', 'findpeaks', 'findrfc', 'rfcfilter', 'findtp', 'findtc',
'findoutliers', 'common_shape', 'argsreduce',
'stirlerr', 'getshipchar', 'betaloge', 'gravity', 'nextpow2', 'stirlerr', 'getshipchar', 'betaloge', 'gravity', 'nextpow2',
'discretize', 'pol2cart', 'cart2pol', 'ndgrid', 'meshgrid', 'histgrm'] 'discretize', 'discretize2', 'pol2cart', 'cart2pol', 'meshgrid', 'ndgrid',
'trangood', 'tranproc', 'histgrm', 'num2pistr']
class JITImport(object): class JITImport(object):
''' '''
@ -434,7 +436,7 @@ def findpeaks(data, n=2, min_h=None, min_p=0.0):
if len(TuP): if len(TuP):
ind = TuP[1::2] #; % extract indices to maxima only ind = TuP[1::2] #; % extract indices to maxima only
else: # % did not find any , try maximum else: # % did not find any , try maximum
ind = S[iy].argmax() ind = np.atleast_1d(S[iy].argmax())
if ndim>1: if ndim>1:
if iy==0: if iy==0:

@ -5,6 +5,6 @@ Spectrum package in WAFO Toolbox.
""" """
from core import SpecData1D, SpecData2D, cltext from core import * #SpecData1D, SpecData2D, cltext
import models import models
import dispersion_relation import dispersion_relation

@ -1,5 +1,5 @@
from __future__ import division from __future__ import division
from wafo.misc import meshgrid, gravity from wafo.misc import meshgrid, gravity, cart2pol, pol2cart
from wafo.objects import mat2timeseries, TimeSeries from wafo.objects import mat2timeseries, TimeSeries
import warnings import warnings
@ -180,6 +180,12 @@ def plotspec(specdata, linetype='b-', flag=1):
NOTE: - lintype may be given anywhere after S. NOTE: - lintype may be given anywhere after S.
Examples Examples
>>> import numpy as np
>>> import wafo.spectrum.models as sm
>>> Sj = sm.Jonswap(Hm0=3, Tp=7)
>>> S = Sj.tospecdata()
>>> plotspec(S,1)
S = demospec('dir'); S2 = mkdspec(jonswap,spreading); S = demospec('dir'); S2 = mkdspec(jonswap,spreading);
plotspec(S,2), hold on plotspec(S,2), hold on
plotspec(S,3,'g') % Same as previous fig. due to frequency independent spreading plotspec(S,3,'g') % Same as previous fig. due to frequency independent spreading
@ -250,8 +256,8 @@ def plotspec(specdata, linetype='b-', flag=1):
spectype = specdata.type.lower() spectype = specdata.type.lower()
stype = spectype[-3::] stype = spectype[-3::]
if stype in ('enc','req','k1d') : #1D plot if stype in ('enc','req','k1d') : #1D plot
Fn = freq(-1) # Nyquist frequency Fn = freq[-1] # Nyquist frequency
indm = findpeaks(data,n=4) indm = findpeaks(data, n=4)
maxS = data.max() maxS = data.max()
# if isfield(S,'CI') && ~isempty(S.CI), # if isfield(S,'CI') && ~isempty(S.CI),
# maxS = maxS*S.CI(2); # maxS = maxS*S.CI(2);
@ -1714,8 +1720,8 @@ class SpecData1D(WafoData):
>>> x2, x1 = S.sim_nl(ns=20000,cases=20) >>> x2, x1 = S.sim_nl(ns=20000,cases=20)
>>> truth1 = [0,np.sqrt(S.moment(1)[0][0])] + S.stats_nl(moments='sk') >>> truth1 = [0,np.sqrt(S.moment(1)[0][0])] + S.stats_nl(moments='sk')
>>> truth1[-1] = truth1[-1]-3 >>> truth1[-1] = truth1[-1]-3
>>> truth1 >>> np.round(truth1, 3)
[0, 1.7495200310090628, 0.18673120577479821, 0.06198852126241805] array([ 0. , 1.75 , 0.187, 0.062])
>>> funs = [np.mean,np.std,st.skew,st.kurtosis] >>> funs = [np.mean,np.std,st.skew,st.kurtosis]
>>> for fun,trueval in zip(funs,truth1): >>> for fun,trueval in zip(funs,truth1):
@ -1736,8 +1742,8 @@ class SpecData1D(WafoData):
>>> x2 = np.hstack(x) >>> x2 = np.hstack(x)
>>> truth1 = [0,np.sqrt(S.moment(1)[0][0])] + S.stats_nl(moments='sk') >>> truth1 = [0,np.sqrt(S.moment(1)[0][0])] + S.stats_nl(moments='sk')
>>> truth1[-1] = truth1[-1]-3 >>> truth1[-1] = truth1[-1]-3
>>> truth1 >>> np.round(truth1,3)
[0, 1.7495200310090628, 0.18673120577479821, 0.06198852126241805] array([ 0. , 1.75 , 0.187, 0.062])
>>> funs = [np.mean,np.std,st.skew,st.kurtosis] >>> funs = [np.mean,np.std,st.skew,st.kurtosis]
>>> for fun,trueval in zip(funs,truth1): >>> for fun,trueval in zip(funs,truth1):
@ -2811,10 +2817,10 @@ class SpecData1D(WafoData):
title = 'Directional Spectrum' title = 'Directional Spectrum'
if self.freqtype.startswith('w'): if self.freqtype.startswith('w'):
labels[0] = 'Frequency [rad/s]' labels[0] = 'Frequency [rad/s]'
labels[2] = 'S(w,\theta) [m^2 s / rad^2]' labels[2] = r'S(w,$\theta$) $[m^2 s / rad^2]$'
else: else:
labels[0] = 'Frequency [Hz]' labels[0] = 'Frequency [Hz]'
labels[2] = 'S(f,\theta) [m^2 s / rad]' labels[2] = r'S(f,$\theta$) $[m^2 s / rad]$'
if self.angletype.startswith('r'): if self.angletype.startswith('r'):
labels[1] = 'Wave directions [rad]' labels[1] = 'Wave directions [rad]'
@ -2824,18 +2830,18 @@ class SpecData1D(WafoData):
title = 'Spectral density' title = 'Spectral density'
if self.freqtype.startswith('w'): if self.freqtype.startswith('w'):
labels[0] = 'Frequency [rad/s]' labels[0] = 'Frequency [rad/s]'
labels[1] = 'S(w) [m^2 s/ rad]' labels[1] = r'S(w) $[m^2 s/ rad]$'
else: else:
labels[0] = 'Frequency [Hz]' labels[0] = 'Frequency [Hz]'
labels[1] = 'S(f) [m^2 s]' labels[1] = r'S(f) $[m^2 s]$'
else: else:
title = 'Wave Number Spectrum' title = 'Wave Number Spectrum'
labels[0] = 'Wave number [rad/m]' labels[0] = 'Wave number [rad/m]'
if self.type.endswith('k1d'): if self.type.endswith('k1d'):
labels[1] = 'S(k) [m^3/ rad]' labels[1] = r'S(k) $[m^3/ rad]$'
elif self.type.endswith('k2d'): elif self.type.endswith('k2d'):
labels[1] = labels[0] labels[1] = labels[0]
labels[2] = 'S(k1,k2) [m^4/ rad^2]' labels[2] = r'S(k1,k2) $[m^4/ rad^2]$'
else: else:
raise ValueError('Object does not appear to be initialized, it is empty!') raise ValueError('Object does not appear to be initialized, it is empty!')
if self.norm != 0: if self.norm != 0:
@ -2975,7 +2981,7 @@ class SpecData2D(WafoData):
if (self.args[0][0]==-pi): if (self.args[0][0]==-pi):
self.data[ntOld,:] = self.data[0,:] self.data[ntOld,:] = self.data[0,:]
else: else:
ftype = self.freqtype #ftype = self.freqtype
freq = self.args[1] freq = self.args[1]
theta = linspace(-pi,pi,ntOld) theta = linspace(-pi,pi,ntOld)
[F,T] = meshgrid(freq,theta) [F,T] = meshgrid(freq,theta)
@ -2985,7 +2991,7 @@ class SpecData2D(WafoData):
self.data[nt,:] = self.data[0,:] self.data[nt,:] = self.data[0,:]
self.data = interp2(freq,np.vstack([self.theta[0]-dtheta,self.theta]), self.data = interp2(freq,np.vstack([self.theta[0]-dtheta,self.theta]),
np.vstack([self.data[nt,:],self.data]),F,T,method) np.vstack([self.data[nt,:],self.data]),F,T,method)
self.args[0] = theta; self.args[0] = theta
elif stype=='k2d': elif stype=='k2d':
#any of the 2D wave number types #any of the 2D wave number types
@ -3053,7 +3059,7 @@ class SpecData2D(WafoData):
>>> SD = D.tospecdata2d(sm.Jonswap().tospecdata(),nt=101) >>> SD = D.tospecdata2d(sm.Jonswap().tospecdata(),nt=101)
>>> m,mtext = SD.moment(nr=2,vari='xyt') >>> m,mtext = SD.moment(nr=2,vari='xyt')
>>> np.round(m,3),mtext >>> np.round(m,3),mtext
(array([ 3.061, 0.132, -0. , 2.13 , 0.011, 0.008, 1.677, -0. , (array([ 3.061, 0.132, 0. , 2.13 , 0.011, 0.008, 1.677, -0. ,
0.109, 0.109]), ['m0', 'mx', 'my', 'mt', 'mxx', 'myy', 'mtt', 'mxy', 'mxt', 'myt']) 0.109, 0.109]), ['m0', 'mx', 'my', 'mt', 'mxx', 'myy', 'mtt', 'mxy', 'mxt', 'myt'])
References References

@ -7,3 +7,4 @@ Statistics package in WAFO Toolbox.
from scipy.stats import * from scipy.stats import *
from core import * from core import *
from wafo.stats.distributions import * from wafo.stats.distributions import *
import estimation

@ -6,11 +6,11 @@ from scipy import special
import numpy as np import numpy as np
from numpy import inf from numpy import inf
from numpy import atleast_1d, nan, ndarray, sqrt, vstack, ones, where, zeros from numpy import atleast_1d, nan, ndarray, sqrt, vstack, ones, where, zeros
from numpy import arange, floor, linspace, asarray, reshape, repeat, product from numpy import arange, floor, linspace, asarray #, reshape, repeat, product
__all__ = ['edf', 'edfcnd','reslife', 'dispersion_idx','decluster','findpot', __all__ = ['edf', 'edfcnd','reslife', 'dispersion_idx','decluster','findpot',
'declustering_time','extremal_idx'] 'declustering_time','interexceedance_times', 'extremal_idx']
arr = asarray arr = asarray
@ -533,8 +533,6 @@ def _find_ok_peaks(Ye, Te, Tmin):
iOK, = where(1 - isTooClose[oOrder]) iOK, = where(1 - isTooClose[oOrder])
return iOK return iOK
def declustering_time(t): def declustering_time(t):
''' '''
Returns minimum distance between clusters. Returns minimum distance between clusters.

Loading…
Cancel
Save