[Yt-svn] yt: 3 new changesets
hg at spacepope.org
hg at spacepope.org
Fri Feb 18 13:51:51 PST 2011
hg Repository: yt
details: yt/rev/6c907c42eade
changeset: 3747:6c907c42eade
user: Sam Skillman <sam.skillman at gmail.com>
date:
Wed Feb 16 18:18:35 2011 -0700
description:
Adding optimized amr_kdtree, not active yet, and kept separate from the old one for now.
hg Repository: yt
details: yt/rev/905a8c9f69a7
changeset: 3748:905a8c9f69a7
user: Sam Skillman <sam.skillman at gmail.com>
date:
Fri Feb 18 14:40:16 2011 -0700
description:
Revamp of amr_kdtree to improve performance. Note that this removes
the 'depth' and 'breadth' options in tree_type, which may or may not
be re-implemented in the future. AMRKDTree.tree is a linked set of
kD-tree nodes. There is also an AMRKDTree.tree_dict, which is a
dictionary of kD-tree node id keys that point to the kD-tree node
objects. Additionally, the HEALpixCamera now uses the AMRKDTree and
the volume.traverse() function to iterate over the bricks in a
back-to-front ordering.
hg Repository: yt
details: yt/rev/8d6cef145d37
changeset: 3749:8d6cef145d37
user: Sam Skillman <sam.skillman at gmail.com>
date:
Fri Feb 18 14:41:21 2011 -0700
description:
Merging.
diffstat:
yt/analysis_modules/halo_merger_tree/merger_tree.py | 2 +-
yt/analysis_modules/level_sets/contour_finder.py | 28 +-
yt/astro_objects/api.py | 9 +-
yt/astro_objects/astrophysical_object.py | 90 +
yt/astro_objects/clumped_region.py | 39 +
yt/astro_objects/simulation_volume.py | 32 +
yt/utilities/_amr_utils/ContourFinding.pyx | 17 +
yt/utilities/amr_kdtree/amr_kdtree.py | 978 ++++++++-----------
yt/visualization/volume_rendering/camera.py | 16 +-
9 files changed, 611 insertions(+), 600 deletions(-)
diffs (truncated from 1577 to 300 lines):
diff -r d8f67aaa2e0d -r 8d6cef145d37 yt/analysis_modules/halo_merger_tree/merger_tree.py
--- a/yt/analysis_modules/halo_merger_tree/merger_tree.py Mon Feb 14 14:52:00 2011 -0700
+++ b/yt/analysis_modules/halo_merger_tree/merger_tree.py Fri Feb 18 14:41:21 2011 -0700
@@ -216,7 +216,7 @@
for cycle, file in enumerate(self.restart_files):
gc.collect()
pf = load(file)
- self.period = self.pf.domain_right_edge - self.pf.domain_left_edge
+ self.period = pf.domain_right_edge - pf.domain_left_edge
# If the halos are already found, skip this data step, unless
# refresh is True.
dir = os.path.dirname(file)
diff -r d8f67aaa2e0d -r 8d6cef145d37 yt/analysis_modules/level_sets/contour_finder.py
--- a/yt/analysis_modules/level_sets/contour_finder.py Mon Feb 14 14:52:00 2011 -0700
+++ b/yt/analysis_modules/level_sets/contour_finder.py Fri Feb 18 14:41:21 2011 -0700
@@ -256,7 +256,11 @@
s1.update(joins.pop(k2))
s1.update([k2])
updated += 1
- return joins
+ tr = []
+ for k in joins.keys():
+ v = joins.pop(k)
+ tr.append((k, na.array(list(v), dtype="int64")))
+ return tr
def identify_contours(data_source, field, min_val, max_val,
cached_fields=None):
@@ -300,15 +304,23 @@
sort_new = na.array(list(set(tree)), dtype='int64')
mylog.info("Coalescing %s joins", sort_new.shape[0])
joins = coalesce_join_tree(sort_new)
+ #joins = [(i, na.array(list(j), dtype="int64")) for i, j in sorted(joins.items())]
pbar = get_pbar("Joining ", len(joins))
# This process could and should be done faster
- for i, new in enumerate(sorted(joins.keys())):
- pbar.update(i)
- old_set = joins[new]
- for old in old_set:
- if old == new: continue
- i1 = (data_source["tempContours"] == old)
- data_source["tempContours"][i1] = new
+ print "Joining..."
+ t1 = time.time()
+ ff = data_source["tempContours"].astype("int64")
+ amr_utils.update_joins(joins, ff)
+ data_source["tempContours"] = ff.astype("float64")
+ #for i, new in enumerate(sorted(joins.keys())):
+ # pbar.update(i)
+ # old_set = joins[new]
+ # for old in old_set:
+ # if old == new: continue
+ # i1 = (data_source["tempContours"] == old)
+ # data_source["tempContours"][i1] = new
+ t2 = time.time()
+ print "Finished joining in %0.2e seconds" % (t2-t1)
pbar.finish()
data_source._flush_data_to_grids("tempContours", -1, dtype='int64')
del data_source.data["tempContours"] # Force a reload from the grids
diff -r d8f67aaa2e0d -r 8d6cef145d37 yt/astro_objects/api.py
--- a/yt/astro_objects/api.py Mon Feb 14 14:52:00 2011 -0700
+++ b/yt/astro_objects/api.py Fri Feb 18 14:41:21 2011 -0700
@@ -24,4 +24,11 @@
"""
-# Nothing here yet!
+from .astrophysical_object import \
+ AstrophysicalObject, identification_method, correlation_method
+
+from .simulation_volume import \
+ SimulationVolume
+
+from .clumped_region import \
+ ClumpedRegion
diff -r d8f67aaa2e0d -r 8d6cef145d37 yt/astro_objects/astrophysical_object.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/yt/astro_objects/astrophysical_object.py Fri Feb 18 14:41:21 2011 -0700
@@ -0,0 +1,90 @@
+"""
+A base-class representing an astrophysical object
+
+Author: Matthew Turk <matthewturk at gmail.com>
+Affiliation: NSF / Columbia
+Homepage: http://yt.enzotools.org/
+License:
+ Copyright (C) 2011 Matthew Turk. All Rights Reserved.
+
+ This file is part of yt.
+
+ yt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+
+astro_object_registry = {}
+
+class AstrophysicalObject(object):
+ # No _type_name
+ _skip_add = False
+
+ class __metaclass__(type):
+ def __init__(cls, name, b, d):
+ type.__init__(cls, name, b, d)
+ if hasattr(cls, "_type_name") and not cls._skip_add:
+ astro_object_registry[cls._type_name] = cls
+ cls.identification_methods = {}
+ cls.correlation_methods = {}
+
+ def _lookup_object(self, obj_name):
+ if obj_name not in astro_object_registry:
+ raise KeyError(obj_name)
+ return astro_object_registry[obj_name]
+
+ def correlate(self, other_collection, correlation_name):
+ pass
+
+ def __init__(self, data_source):
+ self.objects = {}
+ # We mandate that every object have a corresponding AMR3DData source
+ # affiliated with it.
+ self.data_source = data_source
+
+ def find(self, obj_name, identification_name, *args, **kwargs):
+ obj = self._lookup_object(obj_name)
+ if callable(identification_name):
+ identification_method = identification_name
+ else:
+ if identification_name not in obj.identification_methods:
+ raise KeyError(identification_name)
+ identification_method = \
+ obj.identification_methods[identification_name]
+ new_objs = identification_method(self, *args, **kwargs)
+ setattr(self, obj_name, new_objs)
+ self.objects[obj_name] = new_objs
+ return new_objs
+
+ def correlate(self, other_set, correlation_name, *args, **kwargs):
+ if callable(correlation_name):
+ correlation_method = correlation_name
+ else:
+ if correlation_name not in self.correlation_methods:
+ raise KeyError(correlation_name)
+ correlation_method = self.correlation_methods[correlation_name]
+ linked_objs = correlation_method(self, *args, **kwargs)
+ return linked_objs
+
+def correlation_method(obj_name, link_name):
+ def passthrough(func):
+ obj = astro_object_registry[obj_name]
+ obj.correlation_methods[link_name] = func
+ return func
+ return passthrough
+
+def identification_method(obj_name, id_name):
+ def passthrough(func):
+ obj = astro_object_registry[obj_name]
+ obj.identification_methods[id_name] = func
+ return func
+ return passthrough
diff -r d8f67aaa2e0d -r 8d6cef145d37 yt/astro_objects/clumped_region.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/yt/astro_objects/clumped_region.py Fri Feb 18 14:41:21 2011 -0700
@@ -0,0 +1,39 @@
+"""
+A base-class representing an astrophysical object
+
+Author: Matthew Turk <matthewturk at gmail.com>
+Affiliation: NSF / Columbia
+Homepage: http://yt.enzotools.org/
+License:
+ Copyright (C) 2011 Matthew Turk. All Rights Reserved.
+
+ This file is part of yt.
+
+ yt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+
+from .astrophysical_object import \
+ AstrophysicalObject, identification_method, correlation_method
+
+class ClumpedRegion(AstrophysicalObject):
+ _type_name = "clumped_region"
+ def __init__(self, data_source):
+ AstrophysicalObject.__init__(self, data_source)
+
+ at identification_method("clumped_region", "level_set")
+def clumps(obj, field, min_val):
+ ds = obj.data_source
+ mi, ma = ds.quantities["Extrema"](field)[0]
+ cls = obj.data_source.extract_connected_sets(field, 1, min_val, ma)
+ return [ClumpedRegion(o) for o in cls[1][0]]
diff -r d8f67aaa2e0d -r 8d6cef145d37 yt/astro_objects/simulation_volume.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/yt/astro_objects/simulation_volume.py Fri Feb 18 14:41:21 2011 -0700
@@ -0,0 +1,32 @@
+"""
+An AstrophysicalObject that represents a simulation volume
+
+Author: Matthew Turk <matthewturk at gmail.com>
+Affiliation: NSF / Columbia
+Homepage: http://yt.enzotools.org/
+License:
+ Copyright (C) 2011 Matthew Turk. All Rights Reserved.
+
+ This file is part of yt.
+
+ yt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+
+from .astrophysical_object import \
+ AstrophysicalObject, identification_method, correlation_method
+
+class SimulationVolume(AstrophysicalObject):
+ _type_name = "simulation_volume"
+ def __init__(self, data_source):
+ AstrophysicalObject.__init__(self, data_source)
diff -r d8f67aaa2e0d -r 8d6cef145d37 yt/utilities/_amr_utils/ContourFinding.pyx
--- a/yt/utilities/_amr_utils/ContourFinding.pyx Mon Feb 14 14:52:00 2011 -0700
+++ b/yt/utilities/_amr_utils/ContourFinding.pyx Fri Feb 18 14:41:21 2011 -0700
@@ -39,6 +39,7 @@
return i1
@cython.boundscheck(False)
+ at cython.wraparound(False)
def construct_boundary_relationships(
np.ndarray[dtype=np.int64_t, ndim=3] contour_ids):
# We only look at the boundary and one cell in
@@ -174,3 +175,19 @@
for j in proto_contour:
contours[j] = proto_contour
return contours
+
+ at cython.boundscheck(False)
+ at cython.wraparound(False)
+def update_joins(joins, np.ndarray[np.int64_t, ndim=1] contour_ids):
+ cdef np.int64_t new, old, i, oi
+ cdef int n, on
+ cdef np.ndarray[np.int64_t, ndim=1] old_set
+ #print contour_ids.shape[0]
+ n = contour_ids.shape[0]
+ for new, old_set in joins:
+ #print new
+ on = old_set.shape[0]
+ for i in range(n):
+ for oi in range(on):
+ old = old_set[oi]
+ if contour_ids[i] == old: contour_ids[i] = new
diff -r d8f67aaa2e0d -r 8d6cef145d37 yt/utilities/amr_kdtree/amr_kdtree.py
--- a/yt/utilities/amr_kdtree/amr_kdtree.py Mon Feb 14 14:52:00 2011 -0700
+++ b/yt/utilities/amr_kdtree/amr_kdtree.py Fri Feb 18 14:41:21 2011 -0700
@@ -33,7 +33,6 @@
import yt.utilities.parallel_tools.parallel_analysis_interface as PT
from copy import deepcopy
from yt.config import ytcfg
-
from time import time
import h5py
my_rank = ytcfg.getint("yt", "__parallel_rank")
@@ -67,22 +66,28 @@
Used during the construction to act as both dividing nodes and
leaf nodes.
"""
- def __init__(self):
- self.grids = None
- self.parent = None
- self.parent_grid = None
- self.l_corner = None
- self.r_corner = None
More information about the yt-svn
mailing list