[yt-users] multiply a function of a field with another field

Reju Sam John rejusamjohn at gmail.com
Wed Oct 16 22:06:48 PDT 2013


Actually I needed some thing like this ([image: \eta(\mathcal{M}) \times
\frac{1}{2}\rho(\mathcal{M} c_{s})^3] )  *where [image:
\eta(\mathcal{M})]is a function of
"Mach**Number"*, [image: \rho] is  "Density" and [image: c_s]  is "
SoundSpeed".

can I write some thing like this?

 newfield(field,data)
 return new-function(data["MachNumber"])*data["any-other-field"]

Please tell me this is possible or not. If not let me know what is the
correct syntax?




On Wed, Oct 16, 2013 at 4:25 PM, Matthew Turk <matthewturk at gmail.com> wrote:

> Hi Reju,
>
> Your best bet would be to do this with a derived field; there are some
> examples in the docs.  But, as a simple example, this would accomplish
> it:
>
> --
> from yt.mods import *
>
> @derived_field(name = "MyField")
> def my_new_field(field, data):
>     return data["Density"] * data["Temperature"]
> --
>
> In the docs it mostly uses the function "add_field" rather than
> @derived_field, but the result is the same.  This returns Temperature
> * Density.  You can then plot "MyField" or ask for it or whatever, and
> it will be the result.
>
> Hope that helps!
>
> -Matt
>
>
> On Wed, Oct 16, 2013 at 7:53 PM, Reju Sam John <rejusamjohn at gmail.com>
> wrote:
> > Dear All,
> >
> > I want to multiply a function of a field in YT (function of  MachNumber )
> > with another field in YT. How can I proceed?
> >
> >
> >
> > --
> > Reju Sam John
> >
> > _______________________________________________
> > yt-users mailing list
> > yt-users at lists.spacepope.org
> > http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
> >
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>



-- 
Reju Sam John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20131017/964ed69b/attachment.html>


More information about the yt-users mailing list