[Yt-svn] commit/yt: 2 new changesets
Bitbucket
commits-noreply at bitbucket.org
Wed Sep 14 13:56:27 PDT 2011
2 new changesets in yt:
http://bitbucket.org/yt_analysis/yt/changeset/dfb88152f5e0/
changeset: dfb88152f5e0
branch: yt
user: samskillman
date: 2011-09-14 22:54:56
summary: Adding a nearest neighbor search that utilizes the locate_brick functionality in the AMRKDTree. AMRKDTree.locate_neighbors_from_position takes a position and will return the grids and cell indices of the 26 neighbors. The order goes from [-1,-1,-1],[-1,-1,0],..[1,1,0],[1,1,1]. Needs documentation, but I don't have time before tomorrow and it was needed quickly. See http://paste.yt-project.org/show/1803/ for an example.
affected #: 1 file (2.2 KB)
--- a/yt/utilities/amr_kdtree/amr_kdtree.py Fri Sep 09 11:51:19 2011 -0400
+++ b/yt/utilities/amr_kdtree/amr_kdtree.py Wed Sep 14 16:54:56 2011 -0400
@@ -60,6 +60,38 @@
def _rchild_id(id): return (id<<1) + 2
def _parent_id(id): return (id-1)>>1
+steps = na.array([[-1, -1, -1],
+ [-1, -1, 0],
+ [-1, -1, 1],
+ [-1, 0, -1],
+ [-1, 0, 0],
+ [-1, 0, 1],
+ [-1, 1, -1],
+ [-1, 1, 0],
+ [-1, 1, 1],
+
+ [ 0, -1, -1],
+ [ 0, -1, 0],
+ [ 0, -1, 1],
+ [ 0, 0, -1],
+ # [ 0, 0, 0],
+ [ 0, 0, 1],
+ [ 0, 1, -1],
+ [ 0, 1, 0],
+ [ 0, 1, 1],
+
+ [ 1, -1, -1],
+ [ 1, -1, 0],
+ [ 1, -1, 1],
+ [ 1, 0, -1],
+ [ 1, 0, 0],
+ [ 1, 0, 1],
+ [ 1, 1, -1],
+ [ 1, 1, 0],
+ [ 1, 1, 1]
+ ])
+
+
class MasterNode(object):
r"""
A MasterNode object is the building block of the AMR kd-Tree.
@@ -259,6 +291,7 @@
self.current_split_dim = 0
self.pf = pf
+ self.sdx = self.pf.h.get_smallest_dx()
self._id_offset = pf.h.grids[0]._id_offset
if nprocs > len(pf.h.grids):
mylog.info('Parallel rendering requires that the number of \n \
@@ -487,6 +520,37 @@
brick, le=le, re=re, periodic=periodic)]
return grids
+ def locate_neighbors_from_position(self, position):
+ position = na.array(position)
+ grid = self.locate_brick(position).grid
+ ci = ((position-grid.LeftEdge)/grid.dds).astype('int64')
+ return self.locate_neighbors(grid,ci)
+
+ def locate_neighbors(self, grid, ci):
+ center_dds = grid.dds
+ position = na.array([grid['x'][tuple(ci)],
+ grid['y'][tuple(ci)],
+ grid['z'][tuple(ci)]])[:]
+ grids = na.empty(26, dtype='object')
+ cis = na.empty([26,3], dtype='int64')
+ offs = 0.5*(center_dds + self.sdx)
+ new_cis = ci + steps
+ in_grid = na.all((new_cis >=0)*
+ (new_cis < grid.ActiveDimensions),axis=1)
+ new_positions = position + steps*offs
+ grids[in_grid] = grid
+ get_them = na.argwhere(in_grid != True).ravel()
+ cis[in_grid] = new_cis[in_grid]
+
+ if (in_grid != True).sum()>0:
+ grids[in_grid != True] = \
+ [self.locate_brick(new_positions[i]).grid for i in get_them]
+ cis[in_grid != True] = \
+ [(new_positions[i]-grids[i].LeftEdge)/
+ grids[i].dds for i in get_them]
+ cis = [tuple(ci) for ci in cis]
+ return grids, cis
+
def locate_brick(self, position):
r"""Given a position, find the node that contains it.
@@ -506,7 +570,7 @@
if node.grid is not None:
return node
else:
- if position[node.split_ax] <= node.split_pos:
+ if position[node.split_ax] < node.split_pos:
node = node.left_child
else:
node = node.right_child
http://bitbucket.org/yt_analysis/yt/changeset/23222f3979c7/
changeset: 23222f3979c7
branch: yt
user: samskillman
date: 2011-09-14 22:56:15
summary: merging.
affected #: 4 files (371 bytes)
--- a/CREDITS Wed Sep 14 16:54:56 2011 -0400
+++ b/CREDITS Wed Sep 14 16:56:15 2011 -0400
@@ -20,6 +20,7 @@
Casey Stark (caseywstark at gmail.com)
JC Passy (jcpassy at gmail.com)
Eve Lee (elee at cita.utoronto.ca)
+ Elizabeth Tasker (tasker at astro1.sci.hokudai.ac.jp)
We also include the Delaunay Triangulation module written by Robert Kern of
Enthought, the cmdln.py module by Trent Mick, and the progressbar module by
--- a/yt/frontends/enzo/data_structures.py Wed Sep 14 16:54:56 2011 -0400
+++ b/yt/frontends/enzo/data_structures.py Wed Sep 14 16:56:15 2011 -0400
@@ -764,6 +764,8 @@
else:
if any("." in v or "e+" in v or "e-" in v for v in vals):
pcast = float
+ elif v == "inf":
+ pcast = str
else:
pcast = int
# Now we figure out what to do with it.
--- a/yt/utilities/amr_kdtree/amr_kdtree.py Wed Sep 14 16:54:56 2011 -0400
+++ b/yt/utilities/amr_kdtree/amr_kdtree.py Wed Sep 14 16:56:15 2011 -0400
@@ -611,11 +611,14 @@
data = [d[current_node.li[0]:current_node.ri[0]+1,
current_node.li[1]:current_node.ri[1]+1,
current_node.li[2]:current_node.ri[2]+1].copy() for d in dds]
-
- current_node.brick = PartitionedGrid(current_node.grid.id, len(self.fields), data,
- current_node.l_corner.copy(),
- current_node.r_corner.copy(),
- current_node.dims.astype('int64'))
+
+ if na.any(current_node.r_corner-current_node.l_corner == 0):
+ current_node.brick = None
+ else:
+ current_node.brick = PartitionedGrid(current_node.grid.id, len(self.fields), data,
+ current_node.l_corner.copy(),
+ current_node.r_corner.copy(),
+ current_node.dims.astype('int64'))
self.bricks.append(current_node.brick)
self.brick_dimensions.append(current_node.dims)
self.bricks = na.array(self.bricks)
@@ -1074,7 +1077,8 @@
for node in self.viewpoint_traverse(viewpoint):
if node.grid is not None:
- yield node.brick
+ if node.brick is not None:
+ yield node.brick
self.reduce_tree_images(self.tree, front_center)
self._barrier()
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