[Yt-svn] yt: 3 new changesets

hg at spacepope.org hg at spacepope.org
Sun Apr 25 22:17:53 PDT 2010


hg Repository: yt
details:   yt/rev/541465a56c4a
changeset: 1608:541465a56c4a
user:      Matthew Turk <matthewturk at gmail.com>
date:
Sun Apr 25 21:41:42 2010 -0700
description:
Adding widget for pan-n-scanning through multiple outputs.

hg Repository: yt
details:   yt/rev/67f37d999756
changeset: 1609:67f37d999756
user:      Matthew Turk <matthewturk at gmail.com>
date:
Sun Apr 25 21:52:05 2010 -0700
description:
Actually, we need to import yt.mods and we need to specify the data_style as
enzo_packed_3d.  If you're not using enzo_packed_3d, this won't work as is.

hg Repository: yt
details:   yt/rev/055ececd0756
changeset: 1610:055ececd0756
user:      Matthew Turk <matthewturk at gmail.com>
date:
Sun Apr 25 22:17:37 2010 -0700
description:
Removing a print statement, adding a quick loader for the OutputSelector.

diffstat:

 yt/extensions/image_panner/pan_and_scan_widget.py |  57 +++++++++++++++++++++++++++-
 yt/extensions/image_panner/vm_panner.py           |   1 -
 2 files changed, 55 insertions(+), 3 deletions(-)

diffs (82 lines):

diff -r f3df0e2354c6 -r 055ececd0756 yt/extensions/image_panner/pan_and_scan_widget.py
--- a/yt/extensions/image_panner/pan_and_scan_widget.py	Sun Apr 25 20:36:03 2010 -0700
+++ b/yt/extensions/image_panner/pan_and_scan_widget.py	Sun Apr 25 22:17:37 2010 -0700
@@ -28,8 +28,10 @@
 # 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, DelegatesTo, List, Enum
-from enthought.traits.ui.api import Item, Group, View
+        on_trait_change, Bool, DelegatesTo, List, Enum, Int, Property, Str, \
+        cached_property
+from enthought.traits.ui.api import \
+        Group, View, Item, VGroup, InstanceEditor
 
 # Chaco imports
 from enthought.chaco.api import ArrayPlotData, jet, Plot, HPlotContainer, \
@@ -249,3 +251,54 @@
         self.full_container.add(self.colorbar)
         self.full_container.add(self.container)
         self.container.add(self.vm_plot.plot)
+
+class OutputSelector(HasTraits):
+    outputs = List
+    main_plot = Instance(VariableMeshPannerView)
+    main_panner = Property(depends_on = "pf")
+    weight_field = Str("Density")
+
+    pf = Any
+    source = Any
+    axis = Int(0)
+
+    traits_view = View(VGroup(
+                        Item('output'),
+                        Item('main_plot'),
+                        )
+                      )
+
+    def __init__(self, **kwargs):
+        super(OutputSelector, self).__init__(**kwargs)
+        self.add_trait("output", Enum(*self.outputs))
+        self.output = self.outputs[-1]
+        self.main_plot
+
+    def _output_default(self):
+        return self.outputs[0]
+
+    def _output_changed(self, old, new):
+        # We get a string here
+        import yt.mods
+        self.pf = yt.mods.load(new, data_style="enzo_packed_3d")
+        self.source = yt.mods.projload(self.pf, self.axis, "Density")
+        self.main_panner.field = self.main_plot.vm_plot.field
+        self.main_plot.panner = self.main_plot.vm_plot.panner = \
+            self.main_plot.vm_plot.helper.panner = self.main_panner
+        self.main_plot.vm_plot.field = self.main_panner.field
+
+    def _main_plot_default(self):
+        vmpv = VariableMeshPannerView(panner = self.main_panner)
+        vmpv.vm_plot.helper.run_callbacks = True
+        return vmpv
+
+    @cached_property
+    def _get_main_panner(self):
+        return self.pf.h.image_panner(self.source, (512, 512), "Density")
+
+def pan_and_scan_directory(dir_name):
+    import glob, os
+    fns = [ fn[:-10] for fn in
+            glob.glob(os.path.join(dir_name, "**", "*.hierarchy")) ]
+    selector = OutputSelector(outputs = fns)
+    return selector
diff -r f3df0e2354c6 -r 055ececd0756 yt/extensions/image_panner/vm_panner.py
--- a/yt/extensions/image_panner/vm_panner.py	Sun Apr 25 20:36:03 2010 -0700
+++ b/yt/extensions/image_panner/vm_panner.py	Sun Apr 25 22:17:37 2010 -0700
@@ -300,7 +300,6 @@
             new_dict = {}
             new_dict.update(d)
             for f in _wrapped_methods:
-                print "Constructing proxy for", f
                 new_dict[f] = return_proxy(f)
             return type.__new__(cls, name, b, new_dict)
 



More information about the yt-svn mailing list