<div dir="ltr">OK folks, after a quick offline chat with Matt, I realized that I was being overly constrained in my assumption that grid cells need to be cubes - they do not.  To that end, the arbitrary_grid thing works *perfectly* to make dark matter projections.  To deposit all of the particles to a 2D grid, the following script (with a few comments to clarify what's going on) works great and is a vastly better solution than mine.  Thanks to Matt for pointing this out!  :-)<div>  <div><br></div><div><div>import yt</div><div>import numpy as np</div><div>import matplotlib.pyplot as plt</div><div><br></div><div>ds = yt.load("RD0009/RD0009")</div><div><br></div><div>center = [0.5, 0.5, 0.5]</div><div>left = [0.4, 0.4, 0.4]</div><div>right = [0.6, 0.6, 0.6]</div><div><br></div><div># creates 512 x 512 x 1 grid, so the 3rd dimension of the cell is very long.</div><div>my_reg = ds.arbitrary_grid(left, right, dims=[512, 512, 1])</div><div><br></div><div># ("deposit", "all_density") in enzo is equivalent to depositing all particles, so dm, star, etc.</div><div># the ".value" part at the end strips off the units (maybe not necessary)</div><div>dens = my_reg[("deposit", "all_density")].value</div><div><br></div><div># this reshapes the array from (512, 512, 1) to (512, 512), to make plt.imshow happy</div><div>dens = dens.reshape( (512,512))</div><div><br></div><div># sets a floor to the values which was chosen somewhat arbitrarily.</div><div>dens += 1.0e-30 </div><div><br></div><div># plots the log of the density</div><div>plt.imshow(np.log10(dens),cmap='algae')</div></div><div><br></div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 15, 2015 at 8:32 PM, Matthew Turk <span dir="ltr"><<a href="mailto:matthewturk@gmail.com" target="_blank">matthewturk@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 class="HOEnZb"><div class="h5">On Mon, Jun 15, 2015 at 7:30 PM, Brian O'Shea <<a href="mailto:bwoshea@gmail.com">bwoshea@gmail.com</a>> wrote:<br>
>> >><br>
>> >> yt's "arbitrary_grid" feature might also be useful here.<br>
>> >><br>
>> >><br>
>> >><br>
>> >> <a href="http://yt-project.org/docs/dev/analyzing/objects.html?highlight=arbitrary_grid#arbitrary-grid" rel="noreferrer" target="_blank">http://yt-project.org/docs/dev/analyzing/objects.html?highlight=arbitrary_grid#arbitrary-grid</a><br>
>> ><br>
>> ><br>
>> ><br>
>> > I concur, though if the size of the grid or number of particles is large<br>
>> > (as<br>
>> > in the simulation I've been working with) this can result in memory<br>
>> > issues.<br>
>> ><br>
>><br>
>> I'm hesitating to push us further into the weeds here when you've<br>
>> given a very thoughtful and helpful reply to Junhwan, but<br>
>> arbitrary_grid can be flat along one dimension (i.e., NxMx1) and was<br>
>> designed for this use case.<br>
><br>
><br>
> Oh, this is intriguing - I stumbled across this when I came up with my<br>
> original (hacktacular) solution, but in my reading of the documentation<br>
> (and, admittedly, a cursory skim of the source code) suggested that if I<br>
> wanted to, say, project the density of *all* of the particles in a<br>
> simulation onto a grid of [NxMx1] that it would not work - I'd only get<br>
> particles that happened to intersect the one-cell-thick volume of that grid,<br>
> which would give me a slice but not a projection.  Did I misread that?  If<br>
> so, it is a much more elegant solution than mine.  :-)<br>
<br>
</div></div>Yup, arbitrary_grid is more flexible than covering_grid.  It accepts<br>
left edge, right edge, *and* dimensions.<br>
<br>
-Matt<br>
<br>
><br>
> --Brian<br>
<div class="HOEnZb"><div class="h5">><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" rel="noreferrer" 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">yt-users@lists.spacepope.org</a><br>
<a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br>
</div></div></blockquote></div><br></div>