我需要在其中一个for循环中创建数据列。基本上,你可以看到我循环通过24个角度和5个能量。最后,我得到一长串单一数据。有没有办法在一个对应24个角度的数组中获得24列数据?这是我的代码:
# Import OVITO modules.
from ovito.io import *
from ovito.modifiers import *
# Import NumPy module.
import numpy
import sys
f=open("1.out",'w')
sys.stdout = f
with open("1.out",'w') as f:
for i in range(1,24):
for j in range(1,5):
node = import_file("../Angle{}/{}eV/cascade.dump".format(i,j),multiple_frames = True)
ovito.dataset.anim.current_frame = 1
mod = WignerSeitzAnalysisModifier(per_type_occupancies = True)
mod.reference.load("../../position_perfect_300.dump")
node.modifiers.append(mod)
node.compute()
node.modifiers.append(SelectExpressionModifier(expression = 'ParticleType==1 && Occupancy.1==0 && Occupancy.2==0'))
node.compute()
f.write("Number of O vacant sites: %i\n" % numpy.count_nonzero(node.output.particle_properties['Selection']))
f.close()