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

Bitbucket commits-noreply at bitbucket.org
Fri Aug 10 16:38:22 PDT 2012


2 new commits in yt-3.0:


https://bitbucket.org/yt_analysis/yt-3.0/changeset/111cf75c6467/
changeset:   111cf75c6467
branch:      yt-3.0
user:        MatthewTurk
date:        2012-08-11 00:41:16
summary:     Fix a few aspect of the plot window and re-enable some RAMSES data selection
operations.  It appears the initial implementation only masked Octs, not Cells,
so this will have to be rewritten.
affected #:  6 files

diff -r f75f82fca0a8087ca05a2cd2269fa4d351f76767 -r 111cf75c64674025afd6f1776692eb1ba5cf3dcf yt/data_objects/field_info_container.py
--- a/yt/data_objects/field_info_container.py
+++ b/yt/data_objects/field_info_container.py
@@ -67,7 +67,7 @@
 
     def __missing__(self, key):
         if self.fallback is None:
-            raise KeyError("No field named %s" % key)
+            raise KeyError("No field named %s" % (key,))
         return self.fallback[key]
 
     @classmethod


diff -r f75f82fca0a8087ca05a2cd2269fa4d351f76767 -r 111cf75c64674025afd6f1776692eb1ba5cf3dcf yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -252,12 +252,11 @@
                         #print "Reading %s in %s : %s" % (field, level,
                         #        self.domain.domain_id)
                         temp[field][:,i] = fpu.read_vector(content, 'd') # cell 1
-            oct_handler.fill_level(self.domain.domain_id,
-                                   level - min_level,
+            oct_handler.fill_level(self.domain.domain_id, level,
                                    tr, temp, self.mask, level_offset)
-            #print "FILL (%s : %s) %s" % (self.domain.domain_id, level, filled)
-        #print "DONE (%s) %s of %s" % (self.domain.domain_id, filled,
-        #self.cell_count)
+            print "FILL (%s : %s) %s" % (self.domain.domain_id, level, filled)
+        print "DONE (%s) %s of %s" % (self.domain.domain_id, filled,
+        self.cell_count)
         return tr
 
 class RAMSESGeometryHandler(OctreeGeometryHandler):


diff -r f75f82fca0a8087ca05a2cd2269fa4d351f76767 -r 111cf75c64674025afd6f1776692eb1ba5cf3dcf yt/geometry/oct_container.pyx
--- a/yt/geometry/oct_container.pyx
+++ b/yt/geometry/oct_container.pyx
@@ -413,4 +413,4 @@
                             if o.children[i][j][k] != NULL: continue
                             if o.level == level:
                                 dest[local_filled] = source[o.ind,((k*2)+j)*2+i]
-                            local_filled += 1
+                                local_filled += 1


diff -r f75f82fca0a8087ca05a2cd2269fa4d351f76767 -r 111cf75c64674025afd6f1776692eb1ba5cf3dcf yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -177,8 +177,8 @@
                         octree.root_mesh[i][j][k],
                         pos, dds, mask)
                     pos[2] += dds[2]
-                pos[2] += dds[2]
-            pos[2] += dds[2]
+                pos[1] += dds[2]
+            pos[0] += dds[2]
         return mask.astype("bool")
 
     @cython.boundscheck(False)


diff -r f75f82fca0a8087ca05a2cd2269fa4d351f76767 -r 111cf75c64674025afd6f1776692eb1ba5cf3dcf yt/visualization/fixed_resolution.py
--- a/yt/visualization/fixed_resolution.py
+++ b/yt/visualization/fixed_resolution.py
@@ -140,7 +140,8 @@
 
     def _get_data_source_fields(self):
         exclude = self.data_source._key_fields + list(self._exclude_fields)
-        for f in self.data_source.fields:
+        fields = self.data_source.field_data.keys()
+        for f in fields:
             if f not in exclude:
                 self[f]
 


diff -r f75f82fca0a8087ca05a2cd2269fa4d351f76767 -r 111cf75c64674025afd6f1776692eb1ba5cf3dcf yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -440,7 +440,8 @@
         self._callbacks = []
         self._field_transform = {}
         for field in self._frb.data.keys():
-            if self.pf.field_info[field].take_log:
+            finfo = self.data_source._get_field_info(field)
+            if finfo.take_log:
                 self._field_transform[field] = log_transform
             else:
                 self._field_transform[field] = linear_transform
@@ -801,7 +802,8 @@
         """
         axis = fix_axis(axis)
         (bounds,center) = GetBoundsAndCenter(axis, center, width, pf)
-        slc = pf.h.slice(axis, center[axis], fields=fields)
+        slc = pf.h.slice(axis, center[axis])
+        slc.get_data(fields)
         PWViewerMPL.__init__(self, slc, bounds, origin=origin)
 
 class ProjectionPlot(PWViewerMPL):



https://bitbucket.org/yt_analysis/yt-3.0/changeset/f274670eb23a/
changeset:   f274670eb23a
branch:      yt-3.0
user:        MatthewTurk
date:        2012-08-11 01:38:15
summary:     Fixes for PlotWindow with new field system and more fixes for RAMSES data
reading, which now runs to completion without filling all the values correctly.
affected #:  6 files

diff -r 111cf75c64674025afd6f1776692eb1ba5cf3dcf -r f274670eb23a93e38461faab3aac83dafdac6a56 yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -358,7 +358,7 @@
         explicit_fields = []
         for field in fields:
             if field in self._container_fields:
-                explicit_fields.append((field, field))
+                explicit_fields.append(field)
                 continue
             if isinstance(field, types.TupleType):
                 if len(field) != 2 or \


diff -r 111cf75c64674025afd6f1776692eb1ba5cf3dcf -r f274670eb23a93e38461faab3aac83dafdac6a56 yt/frontends/ramses/data_structures.py
--- a/yt/frontends/ramses/data_structures.py
+++ b/yt/frontends/ramses/data_structures.py
@@ -217,7 +217,12 @@
                                         self.cell_count)
 
     def fwidth(self, dobj):
-        pass
+        base_dx = 1.0/self.domain.pf.domain_dimensions
+        coords = na.empty((self.cell_count, 3), dtype="float64")
+        dds = (2**self.ires(dobj))
+        for i in range(3):
+            coords[:,i] = base_dx[i] / dds
+        return coords
 
     def ires(self, dobj):
         return self.oct_handler.ires(self.domain.domain_id, self.mask,
@@ -230,7 +235,7 @@
         all_fields = self.domain.pf.h.field_list
         fields = [f for ft, f in fields]
         tr = {}
-        filled = pos = 0
+        filled = pos = total = 0
         min_level = self.domain.pf.min_level
         for field in fields:
             tr[field] = na.zeros(self.cell_count, 'float64')
@@ -252,11 +257,11 @@
                         #print "Reading %s in %s : %s" % (field, level,
                         #        self.domain.domain_id)
                         temp[field][:,i] = fpu.read_vector(content, 'd') # cell 1
-            oct_handler.fill_level(self.domain.domain_id, level,
+            filled = oct_handler.fill_level(self.domain.domain_id, level,
                                    tr, temp, self.mask, level_offset)
-            print "FILL (%s : %s) %s" % (self.domain.domain_id, level, filled)
-        print "DONE (%s) %s of %s" % (self.domain.domain_id, filled,
-        self.cell_count)
+            total += filled
+            #print "FILL (%s : %s) %s" % (self.domain.domain_id, level, filled)
+        #print "DONE (%s) %s of %s" % (self.domain.domain_id, total, self.cell_count)
         return tr
 
 class RAMSESGeometryHandler(OctreeGeometryHandler):


diff -r 111cf75c64674025afd6f1776692eb1ba5cf3dcf -r f274670eb23a93e38461faab3aac83dafdac6a56 yt/geometry/oct_container.pyx
--- a/yt/geometry/oct_container.pyx
+++ b/yt/geometry/oct_container.pyx
@@ -131,7 +131,7 @@
     @cython.wraparound(False)
     @cython.cdivision(True)
     def count_cells(self, SelectorObject selector,
-              np.ndarray[np.uint8_t, ndim=1, cast=True] mask):
+              np.ndarray[np.uint8_t, ndim=2, cast=True] mask):
         cdef int i, j, k, oi
         # pos here is CELL center, not OCT center.
         cdef np.float64_t pos[3]
@@ -149,24 +149,9 @@
         for oi in range(n):
             if oi - cur.offset >= cur.n:
                 cur = cur.next
-            if mask[oi] == 0: continue
             o = &cur.my_octs[oi - cur.offset]
-            for i in range(3):
-                # This gives the *grid* width for this level
-                dx[i] = base_dx[i] / (1 << o.level)
-                pos[i] = self.DLE[i] + o.pos[i]*dx[i] + dx[i]/4.0
-                dx[i] = dx[i] / 2.0 # This is now the *offset* 
-            for i in range(2):
-                pos[1] = self.DLE[1] + o.pos[1]*dx[1] + dx[1]/4.0
-                for j in range(2):
-                    pos[2] = self.DLE[2] + o.pos[2]*dx[2] + dx[2]/4.0
-                    for k in range(2):
-                        if o.children[i][j][k] == NULL: 
-                            count[o.domain - 1] += \
-                                selector.select_cell(pos, dx, eterm)
-                        pos[2] += dx[2]
-                    pos[1] += dx[1]
-                pos[0] += dx[0]
+            for i in range(8):
+                count[o.domain - 1] += mask[oi,((k*2)+j)*2+i]
         return count
 
 cdef class RAMSESOctreeContainer(OctreeContainer):
@@ -331,7 +316,7 @@
     @cython.wraparound(False)
     @cython.cdivision(True)
     def ires(self, int domain_id,
-                np.ndarray[np.uint8_t, ndim=1, cast=True] mask,
+                np.ndarray[np.uint8_t, ndim=2, cast=True] mask,
                 np.int64_t cell_count):
         # Wham, bam, it's a scam
         cdef np.int64_t i, j, k, oi, ci, n
@@ -342,24 +327,21 @@
         levels = np.empty(cell_count, dtype="int64")
         ci = 0
         for oi in range(cur.n):
-            if mask[oi + cur.offset] == 0: continue
             o = &cur.my_octs[oi]
-            for i in range(2):
-                for j in range(2):
-                    for k in range(2):
-                        if o.children[i][j][k] != NULL: continue
-                        levels[ci] = o.level
-                        ci += 1
+            for i in range(8):
+                if mask[oi + cur.offset, i]:
+                    levels[ci] = o.level
+                    ci += 1
         return levels
 
-    @cython.boundscheck(False)
-    @cython.wraparound(False)
-    @cython.cdivision(True)
+    #@cython.boundscheck(False)
+    #@cython.wraparound(False)
+    #@cython.cdivision(True)
     def fcoords(self, int domain_id,
-                np.ndarray[np.uint8_t, ndim=1, cast=True] mask,
+                np.ndarray[np.uint8_t, ndim=2, cast=True] mask,
                 np.int64_t cell_count):
         # Wham, bam, it's a scam
-        cdef np.int64_t i, j, k, oi, ci, n
+        cdef np.int64_t i, j, k, oi, ci, n, ii
         cdef OctAllocationContainer *cur = self.domains[domain_id - 1]
         cdef Oct *o
         cdef np.float64_t pos[3]
@@ -374,7 +356,6 @@
             base_dx[i] = (self.DRE[i] - self.DLE[i])/self.nn[i]
         ci = 0
         for oi in range(cur.n):
-            if mask[oi + cur.offset] == 0: continue
             o = &cur.my_octs[oi]
             for i in range(3):
                 # This gives the *grid* width for this level
@@ -384,7 +365,8 @@
             for i in range(2):
                 for j in range(2):
                     for k in range(2):
-                        if o.children[i][j][k] != NULL: continue
+                        ii = ((k*2)+j)*2+i
+                        if mask[oi + cur.offset, ii] == 0: continue
                         coords[ci, 0] = pos[0] + dx[0] * i
                         coords[ci, 1] = pos[1] + dx[1] * j
                         coords[ci, 2] = pos[2] + dx[2] * k
@@ -392,25 +374,26 @@
         return coords
 
     def fill_level(self, int domain, int level, dest_fields, source_fields,
-                   np.ndarray[np.uint8_t, ndim=1, cast=True] mask, int offset):
+                   np.ndarray[np.uint8_t, ndim=2, cast=True] mask, int offset):
         cdef np.ndarray[np.float64_t, ndim=2] source
         cdef np.ndarray[np.float64_t, ndim=1] dest
         cdef OctAllocationContainer *dom = self.domains[domain - 1]
         cdef Oct *o
         cdef int n
-        cdef int i, j, k
+        cdef int i, j, k, ii
         cdef int local_pos, local_filled
         for key in dest_fields:
             local_filled = 0
             dest = dest_fields[key]
             source = source_fields[key]
             for n in range(dom.n):
-                if mask[n + dom.offset] == 0: continue
                 o = &dom.my_octs[n]
                 for i in range(2):
                     for j in range(2):
                         for k in range(2):
-                            if o.children[i][j][k] != NULL: continue
+                            ii = ((k*2)+j)*2+i
+                            if mask[n + dom.offset,ii] == 0: continue
                             if o.level == level:
                                 dest[local_filled] = source[o.ind,((k*2)+j)*2+i]
                                 local_filled += 1
+        return local_filled


diff -r 111cf75c64674025afd6f1776692eb1ba5cf3dcf -r f274670eb23a93e38461faab3aac83dafdac6a56 yt/geometry/selection_routines.pxd
--- a/yt/geometry/selection_routines.pxd
+++ b/yt/geometry/selection_routines.pxd
@@ -30,7 +30,7 @@
 cdef class SelectorObject:
     cdef void recursively_select_octs(self, Oct *root,
                         np.float64_t pos[3], np.float64_t dds[3],
-                        np.ndarray[np.uint8_t, ndim=1] mask,
+                        np.ndarray[np.uint8_t, ndim=2] mask,
                         int level = ?)
     cdef int select_grid(self, np.float64_t left_edge[3],
                                np.float64_t right_edge[3]) nogil


diff -r 111cf75c64674025afd6f1776692eb1ba5cf3dcf -r f274670eb23a93e38461faab3aac83dafdac6a56 yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -162,7 +162,7 @@
     @cython.cdivision(True)
     def select_octs(self, OctreeContainer octree):
         cdef int i, j, k, n
-        cdef np.ndarray[np.uint8_t, ndim=1] mask = np.zeros(octree.nocts, dtype='uint8')
+        cdef np.ndarray[np.uint8_t, ndim=2] mask = np.zeros((octree.nocts, 8), dtype='uint8')
         cdef np.float64_t pos[3], dds[3]
         for i in range(3):
             dds[i] = (octree.DRE[i] - octree.DLE[i]) / octree.nn[i]
@@ -186,7 +186,7 @@
     @cython.cdivision(True)
     cdef void recursively_select_octs(self, Oct *root,
                         np.float64_t pos[3], np.float64_t dds[3],
-                        np.ndarray[np.uint8_t, ndim=1] mask,
+                        np.ndarray[np.uint8_t, ndim=2] mask,
                         int level = 0):
         cdef np.float64_t LE[3], RE[3], sdds[3], spos[3]
         cdef int i, j, k, res
@@ -199,10 +199,11 @@
             RE[i] = pos[i] + dds[i]/2.0
         #print LE[0], RE[0], LE[1], RE[1], LE[2], RE[2]
         res = self.select_grid(LE, RE)
+        cdef int eterm[3] 
+        eterm[0] = eterm[1] = eterm[2] = 0
         if res == 0:
-            mask[root.local_ind] = 0
+            for i in range(8): mask[root.local_ind,i] = 0
             return
-        mask[root.local_ind] = 1
         # Now we visit all our children
         spos[0] = pos[0] - sdds[0]/2.0
         for i in range(2):
@@ -214,6 +215,9 @@
                     if ch != NULL:
                         self.recursively_select_octs(
                             ch, spos, sdds, mask, level + 1)
+                    else:
+                        mask[root.local_ind, ((k*2)+j)*2+i] = \
+                            self.select_cell(spos, sdds, eterm)
                     spos[2] += sdds[2]
                 spos[1] += sdds[1]
             spos[0] += sdds[0]


diff -r 111cf75c64674025afd6f1776692eb1ba5cf3dcf -r f274670eb23a93e38461faab3aac83dafdac6a56 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -440,7 +440,7 @@
         self._callbacks = []
         self._field_transform = {}
         for field in self._frb.data.keys():
-            finfo = self.data_source._get_field_info(field)
+            finfo = self.data_source._get_field_info(*field)
             if finfo.take_log:
                 self._field_transform[field] = log_transform
             else:
@@ -550,13 +550,15 @@
     def get_field_units(self, field, strip_mathml = True):
         ds = self._frb.data_source
         pf = self.pf
+        field = self.data_source._determine_fields(field)[0]
+        finfo = self.data_source._get_field_info(*field)
         if ds._type_name in ("slice", "cutting"):
-            units = pf.field_info[field].get_units()
+            units = finfo.get_units()
         if ds._type_name == "proj" and (ds.weight_field is not None or 
                                         ds.proj_style == "mip"):
-            units = pf.field_info[field].get_units()
+            units = finfo.get_units()
         elif ds._type_name == "proj":
-            units = pf.field_info[field].get_projected_units()
+            units = finfo.get_projected_units()
         else:
             units = ""
         if strip_mathml:
@@ -628,10 +630,11 @@
             self.plots[f].axes.set_xlabel(labels[0])
             self.plots[f].axes.set_ylabel(labels[1])
 
+            ftype, fname = f
             if md['units'] == None or md['units'] == '':
-                label = r'$\rm{'+f.encode('string-escape')+r'}$'
+                label = r'$\rm{'+fname.encode('string-escape')+r'}$'
             else:
-                label = r'$\rm{'+f.encode('string-escape')+r'}\/\/('+md['units']+r')$'
+                label = r'$\rm{'+fname.encode('string-escape')+r'}\/\/('+md['units']+r')$'
 
             self.plots[f].cb.set_label(label)
 
@@ -698,6 +701,7 @@
             type = 'OffAxisSlice'
         names = []
         for k, v in self.plots.iteritems():
+            if isinstance(k, types.TupleType): k = k[1]
             if axis:
                 n = "%s_%s_%s_%s" % (name, type, axis, k)
             else:

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