[Yt-svn] yt-commit r498 - trunk/yt/reason

mturk at wrangler.dreamhost.com mturk at wrangler.dreamhost.com
Wed May 28 14:23:08 PDT 2008


Author: mturk
Date: Wed May 28 14:23:06 2008
New Revision: 498
URL: http://yt.spacepope.org/changeset/498

Log:
Some simple bulk velocity stuff.  Right now it looks awful; will work on that
later.  Cutting plane is next.



Modified:
   trunk/yt/reason/Notebook.py
   trunk/yt/reason/Toolbars.py
   trunk/yt/reason/Windows.py

Modified: trunk/yt/reason/Notebook.py
==============================================================================
--- trunk/yt/reason/Notebook.py	(original)
+++ trunk/yt/reason/Notebook.py	Wed May 28 14:23:06 2008
@@ -72,6 +72,8 @@
                  ("field","ChangeFieldFromMessage"),
                  ("limits","ChangeLimitsFromMessage"),
                  ("center","ChangeCenterFromMessage"),
+                 ("field_param","ChangeFieldParamFromMessage"),
+                 ("wipe","WipePlotDataFromMessage"),
                  ("cmap","ChangeColorMapFromMessage")]
         for m,f in pairs:
             Publisher().unsubAll(("viewchange",m))
@@ -354,6 +356,7 @@
         self.take_log_menu = self.popupmenu.AppendCheckItem(-1, "Take Log")
         self.take_log_menu.Check(self.plot.log_field)
         fullDomain = self.popupmenu.Append(-1, "Zoom Top")
+        bulk_velocity = self.popupmenu.Append(-1, "Set Bulk Velocity")
 
         self.Bind(wx.EVT_MENU, self.OnCenterOnMax, centerOnMax)
         self.Bind(wx.EVT_MENU, self.OnCenterHere, centerHere)
@@ -361,6 +364,7 @@
         self.Bind(wx.EVT_MENU, self.show_velocities, velocities)
         self.Bind(wx.EVT_MENU, self.take_log, self.take_log_menu)
         self.Bind(wx.EVT_MENU, self.fulldomain, fullDomain)
+        self.Bind(wx.EVT_MENU, self.set_bulk_velocity, bulk_velocity)
 
     def SetupFigure(self):
         PlotPage.SetupFigure(self)
@@ -450,6 +454,16 @@
             self._velocities_cbid = \
                 self.plot.add_callback(raven.be.quiverCallback(xv,yv,self.axis,20))
 
+    _particles_cbid = None
+    def show_particles(self, event):
+        if self._particles_cbid is not None:
+            self.plot.remove_callback(self._particles_cbid)
+            self._particles_cbid = None
+        else:
+            
+            self._particles_cbid = \
+                self.plot.add_callback(raven.be.quiverCallback(xv,yv,self.axis,20))
+
     def OnCenterHere(self, event):
         xp, yp = self.ContextMenuPosition
         x, y = self.ConvertPositionToDataPosition(xp, yp)
@@ -600,6 +614,21 @@
         self.ChangeWidth(1,'1')
         Publisher().sendMessage(('viewchange','width'), (1,'1'))
 
+    def set_bulk_velocity(self, *args):
+        bv = Toolbars.GetBulkVelocity(self.outputfile, self.center)
+        if bv is not None:
+            Publisher().sendMessage(('viewchange','field_param'),
+                                    ('bulk_velocity', bv))
+            Publisher().sendMessage(('viewchange','wipe'),())
+
+    def WipePlotDataFromMessage(self, message):
+        self.data.clear_data()
+        self.UpdateCanvas()
+
+    def ChangeFieldParamFromMessage(self, message):
+        param, val = message.data
+        self.data.set_field_parameter(param, val)
+
     def set_width(self, *args):
         w, u = Toolbars.ChooseWidth(self.outputfile)
         self.ChangeWidth(w,u)
@@ -625,6 +654,15 @@
             self.figure_canvas.draw()
         #else: print "Opting not to update canvas"
 
+    def ChangeCenterFromMessage(self, message):
+        x, y, z = message.data
+        # We are dealing with a pass-by-reference center
+        self.center[0] = x
+        self.center[1] = y
+        self.center[2] = z
+        self.data.set_field_parameter('center',[x,y,z])
+        #self.UpdateWidth()
+
     def QueryFields(self):
         return QueryFields(self.outputfile)
 
@@ -642,14 +680,6 @@
         self.plot = be.ProjectionPlot(self.data, self.field, figure=self.figure,
                                       axes=self.axes)
 
-    def ChangeCenterFromMessage(self, message):
-        x, y, z = message.data
-        # We are dealing with a pass-by-reference center
-        self.center[0] = x
-        self.center[1] = y
-        self.center[2] = z
-        #self.UpdateWidth()
-
     def QueryFields(self):
         return [self.field]
 

Modified: trunk/yt/reason/Toolbars.py
==============================================================================
--- trunk/yt/reason/Toolbars.py	(original)
+++ trunk/yt/reason/Toolbars.py	Wed May 28 14:23:06 2008
@@ -30,6 +30,8 @@
 import yt.fido as fido
 import yt
 
+import numpy as na
+
 import os
 
 #from yt.reason import *
@@ -94,10 +96,14 @@
                float(self.maxVal.GetValue())
 
 class ReasonWidthSelectionWindow(wx.Dialog):
-    def __init__(self, outputfile):
-        wx.Dialog.__init__(self, None, -1, 'Width Selector',
+    def __init__(self, outputfile, title="Width Selector",
+                 text="Choose the width you would like"):
+        wx.Dialog.__init__(self, None, -1, title,
                            size=wx.Size(300,300))
         self.sizer = wx.BoxSizer(wx.VERTICAL)
+        text = wx.StaticText(self, -1, text)
+        self.sizer.Add(text, 1)
+
         self.width = wx.TextCtrl(self, -1, "1")
         self.width.SetInsertionPoint(0)
         self.sizer.Add(self.width, 1)
@@ -125,6 +131,27 @@
     dlg.Destroy()
     return w, u
 
+def GetBulkVelocity(outputfile, center):
+    dlg = ReasonWidthSelectionWindow(outputfile,
+                "Radius Selector",
+            "With the current display-center, over \n" + \
+            "what radius should bulk velocity be calculated?")
+    resp = dlg.ShowModal()
+    bv = None
+    if resp == wx.ID_OK:
+        w, u = dlg.GetData()
+        sp = outputfile.h.sphere(center=center, radius=w/outputfile[u])
+        bv = sp.quantities["BulkVelocity"](lazy_reader=True)
+        if na.any(na.isnan(bv)):
+            err = wx.MessageDialog(None, "Error",
+                            "The values were bad.  Try a bigger sphere?",
+                            wx.OK)
+            err.ShowModal()
+            err.Destroy()
+            bv = None
+    dlg.Destroy()
+    return bv
+
 def ChooseLimits(plot):
     dlg = ReasonLimitSelectionWindow(plot)
     resp = dlg.ShowModal()

Modified: trunk/yt/reason/Windows.py
==============================================================================
--- trunk/yt/reason/Windows.py	(original)
+++ trunk/yt/reason/Windows.py	Wed May 28 14:23:06 2008
@@ -254,6 +254,7 @@
         self.Fit()
         
 
+
 class ReasonParameterFileViewer(wx.Frame):
     def __init__(self, *args, **kwds):
         kwds["style"] = wx.DEFAULT_FRAME_STYLE



More information about the yt-svn mailing list