Cosmetic fixes

master
per.andreas.brodtkorb 14 years ago
parent 67c005341d
commit 5704928b44

@ -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)

@ -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')

@ -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)
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)

@ -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

@ -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'
os.system('f2py.py -m cov2mod -c %s cov2mmpdfreg_intfc.f' % file_objects)
# 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))
if __name__=='__main__':
compile_all()

@ -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)

@ -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__':

@ -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,7 +2957,7 @@ 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. ,
(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()

@ -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()

Loading…
Cancel
Save