Commits

Sam Leitner committed 1eedaea

fixed the "mangling" issue -- coords functions are no longer tied to levels

Comments (0)

Files changed (4)

yt/frontends/artio/_artio_caller.pyx

         '''
         print 'start filling oct positions'
         self.oct_handler = oct_handler
+        self.oct_count=0
         # fill the root grid yt-only octs 
         if ROOT_LEVEL == 1 :    
             pos = np.empty((1,3), dtype='float64')
                         pos[0,1]=iy*2+1
                         pos[0,2]=iz*2+1
                         level=0
+                        self.oct_count += 1
                         self.oct_handler.add(self.cpu+1, level, 
                                              self.ng, pos, self.domain_id)
             ###################################
                     wrap_oct_pos_callback, <void*>self) 
         check_artio_status(status, artio_grid_routines.__name__)
         artio_fileset_close(handle) 
-        print 'done filling oct positions'
+        print 'done filling oct positions; allocated octs:', self.oct_count
+        # snl FIX assert oct_count matches num octs elsewhere
     def grid_var_fill(self, source, fields):
         print 'start filling grid vars the root grid fill takes too long...'
         self.source = source
             artio_fileset_close(handle) 
         print 'done buffering variables'
     def oct_pos_callback(self, level, refined, isfc, pos):
+#        print 'callerpos ',self.oct_count*8,pos[0,0],pos[0,1],pos[0,2],vars, level
+        self.oct_count += 1
         self.oct_handler.add(self.cpu+1, level-self.min_level_to_read, 
                              self.ng, pos, self.domain_id)
     def cell_var_callback(self, level, refined, ichild, cell_var):
         for field in self.matched_fieldnames : 
             self.source[field][self.count] = cell_var[self.label_index[field]] 
-#            if level > 0:
-#                print '_artio_caller.pyx:sourcefill', level, self.count, self.source[field][self.count]
+#        if (ichild == 0) and (level>0):
+#            print 'callervar ',self.count,cell_var[0],level
         self.count += 1
  
 
     ytlevel = level+1 
     artioroutines = <object>pyobject
     #    print '_artio_caller.pyx:octpositionsandvalues',ytlevel, pos[0],pos[1],pos[2],level,variables[0]
-    artioroutines.oct_pos_callback(ytlevel, refined, isfc, position)
+    artioroutines.oct_pos_callback(ytlevel, refined, isfc, position) #variables[0]
 
 cdef void wrap_cell_var_callback(float *variables, int level, int refined, 
                                  int64_t ichild, void *pyobject):

yt/frontends/artio/artio_headers/artio_grid.c

                     num_next_level_octs = 0;
                 }
                         
-
-		if (min_level_to_read == 0 && (options != ARTIO_READ_REFINED_NOT_ROOT) &&
-                    (options == ARTIO_READ_ALL || 
-                     (options == ARTIO_READ_REFINED && root_tree_levels > 0) || 
-                     (options == ARTIO_READ_LEAFS && root_tree_levels == 0)) ) {
-                    cpos[0] = pos[0]+0.5;
-                    cpos[1] = pos[1]+0.5;
-                    cpos[2] = pos[2]+0.5;
-			refined = (root_tree_levels > 0) ? 1 : 0;
-			callback(variables, min_level, refined, sfc, cpos, pyobject);
-		}
                 // level is the cell_level; current octs live at level-1.
 		for (level = min_level+1; level <= MIN(root_tree_levels,max_level_to_read); level++) { 
 			ret = artio_grid_read_level_begin(handle, level);
 					return ret;
 				}
 
+                                if ( options == ARTIO_READ_ALL || 
+                                    (options == ARTIO_READ_REFINED)  ||
+                                    (options == ARTIO_READ_REFINED_NOT_ROOT) || 
+                                    (options == !ARTIO_READ_LEAFS) ) {
+                                    cpos[0] = level_octs_pos_x[oct]+cell_size;
+                                    cpos[1] = level_octs_pos_y[oct]+cell_size;
+                                    cpos[2] = level_octs_pos_z[oct]+cell_size;
+                                    callback(variables, level-1, 1, sfc, cpos, pyobject);
+                                }
 				for (j = 0; j < num_children; j++) {
                                         pos[0] = level_octs_pos_x[oct]+cell_delta_corner[j][0]*cell_size;
                                         pos[1] = level_octs_pos_y[oct]+cell_delta_corner[j][1]*cell_size;
                                                 next_level_octs_pos_z[num_next_level_octs] = pos[2];
                                                 num_next_level_octs++ ;
                                         }
-					if (options == ARTIO_READ_ALL || 
-                                            (options == ARTIO_READ_REFINED && oct_refined[j]) ||
-                                            (options == ARTIO_READ_REFINED_NOT_ROOT && oct_refined[j]) || 
-                                            (options == ARTIO_READ_LEAFS && !oct_refined[j]) ) {
-                                            cpos[0] = pos[0]+0.5*cell_size;
-                                            cpos[1] = pos[1]+0.5*cell_size;
-                                            cpos[2] = pos[2]+0.5*cell_size;
-                                            callback(variables, level, oct_refined[j], sfc, cpos, pyobject);
-								
-					}
 				}
 			}
                         free(level_octs_pos_x);

yt/frontends/artio/data_structures.py

         self.artiogrid.grid_pos_fill(oct_handler, self.pf.domain_dimensions[0])
         #pdb.set_trace()
         
-    def select(self, selector):
-        if id(selector) == self._last_selector_id:
-            return self._last_mask
-        self._last_mask = selector.fill_mask(self)
-        self._last_selector_id = id(selector)
-        return self._last_mask
-
-    def count(self, selector):
-        if id(selector) == self._last_selector_id:
-            if self._last_mask is None: return 0
-            return self._last_mask.sum()
-        self.select(selector)
-        return self.count(selector)
+#    def select(self, selector):
+#        if id(selector) == self._last_selector_id:
+#            return self._last_mask
+#        self._last_mask = selector.fill_mask(self)
+#        self._last_selector_id = id(selector)
+#        return self._last_mask
+#
+#    def count(self, selector):
+#        if id(selector) == self._last_selector_id:
+#            if self._last_mask is None: return 0
+#            return self._last_mask.sum()
+#        self.select(selector)
+#        return self.count(selector)
 
 class ARTIODomainSubset(object):
 
             #temp[field] = np.empty((no,8), dtype="float64") 
             temp[field] = np.empty(nc, dtype="float32")  
 
+            # snl FIX: change the grid fill call to include domain and mask directly
         #buffer variables 
         self.artiogrid.grid_var_fill(temp, fields)
         
              self.domain.domain_id,
             tr, temp, self.mask, level_offset) #[oct_container.pyx] RISM level_offset
         
-        print 'tr min/max in data_structures.py',tr['Density'].max(), tr['Density'].min() 
+#        print 'tr min/max in data_structures.py',tr['Density'].max(), tr['Density'].min() 
         return tr
 
     def get_particle_pos(self,accessed_species, fieldnames):

yt/geometry/oct_container.pyx

         n = mask.shape[0]
         cdef np.ndarray[np.int64_t, ndim=2] coords
         coords = np.empty((cell_count, 3), dtype="int64")
+        ci=0
         for oi in range(cur.n):
             o = &cur.my_octs[oi]
             for k in range(2):
                     for i in range(2):
                         ii = ((k*2)+j)*2+i
                         if mask[o.local_ind, ii] == 0: continue
-                        ci = level_counts[o.level]
                         coords[ci, 0] = (o.pos[0] << 1) + i
                         coords[ci, 1] = (o.pos[1] << 1) + j
                         coords[ci, 2] = (o.pos[2] << 1) + k
-                        level_counts[o.level] += 1
+                        ci += 1
         return coords
 
     @cython.boundscheck(False)
             o = &cur.my_octs[oi]
             for i in range(8):
                 if mask[oi + cur.offset, i] == 0: continue
-                ci = level_counts[o.level]
                 levels[ci] = o.level
-                level_counts[o.level] += 1
+                ci +=1
         return levels
 
     @cython.boundscheck(False)
         n = mask.shape[0]
         cdef np.ndarray[np.float64_t, ndim=2] coords
         coords = np.empty((cell_count, 3), dtype="float64")
+        ci =0 
         for i in range(3):
             # This is the base_dx, but not the base distance from the center
             # position.  Note that the positions will also all be offset by
                     for i in range(2):
                         ii = ((k*2)+j)*2+i
                         if mask[o.local_ind, ii] == 0: continue
-                        ci = level_counts[o.level]
                         coords[ci, 0] = pos[0] + dx[0] * i
                         coords[ci, 1] = pos[1] + dx[1] * j
                         coords[ci, 2] = pos[2] + dx[2] * k
-                        level_counts[o.level] += 1
+                        ci +=1 
         return coords
 
     @cython.boundscheck(False)
         cdef int i, j, k, ii
         cdef int local_pos, local_filled
         cdef np.float64_t val
-        print 'domain number of octs', dom.n
+        print 'in fill_mask, domains number of octs',dom.n
         for key in dest_fields:
             local_filled = 0
             dest = dest_fields[key]
                             ii = ((k*2)+j)*2+i
                             if mask[o.local_ind, ii] == 0: continue
                             dest[local_filled + offset] = source[o.local_ind*8+ii]
-                            # print 'oct_container.pyx:sourcemasked',o.level, o.local_ind*8+ii, source[o.local_ind*8+ii]
+                            # print 'oct_container.pyx:sourcemasked',o.level,local_filled, o.local_ind*8+ii, source[o.local_ind*8+ii]
                             local_filled += 1
         return local_filled