[yt-users] h5py execution time
Jean-Claude Passy
jcpassy at gmail.com
Thu Aug 12 18:01:09 PDT 2010
Hi all,
I have a unigrid 256^3 simulation that run on 64 processors. I need to
copy/modify some data: I want to set the velocity of all cells having a
density higher than a certain threshold to a fixed value, the others to 0.
I wrote a little script using h5py. I have shortened it below:
###################################################
for grid in glob.glob('%s/*.cpu*' %(folderIN+NameIN)):
file1 = H.File(...,'r')
file2 = H.File(..., 'w')
for group in file1.keys():
mygroup = file1[group]
subgroup = file2.create_group(group)
*density = file1[group]['Density']*
for field in mygroup.keys():
print 'Field:', field, ' in ', mygroup
mydset = mygroup[field]
shape = mydset.shape
where = '/'+group+'/'+field
# Setting up the gas velocity
if (field == 'x-velocity'):
tmp = N.zeros(file1[group][field].shape)
size = file1[group][field].shape
for k1 in range(0,size[0],1):
for k2 in range(0,size[1],1):
for k3 in range(0,size[2],1):
* if (density[k1,k2,k3] > Threshold):*
tmp[k1,k2,k3] = SomeValue
else:
tmp[k1,k2,k3] = 0.0
print 'Setting up Vx = ', SomeValue, 'if rho >', Threshold
dset = subgroup.create_dataset(field,shape,data=tmp)
###################################################
The issue is that this script needs more than 40 minutes to complete
!!!! In the meantime, if I replace the test :
################################
*if (density[k1,k2,k3] > Threshold):*
################################
by a static test like:
################################
*if (10 > Threshold):*
################################
then the execution lasts only a few seconds ! So the problem comes from
the test involving the field density.
I don't really understand what is going on since I declared the variable
density outside every loop. Could it be a memory issue ?
I would really appreciate if someone could help solve that problem.
Thanks a lot,
JC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20100812/c3bb1da8/attachment.htm>
More information about the yt-users
mailing list