[yt-svn] commit/yt: MatthewTurk: Moving _fix_axis to yt/funcs.py as fix_axis, and using it in the PlotWindow so

Bitbucket commits-noreply at bitbucket.org
Tue Jul 24 13:03:09 PDT 2012


1 new commit in yt:


https://bitbucket.org/yt_analysis/yt/changeset/728ec0b440b8/
changeset:   728ec0b440b8
branch:      yt
user:        MatthewTurk
date:        2012-07-24 21:55:11
summary:     Moving _fix_axis to yt/funcs.py as fix_axis, and using it in the PlotWindow so
that 'x', 'y', 'z' can be used directly as axis arguments.
affected #:  3 files

diff -r 8effc60ac29e593931d318f68bd3f2ecb72880fc -r 728ec0b440b8c2f3f062344167859831fe8761dd yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -31,6 +31,7 @@
 
 from yt.utilities.exceptions import *
 from yt.utilities.logger import ytLogger as mylog
+from yt.utilities.definitions import inv_axis_names, axis_names, x_dict, y_dict
 import yt.utilities.progressbar as pb
 import yt.utilities.rpdb as rpdb
 from collections import defaultdict
@@ -561,4 +562,5 @@
         return os.environ.get("OMP_NUM_THREADS", 0)
     return nt
         
-
+def fix_axis(axis):
+    return inv_axis_names.get(axis, axis)


diff -r 8effc60ac29e593931d318f68bd3f2ecb72880fc -r 728ec0b440b8c2f3f062344167859831fe8761dd yt/visualization/plot_collection.py
--- a/yt/visualization/plot_collection.py
+++ b/yt/visualization/plot_collection.py
@@ -62,10 +62,6 @@
         outfile.addPage(infile.getPage(0))
     outfile.write(open(output_fn, "wb"))
 
-def _fix_axis(axis):
-    return inv_axis_names.get(axis, axis)
-
-
 class ImageCollection(object):
     def __init__(self, pf, name):
         self.pf = pf
@@ -424,7 +420,7 @@
         >>> pc = PlotCollection(pf, [0.5, 0.5, 0.5])
         >>> p = pc.add_slice("Density", 'x')
         """
-        axis = _fix_axis(axis)
+        axis = fix_axis(axis)
         if center == None:
             center = self.c
         if coord == None:
@@ -497,7 +493,7 @@
         >>> pc = PlotCollection(pf, [0.5, 0.5, 0.5])
         >>> p = pc.add_particles(0, 1.0)
         """
-        axis = _fix_axis(axis)
+        axis = fix_axis(axis)
         LE = self.pf.domain_left_edge.copy()
         RE = self.pf.domain_right_edge.copy()
         LE[axis] = self.c[axis] - width/2.0
@@ -778,7 +774,7 @@
         >>> pc = PlotCollection(pf, [0.5, 0.5, 0.5])
         >>> p = pc.add_projection("Density", 'x', "Density")
         """
-        axis = _fix_axis(axis)
+        axis = fix_axis(axis)
         if field_parameters is None: field_parameters = {}
         if center == None:
             center = self.c
@@ -867,7 +863,7 @@
         >>> pc = PlotCollection(pf, [0.5, 0.5, 0.5])
         >>> p = pc.add_thin_projection("Density", 0, 0.1, "Density")
         """
-        axis = _fix_axis(axis)
+        axis = fix_axis(axis)
         if field_parameters is None: field_parameters = {}
         if center == None:
             center = self.c
@@ -1460,7 +1456,7 @@
         >>> pc = PlotCollection(pf, [0.5, 0.5, 0.5])
         >>> p = pc.add_ortho_ray(0, (0.5, 0.5), "Density")
         """
-        axis = _fix_axis(axis)
+        axis = fix_axis(axis)
         if field_parameters is None: field_parameters = {}
         if plot_options is None: plot_options = {}
         data_source = self.pf.h.ortho_ray(axis, coords, field,


diff -r 8effc60ac29e593931d318f68bd3f2ecb72880fc -r 728ec0b440b8c2f3f062344167859831fe8761dd yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -695,8 +695,9 @@
         pf : `StaticOutput`
              This is the parameter file object corresponding to the
              simulation output to be plotted.
-        axis : int
-             An int corresponding to the axis to slice along.  (0=x, 1=y, 2=z)
+        axis : int or one of 'x', 'y', 'z'
+             An int corresponding to the axis to slice along (0=x, 1=y, 2=z)
+             or the axis name itself
         fields : string
              The name of the field(s) to be plotted.
         center : two or three-element vector of sequence floats, 'c', or 'center'
@@ -725,6 +726,7 @@
         >>> p.save('sliceplot')
         
         """
+        axis = fix_axis(axis)
         (bounds,center) = GetBoundsAndCenter(axis,center,width,pf)
         slice = pf.h.slice(axis,center[axis],fields=fields)
         PWViewerMPL.__init__(self,slice,bounds,origin=origin)
@@ -746,8 +748,9 @@
         pf : `StaticOutput`
             This is the parameter file object corresponding to the
             simulation output to be plotted.
-        axis : int
-            An int corresponding to the axis to slice along.  (0=x, 1=y, 2=z)
+        axis : int or one of 'x', 'y', 'z'
+             An int corresponding to the axis to slice along (0=x, 1=y, 2=z)
+             or the axis name itself
         fields : string
             The name of the field(s) to be plotted.
         center : A two or three-element vector of sequence floats, 'c', or 'center'
@@ -780,6 +783,7 @@
         >>> p.save('sliceplot')
         
         """
+        axis = fix_axis(axis)
         (bounds,center) = GetBoundsAndCenter(axis,center,width,pf)
         proj = pf.h.proj(axis,fields,weight_field=weight_field,max_level=max_level,center=center)
         PWViewerMPL.__init__(self,proj,bounds,origin=origin)

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list