[yt-users] Profiles and zero-valued fields

Matthew Turk matthewturk at gmail.com
Wed Jun 2 14:09:54 PDT 2010


Hi all,

After a chat with David Collins today, I wanted to share a relatively
quick note about the profiles and how they behave with fields,
specifically the field "Convergence", but any fields that zero out
values are equally applicable -- this will also extend to deposited
particle fields.  The issue here is in how the profiling works.  The
1- and 2-D profile objects are computed as:

sum( f_i * w_i ) / sum( w_i )

Note that for fields where the inapplicable values are zero'd out --
in this case, "Convergence" zeroes out all positive divergence
calculations and returns only the negative values, but sign-flipped.
However, the same is not done for the denominator!  So your profile
will give you the "what you said" results but not the "what you mean"
results.

The solution here is to use either an extracted region or an inline
extracted region (for large datasets):

dd = pf.h.all_data()
convergent_region = dd.extract_region( dd["Divergence"] < 0.0 )
pc.add_profile_object(convergent_region, ["Density", "Convergence"])

-or-

dd = pf.h.all_data()
convergent_region = dd.cut_region( [ "grid['Divergence'] < 0.0" ])
pc.add_profile_object(convergent_region, ["Density", "Convergence"])

Anyway, I hope that if anybody else runs into something similar that
this will help out!

Best,

Matt



More information about the yt-users mailing list