[yt-users] YT Phase Plot Loop

Britton Smith brittonsmith at gmail.com
Thu Dec 30 13:11:44 PST 2010


Hi Nick.

I believe the problem is related to the fact that you define the
PlotCollection outside of the (for item in field) loop.  Each time you do
pc.add_phase_sphere, you are adding another item to the PlotCollection,
which contains everything that has been added since it was created.  Thus,
when you call pc.save, it is saving each item in the collection.  To remedy
this, all you need to do is move the pc = PlotCollection line inside the
loop.  Also, adding a "del pc" line at the end of the loop, while probably
not totally necessary, couldn't hurt either.

Britton

On Thu, Dec 30, 2010 at 4:05 PM, Nicholas Earl <earlnich at msu.edu> wrote:

> Hey all,
>
> I am trying to to have yt load up a data set, and then create phase plots
> with varying weighted fields like the script below.
>
> The problem is that when reaches the 'for item in field' loop, after each
> image output, the loop starts over instead of continuing to the next
> field... for instance, the output for a series of numbers representing the
> images would look like this:
>
> 1
> 1
> 2
> 1
> 2
> 3
> 1
> 2
> 3
> 4
> etc
>
> I am not quite sure how to remedy this, so I'm hoping someone could point
> me in the right direction.
>
> Thanks for your efforts!
> Nicholas Earl
>
> from yt.mods import * # set up our namespace
>
> #field = ['Temperature','Cooling_Time']
>
> field =
> ['Cooling_Time','Density','Electron_Fraction','Gas_Energy','H2II_Fraction','H2I_Fraction','HII_Fraction','HI_Fraction','HM_Fraction','HeIII_Fraction','HeII_Fraction','HeI_Fraction','Metal_Fraction','Temperature','Total_Energy','x-velocity','y-velocity']
>
> for n in range(1,402):
>         #for item in field:
>         pf = load("DD%04i/DD%04i" % (n,n))
>         # load dataset
>         #for item in field:
>         pc = PlotCollection(pf, center=[1.0, 0.5, 0.5]) # defaults to
> center at most dense point
>         for item in field:
>                 #value, position = pf.h.find_max("Density")
>                 #print value, position
>                 pc.add_phase_sphere(10.0, "pc", # how many of which unit at
> pc.center
>                         ["Density", "Temperature", "CellMassMsun"], # our
> fields: x, y, color
>                         weight="%s" % (item))# don't take the average value
> in a cell, just sum them up
>                 #print item
>                 pc.save('./denstemp_weighted/%s' % (pf))  # save all plots
>
>
> _______________________________________________
> 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/20101230/28f7bd6c/attachment.htm>


More information about the yt-users mailing list