Mathematical interpolation (2D)

Hi,
SciPy library has an interesting sub-package for this
https://docs.scipy.org/doc/scipy/reference/interpolate.html

an example with interp2d (linear kind) , there are several methods and options

import sys
import clr
import System
import re
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

reDir = System.IO.DirectoryInfo(re.__file__)
path_py3_lib = reDir.Parent.Parent.FullName
sys.path.append(path_py3_lib + r'\Lib\site-packages')

import openpyxl
import pandas as pd
import numpy as np
from scipy.interpolate import griddata, interp2d


df = pd.read_excel(IN[0], index_col=0)
x = df.columns # A
y = df.index # B
z = df.values

f = interp2d(x, y, z, kind='linear')
interpolate = f(x = 0.22, y = 0.15)
OUT = interpolate

visualization of the interpolated point on the grid

plot interpolated point

8 Likes