Particle only plots
Hello yt, Is there an easy way to plot only particles? What I would like to do is plot a z-axis projection of particle x/y positions, with no background data loaded from the grid. I only see examples for annotate_particles() on top of another plot, but I don't want to unnecessarily load grid data. Thanks! -Jeremy
Hi Jeremy,
Right now there isn't a way to do that in yt. That's something that would
be very nice to add and would probably be a good introductory yt project
for someone who wanted to get more familiar with the codebase.
What you *can* do is take the particle data and plot the positions in a
scatter plot using matplotlib.
Unfortunately I don't have a good example of that right now, but it should
be pretty straightforward. You just need to read in the x and y particle
position fields and then make a scatter plot using e.g. pyplot.plot().
-Nathan
On Wed, May 7, 2014 at 4:32 PM, Jeremy Ritter
Hello yt,
Is there an easy way to plot only particles? What I would like to do is plot a z-axis projection of particle x/y positions, with no background data loaded from the grid. I only see examples for annotate_particles() on top of another plot, but I don't want to unnecessarily load grid data.
Thanks! -Jeremy _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
Hi Jeremy,
I happened have a script that does this. Something like this should work
(in 2.6):
from yt.mods import *
import pylab as plt
fn =
'Chombo/releasedExamples/AMRParticleMesh/exec/output/plt256.2d.hdf5'
pf = load(fn)
data = pf.h.all_data()
x = data['particle_position_x']
y = data['particle_position_y']
plt.plot(x, y, '.')
plt.savefig('scatter')
-Andrew
On Wed, May 7, 2014 at 5:12 PM, Nathan Goldbaum
Hi Jeremy,
Right now there isn't a way to do that in yt. That's something that would be very nice to add and would probably be a good introductory yt project for someone who wanted to get more familiar with the codebase.
What you *can* do is take the particle data and plot the positions in a scatter plot using matplotlib.
Unfortunately I don't have a good example of that right now, but it should be pretty straightforward. You just need to read in the x and y particle position fields and then make a scatter plot using e.g. pyplot.plot().
-Nathan
On Wed, May 7, 2014 at 4:32 PM, Jeremy Ritter
wrote:
Hello yt,
Is there an easy way to plot only particles? What I would like to do is plot a z-axis projection of particle x/y positions, with no background data loaded from the grid. I only see examples for annotate_particles() on top of another plot, but I don't want to unnecessarily load grid data.
Thanks! -Jeremy _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
Thanks! On May 7, 2014, at 9:11 PM, Andrew Myers wrote:
Hi Jeremy,
I happened have a script that does this. Something like this should work (in 2.6):
from yt.mods import * import pylab as plt
fn = 'Chombo/releasedExamples/AMRParticleMesh/exec/output/plt256.2d.hdf5' pf = load(fn)
data = pf.h.all_data()
x = data['particle_position_x'] y = data['particle_position_y']
plt.plot(x, y, '.') plt.savefig('scatter')
-Andrew
On Wed, May 7, 2014 at 5:12 PM, Nathan Goldbaum
wrote: Hi Jeremy, Right now there isn't a way to do that in yt. That's something that would be very nice to add and would probably be a good introductory yt project for someone who wanted to get more familiar with the codebase.
What you *can* do is take the particle data and plot the positions in a scatter plot using matplotlib.
Unfortunately I don't have a good example of that right now, but it should be pretty straightforward. You just need to read in the x and y particle position fields and then make a scatter plot using e.g. pyplot.plot().
-Nathan
On Wed, May 7, 2014 at 4:32 PM, Jeremy Ritter
wrote: Hello yt, Is there an easy way to plot only particles? What I would like to do is plot a z-axis projection of particle x/y positions, with no background data loaded from the grid. I only see examples for annotate_particles() on top of another plot, but I don't want to unnecessarily load grid data.
Thanks! -Jeremy _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
Hi Jeremy,
I just issued a PR that adds a bit of functionality you might be interested
in. Check it out here:
https://bitbucket.org/yt_analysis/yt/pull-request/887/color-splatting/diff
You can use it like this:
Npix = 1024
image = np.zeros([Npix, Npix, 4], dtype='float64')
cbx = yt.visualization.color_maps.mcm.Reds
field = (... insert code here to get some floating point array to act as a
color ... )
# Calculate image coordinates ix and iy based on what your view width is
ix = data['particle_position_x'] * (SOME SCALING/SHIFT)
ix = data['particle_position_y'] * (SOME SCALING/SHIFT)
col_field = (col_field - col_field.min()) / (col_field.max() -
col_field.min())
add_rgba_points_to_image(image, ix.astype('float64'), iy.astype('float64'),
cbx(col_field))
yt.write_bitmap(image, 'all_channels.png')
# OR
yt.write_bitmap(image[:,:,:3], 'no_alpha.png')
I need to document this and all that, but I'd like feedback on it if you
have luck with it! I hope to turn it into a more fully-fledged piece of yt
soon.
Cheers,
Sam
On Wed, May 7, 2014 at 7:11 PM, Andrew Myers
Hi Jeremy,
I happened have a script that does this. Something like this should work (in 2.6):
from yt.mods import * import pylab as plt
fn = 'Chombo/releasedExamples/AMRParticleMesh/exec/output/plt256.2d.hdf5' pf = load(fn)
data = pf.h.all_data()
x = data['particle_position_x'] y = data['particle_position_y']
plt.plot(x, y, '.') plt.savefig('scatter')
-Andrew
On Wed, May 7, 2014 at 5:12 PM, Nathan Goldbaum
wrote: Hi Jeremy,
Right now there isn't a way to do that in yt. That's something that would be very nice to add and would probably be a good introductory yt project for someone who wanted to get more familiar with the codebase.
What you *can* do is take the particle data and plot the positions in a scatter plot using matplotlib.
Unfortunately I don't have a good example of that right now, but it should be pretty straightforward. You just need to read in the x and y particle position fields and then make a scatter plot using e.g. pyplot.plot().
-Nathan
On Wed, May 7, 2014 at 4:32 PM, Jeremy Ritter < jritter@astro.as.utexas.edu> wrote:
Hello yt,
Is there an easy way to plot only particles? What I would like to do is plot a z-axis projection of particle x/y positions, with no background data loaded from the grid. I only see examples for annotate_particles() on top of another plot, but I don't want to unnecessarily load grid data.
Thanks! -Jeremy _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
participants (4)
-
Andrew Myers
-
Jeremy Ritter
-
Nathan Goldbaum
-
Sam Skillman