[yt-svn] commit/yt-3.0: 3 new changesets

Bitbucket commits-noreply at bitbucket.org
Tue Aug 21 12:56:12 PDT 2012


3 new commits in yt-3.0:


https://bitbucket.org/yt_analysis/yt-3.0/changeset/1ee93cc848ce/
changeset:   1ee93cc848ce
branch:      yt-3.0
user:        jzuhone
date:        2012-08-21 21:05:39
summary:     fixed resolution buffers for cylindrical coordinates
affected #:  3 files

diff -r 544d6fe4efe4bdc8421fddcbabe0c2f34c02fcdd -r 1ee93cc848ce190124523526957de8bd2317213e yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -573,6 +573,12 @@
         >>> frb = proj.to_frb( (100.0, 'kpc'), 1024)
         >>> write_image(na.log10(frb["Density"]), 'density_100kpc.png')
         """
+        
+        if self.pf.geometry == "cylindrical" and self.axis == 1:
+            from yt.visualization.fixed_resolution import CylindricalFixedResolutionBuffer
+            frb = CylindricalFixedResolutionBuffer(self, width, resolution)
+            return frb
+        
         if center is None:
             center = self.get_field_parameter("center")
             if center is None:


diff -r 544d6fe4efe4bdc8421fddcbabe0c2f34c02fcdd -r 1ee93cc848ce190124523526957de8bd2317213e yt/utilities/lib/misc_utilities.pyx
--- a/yt/utilities/lib/misc_utilities.pyx
+++ b/yt/utilities/lib/misc_utilities.pyx
@@ -26,6 +26,7 @@
 import numpy as np
 cimport numpy as np
 cimport cython
+cimport libc.math as math
 
 cdef extern from "stdlib.h":
     # NOTE that size_t might not be int
@@ -334,3 +335,51 @@
                     rg[2,i,j,k] = zg[i,j,k] - c[2]
         return rg
 
+ at cython.cdivision(True)
+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,
+                      np.ndarray[np.float64_t, ndim=1] dtheta,
+                      int buff_size,
+                      np.ndarray[np.float64_t, ndim=1] field,
+                      np.float64_t rmax=-1.0) :
+
+    cdef np.ndarray[np.float64_t, ndim=2] img
+    cdef np.float64_t x, y, dx, dy, r0, theta0
+    cdef np.float64_t r_i, theta_i, dr_i, dtheta_i, dthetamin
+    cdef int i, pi, pj
+    
+    if rmax < 0.0 :
+        imax = radius.argmax()
+        rmax = radius[imax] + dradius[imax]
+          
+    img = np.zeros((buff_size, buff_size))
+    extents = [-rmax, rmax] * 2
+    dx = (extents[1] - extents[0]) / img.shape[0]
+    dy = (extents[3] - extents[2]) / img.shape[1]
+      
+    dthetamin = dx / rmax
+      
+    for i in range(radius.shape[0]):
+
+        r0 = radius[i]
+        theta0 = theta[i]
+        dr_i = dradius[i]
+        dtheta_i = dtheta[i]
+
+        theta_i = theta0 - dtheta_i
+        while theta_i < theta0 + dtheta_i:
+            r_i = r0 - dr_i
+            while r_i < r0 + dr_i:
+                if rmax <= r_i:
+                    r_i += 0.5*dx 
+                    continue
+                x = r_i * math.cos(theta_i)
+                y = r_i * math.sin(theta_i)
+                pi = <int>((x + rmax)/dx)
+                pj = <int>((y + rmax)/dy)
+                img[pi, pj] = field[i]
+                r_i += 0.5*dx 
+            theta_i += dthetamin
+
+    return img


diff -r 544d6fe4efe4bdc8421fddcbabe0c2f34c02fcdd -r 1ee93cc848ce190124523526957de8bd2317213e yt/visualization/fixed_resolution.py
--- a/yt/visualization/fixed_resolution.py
+++ b/yt/visualization/fixed_resolution.py
@@ -28,6 +28,8 @@
     x_dict, \
     y_dict, \
     axis_names
+from yt.utilities.lib.misc_utilities import \
+    pixelize_cylinder
 import _MPL
 import numpy as na
 import weakref
@@ -368,6 +370,30 @@
         rv[yn] = (self.bounds[2], self.bounds[3])
         return rv
 
+class CylindricalFixedResolutionBuffer(FixedResolutionBuffer):
+
+    def __init__(self, data_source, radius, buff_size, antialias = True) :
+
+        self.data_source = data_source
+        self.pf = data_source.pf
+        self.radius = radius
+        self.buff_size = buff_size
+        self.antialias = antialias
+        self.data = {}
+        
+        h = getattr(data_source, "hierarchy", None)
+        if h is not None:
+            h.plots.append(weakref.proxy(self))
+
+    def __getitem__(self, item) :
+        if item in self.data: return self.data[item]
+        buff = pixelize_cylinder(self.data_source["r"], self.data_source["dr"],
+                                 self.data_source["theta"], self.data_source["dtheta"],
+                                 self.buff_size, self.data_source[item].astype("float64"),
+                                 self.radius)
+        self[item] = buff
+        return buff
+        
 class ObliqueFixedResolutionBuffer(FixedResolutionBuffer):
     """
     This object is a subclass of :class:`yt.visualization.fixed_resolution.FixedResolutionBuffer`



https://bitbucket.org/yt_analysis/yt-3.0/changeset/5ac8e5582b9f/
changeset:   5ac8e5582b9f
branch:      yt-3.0
user:        jzuhone
date:        2012-08-21 21:19:08
summary:     Merging
affected #:  2 files

diff -r 1ee93cc848ce190124523526957de8bd2317213e -r 5ac8e5582b9fb67f60b184ec6c4b178eeec16a2c yt/frontends/flash/data_structures.py
--- a/yt/frontends/flash/data_structures.py
+++ b/yt/frontends/flash/data_structures.py
@@ -44,7 +44,7 @@
     io_registry
 
 from .fields import FLASHFieldInfo, add_flash_field, KnownFLASHFields, \
-    CylindricalFLASHFieldInfo
+    CylindricalFLASHFieldInfo, PolarFLASHFieldInfo
 from yt.data_objects.field_info_container import FieldInfoContainer, NullFunc, \
      ValidateDataField
 
@@ -408,6 +408,8 @@
             self._setup_cartesian_coordinates()
         elif self.geometry == "cylindrical":
             self._setup_cylindrical_coordinates()
+        elif self.geometry == "polar":
+            self._setup_polar_coordinates()
         else:
             raise YTGeometryNotSupported(self.geometry)
 
@@ -443,6 +445,9 @@
             self.domain_left_edge[2] = 0.0
             self.domain_right_edge[2] = 2.0 * na.pi
 
+    def _setup_polar_coordinates(self):
+        pass
+
     @property
     def _fieldinfo_fallback(self):
         geom = self.parameters.get("geometry", "cartesian")
@@ -450,6 +455,8 @@
             return FLASHFieldInfo
         elif geom == "cylindrical":
             return CylindricalFLASHFieldInfo
+        elif geom == "polar":
+            return PolarFLASHFieldInfo
         else:
             raise RuntimeError
 


diff -r 1ee93cc848ce190124523526957de8bd2317213e -r 5ac8e5582b9fb67f60b184ec6c4b178eeec16a2c yt/frontends/flash/fields.py
--- a/yt/frontends/flash/fields.py
+++ b/yt/frontends/flash/fields.py
@@ -47,6 +47,9 @@
 CylindricalFLASHFieldInfo = FieldInfoContainer.create_with_fallback(FLASHFieldInfo)
 add_cyl_field = CylindricalFLASHFieldInfo.add_field
 
+PolarFLASHFieldInfo = FieldInfoContainer.create_with_fallback(FLASHFieldInfo)
+add_pol_field = PolarFLASHFieldInfo.add_field
+
 # Common fields in FLASH: (Thanks to John ZuHone for this list)
 #
 # dens gas mass density (g/cc) --
@@ -309,3 +312,40 @@
 def _CylindricalVolume(field, data):
     return data["dtheta"] * data["r"] * data["dr"] * data["dz"]
 add_cyl_field("CellVolume", function=_CylindricalVolume)
+
+## Polar fields
+
+add_pol_field("dx", function=_unknown_coord)
+add_pol_field("dy", function=_unknown_coord)
+add_pol_field("x", function=_unknown_coord)
+add_pol_field("y", function=_unknown_coord)
+
+def _dr(field, data):
+    return na.ones(data.ActiveDimensions, dtype='float64') * data.dds[0]
+add_pol_field('dr', function=_dr, display_field=False,
+          validators=[ValidateSpatial(0)])
+
+def _dtheta(field, data):
+    return na.ones(data.ActiveDimensions, dtype='float64') * data.dds[1]
+add_pol_field('dtheta', function=_dtheta,
+          display_field=False, validators=[ValidateSpatial(0)])
+
+def _coordR(field, data):
+    dim = data.ActiveDimensions[0]
+    return (na.ones(data.ActiveDimensions, dtype='float64')
+                   * na.arange(data.ActiveDimensions[0])[:,None,None]
+            +0.5) * data['dr'] + data.LeftEdge[0]
+add_pol_field('r', function=_coordR, display_field=False,
+          validators=[ValidateSpatial(0)])
+
+def _coordTheta(field, data):
+    dim = data.ActiveDimensions[2]
+    return (na.ones(data.ActiveDimensions, dtype='float64')
+                   * na.arange(data.ActiveDimensions[1])[None,:,None]
+            +0.5) * data['dtheta'] + data.LeftEdge[1]
+add_pol_field('theta', function=_coordTheta, display_field=False,
+          validators=[ValidateSpatial(0)])
+
+def _CylindricalVolume(field, data):
+    return data["dtheta"] * data["r"] * data["dr"] * data["dz"]
+add_pol_field("CellVolume", function=_CylindricalVolume)



https://bitbucket.org/yt_analysis/yt-3.0/changeset/687463a42800/
changeset:   687463a42800
branch:      yt-3.0
user:        jzuhone
date:        2012-08-21 21:54:53
summary:     Making the cylindrical fixed resolution buffers available to datasets with polar geometry.
affected #:  1 file

diff -r 5ac8e5582b9fb67f60b184ec6c4b178eeec16a2c -r 687463a4280083e1e2e63c61bd3b60ce28915577 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -574,7 +574,8 @@
         >>> write_image(na.log10(frb["Density"]), 'density_100kpc.png')
         """
         
-        if self.pf.geometry == "cylindrical" and self.axis == 1:
+        if (self.pf.geometry == "cylindrical" and self.axis == 1) or \
+            (self.pf.geometry == "polar" and self.axis == 2):
             from yt.visualization.fixed_resolution import CylindricalFixedResolutionBuffer
             frb = CylindricalFixedResolutionBuffer(self, width, resolution)
             return frb

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