[yt-svn] commit/yt-3.0: MatthewTurk: In FLASH, we had the ordering of the rtz/rzt in Cylindrical and Polar

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Aug 20 12:00:25 PDT 2013


1 new commit in yt-3.0:

https://bitbucket.org/yt_analysis/yt-3.0/commits/12101b782ac8/
Changeset:   12101b782ac8
Branch:      yt-3.0
User:        MatthewTurk
Date:        2013-08-19 18:01:44
Summary:     In FLASH, we had the ordering of the rtz/rzt in Cylindrical and Polar
coordinates backwards.  This fixes that and also fixes the pixelize function to
work properly for FLASH.

Note that we have not yet integrated the polar pixelization directly into
PlotWindow.

This also upcasts FLASH datasets to 64 bit.
Affected #:  4 files

diff -r ee12a3a0500cd4a12aee012bac5b6ef0f1b404e6 -r 12101b782ac8dfa54a0df7833fca0b5bc5d785f6 yt/frontends/flash/data_structures.py
--- a/yt/frontends/flash/data_structures.py
+++ b/yt/frontends/flash/data_structures.py
@@ -444,6 +444,12 @@
                     mylog.warning('Identical domain left edge and right edges '
                                   'along dummy dimension (%i), attempting to read anyway' % d)
                     self.domain_right_edge[d] = self.domain_left_edge[d]+1.0
+        if self.dimensionality < 3 and self.geometry == "cylindrical":
+            mylog.warning("Extending theta dimension to 2PI + left edge.")
+            self.domain_right_edge[2] = self.domain_left_edge[2] + 2*np.pi
+        elif self.dimensionality < 3 and self.geometry == "polar":
+            mylog.warning("Extending theta dimension to 2PI + left edge.")
+            self.domain_right_edge[1] = self.domain_left_edge[1] + 2*np.pi
         self.domain_dimensions = \
             np.array([nblockx*nxb,nblocky*nyb,nblockz*nzb])
 

diff -r ee12a3a0500cd4a12aee012bac5b6ef0f1b404e6 -r 12101b782ac8dfa54a0df7833fca0b5bc5d785f6 yt/frontends/flash/io.py
--- a/yt/frontends/flash/io.py
+++ b/yt/frontends/flash/io.py
@@ -82,7 +82,9 @@
         rv = {}
         for field in fields:
             ftype, fname = field
-            rv[field] = np.empty(size, dtype=f["/%s" % fname].dtype)
+            dt = f["/%s" % fname].dtype
+            if dt == "float32": dt = "float64"
+            rv[field] = np.empty(size, dtype=dt)
         ng = sum(len(c.objs) for c in chunks)
         mylog.debug("Reading %s cells of %s fields in %s blocks",
                     size, [f2 for f1, f2 in fields], ng)

diff -r ee12a3a0500cd4a12aee012bac5b6ef0f1b404e6 -r 12101b782ac8dfa54a0df7833fca0b5bc5d785f6 yt/geometry/coordinate_handler.py
--- a/yt/geometry/coordinate_handler.py
+++ b/yt/geometry/coordinate_handler.py
@@ -189,8 +189,8 @@
 
 class PolarCoordinateHandler(CoordinateHandler):
 
-    def __init__(self, pf, ordering = 'rzt'):
-        if ordering != 'rzt': raise NotImplementedError
+    def __init__(self, pf, ordering = 'rtz'):
+        if ordering != 'rtz': raise NotImplementedError
         super(PolarCoordinateHandler, self).__init__(pf)
 
     def coordinate_fields(self):
@@ -222,7 +222,80 @@
                                  data_source['dr']/2.0,
                                  data_source['theta'],
                                  data_source['dtheta']/2.0,
-                                 size[0], field, bounds[0])
+                                 size[0], data_source[field], bounds[0])
+        return buff
+
+    axis_name = { 0  : 'r',  1  : 'theta',  2  : 'z',
+                 'r' : 'r', 'theta' : 'theta', 'z' : 'z',
+                 'R' : 'r', 'Theta' : 'theta', 'Z' : 'z'}
+
+    axis_id = { 'r' : 0, 'theta' : 1, 'z' : 2,
+                 0  : 0,  1  : 1,  2  : 2}
+
+    x_axis = { 'r' : 1, 'theta' : 0, 'z' : 0,
+                0  : 1,  1  : 0,  2  : 0}
+
+    y_axis = { 'r' : 2, 'theta' : 2, 'z' : 1,
+                0  : 2,  1  : 2,  2  : 1}
+
+    def convert_from_cartesian(self, coord):
+        return cartesian_to_cylindrical(coord)
+
+    def convert_to_cartesian(self, coord):
+        return cylindrical_to_cartesian(coord)
+
+    def convert_to_cylindrical(self, coord):
+        return coord
+
+    def convert_from_cylindrical(self, coord):
+        return coord
+
+    def convert_to_spherical(self, coord):
+        raise NotImplementedError
+
+    def convert_from_spherical(self, coord):
+        raise NotImplementedError
+
+    @property
+    def period(self):
+        return np.array([0.0, 0.0, 2.0*np.pi])
+
+class CylindricalCoordinateHandler(CoordinateHandler):
+
+    def __init__(self, pf, ordering = 'rzt'):
+        if ordering != 'rzt': raise NotImplementedError
+        super(CylindricalCoordinateHandler, self).__init__(pf)
+
+    def coordinate_fields(self):
+        # return the fields for r, z, theta
+        return CylindricalFieldInfo
+
+    def pixelize(self, dimension, data_source, field, bounds, size, antialias = True):
+        ax_name = self.axis_name[dimension]
+        if ax_name in ('r', 'theta'):
+            return self._ortho_pixelize(data_source, field, bounds, size,
+                                        antialias)
+        elif ax_name == "z":
+            return self._cyl_pixelize(data_source, field, bounds, size,
+                                        antialias)
+        else:
+            # Pixelizing along a cylindrical surface is a bit tricky
+            raise NotImplementedError
+
+    def _ortho_pixelize(self, data_source, field, bounds, size, antialias):
+        buff = _MPL.Pixelize(data_source['px'], data_source['py'],
+                             data_source['pdx'], data_source['pdy'],
+                             data_source[field], size[0], size[1],
+                             bounds, int(antialias),
+                             True, self.period).transpose()
+        return buff
+
+    def _cyl_pixelize(self, data_source, field, bounds, size, antialias):
+        buff = pixelize_cylinder(data_source['r'],
+                                 data_source['dr']/2.0,
+                                 data_source['theta'],
+                                 data_source['dtheta']/2.0,
+                                 size[0], data_source[field], bounds[0])
         return buff
 
     axis_name = { 0  : 'r',  1  : 'z',  2  : 'theta',
@@ -260,76 +333,3 @@
     def period(self):
         return np.array([0.0, 0.0, 2.0*np.pi])
 
-class CylindricalCoordinateHandler(CoordinateHandler):
-
-    def __init__(self, pf, ordering = 'rtz'):
-        if ordering != 'rtz': raise NotImplementedError
-        super(CylindricalCoordinateHandler, self).__init__(pf)
-
-    def coordinate_fields(self):
-        # return the fields for r, z, theta
-        return CylindricalFieldInfo
-
-    def pixelize(self, dimension, data_source, field, bounds, size, antialias = True):
-        raise NotImplementedError
-        if dimension == 1:
-            return self._ortho_pixelize(data_source, field, bounds, size,
-                                        antialias)
-        elif dimension == 2:
-            return self._cyl_pixelize(data_source, field, bounds, size,
-                                        antialias)
-        else:
-            # Pixelizing along a cylindrical surface is a bit tricky
-            raise NotImplementedError
-
-    def _ortho_pixelize(self, data_source, field, bounds, size, antialias):
-        buff = _MPL.Pixelize(data_source['px'], data_source['py'],
-                             data_source['pdx'], data_source['pdy'],
-                             data_source[field], size[0], size[1],
-                             bounds, int(antialias),
-                             True, self.period).transpose()
-        return buff
-
-    def _cyl_pixelize(self, data_source, field, bounds, size, antialias):
-        buff = pixelize_cylinder(data_source['r'],
-                                 data_source['dr']/2.0,
-                                 data_source['theta'],
-                                 data_source['dtheta']/2.0,
-                                 size[0], field, bounds[0])
-        return buff
-
-    axis_name = { 0  : 'r',  1  : 'z',  2  : 'theta',
-                 'r' : 'r', 'z' : 'z', 'theta' : 'theta',
-                 'R' : 'r', 'Z' : 'z', 'Theta' : 'theta'}
-
-    axis_id = { 'r' : 0, 'z' : 1, 'theta' : 2,
-                 0  : 0,  1  : 1,  2  : 2}
-
-    x_axis = { 'r' : 1, 'z' : 0, 'theta' : 0,
-                0  : 1,  1  : 0,  2  : 0}
-
-    y_axis = { 'r' : 2, 'z' : 2, 'theta' : 1,
-                0  : 2,  1  : 2,  2  : 1}
-
-    def convert_from_cartesian(self, coord):
-        return cartesian_to_cylindrical(coord)
-
-    def convert_to_cartesian(self, coord):
-        return cylindrical_to_cartesian(coord)
-
-    def convert_to_cylindrical(self, coord):
-        return coord
-
-    def convert_from_cylindrical(self, coord):
-        return coord
-
-    def convert_to_spherical(self, coord):
-        raise NotImplementedError
-
-    def convert_from_spherical(self, coord):
-        raise NotImplementedError
-
-    @property
-    def period(self):
-        return np.array([0.0, 0.0, 2.0*np.pi])
-

diff -r ee12a3a0500cd4a12aee012bac5b6ef0f1b404e6 -r 12101b782ac8dfa54a0df7833fca0b5bc5d785f6 yt/utilities/lib/misc_utilities.pyx
--- a/yt/utilities/lib/misc_utilities.pyx
+++ b/yt/utilities/lib/misc_utilities.pyx
@@ -378,6 +378,8 @@
     raise KeyError
 
 @cython.cdivision(True)
+ at cython.boundscheck(False)
+ at cython.wraparound(False)
 def pixelize_cylinder(np.ndarray[np.float64_t, ndim=1] radius,
                       np.ndarray[np.float64_t, ndim=1] dradius,
                       np.ndarray[np.float64_t, ndim=1] theta,

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

--

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