[Yt-svn] yt: 2 new changesets

hg at spacepope.org hg at spacepope.org
Sun Mar 28 19:29:52 PDT 2010


hg Repository: yt
details:   yt/rev/2beae88033eb
changeset: 1492:2beae88033eb
user:      Matthew Turk <matthewturk at gmail.com>
date:
Sun Mar 28 19:29:37 2010 -0700
description:
Adding the ability to select which field to display in the chaco interface.
Still rough around the edges.

hg Repository: yt
details:   yt/rev/4fa0bfdfdb95
changeset: 1493:4fa0bfdfdb95
user:      Matthew Turk <matthewturk at gmail.com>
date:
Sun Mar 28 19:29:48 2010 -0700
description:
Merging

diffstat:

 yt/extensions/MergerTree.py                       |  10 +++++++---
 yt/extensions/image_panner/pan_and_scan_widget.py |  23 +++++++++++++++++++++--
 2 files changed, 28 insertions(+), 5 deletions(-)

diffs (112 lines):

diff -r 8472d0d8acc3 -r 4fa0bfdfdb95 yt/extensions/MergerTree.py
--- a/yt/extensions/MergerTree.py	Sun Mar 28 15:18:05 2010 -0700
+++ b/yt/extensions/MergerTree.py	Sun Mar 28 19:29:48 2010 -0700
@@ -86,11 +86,12 @@
     def _close_database(self):
         # close the database cleanly.
         self.cursor.close()
+        self.conn.close()
 
 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, dm_only=False, refresh=False):
+            FOF_link_length=0.2, dm_only=False, refresh=False, sleep=5):
         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
@@ -98,6 +99,9 @@
         self.FOF_link_length= FOF_link_length # For FOF
         self.dm_only = dm_only
         self.refresh = refresh
+        self.sleep = sleep # How long to wait between db sync checks.
+        if self.sleep <= 0.:
+            self.sleep = 5
         # MPI stuff
         self.mine = self._mpi_get_rank()
         if self.mine is None:
@@ -211,7 +215,7 @@
             except IOError:
                 # This is to give a little bit of time for the database creation
                 # to replicate across the file system.
-                time.sleep(5)
+                time.sleep(self.sleep)
                 file = open(self.database)
             hash = md5.md5(file.read()).hexdigest()
             file.close()
@@ -221,7 +225,7 @@
                 break
             else:
                 # Wait a little bit for the file system to (hopefully) sync up.
-                time.sleep(5)
+                time.sleep(self.sleep)
         if len(hashes) == 1:
             return
         else:
diff -r 8472d0d8acc3 -r 4fa0bfdfdb95 yt/extensions/image_panner/pan_and_scan_widget.py
--- a/yt/extensions/image_panner/pan_and_scan_widget.py	Sun Mar 28 15:18:05 2010 -0700
+++ b/yt/extensions/image_panner/pan_and_scan_widget.py	Sun Mar 28 19:29:48 2010 -0700
@@ -28,7 +28,7 @@
 # Enthought library imports
 from enthought.enable.api import Component, ComponentEditor, Window
 from enthought.traits.api import HasTraits, Instance, Button, Any, Callable, \
-        on_trait_change, Bool
+        on_trait_change, Bool, DelegatesTo, List, Enum
 from enthought.traits.ui.api import Item, Group, View
 
 # Chaco imports
@@ -103,6 +103,12 @@
     img_plot = Instance(CMapImagePlot)
     panner = Instance(VariableMeshPanner)
     helper = Instance(ImagePixelizerHelper)
+    fields = List
+
+    def __init__(self, *args, **kwargs):
+        super(VMImagePlot, self).__init__(**kwargs)
+        self.add_trait("field", Enum(*self.fields))
+        self.field = self.panner.field
 
     def _plot_default(self):
         pd = ArrayPlotData()
@@ -120,12 +126,24 @@
         self.img_plot = img_plot
         return plot
 
+    def _field_changed(self, old, new):
+        self.panner.field = new
+        self.fid.recalculate()
+
     def _fid_default(self):
         return FunctionImageData(func = self.helper)
 
     def _helper_default(self):
         return ImagePixelizerHelper(self.panner)
 
+    def _fields_default(self):
+        keys = []
+        for field in self.panner.source.data:
+            if field not in ['px','py','pdx','pdy',
+                             'pz','pdz','weight_field']:
+                keys.append(field)
+        return keys
+
 class VariableMeshPannerView(HasTraits):
 
     plot = Instance(Plot)
@@ -137,7 +155,7 @@
                     Group(
                         Item('container', editor=ComponentEditor(size=(512,512)), 
                              show_label=False),
-                        Item('spawn_zoom', show_label=False),
+                        Item('field', show_label=False),
                         orientation = "vertical"),
                     width = 800, height=800,
                     resizable=True, title="Pan and Scan",
@@ -149,6 +167,7 @@
     def __init__(self, **kwargs):
         super(VariableMeshPannerView, self).__init__(**kwargs)
         # Create the plot
+        self.add_trait("field", DelegatesTo("vm_plot"))
 
         plot = self.vm_plot.plot
         img_plot = self.vm_plot.img_plot



More information about the yt-svn mailing list