【问题标题】:Is there a way to visualize an azimuthal average a 3D Cartesian space?有没有办法将方位角平均值可视化为 3D 笛卡尔空间?
【发布时间】:2019-10-18 01:59:15
【问题描述】:

我有一个数据集,其中包含 200x200x38 3D 空间中的值。数据以 [100,100,z] 为中心,其中 z 是高度,前两个值是水平 x 和 y 坐标。我正在尝试创建横截面的可视化,该横截面沿径向和每个高度平均数据集中的值(制作高度半径平均值)。

Most efficient way to calculate radial profile 这篇文章介绍如何为一个二维数据集做了径向平均水平,但我不很明白他们怎么他们的分级数据转换成不同的半径要么̶s̶i̶n̶c̶e̶.̶̶从来就定义功能半径和角度中心,̶但鸵鸟政策知道如何转换我的笛卡尔数据转换成圆柱坐标̶s̶h̶a̶p̶e̶.̶

def radial_profile(data, center):
    y, x = np.indices((data.shape))
    r = np.sqrt((x - center[0])**2 + (y - center[1])**2)
    r = r.astype(np.int)

    tbin = np.bincount(r.ravel(), data.ravel())
    nr = np.bincount(r.ravel())
    radialprofile = tbin / nr
    return radialprofile 
Cent=[100,100]
Rav=[]
for i in range(37):
    B=ref[:,:,i,0]
    if B == -999.9:
        B=np.nan
    RRR=radial_profile(B,Cent)
    Rav.append(RRR)
plt.imshow(Rav, vmin=-15, vmax=70)
plt.colorbar();
plt.show()

使用它我已经能够绘制它,但必须想办法从平均值中删除 -999.9 值。我试图将其分配为空,但没有成功。否则情节有效。

【问题讨论】:

  • 如果您不理解该问题的公认答案,那么您实际上在问什么?对您的问题的一个好的回答基本上是建立在那个基础上的......
  • 提出问题时,如果您提供他们易于理解并用于重现问题的代码,人们将能够更好地提供帮助。您能否发布示例数据和/或代码?

标签: python arrays cartesian-coordinates


【解决方案1】:
def radial_profile(data, center):
    y, x = np.indices((data.shape))
    r = np.sqrt((x - center[0])**2 + (y - center[1])**2)
    r = r.astype(np.int)

    tbin = np.bincount(r.ravel(), data.ravel())
    nr = np.bincount(r.ravel())
    radialprofile = tbin / nr
    return radialprofile 
Cent=[100,100]
Rav=[]
for i in range(37):
    dbz=np.array(ref)
    dbz[dbz == -999.9]=np.nan
    B=dbz[:,:,i,0]
    RRR=radial_profile(B,Cent)
    Rav.append(RRR)
plt.imshow(Rav, vmin=-15, vmax=70)
plt.colorbar();
plt.show()

抱歉,我应该更加努力地理解我在问题中所指的帖子。

如果有人有任何更清洁或更有效的解决方案,我将不胜感激

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-15
    • 1970-01-01
    • 1970-01-01
    • 2016-06-26
    相关资源
    最近更新 更多