我知道在此站点上已经多次询问过这个问题,但是这些解决方案都没有帮助我。我正在运行以下脚本,该脚本给我标题中的错误:

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),所以我不知道为什么在使用它时会出错。我已经安装了Fatiando。

最佳答案

看来fatiando.grd已重命名为fatiando.gridder。如果我这样做,则为我导入OK:

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中找到了更改。

10-06 01:43