scientimate.interpxyz2xyz#

zPoint = scientimate.interpxyz2xyz(x, y, z, xPoint, yPoint, interpMethod='nearest', dispout='no')

Description#

Interpolate 2d scattered data on given point(s) by down-sampling the input data
For down-sampling, the first point of the k-nearest neighbors calculated from Euclidean distance is used
interpxyz2xyz is more suitable for large dataset
griddata is more efficient than interpxyz2xyz for regular size dataset

Inputs#

x

Coordinate of data in x direction, as an 1D array

y

Coordinate of data in y direction, as an 1D array

z

Value of data at (x,y) as z(x,y), as an 1D array

xPoint

Coordinate (in x direction) of point that nearest point to that is desired to be found

yPoint

Coordinate (in y direction) of point that nearest point to that is desired to be found

interpMethod=’nearest’
Interpolation method
‘linear’: Use default or ‘linear’ method to interpolate
‘nearest’: Use nearest neighbor method to interpolate
dispout=’no’
Define to display outputs or not (‘yes’: display, ‘no’: not display)
‘2d’: 2 dimensional scatter plot
‘surface’: 3 dimensional surface plot
‘no’: not display

Outputs#

zPoint

Value of interpolated data at (xPoint,yPoint) as z(xPoint,yPoint)

Examples#

import scientimate as sm
import numpy as np

x=10*np.random.rand(100)
y=10*np.random.rand(100)
z=100*np.random.rand(100)
xPoint=[2.5,5,7.5]
yPoint=[3,6,9]
zPoint=sm.interpxyz2xyz(x,y,z,xPoint,yPoint,'linear','2d')

x=10*np.random.rand(100)
y=10*np.random.rand(100)
z=100*np.random.rand(100)
xgrid,ygrid=np.meshgrid(np.linspace(np.min(x),np.max(x),100),np.linspace(np.min(y),np.max(y),100))
zgrid=sm.interpxyz2xyz(x,y,z,xgrid,ygrid,'nearest','no')

x=10*np.random.rand(100)
y=10*np.random.rand(100)
z=y*np.sin(x)-x*np.cos(y)
xPoint=10*np.random.rand(10,1)
yPoint=10*np.random.rand(10,1)
zPoint=sm.interpxyz2xyz(x,y,z,xPoint,yPoint,'nearest','no')

x=10*np.random.rand(100)
y=10*np.random.rand(100)
z=y*np.sin(x)-x*np.cos(y)
xgrid,ygrid=np.meshgrid(np.linspace(np.min(x),np.max(x),100),np.linspace(np.min(y),np.max(y),100))
zgrid=sm.interpxyz2xyz(x,y,z,xgrid,ygrid,'nearest','surface')

References#