2012-11-19 41 views
2

我正在使用matplotlib来将一些数据拟合到一个网格并将其绘制为极坐标投影。类似于下面的例子。不过,我希望它在地块边缘在0/360度相遇处平滑。任何人都知道我是怎么做到的?griddata和极地图

from pylab import * 
import random 

x = linspace(0, 360, 361).astype(int) 
x = x*pi/180 
y = linspace(0.05, 0.5, 800) 
xgrid, ygrid = meshgrid(x, y) 


baz = [] 
for c in range(2000): baz.append(random.randint(0,360)) 


freq = rand(len(baz)) 
pwr = rand(len(baz)) 

zgrid = griddata(baz,freq,pwr, xgrid, ygrid) 
subplot(111, polar=True) 
pcolormesh(xgrid, ygrid, zgrid) 
show() 

另外我处理的数据具有间隙由于通过的GridData创建的掩模(I使用的GridData如上但随后在循环中总结许多网格)。我想填补缺失的部分(见附图),有谁知道如何做到这一点?

enter image description here 感谢 戴夫

回答

1

如果你知道哪些网格也一起在0/360度位置,你可以只将它们连接起来,并做就可以(scipy interpolation)一个样条插值。 对于第二个问题,我不确定,但是如何在极坐标中创建网格?这会解决你的问题吗?

亲切的问候

+0

嗨,串联是一个好主意,但是丢失的数据段来源于通过的GridData创造的面具,我不认为有办法解决它。所以,我在最后使用了一个不同的apprach [这里] [http://stackoverflow.com/questions/13498172/matplotlib-polar-2d-histogram] – Dave