diff --git a/pywafo/src/wafo/covariance/core.py b/pywafo/src/wafo/covariance/core.py index 9337937..37bc56a 100644 --- a/pywafo/src/wafo/covariance/core.py +++ b/pywafo/src/wafo/covariance/core.py @@ -17,7 +17,7 @@ date : Date and time of creation or change. from __future__ import division import warnings #import numpy as np -from numpy import (zeros, sqrt, dot, newaxis, inf, where, pi, nan, #@UnresolvedImport +from numpy import (zeros, sqrt, dot, inf, where, pi, nan, #@UnresolvedImport atleast_1d, hstack, vstack, r_, linspace, flatnonzero, size, #@UnresolvedImport isnan, finfo, diag, ceil, floor, random, pi) #@UnresolvedImport from numpy.fft import fft #as fft @@ -810,7 +810,7 @@ def sptoeplitz(x): data = data[1::, :] return y + spdiags((data, -offsets), shape=(n, n)) -def test_covdata(): +def _test_covdata(): import wafo.data x = wafo.data.sea() ts = wafo.objects.mat2timeseries(x) diff --git a/pywafo/src/wafo/doc/tutorial_scripts/chapter1.py b/pywafo/src/wafo/doc/tutorial_scripts/chapter1.py index 5d09b9a..f4d8b19 100644 --- a/pywafo/src/wafo/doc/tutorial_scripts/chapter1.py +++ b/pywafo/src/wafo/doc/tutorial_scripts/chapter1.py @@ -195,7 +195,7 @@ ylabel('(m)') #! Formation of 5 min maxima yura = xn[:85500, 1] -yura = np.reshape(yura, (300, 285)) +yura = np.reshape(yura, (285,300)).T maxyura = yura.max(axis=0) subplot(212) plot(xn[299:85500:300, 0] / 3600, maxyura, '.') @@ -207,7 +207,7 @@ show() #! Estimation of GEV for yuramax clf() import wafo.stats as ws -phat = ws.genextreme.fit2(maxyura, method='mps') +phat = ws.genextreme.fit2(maxyura, method='ml') phat.plotfitsummary() show() #disp('Block = 11, Last block') diff --git a/pywafo/src/wafo/misc.py b/pywafo/src/wafo/misc.py index 48be7a4..a6510c5 100644 --- a/pywafo/src/wafo/misc.py +++ b/pywafo/src/wafo/misc.py @@ -1942,21 +1942,26 @@ def tranproc(x, f, x0, *xi): return y #y0,y1,y2,y3,y4 def histgrm(data, n=None, odd=False, scale=False, lintype='b-'): - '''HISTGRM Plot histogram - - CALL: binwidth = histgrm(x,N,odd,scale) - binwidth = the width of each bin - + ''' + Plot histogram + Parameters ----------- - x = the data - n = approximate number of bins wanted - (default depending on length(x)) - odd = placement of bins (0 or 1) (default 0) - scale = argument for scaling (default 0) - scale = 1 yields the area 1 under the histogram + data : array-like + the data + n : scalar integer + approximate number of bins wanted (default depending on length(data)) + odd : bool + placement of bins (0 or 1) (default 0) + scale : bool + argument for scaling (default 0) + scale = 1 yields the area 1 under the histogram lintype : specify color and lintype, see PLOT for possibilities. + Returns + ------- + binwidth = the width of each bin + Example: R=rndgumb(2,2,1,100); histgrm(R,20,0,1) @@ -1985,8 +1990,6 @@ def histgrm(data, n=None, odd=False, scale=False, lintype='b-'): mx = (np.ceil(mx / d) + 1) * d + odd * d / 2 limits = np.arange(mn, mx, d) - - bin, limits = np.histogram(data, bins=limits, normed=scale) #, new=True) limits.shape = (-1, 1) xx = limits.repeat(3, axis=1) diff --git a/pywafo/src/wafo/objects.py b/pywafo/src/wafo/objects.py index 2ed9622..dc40766 100644 --- a/pywafo/src/wafo/objects.py +++ b/pywafo/src/wafo/objects.py @@ -25,7 +25,7 @@ import warnings import numpy as np from numpy import (inf, pi, zeros, ones, sqrt, where, log, exp, sin, arcsin, mod, finfo, interp, #@UnresolvedImport - newaxis, linspace, arange, sort, all, abs, vstack, hstack, atleast_1d, #@UnresolvedImport + linspace, arange, sort, all, abs, vstack, hstack, atleast_1d, #@UnresolvedImport finfo, polyfit, r_, nonzero, cumsum, ravel, size, isnan, nan, floor, ceil, diff, array) #@UnresolvedImport from numpy.fft import fft from numpy.random import randn @@ -34,7 +34,7 @@ from pylab import stineman_interp from matplotlib.mlab import psd, detrend_mean import scipy.signal -from wafo.misc import (nextpow2, findtp, findtc, findcross, sub_dict_select, +from wafo.misc import (nextpow2, findtp, findtc, findcross, ecross, JITImport, DotDict) from wafodata import WafoData from plotbackend import plotbackend diff --git a/pywafo/src/wafo/source/c_codes/c_library.pyd b/pywafo/src/wafo/source/c_codes/c_library.pyd index 4b0e899..1619ad9 100644 Binary files a/pywafo/src/wafo/source/c_codes/c_library.pyd and b/pywafo/src/wafo/source/c_codes/c_library.pyd differ diff --git a/pywafo/src/wafo/source/mreg/build_all_.py b/pywafo/src/wafo/source/mreg/build_all_.py index 6575b70..930c789 100644 --- a/pywafo/src/wafo/source/mreg/build_all_.py +++ b/pywafo/src/wafo/source/mreg/build_all_.py @@ -7,29 +7,15 @@ gfortran -W -Wall -pedantic-errors -fbounds-check -Werror -c dsvdc.f mregmodule. import os def compile_all(): - files = ['mregmodule', 'dsvdc'] + files = ['dsvdc','mregmodule'] compile1_format = 'gfortran -fPIC -c %s.f' format1 = '%s.o ' * len(files) for file in files: os.system(compile1_format % file) file_objects = format1 % tuple(files) - #f2py --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71 -m mymod -c mymod.f90 - - os.system('f2py -m cov2mod -c %s cov2mmpdfreg_intfc.f --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71' % file_objects) - #compile1_txt = 'gfortran -fPIC -c mvnprd.f' - #compile2_txt = 'f2py -m mvnprdmod -c mvnprd.o mvnprd_interface.f --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71' - #os.system(compile1_txt) - #os.system(compile2_txt) - # Install gfortran and run the following to build the module: - #compile_format = 'f2py %s %s -c --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71' - - # Install microsoft visual c++ .NET 2003 and run the following to build the module: - #compile_format = 'f2py %s %s -c' - #pyfs = ('c_library.pyf',) - #files =('c_functions.c',) - - #for pyf,file in zip(pyfs,files): - # os.system(compile_format % (pyf,file)) - + + os.system('f2py.py -m cov2mod -c %s cov2mmpdfreg_intfc.f' % file_objects) + + if __name__=='__main__': compile_all() diff --git a/pywafo/src/wafo/source/mreg/mregmod.mod b/pywafo/src/wafo/source/mreg/mregmod.mod index 0cc4c8f..6c893b5 100644 --- a/pywafo/src/wafo/source/mreg/mregmod.mod +++ b/pywafo/src/wafo/source/mreg/mregmod.mod @@ -1,5 +1,5 @@ -GFORTRAN module version '0' created from mregmodule.f on Wed Aug 05 19:21:17 2009 -MD5:35f9c2506fae455bf63c0bcfadd75d2e -- If you edit this, you'll get what you deserve. +GFORTRAN module version '0' created from mregmodule.f on Tue Jan 25 20:12:17 2011 +MD5:a058cc3e6c0e8bedef8f214da2f5fbdc -- If you edit this, you'll get what you deserve. (() () () () () () () () () () () () () () () () () () () () () () () () () @@ -61,8 +61,6 @@ INTEGER ()) 0 '1') (CONSTANT (INTEGER 4 0 0 INTEGER ()) 0 '40401')) 0 () 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 DUMMY) ( -INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0) 11 'db' '' 'db' 7 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 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 @@ -76,14 +74,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 DUMMY) ( -INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0) 14 'a' '' 'a' 7 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 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 DUMMY) -(INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0) 15 'da' '' 'da' 7 ((VARIABLE INOUT UNKNOWN-PROC UNKNOWN UNKNOWN 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 @@ -92,6 +86,12 @@ INTEGER 4 0 0 INTEGER ()) 0 '1') (CONSTANT (INTEGER 4 0 0 INTEGER ()) 0 (REAL 8 0 0 REAL ()) 0 0 () () 0 () () () 0 0) 17 'm' '' 'm' 7 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN DUMMY) ( INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0) +18 'n' '' 'n' 7 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN DUMMY) ( +INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0) +19 'nit' '' 'nit' 7 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN DUMMY) ( +INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0) +20 'infr' '' 'infr' 7 ((VARIABLE IN UNKNOWN-PROC UNKNOWN UNKNOWN DUMMY) +(INTEGER 4 0 0 INTEGER ()) 0 0 () () 0 () () () 0 0) ) ('fi' 0 2 'mreg' 0 4 'rind' 0 3) diff --git a/pywafo/src/wafo/source/mvn/mvn.pyd b/pywafo/src/wafo/source/mvn/mvn.pyd index 2d0a064..666767f 100644 Binary files a/pywafo/src/wafo/source/mvn/mvn.pyd and b/pywafo/src/wafo/source/mvn/mvn.pyd differ diff --git a/pywafo/src/wafo/source/rind2007/build_all.py b/pywafo/src/wafo/source/rind2007/build_all.py index e187bbc..86487e6 100644 --- a/pywafo/src/wafo/source/rind2007/build_all.py +++ b/pywafo/src/wafo/source/rind2007/build_all.py @@ -11,7 +11,6 @@ def compile_all(): os.system(compile1_format % file) file_objects = format1 % tuple(files) - #os.system('f2py.py -m rindmod -c %s rind_interface.f --fcompiler=gnu95 --compiler=mingw32 -lmsvcr71' % file_objects) os.system('f2py.py -m rindmod -c %s rind_interface.f ' % file_objects) if __name__=='__main__': diff --git a/pywafo/src/wafo/spectrum/core.py b/pywafo/src/wafo/spectrum/core.py index 1f92036..7b11348 100644 --- a/pywafo/src/wafo/spectrum/core.py +++ b/pywafo/src/wafo/spectrum/core.py @@ -803,6 +803,9 @@ class SpecData1D(WafoData): >>> S.data[100:-1] = 0.0 >>> Nt = len(S.data)-1 >>> acf = S.tocovdata(nr=0, nt=Nt) + >>> S1 = acf.tospecdata() + >>> h = S.plot('r') + >>> h1 = S1.plot('b:') R = spec2cov(spec,0,Nt) win = parzen(2*Nt+1) @@ -2345,8 +2348,8 @@ class SpecData1D(WafoData): newNfft = 2 ** nextpow2(ceil(wnNew / dwMin)) + 1 if newNfft > nfft: - if (nfft <= 2 ** 15 + 1) and (newNfft > 2 ** 15 + 1): - warnings.warn('Spectrum matrix is very large (>33k). Memory problems may occur.') + #if (nfft <= 2 ** 15 + 1) and (newNfft > 2 ** 15 + 1): + # warnings.warn('Spectrum matrix is very large (>33k). Memory problems may occur.') nfft = newNfft self.args = linspace(0, wnNew, nfft) @@ -2442,18 +2445,16 @@ class SpecData1D(WafoData): >>> Sj = sm.Jonswap(Hm0=3, Tp=7) >>> w = np.linspace(0,4,256) >>> S = SpecData1D(Sj(w),w) #Make spectrum object from numerical values - >>> S.bandwidth([0,1,2,3]) + >>> S.bandwidth([0,'eps2',2,3]) array([ 0.73062845, 0.34476034, 0.68277527, 2.90817052]) ''' - -# if self.freqtype in 'k': -# vari = 'k' -# else: -# vari = 'w' - m, unused_mtxt = self.moment(nr=4, even=False) - fact = atleast_1d(factors) + fact_dict=dict(alpha=0,eps2=1,eps4=3,qp=3,Qp=3) + fun = lambda fact: fact_dict.get(fact,fact) + fact = atleast_1d(map(fun,list(factors))) + + #fact = atleast_1d(fact) alpha = m[2] / sqrt(m[0] * m[4]) eps2 = sqrt(m[0] * m[2] / m[1] ** 2. - 1.) eps4 = sqrt(1. - m[2] ** 2. / m[0] / m[4]) @@ -2956,8 +2957,8 @@ class SpecData2D(WafoData): >>> SD = D.tospecdata2d(sm.Jonswap().tospecdata(),nt=101) >>> m,mtext = SD.moment(nr=2,vari='xyt') >>> np.round(m,3),mtext - (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']) + (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']) References ---------- @@ -3137,7 +3138,7 @@ class SpecData2D(WafoData): self.labels.ylab = labels[1] self.labels.zlab = labels[2] -def test_specdata(): +def _test_specdata(): import wafo.spectrum.models as sm Sj = sm.Jonswap() S = Sj.tospecdata() diff --git a/pywafo/src/wafo/spectrum/models.py b/pywafo/src/wafo/spectrum/models.py index 2ae535c..5bfa945 100644 --- a/pywafo/src/wafo/spectrum/models.py +++ b/pywafo/src/wafo/spectrum/models.py @@ -1965,7 +1965,7 @@ class Spreading(object): #Snew.note = specdata.note + ', spreading: %s' % self.type return Snew -def test_some_spectra(): +def _test_some_spectra(): S = Jonswap() w = arange(3.0) @@ -2024,7 +2024,7 @@ def test_some_spectra(): plb.show() plb.close('all') -def test_spreading(): +def _test_spreading(): import pylab as plb pi = plb.pi w = plb.linspace(0, 3, 257) @@ -2045,7 +2045,7 @@ def test_spreading(): def main(): if False: # True: # - test_some_spectra() + _test_some_spectra() else: import doctest doctest.testmod()