У меня есть код ошибки после трассировки.
Могу ли я изменить данные [z, y, x] на данные [0,0,0]?
Тогда это сработало.
Traceback (most recent call last):
File "/home/suhui/Downloads/dry.py", line 1194, in <module>
harvest, affinity = getpoints(grid, coord(w), distance = 1.0) # angstroms
File "/home/suhui/Downloads/dry.py", line 739, in getpoints
harvesting.append( data[z,y,x] )
IndexError: index 41 is out of bounds for axis 0 with size 41
Вот мой код.
pt_scan = int( round(float(distance)/(spacing)) )
if pt_scan == 0: pt_scan = 1 # at least one point around
if DEBUG: print "Grid range: %2.2f [ +/- %d points : %2.2f ]" % (distance,pt_scan, pt_scan*spacing),
best = 999
if (coords[0] < max[0]) and (coords[0] > min[0]):
if (coords[1] < max[1]) and (coords[1] > min[1]):
if (coords[2] < max[2]) and (coords[2] > min[2]):
z_pt = int(round((coords[2] - min[2])/spacing))
y_pt = int(round((coords[1] - min[1])/spacing))
x_pt = int(round((coords[0] - min[0])/spacing))
for x_ofs in range(-pt_scan, pt_scan+1):
x = x_pt + x_ofs
if x < 0 :
harvesting.append(0)
break
for y_ofs in range(-pt_scan, pt_scan+1):
y = y_pt + y_ofs
if y < 0 :
harvesting.append(0)
break
for z_ofs in range(-pt_scan, pt_scan+1):
z = z_pt + z_ofs
if z < 0 :
harvesting.append(0)
break
harvesting.append( data[z,y,x] )
if data[z,y,x] < best:
best = data[z,y,x]
if DEBUG: print " %d pts [ best: %2.2f ]" % (len(harvesting), best),
return harvesting, best
return False
Пожалуйста, помогите мне .... Серьезно, я не могу понять ...
Можете ли вы найти мою ошибку?