本文介绍了不规则网格上的插值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我有三个 numpy 数组,它们在网格上存储纬度、经度和一些属性值——也就是说,我有 LAT(y,x)、LON(y,x) 和温度 T(y,x),对于 x 和 y 的某些限制.网格不一定是规则的——事实上,它是三极的.

So, I have three numpy arrays which store latitude, longitude, and some property value on a grid -- that is, I have LAT(y,x), LON(y,x), and, say temperature T(y,x), for some limits of x and y. The grid isn't necessarily regular -- in fact, it's tripolar.

然后我想将这些属性(温度)值插入到一堆不同的纬度/经度点(存储为 lat1(t)、lon1(t),大约 10,000 t...)上,这些点不落在实际网格点.我已经尝试过 matplotlib.mlab.griddata,但这花费的时间太长了(毕竟它并不是真正为我正在做的事情而设计的).我也试过 scipy.interpolate.interp2d,但我得到了一个 MemoryError(我的网格大约是 400x400).

I then want to interpolate these property (temperature) values onto a bunch of different lat/lon points (stored as lat1(t), lon1(t), for about 10,000 t...) which do not fall on the actual grid points. I've tried matplotlib.mlab.griddata, but that takes far too long (it's not really designed for what I'm doing, after all). I've also tried scipy.interpolate.interp2d, but I get a MemoryError (my grids are about 400x400).

是否有任何一种巧妙的,最好是快速的方法来做到这一点?我不禁认为答案很明显......谢谢!

Is there any sort of slick, preferably fast way of doing this? I can't help but think the answer is something obvious... Thanks!!

推荐答案

尝试反距离加权和scipy.spatial.KDTree在 SO 中描述inverse-distance-weighted-idw-interpolation-with-python.Kd-trees在 2d 3d 中很好地工作......,反距离加权是平滑和局部的,并且 k= 最近邻居的数量可以改变以权衡速度/准确性.

Try the combination of inverse-distance weighting andscipy.spatial.KDTreedescribed in SOinverse-distance-weighted-idw-interpolation-with-python.Kd-treeswork nicely in 2d 3d ..., inverse-distance weighting is smooth and local,and the k= number of nearest neighbours can be varied to tradeoff speed / accuracy.

这篇关于不规则网格上的插值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 11:04
查看更多