[yt-users] How ot overplot star particles on density projections

Nathan Goldbaum nathan12343 at gmail.com
Sun Jul 21 08:31:49 PDT 2013


Just as an update, Latif and I were able to work this out off-list and he
is able to make his multipanel annotated plot using the code from my PR.


On Sat, Jul 20, 2013 at 7:14 PM, Nathan Goldbaum <nathan12343 at gmail.com>wrote:

> Hi Latif,
>
> It's hard to say without knowing more information.
>
> What's the output of 'yt inst_info'?  Can you also paste the plotting
> script you're using, if it's different from the one I pasted in the pull
> request?
>
> You'll probably need to make some changes to your initial script to get it
> to work correctly with my changes, compare with the script I pasted in the
> pull request description.  Note how I don't alias the figure, only the axes.
>
> -Nathan
>
>
> On Sat, Jul 20, 2013 at 7:06 PM, Latif <latifne at gmail.com> wrote:
>
>> Hi Nathan,
>> Many thanks for your efforts. Unfortunately, I am still getting empty
>> plots. It seems that I am using stable version and may be the changes are
>> not merged properly in my copy. Could it be the case? otherwise should have
>> worked. What do you say?
>> Cheers
>> Latif
>>
>>
>> On Sun, Jul 21, 2013 at 3:00 AM, Nathan Goldbaum <nathan12343 at gmail.com>wrote:
>>
>>> Hi Latif,
>>>
>>> I've issued a pull request that should allow a plotting script similar
>>> to the one you pasted to work.  The pull request is here:
>>> https://bitbucket.org/yt_analysis/yt/pull-request/556
>>>
>>> To merge the patch into your local copy, do the following:
>>>
>>> $ cd $YT_HG
>>> $ hg pull -r 6f91fb2 https://bitbucket.org/ngoldbaum/yt
>>> $ python setup.py build_ext -i
>>>
>>> Take a look at the multipanel plotting script I pasted into the PR
>>> description.  I think something like that should work for your use case.
>>>
>>> Hope that helps,
>>>
>>> Nathan Goldbaum
>>>
>>>
>>> On Fri, Jul 19, 2013 at 5:02 PM, Nathan Goldbaum <nathan12343 at gmail.com>wrote:
>>>
>>>> Hi Latif,
>>>>
>>>> Unfortunately I don't think Matt's suggestion will work.  What happens
>>>> for these plots is the matplotlib figure object doesn't persist whenever
>>>> you make a modification or call _setup_pltos(). Instead, a new matplotlib
>>>> figure is generated and the old one is discarded.  So what's happening in
>>>> your script is the annotated plots are drawn on an entirely new figure
>>>> object rather than the one you've assigned, while the original figure that
>>>> you set up is left blank, yielding the blank plots you're seeing in the end.
>>>>
>>>> There might be a hacky way around this, but I still think the most
>>>> natural way to do what you're doing is to add the particles to the plot by
>>>> hand, following what happens in the original plot modification.
>>>>
>>>> I'd like to make it so manipulations like what you're trying to do and
>>>> what Matt suggested will work by persisting figures as plots get modified,
>>>> as this will make it much easier to set up animations and some other cool
>>>> stuff, but it will require some modifications to yt's plotting
>>>> infrastructure to ensure that figures are updated rather than just
>>>> discarded.
>>>>
>>>> Hope that helps, sorry that I don't have a suggestion that will work
>>>> using Matt's somewhat simpler suggestion.
>>>>
>>>> -Nathan
>>>>
>>>>
>>>> On Fri, Jul 19, 2013 at 4:48 PM, Latif <latifne at gmail.com> wrote:
>>>>
>>>>> Hi Matt and Nathan,
>>>>> Thank you for your help.  I think Matt's idea is very good and bit
>>>>> easy.  Unfortunately, I didn't get success with it yet.  I am getting empty
>>>>> panels.  Matt, Is it close to what you suggested?  It is most likely that I
>>>>> am messing up some thing due to my poor understanding.  Here is my script.
>>>>> Do you guys know what is going wrong here.
>>>>>
>>>>> http://paste.yt-project.org/show/3708/
>>>>>
>>>>> Cheers
>>>>> Latif
>>>>>
>>>>>
>>>>> On Fri, Jul 19, 2013 at 3:53 PM, Matthew Turk <matthewturk at gmail.com>wrote:
>>>>>
>>>>>> Hi Latif,
>>>>>>
>>>>>> On Fri, Jul 19, 2013 at 9:48 AM, Latif <latifne at gmail.com> wrote:
>>>>>> > Hi all,
>>>>>> > Is there any way to annotate particles to the multi-plot
>>>>>> porjections/slices?
>>>>>> > I am using the following recipe from the webpage.
>>>>>> >
>>>>>> > http://yt-project.org/doc/cookbook/multi_plot_slice_and_proj.py
>>>>>> >
>>>>>> > thanks in advance,
>>>>>> >
>>>>>> > Cheers
>>>>>> > Latif
>>>>>>
>>>>>> Unfortunately this is a lot harder, as the FRBs used there do not
>>>>>> expose the same annotate_* methods that the sliceplot, projectionplot,
>>>>>> etc do.
>>>>>>
>>>>>> However, you *may* be able to do something similar, although I have
>>>>>> not tested it, by creating a ProjectionPlot or SlicePlot, then
>>>>>> swapping out the .axes and .figure objects that resides on the plot
>>>>>> object itself.  Then you can call ._setup_plots() on the
>>>>>> ProjectionPlot or SlicePlot, and it should re-create all the necessary
>>>>>> info.
>>>>>>
>>>>>> So it would look something like this, once you have the axes objects
>>>>>> you're interested in from the recipe you linked to:
>>>>>>
>>>>>> p = ProjectionPlot( ... )
>>>>>> p.plots["Density"].figure = fig
>>>>>> p.plots["Density"].axes = dens_axes[0]
>>>>>> p.annotate_whatever()
>>>>>> p._setup_plots()
>>>>>>
>>>>>> Then you can call:
>>>>>>
>>>>>> fig.savefig("%s_3x2" % pf)
>>>>>>
>>>>>> This is all very rough, but I think it should get you there.
>>>>>>
>>>>>> -Matt
>>>>>>
>>>>>> >
>>>>>> >
>>>>>> > On Thu, Jul 4, 2013 at 9:43 PM, Latif <latifne at gmail.com> wrote:
>>>>>> >>
>>>>>> >> HI Matt,
>>>>>> >> Thank you for a prompt and precise response.
>>>>>> >> Cheers
>>>>>> >> Latif
>>>>>> >>
>>>>>> >>
>>>>>> >>
>>>>>> >> On Thu, Jul 4, 2013 at 7:04 PM, Matthew Turk <
>>>>>> matthewturk at gmail.com>
>>>>>> >> wrote:
>>>>>> >>>
>>>>>> >>> Hi Latif,
>>>>>> >>>
>>>>>> >>> The callback you're looking for is "particles" and you can
>>>>>> specify a
>>>>>> >>> "ptype" argument for specifying the type of particles.  (If you're
>>>>>> >>> using Enzo, this should be the number in the "particle_type"
>>>>>> field you
>>>>>> >>> are selecting.)  Note also that annotate_particles accepts a width
>>>>>> >>> argument, in code units, which says how wide the selected region
>>>>>> will
>>>>>> >>> be around the center of the slice or the center of the box for
>>>>>> >>> projections.  So if you are using a projection and you want the
>>>>>> whole
>>>>>> >>> box, you can do 1.0/pf['unitary'] to get the full domain.
>>>>>> >>>
>>>>>> >>> Here is an example:
>>>>>> >>>
>>>>>> >>> s = SlicePlot(pf, "x", "Density")
>>>>>> >>> s.annotate_particles(1.0/pf['kpc'], p_size = 1.0, ptype = 1)
>>>>>> >>>
>>>>>> >>> which will choose particle_type = =1.
>>>>>> >>>
>>>>>> >>> -Matt
>>>>>> >>>
>>>>>> >>> On Thu, Jul 4, 2013 at 10:20 AM, Latif <latifne at gmail.com> wrote:
>>>>>> >>> > Hi all,
>>>>>> >>> > I want to overplot star particles on density
>>>>>> projections/slices. It is
>>>>>> >>> > probably a very simple question but could not figure out how to
>>>>>> do it.
>>>>>> >>> > Can
>>>>>> >>> > I also get information about their position and velocities as
>>>>>> well?
>>>>>> >>> > thanks in advance,
>>>>>> >>> > Cheers
>>>>>> >>> > Latif
>>>>>> >>> >
>>>>>> >>> > _______________________________________________
>>>>>> >>> > 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
>>>>>> >
>>>>>> _______________________________________________
>>>>>> 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
>>>
>>>
>>
>> _______________________________________________
>> yt-users mailing list
>> yt-users at lists.spacepope.org
>> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20130721/344fc4da/attachment.html>


More information about the yt-users mailing list