gauss2d#
- 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.
- Parameters:
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)
Examples:
# Setup import numpy as np import matplotlib.pyplot as plt x = np.random.rand(40) y = np.random.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(np.random.rand(10,10)) sc.surf3d(zi0) # Method 1 -- form grid xi = np.linspace(0,1,20) yi = np.linspace(0,1,20) zi = sc.gauss2d(x, y, z, xi, yi, scale=0.1, grid=True) # Method 2 -- use points directly xi2 = np.random.rand(400) yi2 = np.random.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.surf3d(zi) sc.scatter3d(xi2, yi2, zi2, c=zi2) plt.show()
New in version 1.3.0.New in version 1.3.1: default arguments; support for 2D inputs