[yt-users] field value at a given location

Stephen Skory stephenskory at yahoo.com
Mon Dec 6 14:38:11 PST 2010


Christine,


>This is a pretty simple issue and probably has a simple solution, 
> but
>I'm not sure how to do it.  I want to access the value of a field at 
> a
>given location.  For example, say I have the location of the peak 
> gas
>density and I want to find the value of the metallicity at that 
> point.
>How would I do 
> that?





you'll want to use numpy's argmax(), which gives the index of the maximum value in an array. Here's an example:

In [1]: pf = load("data0005")

In [2]: dd = pf.h.all_data()
yt         INFO       2010-12-06 15:36:30,714 Getting the binary hierarchy
yt         INFO       2010-12-06 15:36:30,725 Finished with binary hierarchy reading

In [3]: D = dd['Density']
yt         INFO       2010-12-06 15:36:39,620 Getting field Density from 32

In [4]: max = na.argmax(D)

In [5]: max
Out[5]: 911803

In [6]: D[max]
Out[6]: 5.2503087194967203e-26

In [7]: T = dd['Temperature']
yt         INFO       2010-12-06 15:36:58,377 Getting field Temperature from 32

In [8]: T[max]
Out[8]: 10597.077292396227

Let me know if that's not clear enough!

 
Stephen Skory
stephenskory at yahoo.com
http://stephenskory.com/
510.621.3687 (google voice)



More information about the yt-users mailing list