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

问题描述

因此,我有三个numpy数组,它们在网格上存储纬度,经度和某些属性值-也就是说,我有LAT(y,x),LON(y,x),例如温度T( y,x),适用于x和y的某些限制.网格不一定是规则的-实际上,它是三极的.

然后,我想将这些特性(温度)值插值到一堆不同的经度/纬度点(分别存储为lat1(t),lon1(t),大约10,000 t ...)实际的网格点.我已经尝试过matplotlib.mlab.griddata,但这花费了太长的时间(毕竟,它并不是真正针对我的工作而设计的).我也尝试了scipy.interpolate.interp2d,但出现MemoryError(我的网格约为400x400).

是否有任何巧妙的方法,最好是快速的方法?我忍不住认为答案很明显...谢谢!

解决方案

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

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.

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!!

解决方案

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.

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

08-13 19:31