2014-04-04 27 views
2

我知道這已經被問過很多次在此網站上,但沒有任何解決方案對我有幫助。我運行下面的腳本給我的錯誤標題:AttributeError:'模塊'對象沒有任何屬性'grd'

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。

+0

也許fatiando的版本比上面的程序更新或更舊,並且模塊已被重命名。檢查程序是否指定了它需要的fatiando版本。 –

+0

用戶指南沒有指定任何特定的版本,至少可以找到。另一位評論者建議.grd命令已被重命名爲.gridder,但這給了我相同的錯誤。 – Vlad

回答

2

看來,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的變化。

+0

感謝您的回覆。不幸的是,我和'gridder'有同樣的錯誤。 – Vlad

+0

對不起,當我測試它時,我也是如此。編輯我的答案 - 請再試一次。 – foobarbecue

+0

謝謝,已修復gridder錯誤,但現在我得到其他英尺命令的錯誤。我將通過github存儲庫瞭解一下,看看我能否自己解決它們。乾杯。 – Vlad

相關問題