[yt-users] h5py execution time
    Stephen Skory 
    stephenskory at yahoo.com
       
    Thu Aug 12 18:03:00 PDT 2010
    
    
  
JC,
>        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
Using Numpy array functions will make your life much better! Here is a simple 
example below that I think is roughly what you want to do. It should at least 
get you started down the right path. Luckily, 'density' is already a numpy array 
when it gets read in, so you're good to go!
In [1]: import numpy as np
In [2]: a = np.random.random((2,2,2))
In [3]: a
Out[3]: 
array([[[ 0.97104489,  0.25985399],
        [ 0.02646919,  0.50027277]],
       [[ 0.21725962,  0.19100341],
        [ 0.96593371,  0.65269835]]])
In [4]: big = (a > 0.5)
In [5]: small = (a <= 0.5)
In [6]: b = big * 0.7 + small * 0
In [7]: b
Out[7]: 
array([[[ 0.7,  0. ],
        [ 0. ,  0.7]],
       [[ 0. ,  0. ],
        [ 0.7,  0.7]]])
 _______________________________________________________
sskory at physics.ucsd.edu           o__  Stephen Skory
http://physics.ucsd.edu/~sskory/ _.>/ _Graduate Student
________________________________(_)_\(_)_______________
    
    
More information about the yt-users
mailing list