How to generate equispaced interpolating values

前端 未结 5 532
既然无缘
既然无缘 2020-12-25 08:01

I have a list of (x,y) values that are not uniformly spaced. Here is the archive used in this question.

I am able to interpolate between the values but what I get ar

5条回答
  •  心在旅途
    2020-12-25 08:34

    Expanding on the answer by @Christian K., here's how to do this for higher dimensional data with scipy.interpolate.interpn. Let's say we want to resample to 10 equally-spaced points:

    import numpy as np
    import scipy
    # Assuming that 'data' is rows x dims (where dims is the dimensionality)
    diffs = data[1:, :] - data[:-1, :]
    dist = np.linalg.norm(diffs, axis=1)
    u = np.cumsum(dist)
    u = np.hstack([[0], u])
    t = np.linspace(0, u[-1], 10)
    resampled = scipy.interpolate.interpn((u,), pts, t)
    

提交回复
热议问题