【发布时间】:2018-09-25 16:48:34
【问题描述】:
我使用多普勒测风激光雷达进行了测量(PPI 弧形扫描)。数据存储在 pandas 数据框中,其中行表示方位角,列表示径向距离(输入形状 = 30x197)。 Link to example scan, (csv)。我想将其转换为笛卡尔坐标系,并输出一个二维数组,该数组被重新网格化为 x,y 坐标而不是极坐标,并将值存储在适当的网格单元中。插值(最近邻)是可以的,零或不存在数据的区域的 NaN 填充也是如此。
理想情况下,X 和 Y 网格应该对应于点之间的实际距离,但现在我只是想让它工作。这应该不是非常困难,但我无法获得我想要的结果。 到目前为止,我的工作代码可以很好地绘制在极轴上(example image),但这不适用于我接下来的分析步骤。
我用scipy.interpolate.griddata、scipy.ndimage.geometric_transform 和scipy.ndimage.map_coordinates 尝试了许多不同的方法,但没有得到正确的输出。这是我最近尝试的一个示例(df_polar 是链接的 csv 文件):
# Generate polar and cartesian meshgrids
r = df_polar.columns
theta = df_polar.index
theta = np.deg2rad(theta)
# Polar meshgrid
rad_c, theta_c = np.meshgrid(r,theta)
# Cartesian meshgrid
X = rad_c * np.cos(theta_c)
Y = rad_c * np.sin(theta_c)
x,y = np.meshgrid(X,Y)
# Interpolate from polar to cartesian grid
new_grid = scipy.interpolate.griddata(
(rad_c.flatten(), theta_c.flatten()),
np.array(df_polar).flatten(), (x,y), method='nearest')
结果根本不正确,通过阅读文档和示例,我不明白为什么。我将不胜感激任何关于我哪里出错的提示。非常感谢!!
【问题讨论】:
-
你的
new_grid最后是什么形状?我得到(5910, 5910)。 -
我刚刚意识到一个非常相似的问题是answered before。
-
感谢您提供的链接,尽管搜索了很多我还没有看到那个帖子!