Small fixes

master
Per A Brodtkorb 9 years ago
parent 1e285749b7
commit 4f90672e6a

@ -1,7 +1,7 @@
from __future__ import absolute_import from __future__ import absolute_import
import warnings import warnings
from .graphutil import cltext from wafo.graphutil import cltext
from .plotbackend import plotbackend from wafo.plotbackend import plotbackend
from time import gmtime, strftime from time import gmtime, strftime
import numpy as np import numpy as np
from scipy.integrate.quadrature import cumtrapz # @UnresolvedImport from scipy.integrate.quadrature import cumtrapz # @UnresolvedImport
@ -166,13 +166,16 @@ class PlotData(object):
cdf = np.hstack((0, integrate.cumtrapz(self.data, self.args))) cdf = np.hstack((0, integrate.cumtrapz(self.data, self.args)))
return PlotData(cdf, np.copy(self.args), xlab='x', ylab='F(x)') return PlotData(cdf, np.copy(self.args), xlab='x', ylab='F(x)')
def integrate(self, a, b, **kwds): def integrate(self, a=None, b=None, **kwds):
''' '''
>>> x = np.linspace(0,5,60) >>> x = np.linspace(0,5,60)
>>> d = PlotData(np.sin(x), x) >>> d = PlotData(np.sin(x), x)
>>> d.dataCI = np.vstack((d.data*.9,d.data*1.1)).T >>> d.dataCI = np.vstack((d.data*.9,d.data*1.1)).T
>>> d.integrate(0,np.pi/2, return_ci=True) >>> d.integrate(0,np.pi/2, return_ci=True)
array([ 0.99940055, 0.85543644, 1.04553343]) array([ 0.99940055, 0.85543644, 1.04553343])
>>> np.allclose(d.integrate(0, 5, return_ci=True),
... d.integrate(return_ci=True))
True
''' '''
method = kwds.pop('method', 'trapz') method = kwds.pop('method', 'trapz')
@ -193,6 +196,10 @@ class PlotData(object):
else: # One dimensional data else: # One dimensional data
return_ci = kwds.pop('return_ci', False) return_ci = kwds.pop('return_ci', False)
x = self.args x = self.args
if a is None:
a = x[0]
if b is None:
b = x[-1]
ix = np.flatnonzero((a < x) & (x < b)) ix = np.flatnonzero((a < x) & (x < b))
xi = np.hstack((a, x.take(ix), b)) xi = np.hstack((a, x.take(ix), b))
fi = np.hstack( fi = np.hstack(

@ -47,7 +47,7 @@ plt.show()
#! Extreme waves - model check: the highest and steepest wave #! Extreme waves - model check: the highest and steepest wave
#!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
plt.clf() plt.clf()
S, H = ts.wave_height_steepness(method=0) S, H = ts.wave_height_steepness(kind=0)
indS = S.argmax() indS = S.argmax()
indH = H.argmax() indH = H.argmax()
ts.plot_sp_wave([indH, indS],'k.') ts.plot_sp_wave([indH, indS],'k.')
@ -98,7 +98,8 @@ plt.clf()#
fac = wk.TKDE(Ac,L2=L2)(np.linspace(0.01,3,200), output='plot') fac = wk.TKDE(Ac,L2=L2)(np.linspace(0.01,3,200), output='plot')
fac.plot() fac.plot()
# wafostamp([],'(ER)') # wafostamp([],'(ER)')
fac.integrate(a=0.01, b=3) print(fac.integrate(a=0.01, b=3))
print(fac.integrate())
print('Block = 8'), print('Block = 8'),
# pause(pstate) # pause(pstate)
@ -149,7 +150,7 @@ print(mt)
plt.clf() plt.clf()
S.bandwidth(['alpha']) S.bandwidth(['alpha'])
ch, Sa2 = S.characteristic(['Hm0', 'Tm02']) ch, Sa2, chtxt = S.characteristic(['Hm0', 'Tm02'])
# disp('Block = 13'), pause(pstate) # disp('Block = 13'), pause(pstate)

Loading…
Cancel
Save