[yt-users] Annotating particles in Flash with different sizes

Nathan Goldbaum nathan12343 at gmail.com
Sat Nov 19 18:06:05 PST 2016


OK, sorry for the confusion earlier. Never reply to mailing list questions
on your phone!

The issue is that the ParticleCallback (the class that gets invoked when
you call annotate_particles, see yt/visualization/plot_modifcations.py for
more details) generates the list of particles to plot based on a region
data object that it constructs inline, which is *not* necessarily the same
as your "dd" data object that you're using to generate the list of particle
sizes to pass to the p_size keyword argument. In fact, looking at the code,
I suspect we've always expected p_size to be a scalar and it's basically an
accident that it seems to work when you pass it an array of particle sizes.
This means that the mapping from particles to particle sizes is basically
random - it will only be exactly the same if the two data objects happen to
be exactly the same.

I think the best way forward here would be to allow you to specify a custom
data object to gather the particles from, instead of only using the region
generated by the _get_region function defined here:

https://bitbucket.org/yt_analysis/yt/src/9f4dc27f7c8fd399a35e04d0423298753b2994c9/yt/visualization/plot_modifications.py?at=yt&fileviewer=file-view-default#plot_modifications.py-1640

It would also probably be a good idea to error out if you pass a non-scalar
p_size without supplying a custom data object to avoid silently producing
an incorrect result.

I think this would be a relatively straightforward modification to yt, if
you're willing to give it a shot it would be a welcome contribution. I'm
happy to help out with getting your development environment set up and
answering questions.

If you don't want to do that, your custom call to ax.scatter should work
fine. The reason you need to call prj.show() for it to work correctly is
due to the design of the plotting system: plots aren't actually "valid"
until just before they're displayed or saved to disk. You actually don't
need to call prj.show(), you can instead call the lower level
prj._setup_plots() function to get the same effect.

In the long run, I'd like to hide this possibly confusing implementation
detail from users, possibly by making the .plots attribute of the
ProjectionPlot or the .ax attribute of the indifvidual plot objects a
property that calls _setup_plots, so the plot is always constructed and
valid before you do any custom modifications.

I'd actually go so far as to call the need to call _setup_plots(), save(),
or show() before doing custom modifications is a bug, please feel free to
report this as such so we don't lose track. I have some time tomorrow, I
might take a shot at fixing this since it is indeed quite confusing, and
your e-mail here has popped up into the top of my stack of possible ways to
improve yt :)

Anyway, I hope that wasn't too much detail and that it was a helpful
explanation.

Best,

Nathan Goldbaum

On Sat, Nov 19, 2016 at 8:40 PM, Nathan Goldbaum <nathan12343 at gmail.com>
wrote:

> Oh wait, I see, you want to specify the particle sizes when you call
> annotate_particles. Let me see if that's possible right now....
>
> On Sat, Nov 19, 2016 at 8:02 PM Nathan Goldbaum <nathan12343 at gmail.com>
> wrote:
>
>> Hi Josh,
>>
>> Sorry, it's not clear what the difference is, can you explain that a
>> little bit more clearly?
>>
>> Is there any chance you can upload one of your datasets that has this
>> issue so one of us can reproduce the issue locally?
>>
>> Nathan
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20161119/6b7ca7ea/attachment.html>


More information about the yt-users mailing list