[yt-users] Derived field "function" at runtime

Matthew Turk matthewturk at gmail.com
Sun Apr 10 07:51:42 PDT 2016


Hi Boyan,

You can call "get_source" on a derived field object.  For example, I
just loaded up a test dataset and did:

print ds.fields.gas.velocity_magnitude.get_source()

    def _magnitude(field, data):
        fn = field_components[0]
        mag = data[fn] * data[fn]
        for idim in range(1, registry.ds.dimensionality):
            fn = field_components[idim]
            mag += data[fn] * data[fn]
        return np.sqrt(mag)

On Sun, Apr 10, 2016 at 9:48 AM, bh11e <bh11e at my.fsu.edu> wrote:
> Hi,
>
> How one gets a reference to the effective "function" of a derived field at run time? I wish to know how the derived fields I use are calculated. Thus I need the source code either as a string or a source file/line number.
>
> Thanks,
> --Boyan Hristov
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org


More information about the yt-users mailing list