[Yt-svn] yt: Fix issues with the quad tree projection.
hg at spacepope.org
hg at spacepope.org
Tue Feb 22 20:32:36 PST 2011
hg Repository: yt
details: yt/rev/80f278d2d1bd
changeset: 3764:80f278d2d1bd
user: Matthew Turk <matthewturk at gmail.com>
date:
Tue Feb 22 23:32:21 2011 -0500
description:
Fix issues with the quad tree projection.
1. Weighting was broken, because of a bunch of unallocated memory and bad array
broadcasting.
2. Multi-field projecting was broken because of array ordering issues.
diffstat:
yt/data_objects/data_containers.py | 11 ++++++-----
yt/utilities/_amr_utils/QuadTree.pyx | 4 +++-
2 files changed, 9 insertions(+), 6 deletions(-)
diffs (59 lines):
diff -r badcec4be5c9 -r 80f278d2d1bd yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py Tue Feb 22 21:01:15 2011 -0500
+++ b/yt/data_objects/data_containers.py Tue Feb 22 23:32:21 2011 -0500
@@ -1456,7 +1456,7 @@
self._obtain_fields(fields, self._node_name)
fields = [f for f in fields if f not in self.data]
if len(fields) == 0: return
- tree = self._get_tree(len(fields) + int(self._weight is not None))
+ tree = self._get_tree(len(fields))
coord_data = []
field_data = []
dxs = []
@@ -1482,7 +1482,7 @@
for level in range(0, self._max_level + 1):
npos, nvals, nwvals = tree.get_all_from_level(level, False)
coord_data.append(npos)
- if self._weight is not None: nvals /= nwvals
+ if self._weight is not None: nvals /= nwvals[:,None]
field_data.append(nvals)
weight_data.append(nwvals)
gs = self.source.select_grids(level)
@@ -1534,7 +1534,7 @@
masked_data = [field_data[field].copy().astype('float64') * weight_data
for field in fields]
del field_data
- wdl = self.dls[-1]
+ wdl = dls[-1]
full_proj = [self.func(field, axis=self.axis) * dl
for field, dl in zip(masked_data, dls)]
weight_proj = self.func(weight_data, axis=self.axis) * wdl
@@ -1544,11 +1544,12 @@
else:
used_data = na.array([1.0], dtype='bool')
used_points = slice(None)
- xind, yind = [arr[used_points].ravel() for arr in na.indices(full_proj[0].shape)]
+ xind, yind = [arr[used_points].ravel()
+ for arr in na.indices(full_proj[0].shape)]
start_index = grid.get_global_startindex()
xpoints = (xind + (start_index[x_dict[self.axis]])).astype('int64')
ypoints = (yind + (start_index[y_dict[self.axis]])).astype('int64')
- to_add = na.array([d[used_points].ravel() for d in full_proj])
+ to_add = na.array([d[used_points].ravel() for d in full_proj], order='F')
tree.add_array_to_tree(grid.Level, xpoints, ypoints,
to_add, weight_proj[used_points].ravel())
diff -r badcec4be5c9 -r 80f278d2d1bd yt/utilities/_amr_utils/QuadTree.pyx
--- a/yt/utilities/_amr_utils/QuadTree.pyx Tue Feb 22 21:01:15 2011 -0500
+++ b/yt/utilities/_amr_utils/QuadTree.pyx Tue Feb 22 23:32:21 2011 -0500
@@ -98,7 +98,9 @@
cdef class QuadTree:
cdef int nvals
- cdef np.int64_t po2[80]
+ # Hardcode to a maximum 80 levels of refinement.
+ # TODO: Update when we get to yottascale.
+ cdef np.int64_t po2[80]
cdef QuadTreeNode ***root_nodes
cdef np.int64_t top_grid_dims[2]
More information about the yt-svn
mailing list