python错误消息'模块'/类型对象没有属性

时间:2019-07-13 13:47:37

标签: python attributeerror

我正在尝试运行以下使用“ strain”模块的代码。我尝试运行如下所示的代码,并收到以下错误消息:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-20-998f72cd94f8> in <module>()
----> 1 X,Xb=strain.fits.fit(st,fpar=fpar)

AttributeError: 'module' object has no attribute 'fits'

然后,我尝试了以下操作:从应变导入 S 应变(即以大写“ S”开头),并将应变的应变输入到下面的代码行中,并得到以下错误消息:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-23-cc2628fe82a4> in <module>()
----> 1 X,Xb=Strain.fits.fits.fit(st,fpar=fpar)

AttributeError: type object 'Strain' has no attribute 'fits'

任何人都可以建议。

import Strain
import obspy
import numpy as np

st = obspy.read('*B065*.SAC')
for tr in st:
    msk = tr.data==-12345
    tr.data = np.ma.masked_array(tr.data,mask=msk)

st.plot(method='full')

#This is to view main channels only, as RDO will be dominant and overscale other channels
stt = st.select(channel='E-N')+st.select(channel='2EN')+st.select(channel='E+N')
stt.plot(method='full')

# remove a long-term trend and exponential

# parameters
fpar = {'fitlinear':True,'fitconstant':True,'fitexp':True,
        'flm':np.array([0,float('inf')]),'expdec':300,
        'expdeclim':np.array([30,3000])}

# do the fit to estimate fit paramters
X,Xb=strain.fits.fit(st,fpar=fpar)

0 个答案:

没有答案