[yt-users] Particles in volume rendering
Stella Offner
soffner at cfa.harvard.edu
Mon Aug 2 09:20:10 PDT 2010
Thanks, Matt and Stephen! The issue here is that I only have a small
number of stars (< 100), so calculating a particle density would
probably cause problems.
It might be possible to use what you suggest below if I don't start
with a blank field filled with zeros (I also will likely plot in log
space). I will play around with some of these things and let you know
if I find something useful...
Stella
>
>
> The main is to define a new field that translates particles to
> density. This
> example picks out star particles; it should be easy to remove this
> if you like
> by eliminating the 'sel' stuff below.
>
> import yt.lagos.UniversalFields as uf
>
> def _pdensity_pyx(field, data):
> blank = na.zeros(data.ActiveDimensions, dtype='float32')
> if data.NumberOfParticles == 0: return blank
> uf.CICDeposit_3(data["particle_position_x"].astype(na.float64),
> data["particle_position_y"].astype(na.float64),
> data["particle_position_z"].astype(na.float64),
> data["particle_mass"].astype(na.float32),
> na.int64(data["particle_mass"].size),
> blank, na.array(data.LeftEdge).astype(na.float64),
> na.array(data.ActiveDimensions).astype(na.int32),
> na.float64(data['dx']))
> return blank
>
> add_field("particle_density_pyx", function=_pdensity_pyx,
> validators=[uf.ValidateSpatial(0)],
> convert_function=uf._convertDensity,
> display_name=r"\mathrm{Particle\ Density})")
>
> Then you can use the field "particle_density_pyx" as you would
> "Density". The
> one thing to worry about in the case of stars, is there can be cells
> with no
> stars in them, which creates problems if you're doing the volume
> rendering in
> log space. Let me know if you have problems!
>
More information about the yt-users
mailing list