From 4f90672e6aeccffdeafc4ed27a0c582f9de926b1 Mon Sep 17 00:00:00 2001 From: Per A Brodtkorb Date: Tue, 28 Jun 2016 03:30:17 +0200 Subject: [PATCH] Small fixes --- wafo/containers.py | 13 ++++++++++--- wafo/doc/tutorial_scripts/chapter3.py | 7 ++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/wafo/containers.py b/wafo/containers.py index 1771053..7e22ca5 100644 --- a/wafo/containers.py +++ b/wafo/containers.py @@ -1,7 +1,7 @@ from __future__ import absolute_import import warnings -from .graphutil import cltext -from .plotbackend import plotbackend +from wafo.graphutil import cltext +from wafo.plotbackend import plotbackend from time import gmtime, strftime import numpy as np from scipy.integrate.quadrature import cumtrapz # @UnresolvedImport @@ -166,13 +166,16 @@ class PlotData(object): cdf = np.hstack((0, integrate.cumtrapz(self.data, self.args))) 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) >>> d = PlotData(np.sin(x), x) >>> d.dataCI = np.vstack((d.data*.9,d.data*1.1)).T >>> d.integrate(0,np.pi/2, return_ci=True) 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') @@ -193,6 +196,10 @@ class PlotData(object): else: # One dimensional data return_ci = kwds.pop('return_ci', False) x = self.args + if a is None: + a = x[0] + if b is None: + b = x[-1] ix = np.flatnonzero((a < x) & (x < b)) xi = np.hstack((a, x.take(ix), b)) fi = np.hstack( diff --git a/wafo/doc/tutorial_scripts/chapter3.py b/wafo/doc/tutorial_scripts/chapter3.py index 852d88a..8b159c2 100644 --- a/wafo/doc/tutorial_scripts/chapter3.py +++ b/wafo/doc/tutorial_scripts/chapter3.py @@ -47,7 +47,7 @@ plt.show() #! Extreme waves - model check: the highest and steepest wave #!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ plt.clf() -S, H = ts.wave_height_steepness(method=0) +S, H = ts.wave_height_steepness(kind=0) indS = S.argmax() indH = H.argmax() 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.plot() # wafostamp([],'(ER)') -fac.integrate(a=0.01, b=3) +print(fac.integrate(a=0.01, b=3)) +print(fac.integrate()) print('Block = 8'), # pause(pstate) @@ -149,7 +150,7 @@ print(mt) plt.clf() S.bandwidth(['alpha']) -ch, Sa2 = S.characteristic(['Hm0', 'Tm02']) +ch, Sa2, chtxt = S.characteristic(['Hm0', 'Tm02']) # disp('Block = 13'), pause(pstate)