<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><p dir="ltr"><br>
On Oct 20, 2014 7:58 PM, "Brian O'Shea" <<a href="mailto:bwoshea@gmail.com">bwoshea@gmail.com</a>> wrote:<br>
><br>
> Hi Matt,<br>
><br>
>> > I am attempting to create a derived field from a cosmological simulation<br>
>> > dataset using Grackle.  Specifically, I have a simulation that was run with<br>
>> > Grackle, but which unfortunately did not output the cooling time.  Ergo, I'd<br>
>> > like to create that as a derived field.  Does anybody have an example of a<br>
>> > Grackle-based derived field in yt that I can use as a model?  I would note<br>
>> > that I looked at the "run_from_yt.py" example in the Grackle distro, but it<br>
>> > isn't quite what I need.<br>
>><br>
>> You'll probably need to use bits of that, and actually call Grackle on<br>
>> your data object.  If you can set up Grackle outside of the derived<br>
>> field you can minimize the overhead cost.  But, calling grackle just<br>
>> like it would be otherwise, but inside the derived field definition,<br>
>> is going to be the way to go I think.<br>
><br>
><br>
> 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.<br>
></p>
<p dir="ltr">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.</p>
<p dir="ltr">To do the former, you'll want something like:</p>
<p dir="ltr">start = 0<br>
N = 1024<br>
rv = np.zeroes(data["ones "])<br>
while start < rv.size:<br>
    grackle(data["density"][start:start+N], ...)<br>
    start += N</p>
<p dir="ltr">inside your derived field.</p>
<p dir="ltr">Matt<br></p>
<p dir="ltr">> Thank you!<br>
><br>
> --Brian<br>
><br>
><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">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
><br>
</p>