及时均匀地重新采样位置的时间序列

Resample time-series of position evenly in time

正如地球科学中经常发生的那样,我有一个时间序列的位置 (lon,lat)。时间序列的时间间隔不均匀。时间采样看起来像:

    t_diff_every_position = [3.99, 1.00, 3.00, 4.00, 3.98, 3.99, ... ]

而且我有与每个 t 关联的职位 :

   lat = [77.0591,  77.0547,  77.0537, 74.6766,  74.6693,  74.6725, ... ]
   lon = [-135.2876, -135.2825, -135.2776, -143.7432, -143.7994,
   -143.8582, ... ]

我想对位置重新采样以使数据集在时间上均匀分布。所以我希望时间向量看起来像:

    t_resampled = [4.00, 4.00, 4.00, 4.00, 4.00, 4.00, ... ]

并从插值中获得关联位置。

位置不遵循单调函数,所以我不能使用 scipy 中常用的重采样和插值函数。 Positions with time

有人知道如何实现吗?

一种方法是分别对经度和纬度进行插值。下面是一些模拟数据的示例。

假设我们有 100 个经度 (lon)、纬度 (lat) 和时间戳 (t)。时间不规律:

>>> t
array([ 0.        ,  1.09511126,  1.99576514,  2.65742629,  3.35929893,
        4.1379694 ,  5.55703942,  6.52892196,  7.64924527,  8.60496239])

这些坐标绘制的路径看起来像:

我们使用scipy的interp1d分别对纬度和经度进行线性插值:

from scipy.interpolate import interp1d
f_lon = interp1d(t, lon)
f_lat = interp1d(t, lat)

然后我们制作一个常规时间戳数组,[1, 2, 3, ..., 100],并重新采样我们的纬度和经度:

reg_t = np.arange(0, 99)
reg_lon = f_lon(reg_t)
reg_lat = f_lat(reg_t)

下图显示了在规则间隔 np.arange(0, 99, 5) 上进行插值的结果。这是一个比您想要的更粗略的间隔,因为如果使用更精细的间隔,很难看出每个图中实际上有两个函数。