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

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


2 new commits in yt-3.0:


https://bitbucket.org/yt_analysis/yt-3.0/changeset/600836b79bb7/
changeset:   600836b79bb7
branch:      yt-3.0
user:        scopatz
date:        2012-08-22 00:26:57
summary:     First cut at FLASH ray data.
affected #:  1 file

diff -r 7a264cfb25050fa21fe962a91eb1cb11af3d3dd0 -r 600836b79bb7823e83d3358a996671036583146d yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -1086,3 +1086,23 @@
     def __call__(self,plot):
         plot._axes.set_title(self.title)
 
+
+class FlashRayDataCallback(PlotCallback):
+    _type_name = "flash_ray_data"
+    def __init__(self, pf, cmap_name='hot'):
+        self.ray_data = pf._handle["RayData"][:]
+        self.ray_data.sort(kind='mergesort')
+        self.cmap_name = cmap_name
+
+    def __call__(self, plot):
+        coords = self.ray_data[:,1:3]
+        power = self.ray_data[:,4]
+        power /= power.max()
+        cx, cy = self.convert_to_plot(plot, coords.T)
+        coords[:,0], coords[:,1] = cx, cy
+        cmap = matplotlib.cm.get_cmap(self.cmap_name)
+
+        plot._axes.hold(True)
+        lc = matplotlib.collections.LineCollection([coords], colors=cmap(power))
+        plot._axes.add_collection(lc)
+        plot._axes.hold(False)



https://bitbucket.org/yt_analysis/yt-3.0/changeset/d1ad831c6afd/
changeset:   d1ad831c6afd
branch:      yt-3.0
user:        scopatz
date:        2012-08-22 00:27:45
summary:     Merge commit
affected #:  3 files

diff -r 600836b79bb7823e83d3358a996671036583146d -r d1ad831c6afd0fe782a2d61f363ea83160e558a6 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -573,6 +573,13 @@
         >>> 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) or \
+            (self.pf.geometry == "polar" and self.axis == 2):
+            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 600836b79bb7823e83d3358a996671036583146d -r d1ad831c6afd0fe782a2d61f363ea83160e558a6 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 600836b79bb7823e83d3358a996671036583146d -r d1ad831c6afd0fe782a2d61f363ea83160e558a6 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`

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