[yt-users] field value at a given location

Sam Skillman samskillman at gmail.com
Mon Dec 6 14:45:20 PST 2010


Hi Christine,

In addition to Stephen's answer, in the past I have done:

pf = load('data0005')
max_loc = pf.h.find_max_cell_location('Density')
temperature_at_max_den = max_loc[0].get_data('Temperature')[max_loc[1]]

I'm not sure which is faster, but two methods are better than one!
Sam

p.s. I just saw matt's email come through, and mine looks like the last
option he gave..

On Mon, Dec 6, 2010 at 3:38 PM, Stephen Skory <stephenskory at yahoo.com>wrote:

> 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)
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20101206/70443c4d/attachment.html>


More information about the yt-users mailing list