storing the weights used by scipy griddata for re-use

后端 未结 1 657
无人及你
无人及你 2021-01-14 08:07

I am trying to interpolate data from an unstructured mesh M1 to another unstructured mesh M2. For this, scipy.interpolate.griddata

相关标签:
1条回答
  • 2021-01-14 08:43

    A solution is to use the LinearNDInterpolator Scipy function with a pre-computed Delaunay triangulation:

    from scipy.spatial import Delaunay
    from scipy.interpolate import LinearNDInterpolator
    
    tri = Delaunay(mesh1)  # Compute the triangulation
    
    # Perform the interpolation with the given values:
    interpolator = LinearNDInterpolator(tri, values_mesh1)
    values_mesh2 = interpolator(mesh2)
    

    mesh1 is a (number of points * dim) array.

    Note: CloughTocher2DInterpolator could be used for non-linear interpolation. griddata uses either LinearNDInterpolator or CloughTocher2DInterpolator.

    0 讨论(0)
提交回复
热议问题