python - AttributeError:“钻孔”对象没有属性“深度”
问题描述
问题是:
%cd e:\IceChrono import sys sys.argv=['IceChrono.py','AICC2012-VLR'] exec(open('IceChrono.py').read()) e:\IceChrono Parameters directory is: AICC2012-VLR/ Initialization of drilling EDC Traceback (most recent call last):
File "<ipython-input-32-7479f156abda>", line 4, in <module>
exec(open('IceChrono.py').read())
File "<string>", line 92, in <module>
File "<string>", line 64, in init
AttributeError: 'Drilling' object has no attribute 'depth'
问题的部分代码是:
def gaussian(x):
return np.exp(-x**2/2)
class Drilling:
def __init__(self, dlabel,):
self.label=dlabel
def init(self):
# print 'Initialization of drilling '+self.label
self.accu_prior_rep='staircase'
#execfile(datadir+'/parameters-AllDrillings.py')
exec(open(datadir+'/parameters-AllDrillings.py').read())
#execfile(datadir+self.label+'/parameters.py')
exec(open(datadir+'/parameters-AllDrillings.py').read())
self.depth_mid=(self.depth[1:]+self.depth[:-1])/2
self.depth_inter=(self.depth[1:]-self.depth[:-1])
## We set up the raw model
if self.calc_a:
readarray=np.loadtxt(datadir+self.label+'/isotopes.txt')
if (np.size(readarray)==np.shape(readarray)[0]): readarray.resize(1, np.size(readarray))
self.iso_depth=readarray[:,0]
if self.calc_a_method=='fullcorr':
self.iso_d18Oice=readarray[:,1]
self.d18Oice=interp.stair_aver(self.depth, self.iso_depth, self.iso_d18Oice)
self.iso_deutice=readarray[:,2]
self.deutice=interp_stair_aver(self.depth, self.iso_depth, self.iso_deutice)
self.iso_d18Osw=readarray[:,3]
self.d18Osw=interp.stair_aver(self.depth, self.iso_depth, self.iso_d18Osw)
self.excess=self.deutice-8*self.d18Oice # dans Uemura : d=excess
self.a=np.empty_like(self.deutice)
self.d18Oice_corr=self.d18Oice-self.d18Osw*(1+self.d18Oice/1000)/(1+self.d18Osw/1000) #Uemura (1)
self.deutice_corr=self.deutice-8*self.d18Osw*(1+self.deutice/1000)/(1+8*self.d18Osw/1000) #Uemura et al. (CP, 2012) (2)
self.excess_corr=self.deutice_corr-8*self.d18Oice_corr
self.deutice_fullcorr=self.deutice_corr+self.gamma_source/self.beta_source*self.excess_corr
elif self.calc_a_method=='deut':
self.iso_deutice=readarray[:,1]
self.deutice_fullcorr=interp_stair_aver(self.depth, self.iso_depth, self.iso_deutice)
elif selc.calc_a_method=='d18O':
self.d18Oice=readarray[:,1]
self.deutice_fullcorr=8*interp_stair_aver(self.depth, self.iso_depth, self.iso_d18Oice)
else:
print ('Accumulation method not recognized')
quit()
else:
readarray=np.loadtxt(datadir+self.label+'/accu-prior.txt')
if (np.size(readarray)==np.shape(readarray)[0]): readarray.resize(1, np.size(readarray))
self.a_depth=readarray[:,0]
self.a_a=readarray[:,1]
if readarray.shape[1]>=3:
self.a_sigma=readarray[:,2]
if self.accu_prior_rep=='staircase':
self.a_model=interp_stair_aver(self.depth, self.a_depth, self.a_a)
elif self.accu_prior_rep=='linear':
self.a_model=interp_lin_aver(self.depth, self.a_depth, self.a_a)
else:
print ('Representation of prior accu scenario not recognized')
self.a=self.a_model
该程序的链接是:这里
我正在运行一个程序,但遇到了错误。我进行了以下修改,但仍然出现错误。
- IceChrono.py程序和IceChronoClasses.py程序中的第25、90、104、112、114、117、120、123、125、128、131、133、135、137、139、151、163行后面的内容第91、105、180、199、204、205、526、527行的print要加(),代表输出字符串格式
- 程序中的第 19 行
IceChrono.py
替换start_time = time.clock ()
为time.perf_counter
ortime.process_time
- 使用程序中的第35和45行以及
IceChrono.py
程序中的第59和60行IceChronoClasses.py
替换execfile (filename)
为exec(open (filename) .read ())
解决方案
似乎您尚未self.depth
在班级的任何地方初始化(分配给)该属性。
推荐阅读
- python - Pyinstaller 没有执行我的 Python 脚本
- javascript - 将当前窗口重定向到链接后如何调用用 Snippet 编写的函数(例如 window.location = "https://google.com")
- javascript - 有没有办法让一个带有盒子阴影插入和正常的 div
- ruby-on-rails - Rails Devise Token Auth Reset Password Flow - 如何从 302 重定向深层链接
- flutter - 有什么方法可以将页面浏览量的滚动条指示器变为颤动的点状指示器并更改位置?
- python - 从多列的 value_counts 中排除项目
- c# - 我无法从组合框获得价值
- node.js - ndb - 通过 npm 安装后节点调试器不启动
- java - 如果它包含/等于/大于等,如何查询解析json对象子值?
- python - 在屏幕期间找不到 tensorflow(或其他一些 python 包)?