<div dir="ltr">Reju,<div><br></div><div>When you have data[any_field] in your field function, it will just be a Numpy array containing value for that field, so you can do anything you want it, including calling another function, as long as the shape of the data returned from the function is the same as the shape of the field array.  What you have should work just fine.  I encourage you to go ahead and try it.</div>
<div><br></div><div>Britton</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Oct 17, 2013 at 2:06 PM, Reju Sam John <span dir="ltr"><<a href="mailto:rejusamjohn@gmail.com" target="_blank">rejusamjohn@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Actually I needed some thing like this (<img alt="\eta(\mathcal{M}) \times \frac{1}{2}\rho(\mathcal{M} c_{s})^3 " title="\eta(\mathcal{M}) \times \frac{1}{2}\rho(\mathcal{M} c_{s})^3 " style="vertical-align:-5.8px"> )  <b><i>where <img alt="\eta(\mathcal{M}) " title="\eta(\mathcal{M}) " style="vertical-align:-5px"> is a function of <span style="font-size:13px;font-family:arial,sans-serif">"Mach</span></i></b><span style="font-size:13px;font-family:arial,sans-serif"><b><i>Number"</i></b>, <img alt="\rho " title="\rho " style="vertical-align:-3.8px"></span><font face="arial, sans-serif"> is </font><span style="font-family:arial,sans-serif;font-size:13px"> "Density" and <img alt=" c_s " title=" c_s " style="vertical-align:-2.9px">  is "</span><font face="arial, sans-serif">SoundSpeed". </font></div>

<div><span style="font-family:arial,sans-serif"> </span></div><div>can I write some thing like this? </div><div><br></div><span style="font-family:arial,sans-serif;font-size:13px"> newfield(field,data)</span><br style="font-family:arial,sans-serif;font-size:13px">


<div><span style="font-size:13px;font-family:arial,sans-serif"> return new-function(data["MachNumber"</span><span style="font-size:13px;font-family:arial,sans-serif">])*data["any-other-field"]</span> </div>

<div><br></div><div>Please tell me this is possible or not. If not let me know what is the correct syntax? </div><div>
<br></div><br><div class="gmail_extra"><div><div class="h5"><br><br><div class="gmail_quote">On Wed, Oct 16, 2013 at 4:25 PM, Matthew Turk <span dir="ltr"><<a href="mailto:matthewturk@gmail.com" target="_blank">matthewturk@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi Reju,<br>
<br>
Your best bet would be to do this with a derived field; there are some<br>
examples in the docs.  But, as a simple example, this would accomplish<br>
it:<br>
<br>
--<br>
from yt.mods import *<br>
<br>
@derived_field(name = "MyField")<br>
def my_new_field(field, data):<br>
    return data["Density"] * data["Temperature"]<br>
--<br>
<br>
In the docs it mostly uses the function "add_field" rather than<br>
@derived_field, but the result is the same.  This returns Temperature<br>
* Density.  You can then plot "MyField" or ask for it or whatever, and<br>
it will be the result.<br>
<br>
Hope that helps!<br>
<br>
-Matt<br>
<div><div><br>
<br>
On Wed, Oct 16, 2013 at 7:53 PM, Reju Sam John <<a href="mailto:rejusamjohn@gmail.com" target="_blank">rejusamjohn@gmail.com</a>> wrote:<br>
> Dear All,<br>
><br>
> I want to multiply a function of a field in YT (function of  MachNumber )<br>
> with another field in YT. How can I proceed?<br>
><br>
><br>
><br>
> --<br>
> Reju Sam John<br>
><br>
</div></div>> _______________________________________________<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>
><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><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div dir="ltr">Reju Sam John</div>
</font></span></div></div>
<br>_______________________________________________<br>
yt-users mailing list<br>
<a href="mailto:yt-users@lists.spacepope.org">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>
<br></blockquote></div><br></div>