[yt-users] scripts, the write_out method, plot_options, and 1D profiles, oh my!

David A. Ventimiglia ventimig at msu.edu
Tue May 12 21:10:18 PDT 2009


Hi Matt,

Thanks, again, for the quick reply.

On Tue, 2009-05-12 at 18:14 -0700, Matthew Turk wrote:
> Hi David,
> 
> Glad to hear that your installation problems have largely been fixed.
> Let's see if we can help out a bit with these other concerns!
> 
> > 1. How do I write scripts?  Presumably, they're Python scripts with the
> > appropriate imports, but what do I import?  When I try, say, 'import
> > yt.lagos as lagos' from within a vanilla Python interpreter, I get this
> > error from with numpy:
> >
> >        ...undefined symbol: PyUnicodeUCS2_FromUnicode
> >
> 
> This usually implies that the python interpreter you are using is not
> the one your extensions were compiled with/against -- can you check
> that you're running the one the install script installed?

Indeed, I was not using the correct python interpreter.  Running python
from the isolated yt directory tree fixed this problem.

> 
> > 2. How do I use the write_out() method to export data?  Specifically, I
> > tried the following, which generated an error:
> >
> >        x = pf.h.ray(0, [0.5, 0.5], "Density")
> >        x.write_out("x.dat",fields=["Density"])
> >
> > Eventually, I'll probably learn how to do everything I need to do from
> > within yt, so this is a lower priority for me.
> 
> Okay, this one I have to say "mea culpa" on.  The release time between
> the yt-1.0 and yt-1.5 has been much longer than anticipated.  The
> actual meaning of pf.h.ray changed in that interim -- in yt-1.0, this
> was an orthogonal ray.  In yt-1.5 (trunk, which I believe you are
> using) it is the *non*-orthogonal ray.  I apologize for the confusion.
>  The following commands work for me:
> 
> x = pf.h.ortho_ray( ... )
> x.write_out( ... )

This also worked perfectly...

> 
> > 3. The background to question no. 2 is that I'd like to generate, not a
> > radial profile, but a 1D profile along one axis through the center of a
> > box, and I thought I'd see what my options are using other plotting
> > tools.  But maybe EnzoOrthoRay isn't even the best way to go about this.
> > What is the best way to make non-radial, 1D profiles along one axis?
> 
> Profiles can be taken with respect to any variable -- and the three
> spatial variables, x,y,z, are available for profiling.  You can do
> something like:
> 
> pc = PlotCollection(pf)
> pc.add_profile_sphere(1.0, '1', ["x", "Density"])

...as did this.

> 
> or any of the other ways that adding profiles work -- just ensure that
> the first field (which will be the field by which the data is binned)
> is "x" or "y" or "z", and it will discretize and average the second
> field into that bin.  This also works for phase space plots, if you
> want to find the average Temperature as a function of Density, for
> instance.
> 
> > 4. I did generate 1D line profiles using PlotCollection.add_ortho_ray
> > (though I guess they're not binned), which may be just what I need.  In
> > that case (and for other plots), how does one change the look of the
> > plot, such as plot ranges, line weights, colors, types, etc.?
> 
> Unfortunately, right now, the means of doing this is kind of finicky.
> The PlotCollection interface to 1D plots is not meant to be extremely
> flexible just yet, but I am working on that front.  What you can do is
> instead plot the data by hand.  You can generate a single 1D profile (
> the example here is a bit complex -- you can strip it down
> substantially -- but it explains it:
> http://yt.enzotools.org/doc/cookbook/making_profiles.html or you can
> add_profile_sphere as above and access the data attribute of the
> returned object) and then plot it yourself with pylab:
> 
> import pylab
> pylab.semilogy(prof1d["x"], prof1d["Density"], lw=2.5, c='g')
> pylab.savefig("hidavid.png")

I haven't tried this, but I've no doubt that when I do tomorrow I'll
find it's just the ticket.

Best,
David

> 
> which would give you a 2.5 pixel wide line in green.  The matplotlib
> documentation ( http://matplotlib.sf.net/ ) has lots of information
> about how to handle these plots.
> 
> I apologize that some of this is a bit trickier than it ought to be --
> one of the downsides of generating a programmatic API is that it can
> get a bit verbose.  I'll work on the plot modification stuff to see if
> I can make that easier.  Additionally, passing arguments to the plot
> itself when making profiles should be a high priority for me, so I
> will work on that as well.  As it stands, by using the PhasePlot and
> then overlaying the line plot on top, you can get a much better
> looking plot, with full customization:
> 
> http://yt.enzotools.org/wiki/Recipes/OverplottingLines
> 
> Let me know if this helped, and how else we can help out!
> 
> -Matt
> _______________________________________________
> 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