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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Mar 18 12:28:21 PDT 2013


3 new commits in yt-3.0:

https://bitbucket.org/yt_analysis/yt-3.0/commits/d7a076d0ff01/
changeset:   d7a076d0ff01
branch:      yt-3.0
user:        drudd
date:        2013-03-15 00:52:32
summary:     Updates to SphereSelector to allow for periodicity and turn back on grid selection
affected #:  2 files

diff -r a71dffe4bc813fdadc506ccad9efb632e23dc843 -r d7a076d0ff01055eaec8d3c7005e1070a0e4ac90 yt/data_objects/selection_data_containers.py
--- a/yt/data_objects/selection_data_containers.py
+++ b/yt/data_objects/selection_data_containers.py
@@ -928,7 +928,6 @@
             raise YTSphereTooSmall(pf, radius, self.hierarchy.get_smallest_dx())
         self.set_field_parameter('radius',radius)
         self.radius = radius
-        self.DW = self.pf.domain_right_edge - self.pf.domain_left_edge
 
 class YTEllipsoidBase(YTSelectionContainer3D):
     """

diff -r a71dffe4bc813fdadc506ccad9efb632e23dc843 -r d7a076d0ff01055eaec8d3c7005e1070a0e4ac90 yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -407,12 +407,22 @@
 cdef class SphereSelector(SelectorObject):
     cdef np.float64_t radius2
     cdef np.float64_t center[3]
+    cdef np.float64_t domain_left_edge[3]
+    cdef np.float64_t domain_right_edge[3]
+    cdef np.float64_t domain_width[3]
+    cdef bint periodicity[3]
 
     def __init__(self, dobj):
         for i in range(3):
             self.center[i] = dobj.center[i]
         self.radius2 = dobj.radius * dobj.radius
 
+        for i in range(3) :
+            self.domain_left_edge[i] = dobj.pf.domain_left_edge[i]
+            self.domain_right_edge[i] = dobj.pf.domain_right_edge[i]
+            self.domain_width[i] = self.domain_right_edge[i] - self.domain_left_edge[i]
+            self.periodicity[i] = dobj.pf.periodicity[i]
+
     @cython.boundscheck(False)
     @cython.wraparound(False)
     @cython.cdivision(True)
@@ -420,8 +430,7 @@
                                np.float64_t right_edge[3],
                                np.int32_t level) nogil:
         cdef np.float64_t box_center, relcenter, closest, dist, edge
-        return 1
-        cdef int id
+        cdef int i
         if (left_edge[0] <= self.center[0] <= right_edge[0] and
             left_edge[1] <= self.center[1] <= right_edge[1] and
             left_edge[2] <= self.center[2] <= right_edge[2]):
@@ -431,10 +440,15 @@
         for i in range(3):
             box_center = (right_edge[i] + left_edge[i])/2.0
             relcenter = self.center[i] - box_center
+            if self.periodicity[i]:
+                if relcenter > self.domain_width[i]/2.0: 
+                    relcenter -= self.domain_width[i] 
+                elif relcenter < -self.domain_width[i]/2.0: 
+                    relcenter += self.domain_width[i] 
             edge = right_edge[i] - left_edge[i]
             closest = relcenter - fclip(relcenter, -edge/2.0, edge/2.0)
             dist += closest * closest
-        if dist < self.radius2: return 1
+        if dist <= self.radius2: return 1
         return 0
 
     @cython.boundscheck(False)
@@ -444,10 +458,20 @@
                          int eterm[3]) nogil:
         cdef np.float64_t dist2, temp
         cdef int i
+        if (pos[0] - 0.5*dds[0] <= self.center[0] <= pos[0]+0.5*dds[0] and
+            pos[1] - 0.5*dds[1] <= self.center[1] <= pos[1]+0.5*dds[1] and
+            pos[2] - 0.5*dds[2] <= self.center[2] <= pos[2]+0.5*dds[2]):
+            return 1
         dist2 = 0
         for i in range(3):
-            temp = (pos[i] - self.center[i])
-            dist2 += temp * temp
+            temp = self.center[i] - pos[i]
+            if self.periodicity[i]:
+                if temp > self.domain_width[i]/2.0:
+                    temp -= self.domain_width[i]
+                elif temp < -self.domain_width[i]/2.0:
+                    temp += self.domain_width[i]
+            temp = temp - fclip(temp, -dds[i]/2.0, dds[i]/2.0)
+            dist2 += temp*temp
         if dist2 <= self.radius2: return 1
         return 0
 


https://bitbucket.org/yt_analysis/yt-3.0/commits/2f14933d1904/
changeset:   2f14933d1904
branch:      yt-3.0
user:        drudd
date:        2013-03-15 21:08:41
summary:     Re-enabled select_grids for SphereSelector and added periodicity check
affected #:  2 files

diff -r d7a076d0ff01055eaec8d3c7005e1070a0e4ac90 -r 2f14933d1904ac50f512ae72f2200c5c2dc769ff yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -407,8 +407,6 @@
 cdef class SphereSelector(SelectorObject):
     cdef np.float64_t radius2
     cdef np.float64_t center[3]
-    cdef np.float64_t domain_left_edge[3]
-    cdef np.float64_t domain_right_edge[3]
     cdef np.float64_t domain_width[3]
     cdef bint periodicity[3]
 
@@ -418,11 +416,10 @@
         self.radius2 = dobj.radius * dobj.radius
 
         for i in range(3) :
-            self.domain_left_edge[i] = dobj.pf.domain_left_edge[i]
-            self.domain_right_edge[i] = dobj.pf.domain_right_edge[i]
-            self.domain_width[i] = self.domain_right_edge[i] - self.domain_left_edge[i]
+            self.domain_width[i] = dobj.pf.domain_right_edge[i] - \
+                                   dobj.pf.domain_left_edge[i]
             self.periodicity[i] = dobj.pf.periodicity[i]
-
+        
     @cython.boundscheck(False)
     @cython.wraparound(False)
     @cython.cdivision(True)

diff -r d7a076d0ff01055eaec8d3c7005e1070a0e4ac90 -r 2f14933d1904ac50f512ae72f2200c5c2dc769ff yt/utilities/tests/test_selectors.py
--- /dev/null
+++ b/yt/utilities/tests/test_selectors.py
@@ -0,0 +1,31 @@
+from yt.testing import *
+from yt.utilities.math_utils import periodic_dist
+
+def setup():
+    from yt.config import ytcfg
+    ytcfg["yt","__withintesting"] = "True"
+
+def test_sphere_selector():
+    # generate fake data with a number of non-cubical grids
+    pf = fake_random_pf(64,nprocs=51)
+    assert(all(pf.periodicity))
+
+    # aligned tests
+    spheres = [ [0.0,0.0,0.0],
+                [0.5,0.5,0.5],
+                [1.0,1.0,1.0],
+                [0.25,0.75,0.25] ]
+
+    for center in spheres :
+        data = pf.h.sphere(center, 0.25)
+        data.get_data()
+        # WARNING: this value has not be externally verified
+        yield assert_equal, data.size, 19568
+
+        positions = np.array([data[ax] for ax in 'xyz'])
+        centers = np.tile( data.center, data.shape[0] ).reshape(data.shape[0],3).transpose()
+        dist = periodic_dist(positions, centers,
+                         pf.domain_right_edge-pf.domain_left_edge,
+                         pf.periodicity)
+        # WARNING: this value has not been externally verified
+        yield assert_almost_equal, dist.max(), 0.261806188752


https://bitbucket.org/yt_analysis/yt-3.0/commits/dba8e90381b5/
changeset:   dba8e90381b5
branch:      yt-3.0
user:        MatthewTurk
date:        2013-03-18 20:28:15
summary:     Merged in drudd/yt-3.0 (pull request #18)

SphereSelector work
affected #:  3 files

diff -r 190abd27358bdf8728519c9473a85a3a431cd3aa -r dba8e90381b5be3b028790fc00201cca02fd936c yt/data_objects/selection_data_containers.py
--- a/yt/data_objects/selection_data_containers.py
+++ b/yt/data_objects/selection_data_containers.py
@@ -928,7 +928,6 @@
             raise YTSphereTooSmall(pf, radius, self.hierarchy.get_smallest_dx())
         self.set_field_parameter('radius',radius)
         self.radius = radius
-        self.DW = self.pf.domain_right_edge - self.pf.domain_left_edge
 
 class YTEllipsoidBase(YTSelectionContainer3D):
     """

diff -r 190abd27358bdf8728519c9473a85a3a431cd3aa -r dba8e90381b5be3b028790fc00201cca02fd936c yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -407,12 +407,19 @@
 cdef class SphereSelector(SelectorObject):
     cdef np.float64_t radius2
     cdef np.float64_t center[3]
+    cdef np.float64_t domain_width[3]
+    cdef bint periodicity[3]
 
     def __init__(self, dobj):
         for i in range(3):
             self.center[i] = dobj.center[i]
         self.radius2 = dobj.radius * dobj.radius
 
+        for i in range(3) :
+            self.domain_width[i] = dobj.pf.domain_right_edge[i] - \
+                                   dobj.pf.domain_left_edge[i]
+            self.periodicity[i] = dobj.pf.periodicity[i]
+        
     @cython.boundscheck(False)
     @cython.wraparound(False)
     @cython.cdivision(True)
@@ -420,8 +427,7 @@
                                np.float64_t right_edge[3],
                                np.int32_t level) nogil:
         cdef np.float64_t box_center, relcenter, closest, dist, edge
-        return 1
-        cdef int id
+        cdef int i
         if (left_edge[0] <= self.center[0] <= right_edge[0] and
             left_edge[1] <= self.center[1] <= right_edge[1] and
             left_edge[2] <= self.center[2] <= right_edge[2]):
@@ -431,10 +437,15 @@
         for i in range(3):
             box_center = (right_edge[i] + left_edge[i])/2.0
             relcenter = self.center[i] - box_center
+            if self.periodicity[i]:
+                if relcenter > self.domain_width[i]/2.0: 
+                    relcenter -= self.domain_width[i] 
+                elif relcenter < -self.domain_width[i]/2.0: 
+                    relcenter += self.domain_width[i] 
             edge = right_edge[i] - left_edge[i]
             closest = relcenter - fclip(relcenter, -edge/2.0, edge/2.0)
             dist += closest * closest
-        if dist < self.radius2: return 1
+        if dist <= self.radius2: return 1
         return 0
 
     @cython.boundscheck(False)
@@ -444,10 +455,20 @@
                          int eterm[3]) nogil:
         cdef np.float64_t dist2, temp
         cdef int i
+        if (pos[0] - 0.5*dds[0] <= self.center[0] <= pos[0]+0.5*dds[0] and
+            pos[1] - 0.5*dds[1] <= self.center[1] <= pos[1]+0.5*dds[1] and
+            pos[2] - 0.5*dds[2] <= self.center[2] <= pos[2]+0.5*dds[2]):
+            return 1
         dist2 = 0
         for i in range(3):
-            temp = (pos[i] - self.center[i])
-            dist2 += temp * temp
+            temp = self.center[i] - pos[i]
+            if self.periodicity[i]:
+                if temp > self.domain_width[i]/2.0:
+                    temp -= self.domain_width[i]
+                elif temp < -self.domain_width[i]/2.0:
+                    temp += self.domain_width[i]
+            temp = temp - fclip(temp, -dds[i]/2.0, dds[i]/2.0)
+            dist2 += temp*temp
         if dist2 <= self.radius2: return 1
         return 0
 

diff -r 190abd27358bdf8728519c9473a85a3a431cd3aa -r dba8e90381b5be3b028790fc00201cca02fd936c yt/utilities/tests/test_selectors.py
--- /dev/null
+++ b/yt/utilities/tests/test_selectors.py
@@ -0,0 +1,31 @@
+from yt.testing import *
+from yt.utilities.math_utils import periodic_dist
+
+def setup():
+    from yt.config import ytcfg
+    ytcfg["yt","__withintesting"] = "True"
+
+def test_sphere_selector():
+    # generate fake data with a number of non-cubical grids
+    pf = fake_random_pf(64,nprocs=51)
+    assert(all(pf.periodicity))
+
+    # aligned tests
+    spheres = [ [0.0,0.0,0.0],
+                [0.5,0.5,0.5],
+                [1.0,1.0,1.0],
+                [0.25,0.75,0.25] ]
+
+    for center in spheres :
+        data = pf.h.sphere(center, 0.25)
+        data.get_data()
+        # WARNING: this value has not be externally verified
+        yield assert_equal, data.size, 19568
+
+        positions = np.array([data[ax] for ax in 'xyz'])
+        centers = np.tile( data.center, data.shape[0] ).reshape(data.shape[0],3).transpose()
+        dist = periodic_dist(positions, centers,
+                         pf.domain_right_edge-pf.domain_left_edge,
+                         pf.periodicity)
+        # WARNING: this value has not been externally verified
+        yield assert_almost_equal, dist.max(), 0.261806188752

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