沿一个方向插值 [英] Interpolate in one direction

查看:93
本文介绍了沿一个方向插值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经采样了数据,并用imshow()进行了绘制:

I have sampled data and plot it with imshow():

我只想在水平轴上进行插值,以便可以更轻松地区分样本和点特征. 用MPL可以仅在一个方向上进行插值吗?

I would like to interpolate just in horizontal axis so that I can easier distinguish samples and spot features. Is it possible to make interpolation just in one direction with MPL?

更新:
SciPy具有使用各种插值方法的整个程序包. 我使用了最简单的interp1d,如 tcaswell 所建议:

Update:
SciPy has whole package with various interpolation methods. I used simplest interp1d, as suggested by tcaswell:

def smooth_inter_fun(r):
    s = interpolate.interp1d(arange(len(r)), r)
    xnew = arange(0, len(r)-1, .1)
    return s(xnew)

new_data = np.vstack([smooth_inter_fun(r) for r in data])

线性和三次结果:

如预期的那样:)

推荐答案

Python平滑时间序列数据

This tutorial covers a range of interpolation available in numpy/scipy. If you want to just one direction, I would work on each row independently and then re-assemble the results. You might also be interested is simply smoothing your data (exmple, Python Smooth Time Series Data, Using strides for an efficient moving average filter).

def smooth_inter_fun(r):
    #what ever process you want to use
new_data = np.vstack([smooth_inter_fun(r) for r in data])

这篇关于沿一个方向插值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆