[yt-users] derived field with Grackle?

Matthew Turk matthewturk at gmail.com
Mon Oct 20 18:09:05 PDT 2014


On Oct 20, 2014 7:58 PM, "Brian O'Shea" <bwoshea at gmail.com> wrote:
>
> Hi Matt,
>
>> > I am attempting to create a derived field from a cosmological
simulation
>> > dataset using Grackle.  Specifically, I have a simulation that was run
with
>> > Grackle, but which unfortunately did not output the cooling time.
Ergo, I'd
>> > like to create that as a derived field.  Does anybody have an example
of a
>> > Grackle-based derived field in yt that I can use as a model?  I would
note
>> > that I looked at the "run_from_yt.py" example in the Grackle distro,
but it
>> > isn't quite what I need.
>>
>> You'll probably need to use bits of that, and actually call Grackle on
>> your data object.  If you can set up Grackle outside of the derived
>> field you can minimize the overhead cost.  But, calling grackle just
>> like it would be otherwise, but inside the derived field definition,
>> is going to be the way to go I think.
>
>
> As a very high-level answer, that makes sense.  Implementation seems to
be a bit harder - I've been trying to reconcile the way that grackle is
called from its python wrapper with the way that yt generates derived
fields.  In grid_to_grackle(), you feed in individual grids and each grid's
fields (including other derived fields) are accessed by stepping through a
grid in slabs, with a great deal of information about the grid itself being
required.  When I look at derived fields in yt, everything works by calling
data[], possibly using adjacent slabs/cells in various ways, but never
referring to individual grids.  Could you point me toward an example of a
derived field where grids are manipulated more directly?  I don't really
have any idea about how to actually *do* what you've suggested, at least
given the grackle python interface as it stands in grackle 2.
>

Sure. You'll want to either split up the data container into chunks of N
elements of data using an iterator, or use a spatial field as described in
the docs and iterate over slabs.

To do the former, you'll want something like:

start = 0
N = 1024
rv = np.zeroes(data["ones "])
while start < rv.size:
    grackle(data["density"][start:start+N], ...)
    start += N

inside your derived field.

Matt

> Thank you!
>
> --Brian
>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20141020/0ede4544/attachment.htm>
-------------- next part --------------
_______________________________________________
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