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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed May 7 11:50:57 PDT 2014


3 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/dbfd647f945d/
Changeset:   dbfd647f945d
Branch:      yt-3.0
User:        MatthewTurk
Date:        2014-05-07 00:17:29
Summary:     Adding first pass at YTPositionArray.  Will eventually move.
Affected #:  1 file

diff -r 15d24171e3fafdc3e6744984787f635eede0cadc -r dbfd647f945d96ba55aad666df7a5f81645b2e41 yt/data_objects/octree_subset.py
--- a/yt/data_objects/octree_subset.py
+++ b/yt/data_objects/octree_subset.py
@@ -32,6 +32,9 @@
 from yt.utilities.lib.geometry_utils import compute_morton
 from yt.geometry.particle_oct_container import \
     ParticleOctreeContainer
+from yt.units.yt_array import YTArray
+from yt.units.dimensions import length
+from yt.utilities.exceptions import YTInvalidPositionArray
 
 def cell_count_cache(func):
     def cc_cache_func(self, dobj):
@@ -333,3 +336,34 @@
     @property
     def dds(self):
         return self._fwidth[0,0,0,self.ind,:]
+
+class YTPositionArray(YTArray):
+    @property
+    def morton(self):
+        self.validate()
+        eps = np.finfo(self.dtype).eps
+        LE = self.min(axis=0) - eps * self.uq
+        RE = self.max(axis=0) + eps * self.uq
+        morton = compute_morton(
+            self[:,0], self[:,1], self[:,2],
+            LE, RE)
+        return morton
+
+    def to_octree(self, over_refine_factor = 1, dims = (1,1,1),
+                  n_ref = 64):
+        mi = self.morton
+        mi.sort()
+        eps = np.finfo(self.dtype).eps
+        LE = self.min(axis=0) - eps * self.uq
+        RE = self.max(axis=0) + eps * self.uq
+        octree = ParticleOctreeContainer(dims, LE, RE, 
+            over_refine = over_refine_factor)
+        octree.n_ref = n_ref
+        octree.add(mi)
+        octree.finalize()
+        return octree
+
+    def validate(self):
+        if len(self.shape) != 2 or self.shape[1] != 3 \
+           or self.units.dimensions != length:
+            raise YTInvalidPositionArray(self.shape, self.units.dimensions)


https://bitbucket.org/yt_analysis/yt/commits/2c9549b58b9f/
Changeset:   2c9549b58b9f
Branch:      yt-3.0
User:        MatthewTurk
Date:        2014-05-07 00:34:35
Summary:     Adding exception
Affected #:  1 file

diff -r dbfd647f945d96ba55aad666df7a5f81645b2e41 -r 2c9549b58b9f0b8d7789813474093b62f59d49c0 yt/utilities/exceptions.py
--- a/yt/utilities/exceptions.py
+++ b/yt/utilities/exceptions.py
@@ -367,3 +367,13 @@
                But being asked to add it with:
                %s""" % (self.field, self.old_spec, self.new_spec)
         return r
+
+class YTInvalidPositionArray(Exception):
+    def __init__(self, shape, dimensions):
+        self.shape = shape
+        self.dimensions = dimensions
+
+    def __str__(self):
+        r = """Position arrays must be length and shape (N,3).
+               But this one has %s and %s.""" % (self.dimensions, self.shape)
+        return r


https://bitbucket.org/yt_analysis/yt/commits/6347a1dcd087/
Changeset:   6347a1dcd087
Branch:      yt-3.0
User:        MatthewTurk
Date:        2014-05-07 20:50:51
Summary:     Merged in MatthewTurk/yt/yt-3.0 (pull request #883)

Adding first pass at YTPositionArray.
Affected #:  2 files

diff -r bf7a69e38a890425e12e961bc09e9a534ec0113d -r 6347a1dcd0876cc6ab52ab378fa7708b6d41b653 yt/data_objects/octree_subset.py
--- a/yt/data_objects/octree_subset.py
+++ b/yt/data_objects/octree_subset.py
@@ -32,6 +32,9 @@
 from yt.utilities.lib.geometry_utils import compute_morton
 from yt.geometry.particle_oct_container import \
     ParticleOctreeContainer
+from yt.units.yt_array import YTArray
+from yt.units.dimensions import length
+from yt.utilities.exceptions import YTInvalidPositionArray
 
 def cell_count_cache(func):
     def cc_cache_func(self, dobj):
@@ -333,3 +336,34 @@
     @property
     def dds(self):
         return self._fwidth[0,0,0,self.ind,:]
+
+class YTPositionArray(YTArray):
+    @property
+    def morton(self):
+        self.validate()
+        eps = np.finfo(self.dtype).eps
+        LE = self.min(axis=0) - eps * self.uq
+        RE = self.max(axis=0) + eps * self.uq
+        morton = compute_morton(
+            self[:,0], self[:,1], self[:,2],
+            LE, RE)
+        return morton
+
+    def to_octree(self, over_refine_factor = 1, dims = (1,1,1),
+                  n_ref = 64):
+        mi = self.morton
+        mi.sort()
+        eps = np.finfo(self.dtype).eps
+        LE = self.min(axis=0) - eps * self.uq
+        RE = self.max(axis=0) + eps * self.uq
+        octree = ParticleOctreeContainer(dims, LE, RE, 
+            over_refine = over_refine_factor)
+        octree.n_ref = n_ref
+        octree.add(mi)
+        octree.finalize()
+        return octree
+
+    def validate(self):
+        if len(self.shape) != 2 or self.shape[1] != 3 \
+           or self.units.dimensions != length:
+            raise YTInvalidPositionArray(self.shape, self.units.dimensions)

diff -r bf7a69e38a890425e12e961bc09e9a534ec0113d -r 6347a1dcd0876cc6ab52ab378fa7708b6d41b653 yt/utilities/exceptions.py
--- a/yt/utilities/exceptions.py
+++ b/yt/utilities/exceptions.py
@@ -367,3 +367,13 @@
                But being asked to add it with:
                %s""" % (self.field, self.old_spec, self.new_spec)
         return r
+
+class YTInvalidPositionArray(Exception):
+    def __init__(self, shape, dimensions):
+        self.shape = shape
+        self.dimensions = dimensions
+
+    def __str__(self):
+        r = """Position arrays must be length and shape (N,3).
+               But this one has %s and %s.""" % (self.dimensions, self.shape)
+        return r

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