[Yt-svn] yt: 2 new changesets

hg at spacepope.org hg at spacepope.org
Sun Mar 21 14:58:25 PDT 2010


hg Repository: yt
details:   yt/rev/8ea75130468b
changeset: 1463:8ea75130468b
user:      Matthew Turk <matthewturk at gmail.com>
date:
Sun Mar 21 14:58:02 2010 -0700
description:
Adding a couple classes to make "porthole" type interfaces possible -- think
multiple displays running concurrently.  Currently there is no infrastructure
to directly support distributed objects, but the next set of work will include
the necessary wrapping to enable this to be executed through the
MultiEngineClient in IPython.

hg Repository: yt
details:   yt/rev/1aa6eb842a66
changeset: 1464:1aa6eb842a66
user:      Matthew Turk <matthewturk at gmail.com>
date:
Sun Mar 21 14:58:21 2010 -0700
description:
Merging from tip

diffstat:

 yt/extensions/MergerTree.py             |  26 +++++++++---
 yt/extensions/image_panner/__init__.py  |   3 +-
 yt/extensions/image_panner/vm_panner.py |  47 +++++++++++++++++++++++-
 yt/lagos/HaloFinding.py                 |   2 +-
 yt/lagos/StructureFunctionGenerator.py  |   9 ++--
 5 files changed, 73 insertions(+), 14 deletions(-)

diffs (202 lines):

diff -r f25078d03f66 -r 1aa6eb842a66 yt/extensions/MergerTree.py
--- a/yt/extensions/MergerTree.py	Fri Mar 19 15:26:19 2010 -0700
+++ b/yt/extensions/MergerTree.py	Sun Mar 21 14:58:21 2010 -0700
@@ -30,7 +30,7 @@
 import yt.extensions.HaloProfiler as HP
 
 import numpy as na
-import os, glob, md5, time
+import os, glob, md5, time, gc
 import h5py
 import types
 import sqlite3 as sql
@@ -90,12 +90,14 @@
 class MergerTree(DatabaseFunctions, lagos.ParallelAnalysisInterface):
     def __init__(self, restart_files=[], database='halos.db',
             halo_finder_function=HaloFinder, halo_finder_threshold=80.0,
-            FOF_link_length=0.2):
+            FOF_link_length=0.2, dm_only=False, refresh=False):
         self.restart_files = restart_files # list of enzo restart files
         self.database = database # the sqlite database of haloes.
         self.halo_finder_function = halo_finder_function # which halo finder to use
         self.halo_finder_threshold = halo_finder_threshold # overdensity threshold
         self.FOF_link_length= FOF_link_length # For FOF
+        self.dm_only = dm_only
+        self.refresh = refresh
         # MPI stuff
         self.mine = self._mpi_get_rank()
         if self.mine is None:
@@ -104,6 +106,12 @@
         if self.size is None:
             self.size = 1
         # Get to work.
+        if self.refresh and self.mine == 0:
+            try:
+                os.unlink(self.database)
+            except:
+                pass
+        self._barrier()
         self._open_create_database()
         self._create_halo_table()
         self._run_halo_finder_add_to_db()
@@ -126,21 +134,24 @@
 
     def _run_halo_finder_add_to_db(self):
         for file in self.restart_files:
+            gc.collect()
             pf = lagos.EnzoStaticOutput(file)
-            # If the halos are already found, skip this one.
+            # If the halos are already found, skip this data step, unless
+            # refresh is True.
             dir = os.path.dirname(file)
             if os.path.exists(os.path.join(dir, 'MergerHalos.out')) and \
                     os.path.exists(os.path.join(dir, 'MergerHalos.txt')) and \
-                    glob.glob(os.path.join(dir, 'MergerHalos*h5')) is not []:
+                    glob.glob(os.path.join(dir, 'MergerHalos*h5')) is not [] and \
+                    not self.refresh:
                 pass
             else:
                 # Run the halo finder.
                 if self.halo_finder_function == yt.lagos.HaloFinding.FOFHaloFinder:
                     halos = self.halo_finder_function(pf,
-                        link=self.FOF_link_length, dm_only=True)
+                        link=self.FOF_link_length, dm_only=self.dm_only)
                 else:
                     halos = self.halo_finder_function(pf,
-                        threshold=self.halo_finder_threshold, dm_only=True)
+                        threshold=self.halo_finder_threshold, dm_only=self.dm_only)
                 halos.write_out(os.path.join(dir, 'MergerHalos.out'))
                 halos.write_particle_lists(os.path.join(dir, 'MergerHalos'))
                 halos.write_particle_lists_txt(os.path.join(dir, 'MergerHalos'))
@@ -183,6 +194,7 @@
         # doesn't already exist. Open it first on root, and then on the others.
         if self.mine == 0:
             self.conn = sql.connect(self.database)
+        self._barrier()
         self._ensure_db_sync()
         if self.mine != 0:
             self.conn = sql.connect(self.database)
@@ -651,4 +663,4 @@
             fp.write(line)
             results = self.cursor.fetchone()
         fp.close()
-        
\ No newline at end of file
+        
diff -r f25078d03f66 -r 1aa6eb842a66 yt/extensions/image_panner/__init__.py
--- a/yt/extensions/image_panner/__init__.py	Fri Mar 19 15:26:19 2010 -0700
+++ b/yt/extensions/image_panner/__init__.py	Sun Mar 21 14:58:21 2010 -0700
@@ -21,4 +21,5 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
 
-from vm_panner import VariableMeshPanner
+from vm_panner import VariableMeshPanner, WindowedVariableMeshPanner, \
+                MultipleWindowVariableMeshPanner
diff -r f25078d03f66 -r 1aa6eb842a66 yt/extensions/image_panner/vm_panner.py
--- a/yt/extensions/image_panner/vm_panner.py	Fri Mar 19 15:26:19 2010 -0700
+++ b/yt/extensions/image_panner/vm_panner.py	Sun Mar 21 14:58:21 2010 -0700
@@ -29,7 +29,7 @@
 class VariableMeshPanner(object):
     _buffer = None
 
-    def __init__(self, source, size, field, callback = None, pf = None):
+    def __init__(self, source, size, field, callback = None):
         if not isinstance(source, (AMRProjBase, AMRSliceBase)):
             raise RuntimeError
         if callback is None:
@@ -115,3 +115,48 @@
         return b
 
 data_object_registry["image_panner"] = VariableMeshPanner
+
+class WindowedVariableMeshPanner(VariableMeshPanner):
+
+    def __init__(self, source, full_size, my_size, start_indices,
+                 field, callback = None):
+        self.my_size = my_size
+        self.start_indices = start_indices
+        VariableMeshPanner.__init__(self, source, full_size, field, callback)
+
+    def _regenerate_buffer(self):
+        dx = (self.xlim[1] - self.xlim[0])/self.size[0]
+        dy = (self.ylim[1] - self.ylim[0])/self.size[1]
+        my_lim = (self.xlim[0] + dx*self.start_indices[0],
+                  self.xlim[0] + dx*(self.start_indices[0] + self.my_size[0]),
+                  self.ylim[0] + dx*self.start_indices[1],
+                  self.ylim[0] + dx*(self.start_indices[1] + self.my_size[1]))
+        new_buffer = FixedResolutionBuffer(self.source, my_lim, self.my_size)
+        self._buffer = new_buffer
+
+data_object_registry["windowed_image_panner"] = WindowedVariableMeshPanner
+
+class MultipleWindowVariableMeshPanner(object):
+    def __init__(self, windows):
+        self.windows = windows
+
+    def zoom(self, factor):
+        for w in self.windows: w.zoom(factor)
+
+    def pan(self, deltas):
+        for w in self.windows: w.pan(factor)
+
+    def pan_x(self, delta):
+        for w in self.windows: w.pan_x(delta)
+
+    def pan_y(self, delta):
+        for w in self.windows: w.pan_y(delta)
+
+    def pan_rel(self, deltas):
+        for w in self.windows: w.pan_rel(deltas)
+
+    def pan_rel_x(self, delta):
+        for w in self.windows: w.pan_rel_x(delta)
+
+    def pan_rel_y(self, delta):
+        for w in self.windows: w.pan_rel_y(delta)
diff -r f25078d03f66 -r 1aa6eb842a66 yt/lagos/HaloFinding.py
--- a/yt/lagos/HaloFinding.py	Fri Mar 19 15:26:19 2010 -0700
+++ b/yt/lagos/HaloFinding.py	Sun Mar 21 14:58:21 2010 -0700
@@ -952,7 +952,7 @@
             self.rms_vel[groupID] = \
                 na.sqrt(rms_vel_temp[groupID][0] / rms_vel_temp[groupID][1]) * \
                 self.group_sizes[groupID]
-        del rms_vel_temp, ms
+        del rms_vel_temp
         yt_counters("rms vel computing")
         self.taskID = obj.mine
         self.halo_taskmap = obj.halo_taskmap # A defaultdict.
diff -r f25078d03f66 -r 1aa6eb842a66 yt/lagos/StructureFunctionGenerator.py
--- a/yt/lagos/StructureFunctionGenerator.py	Fri Mar 19 15:26:19 2010 -0700
+++ b/yt/lagos/StructureFunctionGenerator.py	Sun Mar 21 14:58:21 2010 -0700
@@ -152,9 +152,10 @@
         # Do all the startup tasks.
         self._init_kd_tree()
         self._build_fields_vals()
-        self._build_points_array()
         for bigloop, length in enumerate(self.lengths):
-            #mylog.info("Doing length %1.5e" % length)
+            self._build_points_array()
+            if self.mine == 0:
+                mylog.info("Doing length %1.5e" % length)
             # Things stop when this value below equals total_values.
             self.generated_points = 0
             self.gen_array = na.zeros(self.size, dtype='int64')
@@ -191,7 +192,8 @@
                     self._send_done_toall()
             #print 'done!', self.mine
             #self._barrier()
-            mylog.info("Length (%d of %d) %1.5e took %d communication cycles to complete." % \
+            if self.mine == 0:
+                mylog.info("Length (%d of %d) %1.5e took %d communication cycles to complete." % \
                 (bigloop+1, len(self.lengths), length, self.comm_cycle_count))
         self._allsum_bin_hits()
     
@@ -321,7 +323,6 @@
         """
         Add up the hits to all the bins globally for all functions.
         """
-        print 'here'
         for fset in self.fsets:
             fset.too_low = self._mpi_allsum(fset.too_low)
             fset.too_high = self._mpi_allsum(fset.too_high)



More information about the yt-svn mailing list