Hi Charles,<br><br>I think you could do this in a couple ways.  The data argument in field functions gives you access to the parameter file of the dataset (<a href="http://data.pf">data.pf</a>).  One thing you can do is set your own parameters in the pf that can later be used by your function.  So you could do:<br>
pf = load(dataset)<br>pf.parameters['temperature_threshold'] = 1.e7<br>Then, inside your field function, you'll have access to that value as data.pf.parameters['temperature_threshold'].<br><br>The other way would be to embed the definition of the field function and the call to add_field within another function that takes temperature_threshold as an argument.  You can call that function over and over and it should overwrite the previous definition of the field.<br>
<br>Britton<br><br><div class="gmail_quote">On Wed, May 12, 2010 at 1:24 AM, Charles Hansen <span dir="ltr"><<a href="mailto:chansen@astro.berkeley.edu">chansen@astro.berkeley.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi all,<br>
<br>
Is it possible to make something like a derived field in yt that takes passed variables?  A simple example would be extracting gas density above a certain temperature, but changing that temperature threshold on the fly<br>

<br>
def _hotgas(field, data, temperature_threshold):<br>
   reutrn data["density"]*(data["Temperature"] > temperature_threshold)<br>
add_field("hotgas", function=_hotgas, Something else goes here?)<br>
<br>
In this particular case I only need a few temperatures and can make a new derived quantity each time, but it seems like a generally useful ability.<br>
<br>
Thanks,<br>
Charles<br>
_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org" target="_blank">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
</blockquote></div><br>