<div dir="ltr">Here's a worked out example that does what you're looking for using a fake 1 million particle dataset:<div><br></div><div><a href="http://nbviewer.ipython.org/gist/ngoldbaum/546d37869aafe71cfe38">http://nbviewer.ipython.org/gist/ngoldbaum/546d37869aafe71cfe38</a><br>

</div><div><br></div><div>In this notebook I make use of two key yt features: `load_particles`, and `covering_grid`.  </div><div><br></div><div>load_particles creates a "stream" dataset based on in-memory data fed in as a numpy array.  This dataset acts just like an on-disk simulation dataset, but doesn't come with the baggage of needing to write a custom frontend to read a specific data format off disk.<br>

</div><div><br></div><div>covering_grid is a way to generate uniform resolution data from an AMR dataset. It acts like a python dictionary where the keys are field names and returns 3D numpy arrays of whatever uniform resolution you specify when you create the covering_grid.</div>

<div><br></div><div>Note that if you're using load_particles all of your data needs to live in memory.  If your data is too big for that you'll need to write a frontend for your data format or use a memmap to an on-disk file somehow.  I'm not an expert on that but others on the list should be able to help out.</div>

<div><br></div><div>Hope that gets you well on your way :)</div><div><br></div><div>-Nathan</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jun 5, 2014 at 5:04 PM, Desika Narayanan <span dir="ltr"><<a href="mailto:dnarayan@haverford.edu" target="_blank">dnarayan@haverford.edu</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">Hey Brendan,<div><br></div><div>A couple of extra tools you might find helpful in conjunction with Nathan's example of depositing the particles onto an octree are at:</div>

<div><br></div><div><a href="http://paste.yt-project.org/show/4737/" target="_blank">http://paste.yt-project.org/show/4737/</a><br>

</div><div><br></div><div>Where I load a gadget snapshot, and then recover the coordinates and width of each cell.  </div><div><br></div><div>In response to your last question - the particles are deposited into an octree grid (so, you'll see that the cell sizes aren't all the same size).   I don't know if depositing onto a regular NxNxN mesh is possible, though would be interested to hear if so.</div>

<span class="HOEnZb"><font color="#888888">

<div><br></div><div>-d</div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jun 5, 2014 at 7:58 PM, Brendan Griffen <span dir="ltr"><<a href="mailto:brendan.f.griffen@gmail.com" target="_blank">brendan.f.griffen@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">Thanks. I'll get the "bleeding edge" version first then try your suggestions. Though I want to return the NxNxN array and be able to write this mesh to a file. It is *only* using the cic part of yt and it should return the mesh to be written? Just wanted to clarify?<div>




<br></div><div>Thanks.<span><font color="#888888"><br><div>Brendan</div></font></span></div></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jun 5, 2014 at 6:49 PM, Nathan Goldbaum <span dir="ltr"><<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@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"><br><div class="gmail_extra"><br><br><div class="gmail_quote"><div>On Thu, Jun 5, 2014 at 3:36 PM, John ZuHone <span dir="ltr"><<a href="mailto:jzuhone@gmail.com" target="_blank">jzuhone@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 Brendan,<br>
<br>
Which version of yt are you using?<br>
<br>
If you're using 3.0, this is actually fairly easy. If you look in <a href="http://yt.fields.particle_fields.py" target="_blank">yt.fields.particle_fields.py</a>, around line 85, you can see how this is done for the "particle_density" and "particle_mass" fields. Basically you can call a "deposit" method which takes the particle field quantity you want deposited and deposits it into cells. The underlying calculation is done using Cython, so it's fast.<br>






</blockquote><div><br></div></div><div>And you shouldn't ever actually need to call these "deposit" functions, since "deposit" is exposed as a field type for all datasets that contain particles.</div>




<div>

<br></div><div>Here is a notebook that does this for Enzo AMR data:</div><div><br></div><div><a href="http://nbviewer.ipython.org/gist/ngoldbaum/5e19e4e6cc2bf330149c" target="_blank">http://nbviewer.ipython.org/gist/ngoldbaum/5e19e4e6cc2bf330149c</a><br>






</div><div><br></div><div>This dataset contains about a million particles and generates a CIC deposition for the whole domain in about 6 seconds from a cold start.</div><div><div> </div><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">







<br>
If you're using 2.x, then you can do the same thing, but it's not as straightforward. You can see how this works in <a href="http://yt.data_objects.universal_fields.py" target="_blank">yt.data_objects.universal_fields.py</a>, around line 986, where the "particle_density" field is defined. Basically, it calls CICDeposit_3, which is in yt.utilities.lib.CICDeposit.pyx.<br>







<br>
Let me know if you need any more clarification.<br>
<br>
Best,<br>
<br>
John Z<br>
<div><div><br>
On Jun 5, 2014, at 6:07 PM, Brendan Griffen <<a href="mailto:brendan.f.griffen@gmail.com" target="_blank">brendan.f.griffen@gmail.com</a>> wrote:<br>
<br>
> Hi,<br>
><br>
> I was wondering if there were any Cython routines within yt which takes particle data and converts it into a cloud-in-cell based mesh which can be written to a file of my choosing. </div></div></blockquote><div><br>






</div></div><div>What sort of mesh were you looking for?  yt will internally construct an octree if it is fed particle data.  I'm not sure whether this octree can be saved to disk for later analysis.  </div><div><br>




</div>
<div>
It's also possible to create a uniform resolution covering grid containing field data for a deposited quantity, which can be quite easily saved to disk in a number of ways.</div><div><div> </div><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">






<div><div>I heard a while ago there was some such functionality but it could be too far down the yt rabbit hole to be used as a standalone? Is this true? I have my own Python code for doing it but it just isn't fast enough and thought I'd ask the yt community if there were any wrapper tools available to boost the speed.<br>







><br>
> Thanks.<br>
> Brendan<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></div><br></div></div>
<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>
<br></blockquote></div><br></div>
</div></div><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>
<br></blockquote></div><br></div>
</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>