[yt-users] adapting multi plot - 3 plots

Elizabeth Harper-Clark h-clark at astro.utoronto.ca
Thu Nov 4 09:07:23 PDT 2010


Erm, *cough*, please ignore me completely. (why do I always figure things
out after sending emails).

Sorry to bother you all.

Libby

ps - if youa re interested p.set_cmap("cold") was the offending part, doh!!

On 4 November 2010 12:04, Elizabeth Harper-Clark
<h-clark at astro.utoronto.ca>wrote:

> Ah, upon further testing the error seems to be related to plotting
> HII_fraction rather than 3 plots. However, I am able to plot HII fraction
> slices fine with the below script:
>
> from yt.mods import *
> import pylab
> import sys
> import cmath
> import matplotlib.ticker
>
> rho_min = 1e-24
> rho_max = 2e-24
>
> ss = 1
>
> centre = (0.511901,  0.452331,  0.434998)
> frame_template = "aaSN/%s/ionisationframezoom_%01i_%04i"
>
> for n in range(132,401,1): # make density projection with particles on
>     print "Dump:", n
>
>     pf = load("SciNet/%s/DD%04i/data%04i" % (sys.argv[-1],n, n))
>     pc = PlotCollection(pf, center=centre)
>     Timemyr = pf["InitialTime"]*pf["years"]/1.e6
>     print "Time(code units):", pf["InitialTime"]
>     for ax in range(3):
>         p = pc.add_slice("HII_Fraction", ax)
>
>         p.set_width(ss, 'pc')
>         sp = pf.h.all_data()
>         if na.any(pf.h.grid_particle_count):
>             colours = sp["ParticleMassMsun"]
>             p.modify["particles"](ss, p_size=6.0, col='k', minimum_mass=
> 6e-26)
>             print "          XXXXX Particles present XXXXX"
>         p.modify["text"]((0.101,0.899),"Time = %8.4f Myr" % (Timemyr),
> text_args = {'color':'k'})
>         p.modify["text"]((0.1,0.9),"Time = %8.4f Myr" % (Timemyr),
> text_args = {'color':'w'})
>         pc.save(frame_template % (sys.argv[-1],ax,n), override=True)
>
> ????
>
>
> On 4 November 2010 11:56, Elizabeth Harper-Clark <
> h-clark at astro.utoronto.ca> wrote:
>
>> Hi all,
>>
>> I have adapted the multi plot script from the cookbook an dit all works as
>> long as I only want 2 plot. When I try to increase to three I get:
>>
>> [h-clark at tpb4 my_scripts]$ python2.6 MultiPlot.py GMCsetup3
>> 1.0 0.714285714286
>> yt         INFO       2010-11-04 11:53:30,115 Created plot collection with
>> default plot-center = [0.51190100000000005, 0.45233099999999998, 0.434998]
>> yt         INFO       2010-11-04 11:53:30,127 Getting the binary hierarchy
>> yt         INFO       2010-11-04 11:53:30,160 Finished with binary
>> hierarchy reading
>> yt         INFO       2010-11-04 11:53:30,253 Adding PotentialField to
>> list of fields
>> yt         INFO       2010-11-04 11:53:30,254 Adding AccelerationField1 to
>> list of fields
>> yt         INFO       2010-11-04 11:53:30,254 Adding HeII_gamma to list of
>> fields
>> yt         INFO       2010-11-04 11:53:30,254 Adding RadAccel1 to list of
>> fields
>> yt         INFO       2010-11-04 11:53:30,254 Adding RadAccel2 to list of
>> fields
>> yt         INFO       2010-11-04 11:53:30,255 Adding RadAccel3 to list of
>> fields
>> yt         INFO       2010-11-04 11:53:30,255 Adding HI_kph to list of
>> fields
>> yt         INFO       2010-11-04 11:53:30,255 Adding HeII_kph to list of
>> fields
>> yt         INFO       2010-11-04 11:53:30,255 Adding HI_gamma to list of
>> fields
>> [0 0 0]
>> yt         INFO       2010-11-04 11:53:31,962 Added slice of Density at x
>> = 0.511901 with 'center' = [0.51190100000000005, 0.45233099999999998,
>> 0.434998]
>> yt         INFO       2010-11-04 11:53:33,265 Added slice of Temperature
>> at x = 0.511901 with 'center' = [0.51190100000000005, 0.45233099999999998,
>> 0.434998]
>> yt         INFO       2010-11-04 11:53:34,933 Added slice of HII_Fraction
>> at x = 0.511901 with 'center' = [0.51190100000000005, 0.45233099999999998,
>> 0.434998]
>> Traceback (most recent call last):
>>   File "MultiPlot.py", line 34, in <module>
>>     fig.savefig(frame_template % (sys.argv[-1],ax,n))
>>   File
>> "/home/h-clark/YT/lib/python2.6/site-packages/matplotlib/figure.py", line
>> 1032, in savefig
>>     self.canvas.print_figure(*args, **kwargs)
>>   File
>> "/home/h-clark/YT/lib/python2.6/site-packages/matplotlib/backend_bases.py",
>> line 1476, in print_figure
>>     **kwargs)
>>   File
>> "/home/h-clark/YT/lib/python2.6/site-packages/matplotlib/backends/backend_agg.py",
>> line 358, in print_png
>>     FigureCanvasAgg.draw(self)
>>   File
>> "/home/h-clark/YT/lib/python2.6/site-packages/matplotlib/backends/backend_agg.py",
>> line 314, in draw
>>     self.figure.draw(self.renderer)
>>   File
>> "/home/h-clark/YT/lib/python2.6/site-packages/matplotlib/artist.py", line
>> 46, in draw_wrapper
>>     draw(artist, renderer, *args, **kwargs)
>>   File
>> "/home/h-clark/YT/lib/python2.6/site-packages/matplotlib/figure.py", line
>> 773, in draw
>>     for a in self.axes: a.draw(renderer)
>>   File
>> "/home/h-clark/YT/lib/python2.6/site-packages/matplotlib/artist.py", line
>> 46, in draw_wrapper
>>     draw(artist, renderer, *args, **kwargs)
>>   File "/home/h-clark/YT/lib/python2.6/site-packages/matplotlib/axes.py",
>> line 1701, in draw
>>     im.draw(renderer)
>>   File
>> "/home/h-clark/YT/lib/python2.6/site-packages/matplotlib/artist.py", line
>> 46, in draw_wrapper
>>     draw(artist, renderer, *args, **kwargs)
>>   File "/home/h-clark/YT/lib/python2.6/site-packages/matplotlib/image.py",
>> line 237, in draw
>>     im = self.make_image(renderer.get_image_magnification())
>>   File "/home/h-clark/YT/lib/python2.6/site-packages/matplotlib/image.py",
>> line 182, in make_image
>>     x = self.to_rgba(self._A, self._alpha)
>>   File "/home/h-clark/YT/lib/python2.6/site-packages/matplotlib/cm.py",
>> line 167, in to_rgba
>>     x = self.cmap(x, alpha=alpha, bytes=bytes)
>> TypeError: 'NoneType' object is not callable
>>
>>
>> *My Script is:*
>>
>> from yt.mods import *
>> import matplotlib.colorbar as cb
>>
>> orient = 'horizontal'
>> frame_template = "aaSN/%s/multiplot_%01i_%04i"
>> centre = (0.511901,  0.452331,  0.434998)
>> ax = 0
>> ss = 1
>> n = 134
>>
>> pf = load("SciNet/%s/DD%04i/data%04i" % (sys.argv[-1],n, n))
>> fig, axes, colorbars = get_multi_plot( 3, 1, colorbar=orient, bw = 4)
>> pc = PlotCollection(pf, center=centre)
>>
>> p = pc.add_slice("Density", ax, figure = fig, axes = axes[0][0],
>> use_colorbar=False)
>> p.set_cmap("bds_highcontrast")
>> p = pc.add_slice("Temperature", ax, figure=fig, axes=axes[0][1],
>> use_colorbar=False)
>> p.set_cmap("hot")
>> p = pc.add_slice("HII_Fraction", ax, figure=fig, axes=axes[0][2],
>> use_colorbar=False)
>> p.set_cmap("cold")
>>
>> p.set_width(ss, 'pc')
>> for p, cax in zip(pc.plots, colorbars):
>>     cbar = cb.Colorbar(cax, p.image, orientation=orient)
>>     p.colorbar = cbar
>>     p._autoset_label()
>> fig.savefig(frame_template % (sys.argv[-1],ax,n))
>>
>>
>>
>> What am I missing?
>>
>> many thanks,
>>
>> Libby
>>
>> --
>> Elizabeth Harper-Clark MA MSci
>> PhD Candidate, Canadian Institute for Theoretical Astrophysics, UofT
>> Sciences and Engineering Coordinator, Teaching Assistants' Training
>> Program, UofT
>>
>> www.astro.utoronto.ca/~h-clark <http://www.astro.utoronto.ca/%7Eh-clark>
>> h-clark at cita.utoronto.ca
>> Astronomy office phone: +1-416-978-5759
>>
>
>
>
> --
> Elizabeth Harper-Clark MA MSci
> PhD Candidate, Canadian Institute for Theoretical Astrophysics, UofT
> Sciences and Engineering Coordinator, Teaching Assistants' Training
> Program, UofT
>
> www.astro.utoronto.ca/~h-clark <http://www.astro.utoronto.ca/%7Eh-clark>
> h-clark at cita.utoronto.ca
> Astronomy office phone: +1-416-978-5759
>



-- 
Elizabeth Harper-Clark MA MSci
PhD Candidate, Canadian Institute for Theoretical Astrophysics, UofT
Sciences and Engineering Coordinator, Teaching Assistants' Training Program,
UofT

www.astro.utoronto.ca/~h-clark <http://www.astro.utoronto.ca/%7Eh-clark>
h-clark at cita.utoronto.ca
Astronomy office phone: +1-416-978-5759
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.spacepope.org/pipermail/yt-users-spacepope.org/attachments/20101104/53fd9a83/attachment.htm>


More information about the yt-users mailing list