[yt-users] wired square in enzo DM slice map

Junhwan Choi (최준환) choi.junhwan at gmail.com
Mon Jun 15 20:34:25 PDT 2015


Thank you Brian, Nathan and Matt,

I will test what you guys suggested soon and will report the progress.
Thank you for your kind suggestions.
Junhwan

On Mon, Jun 15, 2015 at 7:57 PM, Brian O'Shea <bwoshea at gmail.com> wrote:
> 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!  :-)
>
>
> import yt
> import numpy as np
> import matplotlib.pyplot as plt
>
> ds = yt.load("RD0009/RD0009")
>
> center = [0.5, 0.5, 0.5]
> left = [0.4, 0.4, 0.4]
> right = [0.6, 0.6, 0.6]
>
> # creates 512 x 512 x 1 grid, so the 3rd dimension of the cell is very long.
> my_reg = ds.arbitrary_grid(left, right, dims=[512, 512, 1])
>
> # ("deposit", "all_density") in enzo is equivalent to depositing all
> particles, so dm, star, etc.
> # the ".value" part at the end strips off the units (maybe not necessary)
> dens = my_reg[("deposit", "all_density")].value
>
> # this reshapes the array from (512, 512, 1) to (512, 512), to make
> plt.imshow happy
> dens = dens.reshape( (512,512))
>
> # sets a floor to the values which was chosen somewhat arbitrarily.
> dens += 1.0e-30
>
> # plots the log of the density
> plt.imshow(np.log10(dens),cmap='algae')
>
>
>
> On Mon, Jun 15, 2015 at 8:32 PM, Matthew Turk <matthewturk at gmail.com> wrote:
>>
>> On Mon, Jun 15, 2015 at 7:30 PM, Brian O'Shea <bwoshea at gmail.com> wrote:
>> >> >>
>> >> >> yt's "arbitrary_grid" feature might also be useful here.
>> >> >>
>> >> >>
>> >> >>
>> >> >>
>> >> >> http://yt-project.org/docs/dev/analyzing/objects.html?highlight=arbitrary_grid#arbitrary-grid
>> >> >
>> >> >
>> >> >
>> >> > I concur, though if the size of the grid or number of particles is
>> >> > large
>> >> > (as
>> >> > in the simulation I've been working with) this can result in memory
>> >> > issues.
>> >> >
>> >>
>> >> I'm hesitating to push us further into the weeds here when you've
>> >> given a very thoughtful and helpful reply to Junhwan, but
>> >> arbitrary_grid can be flat along one dimension (i.e., NxMx1) and was
>> >> designed for this use case.
>> >
>> >
>> > Oh, this is intriguing - I stumbled across this when I came up with my
>> > original (hacktacular) solution, but in my reading of the documentation
>> > (and, admittedly, a cursory skim of the source code) suggested that if I
>> > wanted to, say, project the density of *all* of the particles in a
>> > simulation onto a grid of [NxMx1] that it would not work - I'd only get
>> > particles that happened to intersect the one-cell-thick volume of that
>> > grid,
>> > which would give me a slice but not a projection.  Did I misread that?
>> > If
>> > so, it is a much more elegant solution than mine.  :-)
>>
>> Yup, arbitrary_grid is more flexible than covering_grid.  It accepts
>> left edge, right edge, *and* dimensions.
>>
>> -Matt
>>
>> >
>> > --Brian
>> >
>> >
>> >
>> > _______________________________________________
>> > yt-users mailing list
>> > yt-users at lists.spacepope.org
>> > http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>> >
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>
>
>
> _______________________________________________
> 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