Small bugfixes

master
Per.Andreas.Brodtkorb 15 years ago
parent d0b1e917ce
commit d0c62a08fa

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>PYWAFO</name> <name>google_pywafo</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>

@ -3,7 +3,7 @@
<pydev_project> <pydev_project>
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> <pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
<path>/PYWAFO/src</path> <path>/google_pywafo/src</path>
</pydev_pathproperty> </pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property> <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> <pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>

@ -17,6 +17,7 @@ python setup.py sdist bdist_wininst upload --show-response
import os, sys import os, sys
sys.argv.append("develop") sys.argv.append("develop")
#sys.argv.append("install")
DISTUTILS_DEBUG = True DISTUTILS_DEBUG = True
pkg_name = 'wafo' pkg_name = 'wafo'
root_dir = os.path.join('src',pkg_name) root_dir = os.path.join('src',pkg_name)
@ -44,7 +45,9 @@ testscripts = [os.path.join(subtst, f) for subtst in subtests
f.endswith('.old') or f.endswith('.bak'))] f.endswith('.old') or f.endswith('.bak'))]
datadir = 'data' datadir = 'data'
datafiles = [os.path.join(datadir, f) for f in os.listdir(os.path.join(root_dir, datadir)) datafiles = [os.path.join(datadir, f) for f in os.listdir(os.path.join(root_dir, datadir))
if not (f.endswith('.py') or f.endswith('test') )] if not (f.startswith('.') or f.endswith('~') or
f.endswith('.old') or f.endswith('.bak') or
f.endswith('.py') or f.endswith('test') )]
libs = [f for f in os.listdir(os.path.join(root_dir)) if f.endswith('.pyd') ] libs = [f for f in os.listdir(os.path.join(root_dir)) if f.endswith('.pyd') ]
packagedata = testscripts + datafiles + libs #['c_library.pyd'] #,'disufq1.c','diffsumfunq.pyd','diffsumfunq.pyf','findrfc.c','rfc.pyd','rfc.pyf'] packagedata = testscripts + datafiles + libs #['c_library.pyd'] #,'disufq1.c','diffsumfunq.pyd','diffsumfunq.pyf','findrfc.c','rfc.pyd','rfc.pyf']

@ -1,92 +1,92 @@
Metadata-Version: 1.0 Metadata-Version: 1.0
Name: WAFO Name: wafo
Version: 0.11 Version: 0.11
Summary: Summary: UNKNOWN
WAFO Home-page: http://www.maths.lth.se/matstat/wafo/
===== Author: WAFO-group
WAFO is a toolbox Python routines for statistical analysis and simulation of random waves and random loads. Author-email: wafo@maths.lth.se
WAFO is freely redistributable software, see WAFO licence, cf. the GNU General Public License (GPL) and License: GPL
contain tools for: Description:
WAFO
=====
WAFO is a toolbox Python routines for statistical analysis and simulation of random waves and random loads.
WAFO is freely redistributable software, see WAFO licence, cf. the GNU General Public License (GPL) and
contain tools for:
Fatigue Analysis Fatigue Analysis
---------------- ----------------
-Fatigue life prediction for random loads -Fatigue life prediction for random loads
-Theoretical density of rainflow cycles -Theoretical density of rainflow cycles
Sea modelling Sea modelling
------------- -------------
-Simulation of linear and non-linear Gaussian waves -Simulation of linear and non-linear Gaussian waves
-Estimation of seamodels (spectrums) -Estimation of seamodels (spectrums)
-Joint wave height, wave steepness, wave period distributions -Joint wave height, wave steepness, wave period distributions
Statistics Statistics
------------ ------------
-Extreme value analysis -Extreme value analysis
-Kernel density estimation -Kernel density estimation
-Hidden markov models -Hidden markov models
WAFO consists of several modules with short descriptions below. WAFO consists of several modules with short descriptions below.
The modules SPECTRUM, COVARIANCE, TRANSFORM, WAVEMODELS, and MULTIDIM are The modules SPECTRUM, COVARIANCE, TRANSFORM, WAVEMODELS, and MULTIDIM are
mainly for oceanographic applications. mainly for oceanographic applications.
The modules CYCLES, MARKOV, and DAMAGE are mainly for fatigue problems. The modules CYCLES, MARKOV, and DAMAGE are mainly for fatigue problems.
The contents file for each module is shown by typing 'help module-name' The contents file for each module is shown by typing 'help module-name'
Type 'help fatigue' for a presentation of all routines related to fatigue. Type 'help fatigue' for a presentation of all routines related to fatigue.
The paths to the modules are initiated by the function 'initwafo'. The paths to the modules are initiated by the function 'initwafo'.
ONEDIM - Data analysis of time series. Example: extraction of ONEDIM - Data analysis of time series. Example: extraction of
turning points, estimation of spectrum and covariance function. turning points, estimation of spectrum and covariance function.
Estimation transformation used in transformed Gaussian model. Estimation transformation used in transformed Gaussian model.
COVARIANCE - Computation of spectral functions, linear COVARIANCE - Computation of spectral functions, linear
and non-linear time series simulation. and non-linear time series simulation.
SPECTRUM - Computation of spectral moments and covariance functions, linear SPECTRUM - Computation of spectral moments and covariance functions, linear
and non-linear time series simulation. and non-linear time series simulation.
Ex: common spectra implemented, directional spectra, Ex: common spectra implemented, directional spectra,
bandwidth measures, exact distributions for wave characteristics. bandwidth measures, exact distributions for wave characteristics.
TRANSFORM - Modelling with linear or transformed Gaussian waves. Ex: TRANSFORM - Modelling with linear or transformed Gaussian waves. Ex:
WAVEMODELS - Models for distributions of wave characteristics found in WAVEMODELS - Models for distributions of wave characteristics found in
the literature. Ex: parametric models for breaking the literature. Ex: parametric models for breaking
limited wave heights. limited wave heights.
MULTIDIM - Multi-dimensional time series analysis. (Under construction) MULTIDIM - Multi-dimensional time series analysis. (Under construction)
CYCLES - Cycle counting, discretization, and crossings, calculation of CYCLES - Cycle counting, discretization, and crossings, calculation of
damage. Simulation of discrete Markov chains, switching Markov damage. Simulation of discrete Markov chains, switching Markov
chains, harmonic oscillator. Ex: Rainflow cycles and matrix, chains, harmonic oscillator. Ex: Rainflow cycles and matrix,
discretization of loads. Damage of a rainflow count or discretization of loads. Damage of a rainflow count or
matrix, damage matrix, S-N plot. matrix, damage matrix, S-N plot.
MARKOV - Routines for Markov loads, switching Markov loads, and MARKOV - Routines for Markov loads, switching Markov loads, and
their connection to rainflow cycles. their connection to rainflow cycles.
DAMAGE - Calculation of damage. Ex: Damage of a rainflow count or DAMAGE - Calculation of damage. Ex: Damage of a rainflow count or
matrix, damage matrix, S-N plot. matrix, damage matrix, S-N plot.
SIMTOOLS - Simulation of random processes. Ex: spectral simulation, SIMTOOLS - Simulation of random processes. Ex: spectral simulation,
simulation of discrete Markov chains, switching Markov simulation of discrete Markov chains, switching Markov
chains, harmonic oscillator chains, harmonic oscillator
STATISTICS - Statistical tools and extreme-value distributions. STATISTICS - Statistical tools and extreme-value distributions.
Ex: generation of random numbers, estimation of parameters, Ex: generation of random numbers, estimation of parameters,
evaluation of pdf and cdf evaluation of pdf and cdf
KDETOOLS - Kernel-density estimation. KDETOOLS - Kernel-density estimation.
MISC - Miscellaneous routines. Ex: numerical integration, smoothing MISC - Miscellaneous routines. Ex: numerical integration, smoothing
spline, binomial coefficient, water density. spline, binomial coefficient, water density.
WDEMOS - WAFO demos. WDEMOS - WAFO demos.
DOCS - Documentation of toolbox, definitions. An overview is given DOCS - Documentation of toolbox, definitions. An overview is given
in the routine wafomenu. in the routine wafomenu.
DATA - Measurements from marine applications. DATA - Measurements from marine applications.
PAPERS - Commands that generate figures in selected scientific PAPERS - Commands that generate figures in selected scientific
publications. publications.
SOURCE - Fortran and C files. Information on compilation. SOURCE - Fortran and C files. Information on compilation.
EXEC - Executable files (cf. SOURCE), pre-compiled for Solaris, EXEC - Executable files (cf. SOURCE), pre-compiled for Solaris,
Alpha-Dec or Windows. Alpha-Dec or Windows.
WAFO homepage: <http://www.maths.lth.se/matstat/wafo/> WAFO homepage: <http://www.maths.lth.se/matstat/wafo/>
On the WAFO home page you will find: On the WAFO home page you will find:
- The WAFO Tutorial - The WAFO Tutorial
- New versions of WAFO to download. - New versions of WAFO to download.
- Reported bugs. - Reported bugs.
- List of publications related to WAFO. - List of publications related to WAFO.
Home-page: http://www.maths.lth.se/matstat/wafo/
Author: WAFO-group
Author-email: wafo@maths.lth.se
License: GPL
Description: UNKNOWN
Platform: UNKNOWN Platform: UNKNOWN

@ -1,5 +1 @@
wafo\spectrum
wafo\covariance
wafo wafo
wafo\data
wafo\transform

Binary file not shown.

@ -1300,7 +1300,7 @@ def quadgr(fun,a,b,abseps=1e-5):
err = err + 2*np.finfo(Q).eps err = err + 2*np.finfo(Q).eps
# Reverse direction # Reverse direction
if reverse: if reverse:
Q = -Q Q = -Q
return Q, err return Q, err

@ -19,7 +19,7 @@ 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
class PPform1(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
x_{i} <= x < x_{i+1} x_{i} <= x < x_{i+1}

@ -9,7 +9,7 @@
# Licence: LGPL # Licence: LGPL
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
#!/usr/bin/env python #!/usr/bin/env python
#import numpy as np import numpy as np
from scipy.special import gamma from scipy.special import gamma
from numpy import pi, atleast_2d #@UnresolvedImport from numpy import pi, atleast_2d #@UnresolvedImport
from misc import tranproc, trangood from misc import tranproc, trangood
@ -112,29 +112,29 @@ class kde(object):
if d != self.d: if d != self.d:
if d == 1 and m == self.d: if d == 1 and m == self.d:
# points was passed in as a row vector # points was passed in as a row vector
points = reshape(points, (self.d, 1)) points = np.reshape(points, (self.d, 1))
m = 1 m = 1
else: else:
msg = "points have dimension %s, dataset has dimension %s" % (d, msg = "points have dimension %s, dataset has dimension %s" % (d,
self.d) self.d)
raise ValueError(msg) raise ValueError(msg)
result = zeros((m,), points.dtype) result = np.zeros((m,), points.dtype)
if m >= self.n: if m >= self.n:
# there are more points than data, so loop over data # there are more points than data, so loop over data
for i in range(self.n): for i in range(self.n):
diff = self.dataset[:,i,newaxis] - points diff = self.dataset[:,i, np.newaxis] - points
tdiff = dot(self.inv_cov, diff) tdiff = np.dot(self.inv_cov, diff)
energy = sum(diff*tdiff,axis=0)/2.0 energy = np.sum(diff*tdiff,axis=0)/2.0
result += exp(-energy) result += np.exp(-energy)
else: else:
# loop over points # loop over points
for i in range(m): for i in range(m):
diff = self.dataset - points[:,i,newaxis] diff = self.dataset - points[:,i,np.newaxis]
tdiff = dot(self.inv_cov, diff) tdiff = np.dot(self.inv_cov, diff)
energy = sum(diff*tdiff,axis=0)/2.0 energy = sum(diff*tdiff,axis=0)/2.0
result[i] = sum(exp(-energy),axis=0) result[i] = np.sum(np.exp(-energy),axis=0)
result /= self._norm_factor result /= self._norm_factor

@ -1563,7 +1563,7 @@ def meshgrid(*xi, ** kwargs):
return broadcast_arrays(*output) return broadcast_arrays(*output)
def ndgrid(*args, ** kwargs): def ndgrid(*args, **kwargs):
""" """
Same as calling meshgrid with indexing='ij' (see meshgrid for Same as calling meshgrid with indexing='ij' (see meshgrid for
documentation). documentation).
@ -1666,7 +1666,7 @@ def trangood(x, f, min_n=None, min_x=None, max_x=None, max_n=inf):
return xo, fo return xo, fo
def tranproc(x, f, x0, * xi): def tranproc(x, f, x0, *xi):
""" """
Transforms process X and up to four derivatives Transforms process X and up to four derivatives
using the transformation f. using the transformation f.
@ -1779,7 +1779,7 @@ def tranproc(x, f, x0, * xi):
y.append(y4) y.append(y4)
if N > 4: if N > 4:
warnings.warn('Transformation of derivatives of order>4 not supported.') warnings.warn('Transformation of derivatives of order>4 not supported.')
return y #0,y1,y2,y3,y4 return y #y0,y1,y2,y3,y4
def test_common_shape(): def test_common_shape():

File diff suppressed because it is too large Load Diff

@ -5,10 +5,10 @@ import os
def compile_all(): def compile_all():
# Install gfortran and run the following to build the module: # Install gfortran and run the following to build the module:
#compile_format = 'f2py %s %s -c --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71' compile_format = 'f2py.py %s %s -c --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71'
# Install microsoft visual c++ .NET 2003 and run the following to build the module: # Install microsoft visual c++ .NET 2003 and run the following to build the module:
compile_format = 'f2py.py %s %s -c' #compile_format = 'f2py.py %s %s -c'
pyfs = ('c_library.pyf',) pyfs = ('c_library.pyf',)
files =('c_functions.c',) files =('c_functions.c',)

@ -16,16 +16,15 @@ from pylab import stineman_interp
from dispersion_relation import w2k #, k2w from dispersion_relation import w2k #, k2w
from wafo.wafodata import WafoData, now from wafo.wafodata import WafoData, now
from wafo.misc import sub_dict_select, nextpow2, discretize, JITImport from wafo.misc import sub_dict_select, nextpow2, discretize, JITImport, tranproc
try: try:
from wafo.gaussian import Rind from wafo.gaussian import Rind
except ImportError: except ImportError:
Rind = None Rind = None
try: try:
from wafo import c_library from wafo import c_library
except ImportError: except ImportError:
warnings.warn('Compile the c_libraray.pyd again!') warnings.warn('Compile the c_library.pyd again!')
c_library = None c_library = None
from wafo.transform import TrData from wafo.transform import TrData
@ -751,8 +750,7 @@ class SpecData1D(WafoData):
tn = paramt[1] tn = paramt[1]
Ntime = paramt[2] Ntime = paramt[2]
t = linspace(0, tn / A, Ntime) #normalized times t = linspace(0, tn / A, Ntime) #normalized times
Nstart = max(round(t0 / tn * (Ntime - 1)), 1) #% index to starting point to Nstart = max(round(t0 / tn * (Ntime - 1)), 1) #% index to starting point to evaluate
#% evaluate
dt = t[1] - t[0] dt = t[1] - t[0]
nr = 2 nr = 2
@ -1055,16 +1053,22 @@ class SpecData1D(WafoData):
if spec.tr is not None: if spec.tr is not None:
print(' Transforming data.') print(' Transforming data.')
g = spec.tr g = spec.tr
G = fliplr(g) #% the invers of g
if derivative: if derivative:
for i in range(cases): for i in range(cases):
tmp = tranproc(hstack((x[:, i + 1], xder[:, i + 1])), G) x[:, i + 1], xder[:, i + 1] = g.gauss2dat(x[:, i + 1], xder[:, i + 1])
x[:, i + 1] = tmp[:, 0]
xder[:, i + 1] = tmp[:, 1]
else: else:
for i in range(cases): for i in range(cases):
x[:, i + 1] = tranproc(x[:, i + 1], G) x[:, i + 1] = g.gauss2dat(x[:, i + 1])
# G = fliplr(g) #% the invers of g
# if derivative:
# for i in range(cases):
# tmp = tranproc(hstack((x[:, i + 1], xder[:, i + 1])), G)
# x[:, i + 1] = tmp[:, 0]
# xder[:, i + 1] = tmp[:, 1]
#
# else:
# for i in range(cases):
# x[:, i + 1] = tranproc(x[:, i + 1], G)
if derivative: if derivative:
return x, xder return x, xder

@ -82,7 +82,7 @@ class TrCommon(object):
t0 = trapz(xn,(xn-yn)**2.) t0 = trapz(xn,(xn-yn)**2.)
return t0 return t0
def gauss2dat(self,y, *yi): def gauss2dat(self, y, *yi):
""" """
Transforms Gaussian data, y, to non-linear scale. Transforms Gaussian data, y, to non-linear scale.
@ -153,12 +153,19 @@ class TrData(WafoData, TrCommon):
>>> g.sigma >>> g.sigma
array([ 5.]) array([ 5.])
>>> g = TrData(y,x,mean=1,sigma=5)
>>> g.mean
1
>>> g.sigma
5
Check that the departure from a Gaussian model is zero Check that the departure from a Gaussian model is zero
>>> g.dist2gauss() < 1e-16 >>> g.dist2gauss() < 1e-16
True True
""" """
def __init__(self, *args, **kwds): def __init__(self, *args, **kwds):
WafoData.__init__(self, *args, **kwds) super(TrData, self).__init__(*args, **kwds)
self.labels.title = 'Transform' self.labels.title = 'Transform'
self.labels.ylab = 'g(x)' self.labels.ylab = 'g(x)'
self.labels.xlab = 'x' self.labels.xlab = 'x'

@ -463,7 +463,7 @@ if __name__=='__main__':
import doctest import doctest
doctest.testmod() doctest.testmod()
else: else:
main() main()

Loading…
Cancel
Save