[yt-users] trouble with callback on phase plot

Christine Simpson csimpson at astro.columbia.edu
Mon Oct 3 11:51:29 PDT 2011


Hey Jeff,

Thanks to you and Matt for fixing this!  The text callback now works.
I'm not sure if you noticed, but I also mentioned that I was having the
same issue with the image_line callback in my ticket on bitbucket (but
not in my original post to this list).  That callback still does not
work.  I posted details to the ticket thread.  I left the ticket open,
but if you still want me to close it, I can.

Christine

On Mon, 2011-10-03 at 10:35 -0700, j s oishi wrote:
> Hi Christine,
> 
> Matt fixed the bug. If you do a yt instinfo -u, you should be able to
> run your original script and it should work. If it does, please close
> the ticket on bitbucket. If it does not, let me know.
> 
> thanks,
> 
> j
> 
> On Sat, Sep 24, 2011 at 12:56 PM, j s oishi <jsoishi at gmail.com> wrote:
> > Hi Christine,
> >
> > Thanks for posting the issue. I'll try to look into this in the next few days.
> >
> > j
> >
> > On Fri, Sep 23, 2011 at 3:55 PM, j s oishi <jsoishi at gmail.com> wrote:
> >> Hi Christine,
> >>
> >> Yup, this is definitely a fairly deep bug. Could you please file a
> >> ticket at the bitbucket site (hg.yt-project.org)? Just record the
> >> problem you're having, and I'll fill in the details below.
> >>
> >> It seems that phase plots actually use matplotlib's pcolormesh to
> >> plot, and this does not have the same image shape as imshow or other
> >> plots; it seems to store the image as a 1D array rather than a 2D
> >> array. This breaks the way the text call back attempts to place text.
> >> Unfortunately, I don't see an easy fix, and I don't have the time at
> >> the moment to sort it out.
> >>
> >> I can offer you a workaround, which is slightly more verbose, but
> >> should do the same thing. If you try
> >>
> >> from yt.mods import *
> >> import yt.visualization.profile_plotter as pp
> >>
> >> phase = pp.PhasePlotter(r200[j],'kpc',["Density","Temperature","CellMassMsun"],weight
> >> = None)
> >> figure, axes = phase.to_mpl()
> >>
> >> axes.hold(True)
> >> axes.text([0.92,0.92],redshift_string,transform = axes.transAxes )
> >>
> >>
> >> from yt.visualization._mpl_imports import \
> >>    FigureCanvasAgg, FigureCanvasPdf
> >> canvas = FigureCanvasPdf(figure)
> >> canvas.print_figure("blah.pdf")
> >> canvas = FigureCanvasAgg(figure)
> >> canvas.print_figure("blah.png")
> >>
> >> that should work. Sorry for the verbosity of this method; it is
> >> somewhat new, but I can say that Matt and I have successfully used it
> >> for exactly this purpose (as seen here:
> >> http://www.slac.stanford.edu/~jsoishi/images/plot.png; those \rho^4/3
> >> labels were done exactly this way).
> >>
> >> Let me know if you need more help.
> >>
> >> j
> >> On Fri, Sep 23, 2011 at 3:16 PM, Christine Simpson
> >> <csimpson at astro.columbia.edu> wrote:
> >>> Hi all,
> >>>
> >>> I'm having trouble adding text through a callback onto a phase plot.
> >>>
> >>> I tried this code:
> >>>
> >>> pc.add_phase_sphere(r200[j],'kpc',["Density","Temperature","CellMassMsun"],weight = None)
> >>> pc.set_zlim(1.0e-2,1.0e5)
> >>> pc.set_xlim(1.0e-30,5.0e-19)
> >>> pc.set_ylim(10.0,1.0e7)
> >>> pc.plots[-1].modify["text"]([0.92,0.92],redshift_string)
> >>>
> >>> pc.save("output_%(file_num)s_branch_%yt-users at lists.spacepope.org(br)i"
> >>> % {"file_num":fn,"axis":ax,"br":branch_index[j]})
> >>>
> >>> And I get this error:
> >>>
> >>> Traceback (most recent call last):
> >>>  File "test_phase_plots.py", line 41, in <module>
> >>>    pc.save("output_%(file_num)s_branch_%(br)i" %
> >>> {"file_num":fn,"axis":ax,"br":branch_index[j]})
> >>>  File
> >>> "/share/home/01112/tg803911/yt_17May2011/yt-x86_64/src/yt-hg/yt/visualization/plot_collection.py", line 157, in save
> >>>    override=override, force_save=force_save))
> >>>  File
> >>> "/share/home/01112/tg803911/yt_17May2011/yt-x86_64/src/yt-hg/yt/visualization/plot_types.py", line 108, in save_image
> >>>    self._redraw_image()
> >>>  File
> >>> "/share/home/01112/tg803911/yt_17May2011/yt-x86_64/src/yt-hg/yt/visualization/plot_types.py", line 903, in _redraw_image
> >>>    self._run_callbacks()
> >>>  File
> >>> "/share/home/01112/tg803911/yt_17May2011/yt-x86_64/src/yt-hg/yt/visualization/plot_types.py", line 800, in _run_callbacks
> >>>    cb(self)
> >>>  File
> >>> "/share/home/01112/tg803911/yt_17May2011/yt-x86_64/src/yt-hg/yt/visualization/plot_modifications.py", line 910, in __call__
> >>>    y = plot.image._A.shape[1] * self.pos[1]
> >>> IndexError: tuple index out of range
> >>>
> >>>
> >>> The error arises in the save command, but the problem only happens when
> >>> I add the modify["text"] command.  Any ideas?
> >>>
> >>> Christine
> >>>
> >>> _______________________________________________
> >>> 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
> 





More information about the yt-users mailing list