[yt-dev] Making a particle density plot

John ZuHone jzuhone at gmail.com
Sat Dec 1 19:21:48 PST 2012


Chris,

Try something like this script:

http://paste.yt-project.org/show/2947/

Which produces these images:

http://i.imgur.com/g4Q7B.png (slice)
http://i.imgur.com/2UYdY.png (projection)

Basically I generate particle x and y positions to be fed into the uniform grid field data, and I define a "ParticleNumberDensity" field that histograms this data. The grid has dimensions of (64,64,1). 

Notice I defined the bounding box 'bbox' oddly--it's because I wanted all of the cells to be cubical. You could probably just get away with defining the bbox as (0,1) along all three axes, but this would mean the cells are long and rectangular along the z-axis. I'm not sure how yt would handle this (my guess is just fine, but I've seen code that seems to assume cubical cells). 

Best,

John

On Dec 1, 2012, at 6:33 PM, Christopher Moody <cemoody at ucsc.edu> wrote:

> Thanks John!
> 
> chris
> 
> 
> 
> 
> On Sat, Dec 1, 2012 at 12:18 PM, John ZuHone <jzuhone at gmail.com> wrote:
> Chris,
> 
> You could probably use the uniform grid stream for what you want. You could just flatten the particle position along the axis you're projecting along and then define a 2D uniform grid with shape, say, (nx, ny, 1) if you were projecting along Z. Then you could use the normal yt stuff to make plots, but the particles would only be on one grid.
> 
> When I'm able to get back to a real keyboard I will write an example script if this sounds good to you.
> 
> John
> 
> John ZuHone
> Laboratory for High-Energy Astrophysics
> NASA/Goddard Space Flight Center
> 8800 Greenbelt Rd., Code 662
> Greenbelt, MD 20771
> (w) 301-286-2531
> (m) 773-758-0172
> jzuhone at gmail.com
> john.zuhone at nasa.gov
> 
> On Dec 1, 2012, at 2:57 PM, Christopher Moody <cemoody at ucsc.edu> wrote:
> 
>> Hi everyone,
>> 
>> I'd like to implement a particle density plot type, but I'm not familiar enough with the yt/visualization classes. I'm explicitly avoiding particle deposition on the grid (ie, the stuff John ZuHone just PR'd), because even after the particles are assigned to grids, splitting the array for each grid, and then concatenating grid-by-grid is slow. And moving to yt-3.0, we should be able to handle particle as particles not on a grid/oct (right?).
>> 
>> To collect all of the particles, project them, and do a 2D histogram is straightforward, but my question is where to do it. I was thinking of imitating the ParticlePlot class, but that basically uses the particle callback that draws a dot for every particle. A histogram'd field is defined everywhere, and is probably not appropriate as a callback.
>> How should I structure this? Which files are the relevant ones?
>> 
>> chris
>> 
>> _______________________________________________
>> yt-dev mailing list
>> yt-dev at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
> 
> _______________________________________________
> yt-dev mailing list
> yt-dev at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-dev-spacepope.org/attachments/20121201/34156c13/attachment.htm>


More information about the yt-dev mailing list