AttributeError:“module”对象没有属性“grd”

2024-10-01 19:17:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我知道这个问题在这个网站上已经被问过很多次了,但是没有一个解决方案对我有帮助。我正在运行以下脚本,该脚本在标题中显示错误:

import numpy as np
import fatiando as ft

shape = (41, 41)
x, y = ft.grd.regular((-10, 10, 30, 50), shape)
height = 800 - 1000*ft.utils.gaussian2d(x, y, 3, 1, x0=0, y0=37)
rel = -7000*ft.utils.gaussian2d(x, y, 3, 5, x0=0, y0=40)
thick = height - rel
dens = 1900*np.ones_like(thick)
data = np.transpose([x, y, height, thick, dens])
with open('layers.txt', 'w') as f:
    f.write("# Synthetic layer model of sediments and topography\n")
    f.write("# Columns are:\n")
    f.write("#   lon   lat   height   thickness   density\n")
    np.savetxt(f, data, fmt='%g')
ft.vis.figure(figsize=(4, 3))
ft.vis.title('Depth of sediments [m]')
ft.vis.axis('scaled')
ft.vis.pcolor(x, y, rel, shape)
ft.vis.colorbar()
ft.vis.savefig('depth.png')
ft.vis.figure(figsize=(4, 3))
ft.vis.title('Topography [m]')
ft.vis.axis('scaled')
ft.vis.pcolor(x, y, height, shape)
ft.vis.colorbar()
ft.vis.savefig('topography.png')
ft.vis.figure(figsize=(4, 3))
ft.vis.title('Thickness of sediment layer [m]')
ft.vis.axis('scaled')
ft.vis.pcolor(x, y, thick, shape)
ft.vis.colorbar()
ft.vis.savefig('thickness.png')
ft.vis.show()

这个脚本不是我自己创建的,而是一个预先打包的演示脚本,其中有一个我已经安装的程序(Tesseroids),所以我不知道为什么我在使用它时会出错。我已经安装了法蒂安多。在


Tags: of脚本titleasnpviswriterel
1条回答
网友
1楼 · 发布于 2024-10-01 19:17:06

看来法蒂安多.grd已重命名为法蒂安多·格里德. 如果我这样做,导入对我来说没问题:

import numpy as np
import fatiando as ft
from fatiando import gridder

shape = (41, 41)
x, y = gridder.regular((-10, 10, 30, 50), shape)

我在项目的github repository中发现了变化。在

相关问题 更多 >

    热门问题