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

Bitbucket commits-noreply at bitbucket.org
Mon Nov 7 11:02:28 PST 2011


2 new commits in yt:


https://bitbucket.org/yt_analysis/yt/changeset/7872e3dd3f97/
changeset:   7872e3dd3f97
branch:      yt
user:        sskory
date:        2011-11-07 17:41:48
summary:     Adding the volume() function to the boolean container.
affected #:  1 file

diff -r 3fc7d938007f1057fa2f67090f30386c2cf09fe2 -r 7872e3dd3f976310db217adb51707292ef8b9053 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -3560,6 +3560,15 @@
             self._cut_masks[grid.id] = this_cut_mask
         return this_cut_mask
 
+    def volume(self, unit = "unitary"):
+        """
+        Return the volume of the boolean container in units *unit*.
+        This is found by adding up the volume of the cells with centers
+        in the container, rather than using the geometric shape of
+        the container, so this may vary very slightly
+        from what might be expected.
+        """
+        return self['CellVolume'].sum() * (self.pf[unit] / self.pf['cm']) ** 3.0
 
 def _reconstruct_object(*args, **kwargs):
     pfid = args[0]



https://bitbucket.org/yt_analysis/yt/changeset/bcc8c8f8ddd9/
changeset:   bcc8c8f8ddd9
branch:      yt
user:        sskory
date:        2011-11-07 18:03:16
summary:     Moving the volume function to the AMR3DData class, removing the subclass
versions. This one is now memory conservative and adds up the volume
of the cells rather than the geometric volume.
affected #:  1 file

diff -r 7872e3dd3f976310db217adb51707292ef8b9053 -r bcc8c8f8ddd9812d9a93405700345aeafe7e221b yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -2668,6 +2668,18 @@
                 particle_handler_registry[self._type_name](self.pf, self)
         return self._particle_handler
 
+
+    def volume(self, unit = "unitary"):
+        """
+        Return the volume of the boolean container in units *unit*.
+        This is found by adding up the volume of the cells with centers
+        in the container, rather than using the geometric shape of
+        the container, so this may vary very slightly
+        from what might be expected from the geometric volume.
+        """
+        return self.quantities["TotalQuantity"]("CellVolume")[0] * \
+            (self.pf[unit] / self.pf['cm']) ** 3.0
+
 class ExtractedRegionBase(AMR3DData):
     """
     ExtractedRegions are arbitrarily defined containers of data, useful
@@ -2991,15 +3003,6 @@
                  & (grid['z'] + dzp > self.left_edge[2]) )
         return cm
 
-    def volume(self, unit = "unitary"):
-        """
-        Return the volume of the region in units *unit*.
-        """
-        diff = na.array(self.right_edge) - na.array(self.left_edge)
-        # Find the full volume
-        vol = na.prod(diff * self.pf[unit])
-        return vol
-
 class AMRRegionStrictBase(AMRRegionBase):
     """
     AMRRegion without any dx padding for cell selection
@@ -3061,21 +3064,6 @@
                           & (grid['z'] + dzp + off_z > self.left_edge[2]) )
             return cm
 
-    def volume(self, unit = "unitary"):
-        """
-        Return the volume of the region in units *unit*.
-        """
-        period = self.pf.domain_right_edge - self.pf.domain_left_edge
-        diff = na.array(self.right_edge) - na.array(self.left_edge)
-        # Correct for wrap-arounds.
-        tofix = (diff < 0)
-        toadd = period[tofix]
-        diff += toadd
-        # Find the full volume
-        vol = na.prod(diff * self.pf[unit])
-        return vol
-        
-
 class AMRPeriodicRegionStrictBase(AMRPeriodicRegionBase):
     """
     AMRPeriodicRegion without any dx padding for cell selection
@@ -3167,12 +3155,6 @@
             self._cut_masks[grid.id] = cm
         return cm
 
-    def volume(self, unit = "unitary"):
-        """
-        Return the volume of the sphere in units *unit*.
-        """
-        return 4./3. * math.pi * (self.radius * self.pf[unit])**3.0
-
 class AMRCoveringGridBase(AMR3DData):
     _spatial = True
     _type_name = "covering_grid"
@@ -3560,16 +3542,6 @@
             self._cut_masks[grid.id] = this_cut_mask
         return this_cut_mask
 
-    def volume(self, unit = "unitary"):
-        """
-        Return the volume of the boolean container in units *unit*.
-        This is found by adding up the volume of the cells with centers
-        in the container, rather than using the geometric shape of
-        the container, so this may vary very slightly
-        from what might be expected.
-        """
-        return self['CellVolume'].sum() * (self.pf[unit] / self.pf['cm']) ** 3.0
-
 def _reconstruct_object(*args, **kwargs):
     pfid = args[0]
     dtype = args[1]

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