class gauss2d(x=None, y=None, z=None, xi=None, yi=None, scale=1.0, xscale=1.0, yscale=1.0, grid=False, use32=True)[source]#

Gaussian 2D smoothing kernel.

Create smooth interpolation of input points at interpolated points. Can handle either 1D or 2D inputs.

  • x (arr) – 1D or 2D array of x coordinates (if None, take from z)

  • y (arr) – ditto, for y

  • z (arr) – 1D or 2D array of z values at each of the (x,y) points

  • xi (arr) – 1D or 2D array of points to calculate the interpolated Z; if None, same as x

  • yi (arr) – ditto, for y

  • scale (float) – overall scale factor

  • xscale (float) – ditto, just for x

  • yscale (float) – ditto, just for y

  • grid (bool) – if True, then return Z at a grid of (xi,yi) rather than at points

  • use32 (bool) – convert arrays to 32-bit floats (doubles speed for large arrays)


# Setup
import pylab as pl
x = pl.rand(40)
y = pl.rand(40)
z = 1-(x-0.5)**2 + (y-0.5)**2 # Make a saddle

# Simple usage -- only works if z is 2D
zi0 = sc.gauss2d(pl.rand(10,10))

# Method 1 -- form grid
xi = pl.linspace(0,1,20)
yi = pl.linspace(0,1,20)
zi = sc.gauss2d(x, y, z, xi, yi, scale=0.1, grid=True)

# Method 2 -- use points directly
xi2 = pl.rand(400)
yi2 = pl.rand(400)
zi2 = sc.gauss2d(x, y, z, xi2, yi2, scale=0.1)

# Plot oiginal and interpolated versions
sc.scatter3d(x, y, z, c=z)
sc.scatter3d(xi2, yi2, zi2, c=zi2)
New in version 1.3.0.
New in version 1.3.1: default arguments; support for 2D inputs