Removed example

master
Per A Brodtkorb 8 years ago
parent ef5cdf4311
commit e4a799d8c3

@ -637,29 +637,35 @@ def smoothn(data, s=None, weight=None, robust=False, z0=None, tolz=1e-3,
2-D example 2-D example
>>> xp = np.r_[0:1:.02] >>> xp = np.r_[0:1:.02]
>>> [x,y] = np.meshgrid(xp,xp) >>> [x,y] = np.meshgrid(xp,xp)
>>> f = np.exp(x+y) + np.sin((x-2*y)*3); >>> f = np.exp(x+y) + np.sin((x-2*y)*3)
>>> fn = f + np.random.randn(*f.shape)*0.5; >>> fn = f + np.random.randn(*f.shape)*0.5
>>> fs = smoothn(fn); >>> fs = smoothn(fn)
h=plt.subplot(121), h=plt.subplot(121),
h=plt.contourf(xp,xp,fn) h=plt.contourf(xp, xp, fn)
h=plt.subplot(122) h=plt.subplot(122)
h=plt.contourf(xp,xp,fs) h=plt.contourf(xp, xp, fs)
2-D example with missing data 2-D example with missing data
n = 256; >>> import wafo.demos as wd
y0 = peaks(n); >>> n = 256
y = y0 + rand(size(y0))*2; >>> x0, y0, z0 = wd.peaks(n)
I = randperm(n^2); >>> z = z0 + rand(size(y0))*2
y(I(1:n^2*0.5)) = NaN; lose 1/2 of data
y(40:90,140:190) = NaN; create a hole I = randperm(n**2)
z = smoothn(y); smooth data z[I(1:n^2*0.5)] = np.NaN; # lose 1/2 of data
subplot(2,2,1:2), imagesc(y), axis equal off z[40:90, 140:190] = np.NaN; # create a hole
title('Noisy corrupt data') zs = smoothn(z)
subplot(223), imagesc(z), axis equal off
title('Recovered data ...') plt.subplot(2,2,1)
subplot(224), imagesc(y0), axis equal off plt.imagesc(y) # , axis equal off
title('... compared with original data') plt.title('Noisy corrupt data')
plt.subplot(223)
plt.imagesc(z) # , axis equal off
plt.title('Recovered data ...')
plt.subplot(224)
plt.imagesc(y0) # , axis equal off
plt.title('... compared with original data')
3-D example 3-D example
[x,y,z] = meshgrid(-2:.2:2); [x,y,z] = meshgrid(-2:.2:2);
@ -671,14 +677,6 @@ def smoothn(data, s=None, weight=None, robust=False, z0=None, tolz=1e-3,
subplot(122), slice(x,y,z,v,xslice,yslice,zslice,'cubic') subplot(122), slice(x,y,z,v,xslice,yslice,zslice,'cubic')
title('Smoothed data') title('Smoothed data')
Cardioid
t = linspace(0,2*pi,1000);
x = 2*cos(t).*(1-cos(t)) + randn(size(t))*0.1;
y = 2*sin(t).*(1-cos(t)) + randn(size(t))*0.1;
z = smoothn(complex(x,y));
plot(x,y,'r.',real(z),imag(z),'k','linewidth',2)
axis equal tight
Cellular vortical flow Cellular vortical flow
[x,y] = meshgrid(linspace(0,1,24)); [x,y] = meshgrid(linspace(0,1,24));
@ -697,7 +695,9 @@ def smoothn(data, s=None, weight=None, robust=False, z0=None, tolz=1e-3,
subplot(122), quiver(x,y,real(Vs),imag(Vs)), axis square subplot(122), quiver(x,y,real(Vs),imag(Vs)), axis square
title('Smoothed velocity field') title('Smoothed velocity field')
See also SMOOTH, SMOOTH3, DCTN, IDCTN. See also
-------
SmoothNd
-- Damien Garcia -- 2009/03, revised 2010/11 -- Damien Garcia -- 2009/03, revised 2010/11
Visit Visit

Loading…
Cancel
Save