我知道这个问题以前在这个网站上被问过很多次,但没有一个解决方案对我有帮助。我正在运行以下脚本,它在标题中给出了错误:
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 。如果我这样做,导入对我来说没问题:
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中发现了变化.
我是一名优秀的程序员,十分优秀!