[Yt-svn] commit/yt: 25 new changesets

Bitbucket commits-noreply at bitbucket.org
Wed Apr 20 16:31:38 PDT 2011


25 new changesets in yt:

http://bitbucket.org/yt_analysis/yt/changeset/2c6ecba3b219/
changeset:   r4151:2c6ecba3b219
branch:      yt
user:        MatthewTurk
date:        2011-04-16 13:44:21
summary:     Narrowing in on a way to reduce the number of heartbeat calls and decrease
latency between request/response for results.  This uses the 'event' mechanism.
If you don't prevent multiply heartbeat calls from being made in the javascript
(which I believe I have done) then it can blow out the number of open files by
simply creating too many sockets.  Even as is, it may not be completely what we
want, either.
affected #:  3 files (284 bytes)

--- a/yt/gui/reason/bottle_mods.py	Fri Apr 15 17:27:28 2011 -0600
+++ b/yt/gui/reason/bottle_mods.py	Sat Apr 16 07:44:21 2011 -0400
@@ -53,6 +53,7 @@
     recorded_payloads = None
     lock = None
     record = False
+    event = None
     count = 0
 
 
@@ -65,6 +66,7 @@
         if self.payloads is None: self.payloads = []
         if self.lock is None: self.lock = threading.Lock()
         if self.recorded_payloads is None: self.recorded_payloads = []
+        if self.event is None: self.event = threading.Event()
 
     def deliver_payloads(self):
         with self.lock:
@@ -73,12 +75,14 @@
             if self.record:
                 self.recorded_payloads += self.payloads
             self.payloads = []
+            self.event.clear()
         return payloads
 
     def add_payload(self, to_add):
         with self.lock:
             self.payloads.append(to_add)
             self.count += 1
+            self.event.set()
 
     def replay_payloads(self):
         return self.recorded_payloads


--- a/yt/gui/reason/extdirect_repl.py	Fri Apr 15 17:27:28 2011 -0600
+++ b/yt/gui/reason/extdirect_repl.py	Sat Apr 16 07:44:21 2011 -0400
@@ -151,7 +151,9 @@
 
     def heartbeat(self):
         self.last_heartbeat = time.time()
-        return self.payload_handler.deliver_payloads()
+        if self.payload_handler.event.wait(30):
+            return self.payload_handler.deliver_payloads()
+        return []
 
     def _check_heartbeat(self):
         if self.server is not None:
@@ -172,6 +174,7 @@
         if self.server is None:
             return
         self._heartbeat_timer.cancel()
+        self.payload_handler.event.set()
         for v in self.server.values():
             v.stop()
 


--- a/yt/gui/reason/html/js/reason.js	Fri Apr 15 17:27:28 2011 -0600
+++ b/yt/gui/reason/html/js/reason.js	Sat Apr 16 07:44:21 2011 -0400
@@ -321,6 +321,7 @@
     heartbeat = {
     run:
       function(){ if (heartbeat_request == true) return; 
+        heartbeat_request = true;
         yt_rpc.ExtDirectREPL.heartbeat(
             {}, function(f, a) {
             heartbeat_request = false;


http://bitbucket.org/yt_analysis/yt/changeset/251d34326191/
changeset:   r4152:251d34326191
branch:      yt
user:        MatthewTurk
date:        2011-04-16 16:24:21
summary:     Initial, incomplete pass at marching cubes.
affected #:  2 files (18.9 KB)

--- a/yt/utilities/_amr_utils/FixedInterpolator.c	Sat Apr 16 07:44:21 2011 -0400
+++ b/yt/utilities/_amr_utils/FixedInterpolator.c	Sat Apr 16 10:24:21 2011 -0400
@@ -70,6 +70,18 @@
     return vz[0];
 }
 
+void offset_fill(int ds[3], npy_float64 *data, npy_float64 gridval[8])
+{
+    gridval[0] = OINDEX(0,0,0);
+    gridval[1] = OINDEX(0,0,1);
+    gridval[2] = OINDEX(0,1,0);
+    gridval[3] = OINDEX(0,1,1);
+    gridval[4] = OINDEX(1,0,0);
+    gridval[5] = OINDEX(1,1,0);
+    gridval[6] = OINDEX(1,0,1);
+    gridval[7] = OINDEX(1,1,1);
+}
+
 npy_float64 trilinear_interpolate(int ds[3], int ci[3], npy_float64 dp[3],
 				  npy_float64 *data)
 {
@@ -128,3 +140,295 @@
       grad[0]=grad[1]=grad[2]=0.0;
     }
 }
+
+int edge_table[256]={
+0x0  , 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,
+0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
+0x190, 0x99 , 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,
+0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,
+0x230, 0x339, 0x33 , 0x13a, 0x636, 0x73f, 0x435, 0x53c,
+0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,
+0x3a0, 0x2a9, 0x1a3, 0xaa , 0x7a6, 0x6af, 0x5a5, 0x4ac,
+0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,
+0x460, 0x569, 0x663, 0x76a, 0x66 , 0x16f, 0x265, 0x36c,
+0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,
+0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff , 0x3f5, 0x2fc,
+0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,
+0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55 , 0x15c,
+0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,
+0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc ,
+0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,
+0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,
+0xcc , 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,
+0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,
+0x15c, 0x55 , 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,
+0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,
+0x2fc, 0x3f5, 0xff , 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
+0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,
+0x36c, 0x265, 0x16f, 0x66 , 0x76a, 0x663, 0x569, 0x460,
+0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,
+0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa , 0x1a3, 0x2a9, 0x3a0,
+0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,
+0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33 , 0x339, 0x230,
+0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,
+0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99 , 0x190,
+0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,
+0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0   };
+
+int tri_table[256][16] =
+{{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1},
+{3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1},
+{3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1},
+{3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1},
+{9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1},
+{1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1},
+{9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1},
+{2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1},
+{8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1},
+{9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1},
+{4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1},
+{3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1},
+{1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1},
+{4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1},
+{4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1},
+{9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1},
+{1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1},
+{5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1},
+{2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1},
+{9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1},
+{0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1},
+{2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1},
+{10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1},
+{4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1},
+{5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1},
+{5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1},
+{9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1},
+{0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1},
+{1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1},
+{10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1},
+{8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1},
+{2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1},
+{7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1},
+{9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1},
+{2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1},
+{11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1},
+{9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1},
+{5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1},
+{11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1},
+{11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1},
+{1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1},
+{9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1},
+{5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1},
+{2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1},
+{0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1},
+{5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1},
+{6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1},
+{0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1},
+{3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1},
+{6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1},
+{5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1},
+{1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1},
+{10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1},
+{6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1},
+{1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1},
+{8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1},
+{7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1},
+{3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1},
+{5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1},
+{0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1},
+{9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1},
+{8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1},
+{5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1},
+{0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1},
+{6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1},
+{10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1},
+{10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1},
+{8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1},
+{1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1},
+{3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1},
+{0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1},
+{10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1},
+{0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1},
+{3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1},
+{6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1},
+{9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1},
+{8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1},
+{3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1},
+{6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1},
+{0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1},
+{10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1},
+{10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1},
+{1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1},
+{2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1},
+{7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1},
+{7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1},
+{2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1},
+{1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1},
+{11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1},
+{8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1},
+{0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1},
+{7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1},
+{10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1},
+{2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1},
+{6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1},
+{7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1},
+{2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1},
+{1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1},
+{10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1},
+{10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1},
+{0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1},
+{7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1},
+{6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1},
+{8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1},
+{9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1},
+{6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1},
+{1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1},
+{4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1},
+{10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1},
+{8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1},
+{0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1},
+{1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1},
+{8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1},
+{10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1},
+{4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1},
+{10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1},
+{5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1},
+{11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1},
+{9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1},
+{6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1},
+{7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1},
+{3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1},
+{7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1},
+{9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1},
+{3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1},
+{6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1},
+{9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1},
+{1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1},
+{4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1},
+{7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1},
+{6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1},
+{3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1},
+{0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1},
+{6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1},
+{1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1},
+{0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1},
+{11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1},
+{6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1},
+{5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1},
+{9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1},
+{1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1},
+{1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1},
+{10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1},
+{0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1},
+{5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1},
+{10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1},
+{11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1},
+{0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1},
+{9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1},
+{7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1},
+{2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1},
+{8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1},
+{9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1},
+{9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1},
+{1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1},
+{9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1},
+{9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1},
+{5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1},
+{0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1},
+{10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1},
+{2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1},
+{0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1},
+{0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1},
+{9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1},
+{5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1},
+{3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1},
+{5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1},
+{8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1},
+{0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1},
+{9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1},
+{0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1},
+{1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1},
+{3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1},
+{4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1},
+{9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1},
+{11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1},
+{11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1},
+{2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1},
+{9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1},
+{3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1},
+{1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1},
+{4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1},
+{4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1},
+{0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1},
+{3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1},
+{3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1},
+{0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1},
+{9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1},
+{1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
+{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}};


--- a/yt/utilities/_amr_utils/VolumeIntegrator.pyx	Sat Apr 16 07:44:21 2011 -0400
+++ b/yt/utilities/_amr_utils/VolumeIntegrator.pyx	Sat Apr 16 10:24:21 2011 -0400
@@ -65,6 +65,36 @@
     long int lrint(double x)
     double fabs(double x)
 
+cdef struct Triangle:
+    Triangle *next
+    np.float64_t p[3]
+
+cdef void AddTriangle(Triangle *self, np.float64_t *p):
+    cdef Triangle *nn = <Triangle *> malloc(sizeof(Triangle))
+    self.next = nn
+
+cdef int CountTriangles(Triangle *first):
+    cdef int count = 0
+    cdef Triangle *this = first
+    while this != NULL:
+        count += 1
+        this = this.next
+    return count
+
+cdef void FillAndWipeTriangles(np.ndarray[np.float64_t, ndim=2] vertices,
+                               Triangle *first):
+    cdef int count = 0
+    cdef Triangle *this = first
+    cdef Triangle *last
+    cdef int i = 0
+    while this != NULL:
+        for i in range(3):
+            vertices[count, i] = this.p[i]
+        count += 1 # Do it at the end because it's an index
+        last = this
+        this = this.next
+        free(last)
+
 cdef extern from "FixedInterpolator.h":
     np.float64_t fast_interpolate(int ds[3], int ci[3], np.float64_t dp[3],
                                   np.float64_t *data)
@@ -73,6 +103,10 @@
                                        np.float64_t *data)
     np.float64_t eval_gradient(int *ds, int *ci, np.float64_t *dp,
                                        np.float64_t *data, np.float64_t *grad)
+    void offset_fill(int *ds, np.float64_t *data, np.float64_t *gridval)
+
+cdef extern int *edge_table
+cdef extern int **tri_table
 
 def hp_pix2vec_nest(long nside, long ipix):
     cdef double v[3]
@@ -777,6 +811,36 @@
             for i in range(3):
                 vel[i] /= vel_mag
 
+    @cython.boundscheck(False)
+    @cython.wraparound(False)
+    @cython.cdivision(True)
+    def get_isocontour_triangles(self, np.float64_t isovalue, int field_id = 0):
+        # Much of this was inspired by code from Paul Bourke's website:
+        # http://paulbourke.net/geometry/polygonise/
+        cdef int i, j, k
+        cdef int offset
+        cdef np.float64_t gridval[8]
+        cdef int cubeindex
+        cdef np.float64_t vertlist[12]
+        cdef int ntriang
+        for i in range(self.dims[0]):
+            for j in range(self.dims[1]):
+                for k in range(self.dims[2]):
+                    offset = i * (self.dims[1] + 1) * (self.dims[2] + 1) \
+                           + j * (self.dims[2] + 1) + k
+                    offset_fill(self.dims, self.data[field_id] + offset,
+                                gridval)
+                    cubeindex = 0
+                    if gridval[0] < isovalue: cubeindex |= 1
+                    if gridval[1] < isovalue: cubeindex |= 2
+                    if gridval[2] < isovalue: cubeindex |= 4
+                    if gridval[3] < isovalue: cubeindex |= 8
+                    if gridval[4] < isovalue: cubeindex |= 16
+                    if gridval[5] < isovalue: cubeindex |= 32
+                    if gridval[6] < isovalue: cubeindex |= 64
+                    if gridval[7] < isovalue: cubeindex |= 128
+                    if edge_table[cubeindex] == 0: continue
+
 cdef class GridFace:
     cdef int direction
     cdef public np.float64_t coord


http://bitbucket.org/yt_analysis/yt/changeset/a13b0c02298d/
changeset:   r4153:a13b0c02298d
branch:      yt
user:        MatthewTurk
date:        2011-04-16 22:11:52
summary:     All the bits are sort of there for the marching cubes, although they may not be
functional at all.
affected #:  2 files (3.9 KB)

--- a/yt/utilities/_amr_utils/FixedInterpolator.c	Sat Apr 16 10:24:21 2011 -0400
+++ b/yt/utilities/_amr_utils/FixedInterpolator.c	Sat Apr 16 16:11:52 2011 -0400
@@ -73,13 +73,21 @@
 void offset_fill(int ds[3], npy_float64 *data, npy_float64 gridval[8])
 {
     gridval[0] = OINDEX(0,0,0);
-    gridval[1] = OINDEX(0,0,1);
-    gridval[2] = OINDEX(0,1,0);
-    gridval[3] = OINDEX(0,1,1);
-    gridval[4] = OINDEX(1,0,0);
-    gridval[5] = OINDEX(1,1,0);
-    gridval[6] = OINDEX(1,0,1);
-    gridval[7] = OINDEX(1,1,1);
+    gridval[1] = OINDEX(1,0,0);
+    gridval[2] = OINDEX(1,1,0);
+    gridval[3] = OINDEX(0,1,0);
+    gridval[4] = OINDEX(0,0,1);
+    gridval[5] = OINDEX(1,0,1);
+    gridval[6] = OINDEX(1,1,1);
+    gridval[7] = OINDEX(0,1,1);
+}
+
+npy_float64 vertex_interp(npy_float64 v1, npy_float64 v2, npy_float64 isovalue)
+{
+    if (fabs(isovalue - v1) < 0.000001) return 0.0;
+    if (fabs(isovalue - v2) < 0.000001) return 1.0;
+    if (fabs(v1 - v2) < 0.000001) return 0.0;
+    return (isovalue - v1) / (v2 - v1);
 }
 
 npy_float64 trilinear_interpolate(int ds[3], int ci[3], npy_float64 dp[3],


--- a/yt/utilities/_amr_utils/VolumeIntegrator.pyx	Sat Apr 16 10:24:21 2011 -0400
+++ b/yt/utilities/_amr_utils/VolumeIntegrator.pyx	Sat Apr 16 16:11:52 2011 -0400
@@ -69,9 +69,16 @@
     Triangle *next
     np.float64_t p[3]
 
-cdef void AddTriangle(Triangle *self, np.float64_t *p):
+cdef Triangle *AddTriangle(Triangle *self,
+                    np.float64_t p0, np.float64_t p1, np.float64_t p2):
     cdef Triangle *nn = <Triangle *> malloc(sizeof(Triangle))
-    self.next = nn
+    if self != NULL:
+        self.next = nn
+    nn.p[0] = p0
+    nn.p[1] = p1
+    nn.p[2] = p2
+    nn.next = NULL
+    return nn
 
 cdef int CountTriangles(Triangle *first):
     cdef int count = 0
@@ -104,6 +111,7 @@
     np.float64_t eval_gradient(int *ds, int *ci, np.float64_t *dp,
                                        np.float64_t *data, np.float64_t *grad)
     void offset_fill(int *ds, np.float64_t *data, np.float64_t *gridval)
+    np.float64_t vertex_interp(np.float64_t v1, np.float64_t v2, np.float64_t isovalue)
 
 cdef extern int *edge_table
 cdef extern int **tri_table
@@ -817,29 +825,91 @@
     def get_isocontour_triangles(self, np.float64_t isovalue, int field_id = 0):
         # Much of this was inspired by code from Paul Bourke's website:
         # http://paulbourke.net/geometry/polygonise/
-        cdef int i, j, k
+        cdef int i, j, k, n
         cdef int offset
-        cdef np.float64_t gridval[8]
+        cdef np.float64_t gv[8]
         cdef int cubeindex
         cdef np.float64_t vertlist[12]
-        cdef int ntriang
+        cdef int ntriang = 0
+        cdef np.float64_t *intdata = NULL
+        cdef np.float64_t x, y, z
+        cdef np.float64_t mu
+        cdef Triangle *first = NULL
+        cdef Triangle *current = NULL
+        x = self.left_edge[0]
         for i in range(self.dims[0]):
+            x += self.dds[0]
+            y = self.left_edge[1]
             for j in range(self.dims[1]):
+                y += self.dds[1]
+                z = self.left_edge[2]
                 for k in range(self.dims[2]):
+                    z += self.dds[2]
                     offset = i * (self.dims[1] + 1) * (self.dims[2] + 1) \
                            + j * (self.dims[2] + 1) + k
-                    offset_fill(self.dims, self.data[field_id] + offset,
-                                gridval)
+                    intdata = self.data[field_id] + offset
+                    offset_fill(self.dims, intdata, gv)
                     cubeindex = 0
-                    if gridval[0] < isovalue: cubeindex |= 1
-                    if gridval[1] < isovalue: cubeindex |= 2
-                    if gridval[2] < isovalue: cubeindex |= 4
-                    if gridval[3] < isovalue: cubeindex |= 8
-                    if gridval[4] < isovalue: cubeindex |= 16
-                    if gridval[5] < isovalue: cubeindex |= 32
-                    if gridval[6] < isovalue: cubeindex |= 64
-                    if gridval[7] < isovalue: cubeindex |= 128
+                    if gv[0] < isovalue: cubeindex |= 1
+                    if gv[1] < isovalue: cubeindex |= 2
+                    if gv[2] < isovalue: cubeindex |= 4
+                    if gv[3] < isovalue: cubeindex |= 8
+                    if gv[4] < isovalue: cubeindex |= 16
+                    if gv[5] < isovalue: cubeindex |= 32
+                    if gv[6] < isovalue: cubeindex |= 64
+                    if gv[7] < isovalue: cubeindex |= 128
                     if edge_table[cubeindex] == 0: continue
+                    if (edge_table[cubeindex] & 1): # 0,0,0 with 1,0,0
+                        mu = vertex_interp(gv[0], gv[1], isovalue)
+                        vertlist[0] = x + mu * self.dds[0]
+                    if (edge_table[cubeindex] & 2): # 1,0,0 with 1,1,0
+                        mu = vertex_interp(gv[1], gv[2], isovalue)
+                        vertlist[1] = y + mu * self.dds[1]
+                    if (edge_table[cubeindex] & 4): # 1,1,0 with 0,1,0
+                        mu = vertex_interp(gv[2], gv[3], isovalue)
+                        vertlist[2] = x + (1.0 - mu) * self.dds[0]
+                    if (edge_table[cubeindex] & 8): # 0,1,0 with 0,0,0
+                        mu = vertex_interp(gv[3], gv[0], isovalue)
+                        vertlist[3] = y + (1.0 - mu) * self.dds[1]
+                    if (edge_table[cubeindex] & 16): # 0,0,1 with 1,0,1
+                        mu = vertex_interp(gv[4], gv[5], isovalue)
+                        vertlist[4] = x + mu * self.dds[0]
+                    if (edge_table[cubeindex] & 32): # 1,0,1 with 1,1,1
+                        mu = vertex_interp(gv[5], gv[6], isovalue)
+                        vertlist[5] = y + mu * self.dds[1]
+                    if (edge_table[cubeindex] & 64): # 1,1,1 with 0,1,1
+                        mu = vertex_interp(gv[6], gv[7], isovalue)
+                        vertlist[6] = x + (1.0 - mu) * self.dds[0]
+                    if (edge_table[cubeindex] & 128): # 0,1,1 with 0,0,1
+                        mu = vertex_interp(gv[7], gv[4], isovalue)
+                        vertlist[7] = y + (1.0 - mu) * self.dds[1]
+                    if (edge_table[cubeindex] & 256): # 0,0,0 with 0,0,1
+                        mu = vertex_interp(gv[0], gv[4], isovalue)
+                        vertlist[8] = z + mu * self.dds[2]
+                    if (edge_table[cubeindex] & 512): # 1,0,0 with 1,0,1
+                        mu = vertex_interp(gv[1], gv[5], isovalue)
+                        vertlist[9] = z + mu * self.dds[2]
+                    if (edge_table[cubeindex] & 1024): # 1,1,0 with 1,1,1
+                        mu = vertex_interp(gv[2], gv[6], isovalue)
+                        vertlist[10] = z + (1.0 - mu) * self.dds[2]
+                    if (edge_table[cubeindex] & 2048): # 0,1,0 with 0,1,1
+                        mu = vertex_interp(gv[3], gv[7], isovalue)
+                        vertlist[11] = z + mu * self.dds[2]
+                    n = 0
+                    while 1:
+                        current = AddTriangle(current, 
+                                    vertlist[tri_table[cubeindex][n  ]],
+                                    vertlist[tri_table[cubeindex][n+1]],
+                                    vertlist[tri_table[cubeindex][n+2]])
+                        ntriang += 1
+                        if first == NULL: first = current
+                        n += 3
+                        if tri_table[cubeindex][n] == -1: break
+        # Hallo, we are all done.
+        cdef np.ndarray[np.float64_t, ndim=2] vertices 
+        vertices = np.zeros((ntriang,3), dtype='float64')
+        FillAndWipeTriangles(vertices, first)
+        return vertices
 
 cdef class GridFace:
     cdef int direction


http://bitbucket.org/yt_analysis/yt/changeset/ebf96554cdc7/
changeset:   r4154:ebf96554cdc7
branch:      yt
user:        MatthewTurk
date:        2011-04-16 22:28:30
summary:     In the interest of getting something that functions, at the expense of
really nasty inclusions of tables in the .pyx file (which will be removed at a
later date!) this commit gets the isocontour identifier to at least spit
something out.
affected #:  2 files (18.6 KB)

--- a/yt/utilities/_amr_utils/FixedInterpolator.c	Sat Apr 16 16:11:52 2011 -0400
+++ b/yt/utilities/_amr_utils/FixedInterpolator.c	Sat Apr 16 16:28:30 2011 -0400
@@ -149,6 +149,7 @@
     }
 }
 
+/*
 int edge_table[256]={
 0x0  , 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,
 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
@@ -440,3 +441,4 @@
 {0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
 {0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
 {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}};
+*/


--- a/yt/utilities/_amr_utils/VolumeIntegrator.pyx	Sat Apr 16 16:11:52 2011 -0400
+++ b/yt/utilities/_amr_utils/VolumeIntegrator.pyx	Sat Apr 16 16:28:30 2011 -0400
@@ -113,8 +113,8 @@
     void offset_fill(int *ds, np.float64_t *data, np.float64_t *gridval)
     np.float64_t vertex_interp(np.float64_t v1, np.float64_t v2, np.float64_t isovalue)
 
-cdef extern int *edge_table
-cdef extern int **tri_table
+#cdef extern int *edge_table
+#cdef extern int **tri_table
 
 def hp_pix2vec_nest(long nside, long ipix):
     cdef double v[3]
@@ -819,12 +819,303 @@
             for i in range(3):
                 vel[i] /= vel_mag
 
-    @cython.boundscheck(False)
-    @cython.wraparound(False)
+    #@cython.boundscheck(False)
+    #@cython.wraparound(False)
     @cython.cdivision(True)
     def get_isocontour_triangles(self, np.float64_t isovalue, int field_id = 0):
         # Much of this was inspired by code from Paul Bourke's website:
         # http://paulbourke.net/geometry/polygonise/
+        cdef int *edge_table=[
+        0x0  , 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,
+        0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
+        0x190, 0x99 , 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,
+        0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,
+        0x230, 0x339, 0x33 , 0x13a, 0x636, 0x73f, 0x435, 0x53c,
+        0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,
+        0x3a0, 0x2a9, 0x1a3, 0xaa , 0x7a6, 0x6af, 0x5a5, 0x4ac,
+        0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,
+        0x460, 0x569, 0x663, 0x76a, 0x66 , 0x16f, 0x265, 0x36c,
+        0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,
+        0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff , 0x3f5, 0x2fc,
+        0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,
+        0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55 , 0x15c,
+        0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,
+        0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc ,
+        0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,
+        0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,
+        0xcc , 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,
+        0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,
+        0x15c, 0x55 , 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,
+        0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,
+        0x2fc, 0x3f5, 0xff , 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
+        0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,
+        0x36c, 0x265, 0x16f, 0x66 , 0x76a, 0x663, 0x569, 0x460,
+        0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,
+        0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa , 0x1a3, 0x2a9, 0x3a0,
+        0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,
+        0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33 , 0x339, 0x230,
+        0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,
+        0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99 , 0x190,
+        0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,
+        0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0   ]
+
+        cdef int **tri_table = \
+        [[-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1],
+        [3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1],
+        [3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1],
+        [3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1],
+        [9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1],
+        [1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1],
+        [9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1],
+        [2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1],
+        [8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1],
+        [9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1],
+        [4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1],
+        [3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1],
+        [1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1],
+        [4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1],
+        [4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1],
+        [9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1],
+        [1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1],
+        [5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1],
+        [2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1],
+        [9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1],
+        [0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1],
+        [2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1],
+        [10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1],
+        [4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1],
+        [5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1],
+        [5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1],
+        [9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1],
+        [0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1],
+        [1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1],
+        [10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1],
+        [8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1],
+        [2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1],
+        [7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1],
+        [9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1],
+        [2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1],
+        [11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1],
+        [9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1],
+        [5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1],
+        [11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1],
+        [11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1],
+        [1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1],
+        [9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1],
+        [5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1],
+        [2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1],
+        [0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1],
+        [5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1],
+        [6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1],
+        [0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1],
+        [3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1],
+        [6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1],
+        [5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1],
+        [1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1],
+        [10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1],
+        [6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1],
+        [1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1],
+        [8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1],
+        [7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1],
+        [3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1],
+        [5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1],
+        [0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1],
+        [9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1],
+        [8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1],
+        [5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1],
+        [0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1],
+        [6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1],
+        [10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1],
+        [10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1],
+        [8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1],
+        [1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1],
+        [3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1],
+        [0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1],
+        [10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1],
+        [0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1],
+        [3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1],
+        [6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1],
+        [9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1],
+        [8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1],
+        [3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1],
+        [6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1],
+        [0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1],
+        [10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1],
+        [10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1],
+        [1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1],
+        [2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1],
+        [7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1],
+        [7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1],
+        [2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1],
+        [1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1],
+        [11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1],
+        [8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1],
+        [0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1],
+        [7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1],
+        [10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1],
+        [2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1],
+        [6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1],
+        [7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1],
+        [2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1],
+        [1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1],
+        [10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1],
+        [10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1],
+        [0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1],
+        [7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1],
+        [6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1],
+        [8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1],
+        [9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1],
+        [6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1],
+        [1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1],
+        [4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1],
+        [10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1],
+        [8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1],
+        [0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1],
+        [1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1],
+        [8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1],
+        [10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1],
+        [4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1],
+        [10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1],
+        [5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1],
+        [11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1],
+        [9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1],
+        [6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1],
+        [7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1],
+        [3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1],
+        [7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1],
+        [9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1],
+        [3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1],
+        [6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1],
+        [9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1],
+        [1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1],
+        [4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1],
+        [7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1],
+        [6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1],
+        [3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1],
+        [0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1],
+        [6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1],
+        [1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1],
+        [0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1],
+        [11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1],
+        [6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1],
+        [5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1],
+        [9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1],
+        [1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1],
+        [1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1],
+        [10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1],
+        [0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1],
+        [5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1],
+        [10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1],
+        [11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1],
+        [0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1],
+        [9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1],
+        [7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1],
+        [2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1],
+        [8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1],
+        [9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1],
+        [9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1],
+        [1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1],
+        [9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1],
+        [9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1],
+        [5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1],
+        [0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1],
+        [10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1],
+        [2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1],
+        [0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1],
+        [0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1],
+        [9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1],
+        [5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1],
+        [3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1],
+        [5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1],
+        [8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1],
+        [0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1],
+        [9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1],
+        [0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1],
+        [1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1],
+        [3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1],
+        [4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1],
+        [9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1],
+        [11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1],
+        [11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1],
+        [2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1],
+        [9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1],
+        [3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1],
+        [1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1],
+        [4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1],
+        [4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1],
+        [0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1],
+        [3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1],
+        [3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1],
+        [0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1],
+        [9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1],
+        [1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
+        [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]
         cdef int i, j, k, n
         cdef int offset
         cdef np.float64_t gv[8]
@@ -858,6 +1149,7 @@
                     if gv[5] < isovalue: cubeindex |= 32
                     if gv[6] < isovalue: cubeindex |= 64
                     if gv[7] < isovalue: cubeindex |= 128
+                    #print cubeindex
                     if edge_table[cubeindex] == 0: continue
                     if (edge_table[cubeindex] & 1): # 0,0,0 with 1,0,0
                         mu = vertex_interp(gv[0], gv[1], isovalue)


http://bitbucket.org/yt_analysis/yt/changeset/46d754a405c5/
changeset:   r4155:46d754a405c5
branch:      yt
user:        samskillman
date:        2011-04-17 06:58:43
summary:     Adding colors and alpha blending to the grid viewer.
affected #:  3 files (567 bytes)

--- a/yt/gui/reason/extdirect_repl.py	Sat Apr 16 16:28:30 2011 -0400
+++ b/yt/gui/reason/extdirect_repl.py	Sun Apr 17 00:58:43 2011 -0400
@@ -38,6 +38,7 @@
 from yt.funcs import *
 from yt.utilities.logger import ytLogger, ufstring
 from yt.utilities.definitions import inv_axis_names
+from yt.visualization.image_writer import apply_colormap
 
 from .bottle_mods import preroute, BottleDirectRouter, notify_route, \
                          PayloadHandler
@@ -393,8 +394,15 @@
         self.execute(funccall, hide = True)
         pf = self.locals['_tpf']
         corners = pf.h.grid_corners
+        levels = pf.h.grid_levels
+        colors = apply_colormap(levels*1.0,
+                                color_bounds=[0,pf.h.max_level],
+                                cmap_name="algae").repeat(24,axis=0)[:,0,:]*1.0/255.
+        colors[:,3]=0.7
+        colors = colors.ravel().tolist()
+        
         vertices = []
-
+        
         trans  = [0, 1, 2, 7, 5, 6, 3, 4]
         order  = [0, 1, 1, 2, 2, 3, 3, 0]
         order += [4, 5, 5, 6, 6, 7, 7, 4]
@@ -411,8 +419,9 @@
                    'widget_type': 'grid_viewer',
                    'varname': varname, # Is just "None"
                    'data': dict(n_vertices = len(vertices)/3,
-                                vertex_positions = vertices)
-                  }
+                                vertex_positions = vertices,
+                                vertex_colors = colors)
+                   }
         self.execute("%s = None\n" % (varname), hide=True)
         self.payload_handler.add_payload(payload)
 


--- a/yt/gui/reason/html/index.html	Sat Apr 16 16:28:30 2011 -0400
+++ b/yt/gui/reason/html/index.html	Sun Apr 17 00:58:43 2011 -0400
@@ -96,24 +96,30 @@
     <!-- THE GRID VIEWER FUNCTIONS --><script type="text/javascript" src="js/widget_gridviewer.js"></script><script id="gv-shader-fs" type="x-shader/x-fragment">
-      #ifdef GL_ES
-      precision highp float;
-      #endif
+    #ifdef GL_ES
+    precision highp float;
+    #endif
 
-      void main(void) {
-        gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
-      }
+    varying vec4 vColor;
+
+    void main(void) {
+      gl_FragColor = vColor;
+    }
     </script><script id="gv-shader-vs" type="x-shader/x-vertex">
-      attribute vec3 aVertexPosition;
+    attribute vec3 aVertexPosition;
+    attribute vec4 aVertexColor;
 
-      uniform mat4 uMVMatrix;
-      uniform mat4 uPMatrix;
+    uniform mat4 uMVMatrix;
+    uniform mat4 uPMatrix;
 
-      void main(void) {
-        gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
-      }
+    varying vec4 vColor;
+
+    void main(void) {
+      gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
+      vColor = aVertexColor;
+    }
     </script></head>


--- a/yt/gui/reason/html/js/widget_gridviewer.js	Sat Apr 16 16:28:30 2011 -0400
+++ b/yt/gui/reason/html/js/widget_gridviewer.js	Sun Apr 17 00:58:43 2011 -0400
@@ -134,36 +134,43 @@
                 program = app.program,
                 scene = app.scene,
                 camera = app.camera;
-    
-            gl.viewport(0, 0, canvas.width, canvas.height);
-            gl.clearColor(0, 0, 0, 1);
-            gl.clearDepth(1);
-            gl.enable(gl.DEPTH_TEST);
-            gl.depthFunc(gl.LEQUAL);
 
-            program.setBuffers({
-                'shapeset': {
-                    attribute: 'aVertexPosition',
+	    gl.viewport(0, 0, canvas.width, canvas.height);
+	    gl.clearColor(0, 0, 0, 1);
+	    gl.clearDepth(1);
+            gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
+            gl.enable(gl.BLEND);
+            gl.disable(gl.DEPTH_TEST);
+            program.setUniform('alpha',0.8);
+	    gl.depthFunc(gl.LEQUAL);
+
+	    program.setBuffers({
+	    	'shapeset': {
+	    	    attribute: 'aVertexPosition',
                     value: new Float32Array(widget_data['vertex_positions']),
-                    size: 3
-                    },
-    
-                    });
-            camera.modelView.id();
+	    	    size: 3
+	    	},
+	    	'shapesetColors': {
+	    	    attribute: 'aVertexColor',
+                    value: new Float32Array(widget_data['vertex_colors']),
+	    	    size: 4
+	    	},
+		
+	    });
+
+	    camera.modelView.id();
 	    camera.update()
-
 	    setInterval(draw, 100/60);
-            //Draw the scene
-            function draw() {
-                gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
-                //Draw Triangle
-                program.setUniform('uMVMatrix', camera.modelView);
-                program.setUniform('uPMatrix', camera.projection);
-                program.setBuffer('triangle');
+	    //Draw the scene
+	    function draw() {
+		gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+		program.setUniform('uMVMatrix', camera.modelView);
+		program.setUniform('uPMatrix', camera.projection);
+		program.setBuffer('shapeset');
+		program.setBuffer('shapesetColors');
                 gl.drawArrays(gl.LINES, 0, widget_data['n_vertices']);        
-                examine = camera
-                }
-            }
+	    }
+	    }
         });  
     }        
 


http://bitbucket.org/yt_analysis/yt/changeset/b9c081a60750/
changeset:   r4156:b9c081a60750
branch:      yt
user:        samskillman
date:        2011-04-19 00:36:01
summary:     Adding Streamline viewer.  Currently hardcodes number of streamlines
and characteristics.
affected #:  4 files (2.8 KB)

--- a/yt/gui/reason/extdirect_repl.py	Sun Apr 17 00:58:43 2011 -0400
+++ b/yt/gui/reason/extdirect_repl.py	Mon Apr 18 18:36:01 2011 -0400
@@ -425,6 +425,47 @@
         self.execute("%s = None\n" % (varname), hide=True)
         self.payload_handler.add_payload(payload)
 
+    @lockit
+    def create_streamline_viewer(self, pfname):
+        funccall = """
+        _tpf = %(pfname)s
+        """ % dict(pfname = pfname)
+        funccall = "\n".join((line.strip() for line in funccall.splitlines()))
+        self.execute(funccall, hide = True)
+        pf = self.locals['_tpf']
+
+        c = na.array([0.5]*3)
+        N = 1000
+        scale = 1.0
+        pos_dx = na.random.random((N,3))*scale-scale/2.
+        pos = c+pos_dx
+        
+        SL = Streamlines(pf,pos,'x-velocity', 'y-velocity', 'z-velocity', length=1.0)
+        SL.integrate_through_volume()
+        streamlist=[]
+        stream_lengths = []
+        for i,stream in enumerate(SL.streamlines):
+            stream_lengths.append( stream[na.all(stream != 0.0, axis=1)].shape[0])
+        streamlist = SL.streamlines.flatten()
+        streamlist = streamlist[streamlist!=0.0].tolist()
+        stream_colors = apply_colormap(na.array(streamlist)[::3]*1., cmap_name='algae', color_bounds=[0.,1.])
+        stream_colors = stream_colors*1./255.
+        stream_colors[:,:,3] = 0.8
+        stream_colors = stream_colors.flatten().tolist()
+
+        uu = str(uuid.uuid1()).replace("-","_")
+        varname = "sl_%s" % (uu)
+        payload = {'type': 'widget',
+                   'widget_type': 'streamline_viewer',
+                   'varname': varname, # Is just "None"
+                   'data': dict(n_streamlines = SL.streamlines.shape[0],
+                                stream_positions = streamlist,
+                                stream_colors = stream_colors,
+                                stream_lengths = stream_lengths)
+                   }
+        self.execute("%s = None\n" % (varname), hide=True)
+        self.payload_handler.add_payload(payload)
+
 class ExtDirectParameterFileList(BottleDirectRouter):
     my_name = "ExtDirectParameterFileList"
     api_url = "pflist"


--- a/yt/gui/reason/html/index.html	Sun Apr 17 00:58:43 2011 -0400
+++ b/yt/gui/reason/html/index.html	Mon Apr 18 18:36:01 2011 -0400
@@ -122,6 +122,36 @@
     }
     </script>
 
+    <!-- THE STREAMLINE VIEWER FUNCTIONS -->
+    <script type="text/javascript" src="js/widget_streamlineviewer.js"></script>
+    <script id="sl-shader-fs" type="x-shader/x-fragment">
+    #ifdef GL_ES
+    precision highp float;
+    #endif
+
+    varying vec4 vColor;
+
+    void main(void) {
+      gl_FragColor = vColor;
+    }
+    </script>
+
+    <script id="sl-shader-vs" type="x-shader/x-vertex">
+    attribute vec3 aVertexPosition;
+    attribute vec4 aVertexColor;
+
+    uniform mat4 uMVMatrix;
+    uniform mat4 uPMatrix;
+
+    varying vec4 vColor;
+
+    void main(void) {
+      gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
+      vColor = aVertexColor;
+    }
+    </script>
+
+
 </head><body><!-- use class="x-hide-display" to prevent a brief flicker of the content -->


--- a/yt/gui/reason/html/js/functions.js	Sun Apr 17 00:58:43 2011 -0400
+++ b/yt/gui/reason/html/js/functions.js	Mon Apr 18 18:36:01 2011 -0400
@@ -169,6 +169,15 @@
 return gridViewerHandler;
 }
 
+function getStreamlineViewerHandler(node){
+function streamlineViewerHandler(item, pressed){
+    yt_rpc.ExtDirectREPL.create_streamline_viewer(
+        {pfname:node.attributes.objdata.varname},
+        handle_result);
+}
+return streamlineViewerHandler;
+}
+
 function getSliceHandler(node){
 function sliceHandler(item,pressed){
     var win = new Ext.Window({


--- a/yt/gui/reason/html/js/reason.js	Sun Apr 17 00:58:43 2011 -0400
+++ b/yt/gui/reason/html/js/reason.js	Mon Apr 18 18:36:01 2011 -0400
@@ -186,6 +186,9 @@
                                 }, {
                                     text: 'Open projection',
                                     handler: getProjectionHandler(node),
+                                }, {
+                                    text: 'View Streamlines',
+                                    handler: getStreamlineViewerHandler(node),
                                 }
                             ]
                         });


http://bitbucket.org/yt_analysis/yt/changeset/9f9b6a8f918a/
changeset:   r4157:9f9b6a8f918a
branch:      yt
user:        samskillman
date:        2011-04-19 01:09:53
summary:     Adding the widget!
affected #:  1 file (7.2 KB)

--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/yt/gui/reason/html/js/widget_streamlineviewer.js	Mon Apr 18 19:09:53 2011 -0400
@@ -0,0 +1,217 @@
+/**********************************************************************
+The Streamline Viewer Widget
+
+Author: Samuel Skillman <samskillman at gmail.com>
+Affiliation: University of Colorado at Boulder
+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/>.
+***********************************************************************/
+
+
+
+var WidgetStreamlineViewer = function(python_varname, widget_data) {
+    this.id = python_varname;
+    this.widget_data = widget_data;
+    examine = "canvas_" + python_varname;
+    var StreamlineViewerStart = function() {
+        this.curX = 0;
+        this.curY = 0;
+        this.dist = 0;
+        function updateBasedOnOffset(camera, offset){
+        camera.position.x = camera.target.x + offset.x;
+        camera.position.y = camera.target.y + offset.y;
+        camera.position.z = camera.target.z + offset.z;
+        }
+        function camGetOffset(camera){
+        return PhiloGL.Vec3.sub(camera.position, camera.target)
+            }
+        PhiloGL('canvas_' + python_varname, {
+            camera: {
+            position: {
+                x: 0.5, y: 0.5, z: 5
+                },
+                target: {
+                x: 0.5, y: 0.5, z: 0.5
+                },
+                },
+            program: {
+            from: 'ids',
+                vs: 'sl-shader-vs',
+                fs: 'sl-shader-fs'
+                },    
+            events: {
+            onDragStart: function(e) {
+                pos = {
+                x: e.x,
+                y: e.y
+                };
+                this.curX = e.x;
+                this.curY = e.y;
+                this.dist = camGetOffset(this.camera).norm();
+            },
+                onDragEnd: function(e) {
+                pos = {
+                x: e.x,
+                y: e.y
+                };
+            },
+                onDragMove: function(e) {
+                var c = this.camera;
+                var off = camGetOffset(c);
+                // Get Horizontal vector
+                var horiz = PhiloGL.Vec3.cross(c.up, 
+                               camGetOffset(c))
+                horiz.$scale(1./horiz.norm());
+
+                if (e.event.button == 0){ // Rotation
+                // Do vertical rotation about horizontal vector
+                var vert_rot = new PhiloGL.Mat4();
+                vert_rot.id();
+                vert_rot.$rotateAxis((e.y-this.curY)/100., horiz);
+                PhiloGL.Mat4.$mulVec3(vert_rot, off);
+                PhiloGL.Mat4.$mulVec3(vert_rot, c.up);
+                c.up.$scale(1./c.up.norm());
+
+                // Do horizontal rotation about up vector
+                var side_rot = new PhiloGL.Mat4();
+                side_rot.id();
+                side_rot.$rotateAxis(-(e.x-this.curX)/100., c.up);
+                side_rot.$mulVec3(off);
+        
+                // Update current positions
+                this.curX = e.x;
+                this.curY = e.y;
+                this.dist = off.norm();
+                updateBasedOnOffset(c, off);
+                c.update();
+                } else if (e.event.button = 2){ // Right click - transpose
+		    var tscale = 1.0*off.norm()/512.;
+		    var move_up = c.up.scale(-(e.y-this.curY)*tscale);
+		    var move_over = horiz.scale(-(e.x-this.curX)*tscale);
+                c.position.$add(move_up);
+                c.position.$add(move_over);
+                c.target.$add(move_up);
+                c.target.$add(move_over);
+                // Update current positions
+                this.curX = e.x;
+                this.curY = e.y;
+                c.update();
+                }
+    
+            },
+                onMouseWheel: function(e){
+                e.stop();
+                var offset = PhiloGL.Vec3.scale(camGetOffset(this.camera),
+                                1.0 - e.wheel/10.);
+                updateBasedOnOffset(this.camera, offset);
+                this.camera.update();
+            }
+            },
+            onError: function() {
+            alert("An error ocurred while loading the application");
+            },
+            onLoad: function(app) {
+            var gl = app.gl,
+                canvas = app.canvas,
+                program = app.program,
+                scene = app.scene,
+                camera = app.camera;
+
+	    gl.viewport(0, 0, canvas.width, canvas.height);
+	    gl.clearColor(0, 0, 0, 1);
+	    gl.clearDepth(1);
+	    gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
+	    gl.enable(gl.BLEND);
+	    gl.disable(gl.DEPTH_TEST);
+	    program.setUniform('alpha', 0.8);
+
+	    program.setBuffers({
+
+		    'shapeset': {
+			attribute: 'aVertexPosition',
+			    value: new Float32Array(widget_data['stream_positions']),
+			    size: 3
+			    },
+			
+			'shapesetColors': {
+			    attribute: 'aVertexColor',
+				value: new Float32Array(widget_data['stream_colors']),
+				size: 4
+			    },
+			    });
+
+
+	    camera.modelView.id();
+	    setInterval(draw, 30/60);
+	    var stream_counter =0;
+	    //Draw the scene
+	    function draw() {
+		stream_counter = 0;
+		gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+		//Draw Triangle
+		program.setUniform('uMVMatrix', camera.modelView);
+		program.setUniform('uPMatrix', camera.projection);
+		program.setBuffer('shapeset');
+		program.setBuffer('shapesetColors');
+		for (var i=0; i<widget_data['n_streamlines']; i++){
+		    gl.drawArrays(gl.LINES, stream_counter, widget_data['stream_lengths'][i]-1);
+		    gl.drawArrays(gl.LINES, stream_counter+1, widget_data['stream_lengths'][i]-1);
+		    stream_counter += widget_data['stream_lengths'][i];
+		}
+		
+	    }
+	    }
+        });  
+    }        
+
+    viewport.get("center-panel").add(
+        {
+            xtype: 'panel',
+            id: "sl_" + python_varname,
+            title: "WebGL Streamline Viewer",
+            iconCls: 'graph',
+            autoScroll: true,
+            layout:'absolute',
+            closable: true,
+            items: [
+                { xtype:'panel',
+                  autoEl: {
+                    tag: 'canvas',
+                    id: 'canvas_' + python_varname,
+                    style: 'border: none;',
+                    width: 512, height:512
+                  },
+                  width: 512,
+                  height: 512
+                }],
+            listeners: { afterlayout: StreamlineViewerStart },
+        }
+    );
+
+    viewport.get("center-panel").activate("sl_" + this.id);
+    viewport.doLayout();
+    this.panel = viewport.get("center-panel").get("sl_" + python_varname);
+    this.panel.doLayout();
+
+    this.accept_results = function(payload) { }
+}
+
+widget_types['streamline_viewer'] = WidgetStreamlineViewer;


http://bitbucket.org/yt_analysis/yt/changeset/4b48e12554a5/
changeset:   r4158:4b48e12554a5
branch:      yt
user:        samskillman
date:        2011-04-19 01:32:53
summary:     Changing number of streamlines to 100 by default.  I'm having issues
with the streamlining not finishing fast enough for the heartbeat or
something.  It starts streamlining multiple times if it doesn't go
fast enough.  Also had to get the import of Streamlines!
affected #:  1 file (44 bytes)

--- a/yt/gui/reason/extdirect_repl.py	Mon Apr 18 19:09:53 2011 -0400
+++ b/yt/gui/reason/extdirect_repl.py	Mon Apr 18 19:32:53 2011 -0400
@@ -39,6 +39,7 @@
 from yt.utilities.logger import ytLogger, ufstring
 from yt.utilities.definitions import inv_axis_names
 from yt.visualization.image_writer import apply_colormap
+from yt.visualization.api import Streamlines
 
 from .bottle_mods import preroute, BottleDirectRouter, notify_route, \
                          PayloadHandler
@@ -435,7 +436,7 @@
         pf = self.locals['_tpf']
 
         c = na.array([0.5]*3)
-        N = 1000
+        N = 100
         scale = 1.0
         pos_dx = na.random.random((N,3))*scale-scale/2.
         pos = c+pos_dx


http://bitbucket.org/yt_analysis/yt/changeset/311584acdeba/
changeset:   r4159:311584acdeba
branch:      yt
user:        samskillman
date:        2011-04-20 00:30:12
summary:     Adding ability to get the magnitude of the vector field and save it in
the Streamlines.magnitudes array.  This is off by default, and can be
enabled with get_magnitude=True in the Streamlines(...) call.  Seems
to be a <~10% performance hit in my test cases.
affected #:  2 files (1.5 KB)

--- a/yt/utilities/_amr_utils/VolumeIntegrator.pyx	Mon Apr 18 19:32:53 2011 -0400
+++ b/yt/utilities/_amr_utils/VolumeIntegrator.pyx	Tue Apr 19 18:30:12 2011 -0400
@@ -753,57 +753,69 @@
     @cython.boundscheck(False)
     @cython.wraparound(False)
     @cython.cdivision(True)
-    def integrate_streamline(self, pos, np.float64_t h):
+    def integrate_streamline(self, pos, np.float64_t h, mag):
+        cdef np.float64_t cmag[1]
         cdef np.float64_t k1[3], k2[3], k3[3], k4[3]
         cdef np.float64_t newpos[3], oldpos[3]
         for i in range(3):
             newpos[i] = oldpos[i] = pos[i]
-        self.get_vector_field(newpos, k1)
+        self.get_vector_field(newpos, k1, cmag)
         for i in range(3):
             newpos[i] = oldpos[i] + 0.5*k1[i]*h
 
         if not (self.left_edge[0] < newpos[0] and newpos[0] < self.right_edge[0] and \
                 self.left_edge[1] < newpos[1] and newpos[1] < self.right_edge[1] and \
                 self.left_edge[2] < newpos[2] and newpos[2] < self.right_edge[2]):
+            if mag is not None:
+                mag[0] = cmag[0]
             for i in range(3):
                 pos[i] = newpos[i]
             return
         
-        self.get_vector_field(newpos, k2)
+        self.get_vector_field(newpos, k2, cmag)
         for i in range(3):
             newpos[i] = oldpos[i] + 0.5*k2[i]*h
 
         if not (self.left_edge[0] <= newpos[0] and newpos[0] <= self.right_edge[0] and \
                 self.left_edge[1] <= newpos[1] and newpos[1] <= self.right_edge[1] and \
                 self.left_edge[2] <= newpos[2] and newpos[2] <= self.right_edge[2]):
+            if mag is not None:
+                mag[0] = cmag[0]
             for i in range(3):
                 pos[i] = newpos[i]
             return
 
-        self.get_vector_field(newpos, k3)
+        self.get_vector_field(newpos, k3, cmag)
         for i in range(3):
             newpos[i] = oldpos[i] + k3[i]*h
             
         if not (self.left_edge[0] <= newpos[0] and newpos[0] <= self.right_edge[0] and \
                 self.left_edge[1] <= newpos[1] and newpos[1] <= self.right_edge[1] and \
                 self.left_edge[2] <= newpos[2] and newpos[2] <= self.right_edge[2]):
+            if mag is not None:
+                mag[0] = cmag[0]
             for i in range(3):
                 pos[i] = newpos[i]
             return
 
-        self.get_vector_field(newpos, k4)
+        self.get_vector_field(newpos, k4, cmag)
 
         for i in range(3):
             pos[i] = oldpos[i] + h*(k1[i]/6.0 + k2[i]/3.0 + k3[i]/3.0 + k4[i]/6.0)
-    
+
+        if mag is not None:
+            for i in range(3):
+                newpos[i] = pos[i]
+            self.get_vector_field(newpos, k4, cmag)
+            mag[0] = cmag[0]
+            
     @cython.boundscheck(False)
     @cython.wraparound(False)
     @cython.cdivision(True)
     cdef void get_vector_field(self, np.float64_t pos[3],
-                               np.float64_t *vel):
+                               np.float64_t *vel, np.float64_t *vel_mag):
         cdef np.float64_t dp[3]
         cdef int ci[3] 
-        cdef np.float64_t vel_mag = 0.0
         for i in range(3):
             ci[i] = (int)((pos[i]-self.left_edge[i])/self.dds[i])
             dp[i] = (pos[i] - self.left_edge[i])%(self.dds[i])
@@ -811,13 +823,14 @@
         cdef int offset = ci[0] * (self.dims[1] + 1) * (self.dims[2] + 1) \
                           + ci[1] * (self.dims[2] + 1) + ci[2]
         
+        vel_mag[0] = 0.0
         for i in range(3):
             vel[i] = offset_interpolate(self.dims, dp, self.data[i] + offset)
-            vel_mag += vel[i]*vel[i]
-        vel_mag = np.sqrt(vel_mag)
-        if vel_mag != 0.0:
+            vel_mag[0] += vel[i]*vel[i]
+        vel_mag[0] = np.sqrt(vel_mag[0])
+        if vel_mag[0] != 0.0:
             for i in range(3):
-                vel[i] /= vel_mag
+                vel[i] /= vel_mag[0]
 
     #@cython.boundscheck(False)
     #@cython.wraparound(False)


--- a/yt/visualization/streamlines.py	Mon Apr 18 19:32:53 2011 -0400
+++ b/yt/visualization/streamlines.py	Tue Apr 19 18:30:12 2011 -0400
@@ -65,6 +65,11 @@
     direction : real, optional
         Specifies the direction of integration.  The magnitude of this
         value has no effect, only the sign.
+    get_magnitude: bool, optional
+        Specifies whether the Streamlines.magnitudes array should be
+        filled with the magnitude of the vector field at each point in
+        the streamline.  This seems to be a ~10% hit to performance.
+        Default: False
     
     Examples
     --------
@@ -92,13 +97,15 @@
     """
     def __init__(self, pf, positions, xfield='x-velocity', yfield='x-velocity',
                  zfield='x-velocity', volume=None,
-                 dx=None, length=None, direction=1):
+                 dx=None, length=None, direction=1,
+                 get_magnitude=False):
         self.pf = pf
         self.start_positions = na.array(positions)
         self.N = self.start_positions.shape[0]
         self.xfield = xfield
         self.yfield = yfield
         self.zfield = zfield
+        self.get_magnitude=get_magnitude
         self.direction = na.sign(direction)
         if volume is None:
             volume = AMRKDTree(self.pf, fields=[self.xfield,self.yfield,self.zfield],
@@ -112,6 +119,9 @@
         self.length = length
         self.steps = int(length/dx)
         self.streamlines = na.zeros((self.N,self.steps,3), dtype='float64')
+        self.magnitudes = None
+        if self.get_magnitude:
+            self.magnitudes = na.zeros((self.N,self.steps), dtype='float64')
         
     def integrate_through_volume(self):
         nprocs = self._mpi_get_size()
@@ -120,10 +130,13 @@
 
         pbar = get_pbar("Streamlining", self.N)
         for i,stream in enumerate(self.streamlines[my_rank::nprocs]):
+            thismag = None
+            if self.get_magnitude:
+                thismag = self.magnitudes[i,:]
             step = self.steps
             while (step > 1):
                 this_brick = self.volume.locate_brick(stream[-step,:])
-                step = self._integrate_through_brick(this_brick, stream, step)
+                step = self._integrate_through_brick(this_brick, stream, step, mag=thismag)
             pbar.update(i)
         pbar.finish()
         
@@ -132,14 +145,21 @@
     @parallel_passthrough
     def _finalize_parallel(self,data):
         self.streamlines = self._mpi_allsum(self.streamlines)
+        self.magnitudes = self._mpi_allsum(self.magnitudes)
         
     def _integrate_through_brick(self, node, stream, step,
-                                 periodic=False):
+                                 periodic=False, mag=None):
         while (step > 1):
             self.volume.get_brick_data(node)
             brick = node.brick
             stream[-step+1] = stream[-step]
-            brick.integrate_streamline(stream[-step+1], self.direction*self.dx)
+            if mag is None:
+                brick.integrate_streamline(stream[-step+1], self.direction*self.dx, None)
+            else:
+                marr = [mag]
+                brick.integrate_streamline(stream[-step+1], self.direction*self.dx, marr)
+                mag[-step+1] = marr[0]
+                
             if na.any(stream[-step+1,:] <= self.pf.domain_left_edge) | \
                    na.any(stream[-step+1,:] >= self.pf.domain_right_edge):
                 return 0
@@ -152,9 +172,13 @@
 
     def clean_streamlines(self):
         temp = na.empty(self.N, dtype='object')
+        temp2 = na.empty(self.N, dtype='object')
         for i,stream in enumerate(self.streamlines):
-            temp[i] = stream[na.all(stream != 0.0, axis=1)]
+            mask = na.all(stream != 0.0, axis=1)
+            temp[i] = stream[mask]
+            temp2[i] = self.magnitudes[i,mask]
         self.streamlines = temp
+        self.magnitudes = temp2
 
     def path(self, streamline_id):
         """


http://bitbucket.org/yt_analysis/yt/changeset/5a8113c2a84b/
changeset:   r4160:5a8113c2a84b
branch:      yt
user:        MatthewTurk
date:        2011-04-19 15:57:14
summary:     Making the pf loading be more explicit, for reproducibility.
affected #:  1 file (160 bytes)

--- a/yt/utilities/command_line.py	Mon Apr 18 19:09:53 2011 -0400
+++ b/yt/utilities/command_line.py	Tue Apr 19 09:57:14 2011 -0400
@@ -953,7 +953,10 @@
         hr = ExtDirectREPL(base_extjs_path)
         if opts.find:
             # We just have to find them and store references to them.
-            hr.execute("pfs = list(all_pfs(max_depth=2))")
+            command_line = ["pfs = []"]
+            for fn in sorted(glob.glob("*/*.hierarchy")):
+                command_line.append("pfs.append(load('%s'))" % fn[:-10])
+            hr.execute("\n".join(command_line))
         bottle.debug()
         uuid_serve_functions(open_browser=opts.open_browser,
                     port=int(opts.port), repl=hr)


http://bitbucket.org/yt_analysis/yt/changeset/ca37b64f45d9/
changeset:   r4161:ca37b64f45d9
branch:      yt
user:        MatthewTurk
date:        2011-04-19 19:22:59
summary:     Adding streamlines to the JS includes (still doesn't work for me) and adding a
progress bar widget.  This should lock down execution while anything in
progress occurs.  Note that in the interest of responsiveness, it doesn't
update every single time, so there will be some lag between the actual progress
and the display.  This is fine.
affected #:  4 files (3.0 KB)

--- a/yt/funcs.py	Tue Apr 19 09:57:14 2011 -0400
+++ b/yt/funcs.py	Tue Apr 19 13:22:59 2011 -0400
@@ -328,6 +328,9 @@
             pass
     elif "CODENODE" in os.environ:
         return DummyProgressBar()
+    elif ytcfg.getboolean("yt", "__withinreason"):
+        from yt.gui.reason.extdirect_repl import ExtProgressBar
+        return ExtProgressBar(title, maxval)
     widgets = [ title,
             pb.Percentage(), ' ',
             pb.Bar(marker=pb.RotatingMarker()),


--- a/yt/gui/reason/extdirect_repl.py	Tue Apr 19 09:57:14 2011 -0400
+++ b/yt/gui/reason/extdirect_repl.py	Tue Apr 19 13:22:59 2011 -0400
@@ -524,4 +524,32 @@
     response.headers['Content-Type'] = "image/x-icon"
     return open(ico).read()
 
+class ExtProgressBar(object):
+    def __init__(self, title, maxval):
+        self.title = title
+        self.maxval = maxval
+        self.last = 0
+        # Now we add a payload for the progress bar
+        self.payload_handler = PayloadHandler()
+        self.payload_handler.add_payload(
+            {'type': 'widget',
+             'widget_type': 'progressbar',
+             'varname': None,
+             'data': {'title':title}
+            })
 
+    def update(self, val):
+        # An update is only meaningful if it's on the order of 1/100 or greater
+        if ceil(100*self.last / self.maxval) + 1 == \
+           floor(100*val / self.maxval) or val == self.maxval:
+            self.last = val
+            self.payload_handler.add_payload(
+                {'type': 'widget_payload',
+                 'widget_id': 'pbar_top',
+                 'value': float(val) / self.maxval})
+
+    def finish(self):
+        self.payload_handler.add_payload(
+            {'type': 'widget_payload',
+             'widget_id': 'pbar_top',
+             'value': -1})


--- a/yt/gui/reason/html/index.html	Tue Apr 19 09:57:14 2011 -0400
+++ b/yt/gui/reason/html/index.html	Tue Apr 19 13:22:59 2011 -0400
@@ -95,6 +95,12 @@
 
     <!-- THE GRID VIEWER FUNCTIONS --><script type="text/javascript" src="js/widget_gridviewer.js"></script>
+
+    <!-- THE STREAMLINE VIEWER FUNCTIONS -->
+    <script type="text/javascript" src="js/widget_streamlineviewer.js"></script>
+
+    <!-- THE PROGRESS BAR FUNCTIONS -->
+    <script type="text/javascript" src="js/widget_progressbar.js"></script><script id="gv-shader-fs" type="x-shader/x-fragment">
     #ifdef GL_ES
     precision highp float;


--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/yt/gui/reason/html/js/widget_progressbar.js	Tue Apr 19 13:22:59 2011 -0400
@@ -0,0 +1,51 @@
+/**********************************************************************
+The Plot Window Widget
+
+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/>.
+***********************************************************************/
+
+
+
+var WidgetProgressBar = function(python_varname, widget_data) {
+    this.id = 'pbar_top';
+
+    Ext.MessageBox.show({
+        title: 'yt is working ...',
+        msg: widget_data.title,
+        progressText: 'Progress',
+        width: 300,
+        progress: true,
+        closable: false,
+    });
+
+    this.accept_results = function(payload) {
+        var i = payload['value'];
+        if (i == -1) {
+            Ext.MessageBox.hide();
+        } else {
+            Ext.MessageBox.updateProgress(i, Math.round(100*i)+'% completed');
+        }
+    }
+
+}
+
+widget_types['progressbar'] = WidgetProgressBar;


http://bitbucket.org/yt_analysis/yt/changeset/c2f23aeb5b63/
changeset:   r4162:c2f23aeb5b63
branch:      yt
user:        MatthewTurk
date:        2011-04-19 19:36:24
summary:     This should bandaid the thread acquiring to work again.
affected #:  1 file (300 bytes)

--- a/yt/gui/reason/extdirect_repl.py	Tue Apr 19 13:22:59 2011 -0400
+++ b/yt/gui/reason/extdirect_repl.py	Tue Apr 19 13:36:24 2011 -0400
@@ -95,6 +95,7 @@
     my_name = "ExtDirectREPL"
     timeout = 660 # a minute longer than the rocket server timeout
     server = None
+    stopped = False
 
     def __init__(self, base_extjs_path, locals=None):
         # First we do the standard initialization
@@ -152,8 +153,11 @@
 
     def heartbeat(self):
         self.last_heartbeat = time.time()
-        if self.payload_handler.event.wait(30):
-            return self.payload_handler.deliver_payloads()
+        for i in range(30): # The total time to wait
+            # Check for stop
+            if self.stopped: return # No race condition
+            if self.payload_handler.event.wait(1): # One second timeout
+                return self.payload_handler.deliver_payloads()
         return []
 
     def _check_heartbeat(self):
@@ -175,9 +179,12 @@
         if self.server is None:
             return
         self._heartbeat_timer.cancel()
+        self.stopped = True
         self.payload_handler.event.set()
         for v in self.server.values():
             v.stop()
+        for t in threading.enumerate():
+            print "Found a living thread:", t
 
     def _help_html(self):
         vals = open(os.path.join(local_dir, "html/help.html")).read()


http://bitbucket.org/yt_analysis/yt/changeset/a2132da2b0f6/
changeset:   r4163:a2132da2b0f6
branch:      yt
user:        MatthewTurk
date:        2011-04-19 20:02:46
summary:     This removes the spurious display of a single image in the notebook.
affected #:  1 file (16 bytes)

--- a/yt/gui/reason/extdirect_repl.py	Tue Apr 19 13:36:24 2011 -0400
+++ b/yt/gui/reason/extdirect_repl.py	Tue Apr 19 14:02:46 2011 -0400
@@ -341,7 +341,7 @@
         from yt.visualization.plot_window import PWViewerExtJS
         _tpw = PWViewerExtJS(_tsl, (DLE[_txax], DRE[_txax], DLE[_tyax], DRE[_tyax]), setup = False)
         _tpw._current_field = _tfield
-        _tpw.set_log(_tfield, True)
+        _tpw._field_transform["%(field)s"] = na.log
         _tfield_list = list(set(_tpf.h.field_list + _tpf.h.derived_field_list))
         _tfield_list.sort()
         _twidget_data = {'fields': _tfield_list,


http://bitbucket.org/yt_analysis/yt/changeset/fa12de10e2e7/
changeset:   r4164:fa12de10e2e7
branch:      yt
user:        MatthewTurk
date:        2011-04-19 21:26:34
summary:     Some fixes for firefox, and a way to indicate that a widget is being created.
affected #:  2 files (425 bytes)

--- a/yt/gui/reason/html/js/functions.js	Tue Apr 19 14:02:46 2011 -0400
+++ b/yt/gui/reason/html/js/functions.js	Tue Apr 19 15:26:34 2011 -0400
@@ -29,6 +29,18 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ***********************************************************************/
 
+function enable_input() {
+    repl_input.body.removeClass("cell_waiting");
+    repl_input.get('input_line').setReadOnly(false);
+    repl_input.get("input_line").focus();
+    yt_rpc.ExtDirectParameterFileList.get_list_of_pfs({}, fill_tree);
+}
+
+function disable_input() {
+    repl_input.get('input_line').setReadOnly(true);
+    repl_input.body.addClass("cell_waiting");
+}
+
 function cell_finished(result) {
     var new_log = false;
     var cell_resulted = false;
@@ -81,6 +93,12 @@
             var widget = new widget_types[widget_type](payload['varname'],
                                                        payload['data']);
             widget_list[widget.id] = widget;
+            /*
+               Sometimes instantiating a widget adds some objects ...
+               Plus, often when creating a widget we disable the 
+               entry of data and whatnot. 
+            */
+            cell_resulted = true;
         } else if (payload['type'] == 'widget_payload') {
             var widget = widget_list[payload['widget_id']];
             widget.accept_results(payload);
@@ -90,18 +108,10 @@
         viewport.get("status-region").getView().focusRow(number_log_records-1);
     }
     if (cell_resulted == true) {
-        repl_input.body.removeClass("cell_waiting");
-        repl_input.get('input_line').setReadOnly(false);
-        repl_input.get("input_line").focus();
-        yt_rpc.ExtDirectParameterFileList.get_list_of_pfs({}, fill_tree);
+        enable_input();
     }
 }
 
-function cell_sent() {
-    repl_input.get('input_line').setReadOnly(true);
-    repl_input.body.addClass("cell_waiting");
-}
-
 function display_image(image_id) {
     var image = Ext.get(image_id);
     var src = image.dom.src;
@@ -264,12 +274,14 @@
                             pfname:node.attributes.objdata.varname,
                             center: center, axis:axis, field:field, onmax:onmax},
                           handle_result);
+                        disable_input();
                         win.close();
                     }
                 },{
                     text: 'Cancel',
                     handler: function(b, e){
                         win.close();
+
                     }
                 }
             ]
@@ -349,6 +361,7 @@
                                 axis: axis, field: field, weight: weight,
                                 onmax: onmax},
                               handle_result);
+                        disable_input();
                         win.close();
                     }
                 },{


--- a/yt/gui/reason/html/js/reason.js	Tue Apr 19 14:02:46 2011 -0400
+++ b/yt/gui/reason/html/js/reason.js	Tue Apr 19 15:26:34 2011 -0400
@@ -66,7 +66,7 @@
             listeners: {
                 specialkey: function(f, e){
                     if (e.getKey() == e.ENTER) {
-                        cell_sent();
+                        disable_input();
                         yt_rpc.ExtDirectREPL.execute({
                             code:repl_input.get('input_line').getValue()},
                         handle_result);
@@ -287,7 +287,10 @@
         });
 
 // get a reference to the HTML element with id "hideit" and add a click listener to it 
-    console.log('Mitchell!\nPardon me! Mitchell!')
+    if (typeof(console) != "undefined") {
+        console.log('Mitchell!\nPardon me! Mitchell!');
+    }
+
     Ext.get("hideit").on('click', function(){
 // get a reference to the Panel that was created with id = 'west-panel' 
 	    var w = Ext.getCmp('west-panel');


http://bitbucket.org/yt_analysis/yt/changeset/36a0712fc179/
changeset:   r4165:36a0712fc179
branch:      yt
user:        MatthewTurk
date:        2011-04-19 21:53:20
summary:     Adding very simple metadata string as a stopgap
affected #:  1 file (732 bytes)

--- a/yt/visualization/plot_window.py	Tue Apr 19 15:26:34 2011 -0400
+++ b/yt/visualization/plot_window.py	Tue Apr 19 15:53:20 2011 -0400
@@ -33,6 +33,7 @@
 from fixed_resolution import \
     FixedResolutionBuffer
 import matplotlib.pyplot
+from .plot_modifications import get_smallest_appropriate_unit
 
 def invalidate_data(f):
     def newfunc(*args, **kwargs):
@@ -300,6 +301,12 @@
             print "writing %s" % nm
             write_image(self._frb[field],nm)
 
+_metadata_template = """
+X Field of View     %(x_width)0.3f %(unit)s
+Y Field of View     %(y_width)0.3f %(unit)s
+Extrema             %(mi)0.3e - %(ma)0.3e
+"""
+
 class PWViewerExtJS(PWViewer):
     """A viewer for the web interface.
 
@@ -321,13 +328,24 @@
             addl_keys = {}
         for field in fields:
             tf = tempfile.TemporaryFile()
-            to_plot = apply_colormap(self._frb[field],func = self._field_transform[field])
+            fval = self._frb[field]
+            to_plot = apply_colormap(fval, func = self._field_transform[field])
             write_png_to_file(to_plot, tf)
             tf.seek(0)
             img_data = base64.b64encode(tf.read())
             tf.close()
+            mi = fval.min()
+            ma = fval.max()
+            x_width = self.xlim[1] - self.xlim[0]
+            y_width = self.ylim[1] - self.ylim[0]
+            unit = get_smallest_appropriate_unit(x_width, self._frb.pf)
+            md = _metadata_template % dict(
+                    x_width = x_width*self._frb.pf[unit],
+                    y_width = y_width*self._frb.pf[unit],
+                    unit = unit, mi = mi, ma = ma)
             payload = {'type':'png_string',
-                       'image_data':img_data}
+                       'image_data':img_data,
+                       'metadata_string': md}
             payload.update(addl_keys)
             ph.add_payload(payload)
 


http://bitbucket.org/yt_analysis/yt/changeset/812797919fcd/
changeset:   r4166:812797919fcd
branch:      yt
user:        MatthewTurk
date:        2011-04-19 23:30:55
summary:     Setting up enable/disable of keymappers
affected #:  1 file (676 bytes)

--- a/yt/gui/reason/html/js/widget_plotwindow.js	Tue Apr 19 15:53:20 2011 -0400
+++ b/yt/gui/reason/html/js/widget_plotwindow.js	Tue Apr 19 17:30:55 2011 -0400
@@ -42,6 +42,13 @@
         );
     }
 
+    this.widget_keys = new Ext.KeyMap(document, [
+        {key: 'z', fn: function(){control_panel.get("zoom10x").handler();}}
+    ]);
+    var widget_keys = this.widget_keys;
+    widget_keys.disable();
+    widget_keys.varname = python_varname;
+
     viewport.get("center-panel").add(
         {
             xtype: 'panel',
@@ -51,6 +58,13 @@
             autoScroll: true,
             layout:'absolute',
             closable: true,
+            listeners: {activate: function(p){
+                                widget_keys.enable();
+                            },
+                        deactivate: function(p){
+                                widget_keys.disable();
+                            }
+                        },
             items: [ 
                 {
                     xtype:'panel',
@@ -168,6 +182,7 @@
                 {
                     xtype: 'button',
                     text: 'Zoom In 10x',
+                    id: "zoom10x",
                     x: 10,
                     y: 160,
                     width: 80,
@@ -260,11 +275,14 @@
     );
 
     viewport.get("center-panel").activate("pw_" + this.id);
+    viewport.get("center-panel").doLayout();
     viewport.doLayout();
     this.panel = viewport.get("center-panel").get("pw_" + python_varname);
     this.panel.doLayout();
+    this.panel.show();
     this.image_panel = this.panel.get("image_panel_"+python_varname);
     var image_dom = this.image_panel.el.dom;
+    var control_panel = this.panel;
 
     this.accept_results = function(payload) {
         this.image_panel.el.dom.src = "data:image/png;base64," + payload['image_data'];


http://bitbucket.org/yt_analysis/yt/changeset/2ac66fc2469e/
changeset:   r4167:2ac66fc2469e
branch:      yt
user:        Cameron Hummels
date:        2011-04-19 21:53:26
summary:     Cleaned up reason.js formatting and removed old references to initial plot window.
affected #:  1 file (1.7 KB)

--- a/yt/gui/reason/html/js/reason.js	Tue Apr 19 14:02:46 2011 -0400
+++ b/yt/gui/reason/html/js/reason.js	Tue Apr 19 15:53:26 2011 -0400
@@ -45,246 +45,208 @@
     cell_finished(a.result);
 }
 
-    var handle_payload = function(pp) {
-        cell_finished(pp);
+var handle_payload = function(pp) {
+    cell_finished(pp);
+}
+
+var repl_input = new Ext.FormPanel({
+    title: 'YT Input',
+    url: 'push',
+    flex: 0.2,
+    layout: 'fit',
+    padding: 5,
+    items: [{
+        id: 'input_line',
+        xtype: 'textarea',
+        width: '100%',
+        autoScroll: true,
+        name: 'line',
+        allowBlank: 'True',
+        bodyStyle: 'font-family: "monospace";',
+        listeners: {
+            specialkey: function(f, e){
+                if (e.getKey() == e.ENTER) {
+                    cell_sent();
+                    yt_rpc.ExtDirectREPL.execute({
+                        code:repl_input.get('input_line').getValue()},
+                    handle_result);
+                }
+            },
+            afterrender: function(f, e){
+                //var input_line_drop_target_el = repl_input.get("input_line").el.dom;
+                var input_line_drop_target_el = repl_input.body.dom;
+
+                var input_line_drop_target = new Ext.dd.DropTarget(input_line_drop_target_el, {
+                    ddGroup     : 'pfDDgroup',
+                    notifyEnter : function(ddSource, e, data) {
+                        repl_input.body.stopFx();
+                        repl_input.body.highlight();
+                    },
+                    notifyDrop  : function(ddSource, e, data){
+
+                        var varname = data.node.attributes.objdata.varname;
+                        /* There is possibly a better way to do this, where it's also inserted correctly. */
+                        var line = repl_input.get("input_line");
+                        line.setValue(line.getValue() + varname);
+                        line.focus();
+                        return(true);
+                    }
+                });
+            },
+        },
+    },],
+});
+
+
+
+
+
+var OutputContainer = new Ext.Panel({
+    title: 'YT Output',
+    id: 'output_container',
+    autoScroll: true,
+    flex: 0.8,
+    items: []
+});
+
+var examine;
+var notebook;
+
+var treePanel = new Ext.tree.TreePanel({
+    iconCls: 'nav',
+    id: 'tree-panel',
+    layout: 'anchor',
+    region:'west',
+    split: true,
+    anchor: '100% -35',
+    minSize: 150,
+    autoScroll: true,
+    rootVisible: false,
+    ddGroup: 'pfDDgroup',
+    enableDD: true,
+    root:new Ext.tree.TreeNode({
+        expanded:true,
+        leaf:false,
+        text:''
+    }),
+    listeners: {
+        render: {
+            fn: function() {
+                Ext.getBody().on("contextmenu", Ext.emptyFn,
+                null, {preventDefault: true});
+            }
+        },
+        contextmenu: {
+            fn: function(node, event){
+                if (node.attributes.objdata.type == 'obj') return;
+                var rightClickMenu = new Ext.menu.Menu({
+                    items: [
+                        {
+                            text: 'View Grids',
+                            handler: getGridViewerHandler(node),
+                        }, {
+                            text: 'Open slice',
+                            handler: getSliceHandler(node),
+                        }, {
+                            text: 'Open projection',
+                            handler: getProjectionHandler(node),
+                        }, {
+                            text: 'View Streamlines',
+                            handler: getStreamlineViewerHandler(node),
+                        }
+                    ]
+                });
+                rightClickMenu.showAt(event.xy);
+            }
+        }
     }
+});
 
-    var repl_input = new Ext.FormPanel({
-        title: 'YT Input',
-        url: 'push',
-        flex: 0.2,
-        layout: 'fit',
-        padding: 5,
-        items: [{
-            id: 'input_line',
-            xtype: 'textarea',
-            width: '100%',
-            autoScroll: true,
-            name: 'line',
-            allowBlank: 'True',
-            bodyStyle: 'font-family: "monospace";',
-            listeners: {
-                specialkey: function(f, e){
-                    if (e.getKey() == e.ENTER) {
-                        cell_sent();
-                        yt_rpc.ExtDirectREPL.execute({
-                            code:repl_input.get('input_line').getValue()},
-                        handle_result);
-	                }
-	            },
-                afterrender: function(f, e){
-                    //var input_line_drop_target_el = repl_input.get("input_line").el.dom;
-                    var input_line_drop_target_el = repl_input.body.dom;
+var status_panel;
+var logging_store = new Ext.data.Store({
+    fields: [{name:'record'}],
+    reader: new Ext.data.ArrayReader({}, [{name: 'record'}]),
+});
 
-                    var input_line_drop_target = new Ext.dd.DropTarget(input_line_drop_target_el, {
-                        ddGroup     : 'pfDDgroup',
-                        notifyEnter : function(ddSource, e, data) {
-                            repl_input.body.stopFx();
-                            repl_input.body.highlight();
-                        },
-                        notifyDrop  : function(ddSource, e, data){
+var heartbeat_request = false;
+var task_runner = new Ext.util.TaskRunner();
+var heartbeat;
 
-                            var varname = data.node.attributes.objdata.varname;
-                            /* There is possibly a better way to do this, where it's also
-                               inserted correctly. */
-                            var line = repl_input.get("input_line");
-                            line.setValue(line.getValue() + varname);
-                            line.focus();
-                            return(true);
-                        }
-                    });
-                },
-            },
-        },],
-    });
 
-    var NorthButton = new Ext.Button({
-        text : 'North',
-	    pageX : 205,
-        pageY : 10
-//        handler: function(b, e) { window.open("session.py", "_top"); }
-    });
-
-    var EastButton = new Ext.Button({
-        text:'East',
-        pageX : 410,
-        pageY : 205
-    });
-
-    var SouthButton = new Ext.Button({
-        text:'South',
-        pageX : 205,
-        pageY : 410
-    });
-
-    var WestButton = new Ext.Button({
-        text:'West',
-        pageX : 10,
-        pageY : 205
-    });
-
-    var OutputContainer = new Ext.Panel({
-        title: 'YT Output',
-        id: 'output_container',
-        autoScroll: true,
-        flex: 0.8,
-        items: []
-    });
-
-    var PlotPanel = new Ext.Panel({
-        title: 'Plot Window 1',
-        iconCls: 'graph',
-        autoScroll: true,
-        layout:'absolute',
-        items: [ 
-            NorthButton,
-            EastButton,
-            SouthButton,
-            WestButton
-        ]
-    });
-
-    var examine;
-    var notebook;
-
-
-    var treePanel = new Ext.tree.TreePanel({
-        iconCls: 'nav',
-        id: 'tree-panel',
-        layout: 'anchor',
-        region:'west',
-        split: true,
-        anchor: '100% -35',
-        minSize: 150,
-        autoScroll: true,
-        rootVisible: false,
-        ddGroup: 'pfDDgroup',
-        enableDD: true,
-        root:new Ext.tree.TreeNode({
-            expanded:true,
-            leaf:false,
-            text:''
-        }),
-        listeners: {
-                render: {
-                    fn: function() {
-                        Ext.getBody().on("contextmenu", Ext.emptyFn,
-                            null, {preventDefault: true});
-                    }
-                },
-                contextmenu: {
-                    fn: function(node, event){
-                        if (node.attributes.objdata.type == 'obj') return;
-                        var rightClickMenu = new Ext.menu.Menu({
-                            items: [
-                                {
-                                    text: 'View Grids',
-                                    handler: getGridViewerHandler(node),
-                                }, {
-                                    text: 'Open slice',
-                                    handler: getSliceHandler(node),
-                                }, {
-                                    text: 'Open projection',
-                                    handler: getProjectionHandler(node),
-                                }, {
-                                    text: 'View Streamlines',
-                                    handler: getStreamlineViewerHandler(node),
-                                }
-                            ]
-                        });
-                        rightClickMenu.showAt(event.xy);
-                    }
-                }
-          }
-    });
-
-    var status_panel;
-    var logging_store = new Ext.data.Store({
-        fields: [{name:'record'}],
-        reader: new Ext.data.ArrayReader({}, [{name: 'record'}]),
-    });
-
-    var heartbeat_request = false;
-    var task_runner = new Ext.util.TaskRunner();
-    var heartbeat;
-
-
-    Ext.onReady(function(){
-       Ext.BLANK_IMAGE_URL = 'resources/resources/images/default/s.gif';
+Ext.onReady(function(){
+    Ext.BLANK_IMAGE_URL = 'resources/resources/images/default/s.gif';
 
     // NOTE: This is an example showing simple state management. During development,
     // it is generally best to disable state management as dynamically-generated ids
     // can change across page loads, leading to unpredictable results.  The developer
     // should ensure that stable state ids are set for stateful components in real apps.
     // it's a cold day for pontooning.
-        Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
+    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
 
     // Go ahead and create the TreePanel now so that we can use it below
-        viewport = new Ext.Viewport({
-            layout: 'border',
-            items: [
-		    // lazily created panel (xtype:'panel' is default)
-                {
-                    xtype: 'grid',
-                    store: logging_store,
-                    defaults: { width: 800 },
-                    columns: [ {id:'record', 
-                        sortable: false,
-                        width:800} ],
-                    autofill: true,
-                    region: 'south',
-                    id: "status-region",
-                    cls: "status-logger",
-                    split: true,
-                    height: 100,
-                    maxSize: 200,
-                    collapsible: true,
-                    title: 'Status',
-                    margins: '0 0 0 0',
-                }, {
-                    region: 'west',
-                    id: 'west-panel', // see Ext.getCmp() below
-                    title: 'Data Objects',
-                    split: true,
-                    width: 200,
-                    minSize: 175,
-                    maxSize: 400,
-                    collapsible: true,
-                    margins: '0 0 0 5',
-                    layout: {
-                        type: 'anchor',
+    viewport = new Ext.Viewport({
+        layout: 'border',
+        items: [
+		// lazily created panel (xtype:'panel' is default)
+            {
+                xtype: 'grid',
+                store: logging_store,
+                defaults: { width: 800 },
+                columns: [ {id:'record', 
+                    sortable: false,
+                    width:800} ],
+                autofill: true,
+                region: 'south',
+                id: "status-region",
+                cls: "status-logger",
+                split: true,
+                height: 100,
+                maxSize: 200,
+                collapsible: true,
+                title: 'Status',
+                margins: '0 0 0 0',
+            }, {
+                region: 'west',
+                id: 'west-panel', // see Ext.getCmp() below
+                title: 'Data Objects',
+                split: true,
+                width: 200,
+                minSize: 175,
+                maxSize: 400,
+                collapsible: true,
+                margins: '0 0 0 5',
+                layout: {
+                    type: 'anchor',
+                },
+                items: [{
+                        xtype: 'toolbar',
+                        items: [ main_menu ],
                     },
-                    items: [
-                        {xtype: 'toolbar',
-                          items: [ main_menu ],
-                        },
-                        treePanel,
-                    ]
+                    treePanel,
+                ]
 		  // in this instance the TabPanel is not wrapped by another panel
 		  // since no title is needed, this Panel is added directly
 		  // as a Container
-                },{
-                    xtype: 'tabpanel',
-                    region: 'center', 
-                    id: 'center-panel',
-                    deferredRender: false,
-                    activeTab: 0,     
-                    items: [
-                        {
-                            title: 'YT',
-                            id: 'notebook',
-                            layout: 'vbox',
-                            layoutConfig: {align:'stretch'},
-                            closable: false,
-                            autoScroll: false,
-                            iconCls: 'console',
-                            items: [repl_input, OutputContainer]
-                        }, 
-//                        PlotPanel
-                    ]
-                }
-            ]
-        });
+            },{
+                xtype: 'tabpanel',
+                region: 'center', 
+                id: 'center-panel',
+                deferredRender: false,
+                activeTab: 0,     
+                items: [{
+                        title: 'YT',
+                        id: 'notebook',
+                        layout: 'vbox',
+                        layoutConfig: {align:'stretch'},
+                        closable: false,
+                        autoScroll: false,
+                        iconCls: 'console',
+                        items: [repl_input, OutputContainer]
+                    }, 
+                ]
+            }
+        ]
+    });
 
 // get a reference to the HTML element with id "hideit" and add a click listener to it 
     console.log('Mitchell!\nPardon me! Mitchell!')
@@ -335,4 +297,4 @@
 
     task_runner.start(heartbeat);
                          
-    });
+});


http://bitbucket.org/yt_analysis/yt/changeset/579252cb396c/
changeset:   r4168:579252cb396c
branch:      yt
user:        MatthewTurk
date:        2011-04-19 23:34:12
summary:     Merging from my branch into Cameron's.
affected #:  4 files (1.8 KB)

--- a/yt/gui/reason/html/js/functions.js	Tue Apr 19 15:53:26 2011 -0400
+++ b/yt/gui/reason/html/js/functions.js	Tue Apr 19 17:34:12 2011 -0400
@@ -29,6 +29,18 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ***********************************************************************/
 
+function enable_input() {
+    repl_input.body.removeClass("cell_waiting");
+    repl_input.get('input_line').setReadOnly(false);
+    repl_input.get("input_line").focus();
+    yt_rpc.ExtDirectParameterFileList.get_list_of_pfs({}, fill_tree);
+}
+
+function disable_input() {
+    repl_input.get('input_line').setReadOnly(true);
+    repl_input.body.addClass("cell_waiting");
+}
+
 function cell_finished(result) {
     var new_log = false;
     var cell_resulted = false;
@@ -81,6 +93,12 @@
             var widget = new widget_types[widget_type](payload['varname'],
                                                        payload['data']);
             widget_list[widget.id] = widget;
+            /*
+               Sometimes instantiating a widget adds some objects ...
+               Plus, often when creating a widget we disable the 
+               entry of data and whatnot. 
+            */
+            cell_resulted = true;
         } else if (payload['type'] == 'widget_payload') {
             var widget = widget_list[payload['widget_id']];
             widget.accept_results(payload);
@@ -90,18 +108,10 @@
         viewport.get("status-region").getView().focusRow(number_log_records-1);
     }
     if (cell_resulted == true) {
-        repl_input.body.removeClass("cell_waiting");
-        repl_input.get('input_line').setReadOnly(false);
-        repl_input.get("input_line").focus();
-        yt_rpc.ExtDirectParameterFileList.get_list_of_pfs({}, fill_tree);
+        enable_input();
     }
 }
 
-function cell_sent() {
-    repl_input.get('input_line').setReadOnly(true);
-    repl_input.body.addClass("cell_waiting");
-}
-
 function display_image(image_id) {
     var image = Ext.get(image_id);
     var src = image.dom.src;
@@ -264,12 +274,14 @@
                             pfname:node.attributes.objdata.varname,
                             center: center, axis:axis, field:field, onmax:onmax},
                           handle_result);
+                        disable_input();
                         win.close();
                     }
                 },{
                     text: 'Cancel',
                     handler: function(b, e){
                         win.close();
+
                     }
                 }
             ]
@@ -349,6 +361,7 @@
                                 axis: axis, field: field, weight: weight,
                                 onmax: onmax},
                               handle_result);
+                        disable_input();
                         win.close();
                     }
                 },{


--- a/yt/gui/reason/html/js/reason.js	Tue Apr 19 15:53:26 2011 -0400
+++ b/yt/gui/reason/html/js/reason.js	Tue Apr 19 17:34:12 2011 -0400
@@ -66,7 +66,7 @@
         listeners: {
             specialkey: function(f, e){
                 if (e.getKey() == e.ENTER) {
-                    cell_sent();
+                    disable_input();
                     yt_rpc.ExtDirectREPL.execute({
                         code:repl_input.get('input_line').getValue()},
                     handle_result);
@@ -249,7 +249,9 @@
     });
 
 // get a reference to the HTML element with id "hideit" and add a click listener to it 
-    console.log('Mitchell!\nPardon me! Mitchell!')
+    if (typeof(console) != "undefined") {
+        console.log('Mitchell!\nPardon me! Mitchell!')
+    }
     Ext.get("hideit").on('click', function(){
 // get a reference to the Panel that was created with id = 'west-panel' 
 	    var w = Ext.getCmp('west-panel');


--- a/yt/gui/reason/html/js/widget_plotwindow.js	Tue Apr 19 15:53:26 2011 -0400
+++ b/yt/gui/reason/html/js/widget_plotwindow.js	Tue Apr 19 17:34:12 2011 -0400
@@ -42,6 +42,13 @@
         );
     }
 
+    this.widget_keys = new Ext.KeyMap(document, [
+        {key: 'z', fn: function(){control_panel.get("zoom10x").handler();}}
+    ]);
+    var widget_keys = this.widget_keys;
+    widget_keys.disable();
+    widget_keys.varname = python_varname;
+
     viewport.get("center-panel").add(
         {
             xtype: 'panel',
@@ -51,6 +58,13 @@
             autoScroll: true,
             layout:'absolute',
             closable: true,
+            listeners: {activate: function(p){
+                                widget_keys.enable();
+                            },
+                        deactivate: function(p){
+                                widget_keys.disable();
+                            }
+                        },
             items: [ 
                 {
                     xtype:'panel',
@@ -168,6 +182,7 @@
                 {
                     xtype: 'button',
                     text: 'Zoom In 10x',
+                    id: "zoom10x",
                     x: 10,
                     y: 160,
                     width: 80,
@@ -260,11 +275,14 @@
     );
 
     viewport.get("center-panel").activate("pw_" + this.id);
+    viewport.get("center-panel").doLayout();
     viewport.doLayout();
     this.panel = viewport.get("center-panel").get("pw_" + python_varname);
     this.panel.doLayout();
+    this.panel.show();
     this.image_panel = this.panel.get("image_panel_"+python_varname);
     var image_dom = this.image_panel.el.dom;
+    var control_panel = this.panel;
 
     this.accept_results = function(payload) {
         this.image_panel.el.dom.src = "data:image/png;base64," + payload['image_data'];


--- a/yt/visualization/plot_window.py	Tue Apr 19 15:53:26 2011 -0400
+++ b/yt/visualization/plot_window.py	Tue Apr 19 17:34:12 2011 -0400
@@ -33,6 +33,7 @@
 from fixed_resolution import \
     FixedResolutionBuffer
 import matplotlib.pyplot
+from .plot_modifications import get_smallest_appropriate_unit
 
 def invalidate_data(f):
     def newfunc(*args, **kwargs):
@@ -300,6 +301,12 @@
             print "writing %s" % nm
             write_image(self._frb[field],nm)
 
+_metadata_template = """
+X Field of View     %(x_width)0.3f %(unit)s
+Y Field of View     %(y_width)0.3f %(unit)s
+Extrema             %(mi)0.3e - %(ma)0.3e
+"""
+
 class PWViewerExtJS(PWViewer):
     """A viewer for the web interface.
 
@@ -321,13 +328,24 @@
             addl_keys = {}
         for field in fields:
             tf = tempfile.TemporaryFile()
-            to_plot = apply_colormap(self._frb[field],func = self._field_transform[field])
+            fval = self._frb[field]
+            to_plot = apply_colormap(fval, func = self._field_transform[field])
             write_png_to_file(to_plot, tf)
             tf.seek(0)
             img_data = base64.b64encode(tf.read())
             tf.close()
+            mi = fval.min()
+            ma = fval.max()
+            x_width = self.xlim[1] - self.xlim[0]
+            y_width = self.ylim[1] - self.ylim[0]
+            unit = get_smallest_appropriate_unit(x_width, self._frb.pf)
+            md = _metadata_template % dict(
+                    x_width = x_width*self._frb.pf[unit],
+                    y_width = y_width*self._frb.pf[unit],
+                    unit = unit, mi = mi, ma = ma)
             payload = {'type':'png_string',
-                       'image_data':img_data}
+                       'image_data':img_data,
+                       'metadata_string': md}
             payload.update(addl_keys)
             ph.add_payload(payload)
 


http://bitbucket.org/yt_analysis/yt/changeset/3a94922d810b/
changeset:   r4169:3a94922d810b
branch:      yt
user:        samskillman
date:        2011-04-20 00:32:01
summary:     Merging
affected #:  9 files (6.8 KB)

--- a/yt/funcs.py	Tue Apr 19 18:30:12 2011 -0400
+++ b/yt/funcs.py	Tue Apr 19 18:32:01 2011 -0400
@@ -328,6 +328,9 @@
             pass
     elif "CODENODE" in os.environ:
         return DummyProgressBar()
+    elif ytcfg.getboolean("yt", "__withinreason"):
+        from yt.gui.reason.extdirect_repl import ExtProgressBar
+        return ExtProgressBar(title, maxval)
     widgets = [ title,
             pb.Percentage(), ' ',
             pb.Bar(marker=pb.RotatingMarker()),


--- a/yt/gui/reason/extdirect_repl.py	Tue Apr 19 18:30:12 2011 -0400
+++ b/yt/gui/reason/extdirect_repl.py	Tue Apr 19 18:32:01 2011 -0400
@@ -96,6 +96,7 @@
     my_name = "ExtDirectREPL"
     timeout = 660 # a minute longer than the rocket server timeout
     server = None
+    stopped = False
 
     def __init__(self, base_extjs_path, locals=None):
         # First we do the standard initialization
@@ -153,8 +154,11 @@
 
     def heartbeat(self):
         self.last_heartbeat = time.time()
-        if self.payload_handler.event.wait(30):
-            return self.payload_handler.deliver_payloads()
+        for i in range(30): # The total time to wait
+            # Check for stop
+            if self.stopped: return # No race condition
+            if self.payload_handler.event.wait(1): # One second timeout
+                return self.payload_handler.deliver_payloads()
         return []
 
     def _check_heartbeat(self):
@@ -176,9 +180,12 @@
         if self.server is None:
             return
         self._heartbeat_timer.cancel()
+        self.stopped = True
         self.payload_handler.event.set()
         for v in self.server.values():
             v.stop()
+        for t in threading.enumerate():
+            print "Found a living thread:", t
 
     def _help_html(self):
         vals = open(os.path.join(local_dir, "html/help.html")).read()
@@ -335,7 +342,7 @@
         from yt.visualization.plot_window import PWViewerExtJS
         _tpw = PWViewerExtJS(_tsl, (DLE[_txax], DRE[_txax], DLE[_tyax], DRE[_tyax]), setup = False)
         _tpw._current_field = _tfield
-        _tpw.set_log(_tfield, True)
+        _tpw._field_transform["%(field)s"] = na.log
         _tfield_list = list(set(_tpf.h.field_list + _tpf.h.derived_field_list))
         _tfield_list.sort()
         _twidget_data = {'fields': _tfield_list,
@@ -525,4 +532,32 @@
     response.headers['Content-Type'] = "image/x-icon"
     return open(ico).read()
 
+class ExtProgressBar(object):
+    def __init__(self, title, maxval):
+        self.title = title
+        self.maxval = maxval
+        self.last = 0
+        # Now we add a payload for the progress bar
+        self.payload_handler = PayloadHandler()
+        self.payload_handler.add_payload(
+            {'type': 'widget',
+             'widget_type': 'progressbar',
+             'varname': None,
+             'data': {'title':title}
+            })
 
+    def update(self, val):
+        # An update is only meaningful if it's on the order of 1/100 or greater
+        if ceil(100*self.last / self.maxval) + 1 == \
+           floor(100*val / self.maxval) or val == self.maxval:
+            self.last = val
+            self.payload_handler.add_payload(
+                {'type': 'widget_payload',
+                 'widget_id': 'pbar_top',
+                 'value': float(val) / self.maxval})
+
+    def finish(self):
+        self.payload_handler.add_payload(
+            {'type': 'widget_payload',
+             'widget_id': 'pbar_top',
+             'value': -1})


--- a/yt/gui/reason/html/index.html	Tue Apr 19 18:30:12 2011 -0400
+++ b/yt/gui/reason/html/index.html	Tue Apr 19 18:32:01 2011 -0400
@@ -95,6 +95,12 @@
 
     <!-- THE GRID VIEWER FUNCTIONS --><script type="text/javascript" src="js/widget_gridviewer.js"></script>
+
+    <!-- THE STREAMLINE VIEWER FUNCTIONS -->
+    <script type="text/javascript" src="js/widget_streamlineviewer.js"></script>
+
+    <!-- THE PROGRESS BAR FUNCTIONS -->
+    <script type="text/javascript" src="js/widget_progressbar.js"></script><script id="gv-shader-fs" type="x-shader/x-fragment">
     #ifdef GL_ES
     precision highp float;


--- a/yt/gui/reason/html/js/functions.js	Tue Apr 19 18:30:12 2011 -0400
+++ b/yt/gui/reason/html/js/functions.js	Tue Apr 19 18:32:01 2011 -0400
@@ -29,6 +29,18 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ***********************************************************************/
 
+function enable_input() {
+    repl_input.body.removeClass("cell_waiting");
+    repl_input.get('input_line').setReadOnly(false);
+    repl_input.get("input_line").focus();
+    yt_rpc.ExtDirectParameterFileList.get_list_of_pfs({}, fill_tree);
+}
+
+function disable_input() {
+    repl_input.get('input_line').setReadOnly(true);
+    repl_input.body.addClass("cell_waiting");
+}
+
 function cell_finished(result) {
     var new_log = false;
     var cell_resulted = false;
@@ -81,6 +93,12 @@
             var widget = new widget_types[widget_type](payload['varname'],
                                                        payload['data']);
             widget_list[widget.id] = widget;
+            /*
+               Sometimes instantiating a widget adds some objects ...
+               Plus, often when creating a widget we disable the 
+               entry of data and whatnot. 
+            */
+            cell_resulted = true;
         } else if (payload['type'] == 'widget_payload') {
             var widget = widget_list[payload['widget_id']];
             widget.accept_results(payload);
@@ -90,18 +108,10 @@
         viewport.get("status-region").getView().focusRow(number_log_records-1);
     }
     if (cell_resulted == true) {
-        repl_input.body.removeClass("cell_waiting");
-        repl_input.get('input_line').setReadOnly(false);
-        repl_input.get("input_line").focus();
-        yt_rpc.ExtDirectParameterFileList.get_list_of_pfs({}, fill_tree);
+        enable_input();
     }
 }
 
-function cell_sent() {
-    repl_input.get('input_line').setReadOnly(true);
-    repl_input.body.addClass("cell_waiting");
-}
-
 function display_image(image_id) {
     var image = Ext.get(image_id);
     var src = image.dom.src;
@@ -264,12 +274,14 @@
                             pfname:node.attributes.objdata.varname,
                             center: center, axis:axis, field:field, onmax:onmax},
                           handle_result);
+                        disable_input();
                         win.close();
                     }
                 },{
                     text: 'Cancel',
                     handler: function(b, e){
                         win.close();
+
                     }
                 }
             ]
@@ -349,6 +361,7 @@
                                 axis: axis, field: field, weight: weight,
                                 onmax: onmax},
                               handle_result);
+                        disable_input();
                         win.close();
                     }
                 },{


--- a/yt/gui/reason/html/js/reason.js	Tue Apr 19 18:30:12 2011 -0400
+++ b/yt/gui/reason/html/js/reason.js	Tue Apr 19 18:32:01 2011 -0400
@@ -45,249 +45,213 @@
     cell_finished(a.result);
 }
 
-    var handle_payload = function(pp) {
-        cell_finished(pp);
+var handle_payload = function(pp) {
+    cell_finished(pp);
+}
+
+var repl_input = new Ext.FormPanel({
+    title: 'YT Input',
+    url: 'push',
+    flex: 0.2,
+    layout: 'fit',
+    padding: 5,
+    items: [{
+        id: 'input_line',
+        xtype: 'textarea',
+        width: '100%',
+        autoScroll: true,
+        name: 'line',
+        allowBlank: 'True',
+        bodyStyle: 'font-family: "monospace";',
+        listeners: {
+            specialkey: function(f, e){
+                if (e.getKey() == e.ENTER) {
+                    disable_input();
+                    yt_rpc.ExtDirectREPL.execute({
+                        code:repl_input.get('input_line').getValue()},
+                    handle_result);
+                }
+            },
+            afterrender: function(f, e){
+                //var input_line_drop_target_el = repl_input.get("input_line").el.dom;
+                var input_line_drop_target_el = repl_input.body.dom;
+
+                var input_line_drop_target = new Ext.dd.DropTarget(input_line_drop_target_el, {
+                    ddGroup     : 'pfDDgroup',
+                    notifyEnter : function(ddSource, e, data) {
+                        repl_input.body.stopFx();
+                        repl_input.body.highlight();
+                    },
+                    notifyDrop  : function(ddSource, e, data){
+
+                        var varname = data.node.attributes.objdata.varname;
+                        /* There is possibly a better way to do this, where it's also inserted correctly. */
+                        var line = repl_input.get("input_line");
+                        line.setValue(line.getValue() + varname);
+                        line.focus();
+                        return(true);
+                    }
+                });
+            },
+        },
+    },],
+});
+
+
+
+
+
+var OutputContainer = new Ext.Panel({
+    title: 'YT Output',
+    id: 'output_container',
+    autoScroll: true,
+    flex: 0.8,
+    items: []
+});
+
+var examine;
+var notebook;
+
+var treePanel = new Ext.tree.TreePanel({
+    iconCls: 'nav',
+    id: 'tree-panel',
+    layout: 'anchor',
+    region:'west',
+    split: true,
+    anchor: '100% -35',
+    minSize: 150,
+    autoScroll: true,
+    rootVisible: false,
+    ddGroup: 'pfDDgroup',
+    enableDD: true,
+    root:new Ext.tree.TreeNode({
+        expanded:true,
+        leaf:false,
+        text:''
+    }),
+    listeners: {
+        render: {
+            fn: function() {
+                Ext.getBody().on("contextmenu", Ext.emptyFn,
+                null, {preventDefault: true});
+            }
+        },
+        contextmenu: {
+            fn: function(node, event){
+                if (node.attributes.objdata.type == 'obj') return;
+                var rightClickMenu = new Ext.menu.Menu({
+                    items: [
+                        {
+                            text: 'View Grids',
+                            handler: getGridViewerHandler(node),
+                        }, {
+                            text: 'Open slice',
+                            handler: getSliceHandler(node),
+                        }, {
+                            text: 'Open projection',
+                            handler: getProjectionHandler(node),
+                        }, {
+                            text: 'View Streamlines',
+                            handler: getStreamlineViewerHandler(node),
+                        }
+                    ]
+                });
+                rightClickMenu.showAt(event.xy);
+            }
+        }
     }
+});
 
-    var repl_input = new Ext.FormPanel({
-        title: 'YT Input',
-        url: 'push',
-        flex: 0.2,
-        layout: 'fit',
-        padding: 5,
-        items: [{
-            id: 'input_line',
-            xtype: 'textarea',
-            width: '100%',
-            autoScroll: true,
-            name: 'line',
-            allowBlank: 'True',
-            bodyStyle: 'font-family: "monospace";',
-            listeners: {
-                specialkey: function(f, e){
-                    if (e.getKey() == e.ENTER) {
-                        cell_sent();
-                        yt_rpc.ExtDirectREPL.execute({
-                            code:repl_input.get('input_line').getValue()},
-                        handle_result);
-	                }
-	            },
-                afterrender: function(f, e){
-                    //var input_line_drop_target_el = repl_input.get("input_line").el.dom;
-                    var input_line_drop_target_el = repl_input.body.dom;
+var status_panel;
+var logging_store = new Ext.data.Store({
+    fields: [{name:'record'}],
+    reader: new Ext.data.ArrayReader({}, [{name: 'record'}]),
+});
 
-                    var input_line_drop_target = new Ext.dd.DropTarget(input_line_drop_target_el, {
-                        ddGroup     : 'pfDDgroup',
-                        notifyEnter : function(ddSource, e, data) {
-                            repl_input.body.stopFx();
-                            repl_input.body.highlight();
-                        },
-                        notifyDrop  : function(ddSource, e, data){
+var heartbeat_request = false;
+var task_runner = new Ext.util.TaskRunner();
+var heartbeat;
 
-                            var varname = data.node.attributes.objdata.varname;
-                            /* There is possibly a better way to do this, where it's also
-                               inserted correctly. */
-                            var line = repl_input.get("input_line");
-                            line.setValue(line.getValue() + varname);
-                            line.focus();
-                            return(true);
-                        }
-                    });
-                },
-            },
-        },],
-    });
 
-    var NorthButton = new Ext.Button({
-        text : 'North',
-	    pageX : 205,
-        pageY : 10
-//        handler: function(b, e) { window.open("session.py", "_top"); }
-    });
-
-    var EastButton = new Ext.Button({
-        text:'East',
-        pageX : 410,
-        pageY : 205
-    });
-
-    var SouthButton = new Ext.Button({
-        text:'South',
-        pageX : 205,
-        pageY : 410
-    });
-
-    var WestButton = new Ext.Button({
-        text:'West',
-        pageX : 10,
-        pageY : 205
-    });
-
-    var OutputContainer = new Ext.Panel({
-        title: 'YT Output',
-        id: 'output_container',
-        autoScroll: true,
-        flex: 0.8,
-        items: []
-    });
-
-    var PlotPanel = new Ext.Panel({
-        title: 'Plot Window 1',
-        iconCls: 'graph',
-        autoScroll: true,
-        layout:'absolute',
-        items: [ 
-            NorthButton,
-            EastButton,
-            SouthButton,
-            WestButton
-        ]
-    });
-
-    var examine;
-    var notebook;
-
-
-    var treePanel = new Ext.tree.TreePanel({
-        iconCls: 'nav',
-        id: 'tree-panel',
-        layout: 'anchor',
-        region:'west',
-        split: true,
-        anchor: '100% -35',
-        minSize: 150,
-        autoScroll: true,
-        rootVisible: false,
-        ddGroup: 'pfDDgroup',
-        enableDD: true,
-        root:new Ext.tree.TreeNode({
-            expanded:true,
-            leaf:false,
-            text:''
-        }),
-        listeners: {
-                render: {
-                    fn: function() {
-                        Ext.getBody().on("contextmenu", Ext.emptyFn,
-                            null, {preventDefault: true});
-                    }
-                },
-                contextmenu: {
-                    fn: function(node, event){
-                        if (node.attributes.objdata.type == 'obj') return;
-                        var rightClickMenu = new Ext.menu.Menu({
-                            items: [
-                                {
-                                    text: 'View Grids',
-                                    handler: getGridViewerHandler(node),
-                                }, {
-                                    text: 'Open slice',
-                                    handler: getSliceHandler(node),
-                                }, {
-                                    text: 'Open projection',
-                                    handler: getProjectionHandler(node),
-                                }, {
-                                    text: 'View Streamlines',
-                                    handler: getStreamlineViewerHandler(node),
-                                }
-                            ]
-                        });
-                        rightClickMenu.showAt(event.xy);
-                    }
-                }
-          }
-    });
-
-    var status_panel;
-    var logging_store = new Ext.data.Store({
-        fields: [{name:'record'}],
-        reader: new Ext.data.ArrayReader({}, [{name: 'record'}]),
-    });
-
-    var heartbeat_request = false;
-    var task_runner = new Ext.util.TaskRunner();
-    var heartbeat;
-
-
-    Ext.onReady(function(){
-       Ext.BLANK_IMAGE_URL = 'resources/resources/images/default/s.gif';
+Ext.onReady(function(){
+    Ext.BLANK_IMAGE_URL = 'resources/resources/images/default/s.gif';
 
     // NOTE: This is an example showing simple state management. During development,
     // it is generally best to disable state management as dynamically-generated ids
     // can change across page loads, leading to unpredictable results.  The developer
     // should ensure that stable state ids are set for stateful components in real apps.
     // it's a cold day for pontooning.
-        Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
+    Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
 
     // Go ahead and create the TreePanel now so that we can use it below
-        viewport = new Ext.Viewport({
-            layout: 'border',
-            items: [
-		    // lazily created panel (xtype:'panel' is default)
-                {
-                    xtype: 'grid',
-                    store: logging_store,
-                    defaults: { width: 800 },
-                    columns: [ {id:'record', 
-                        sortable: false,
-                        width:800} ],
-                    autofill: true,
-                    region: 'south',
-                    id: "status-region",
-                    cls: "status-logger",
-                    split: true,
-                    height: 100,
-                    maxSize: 200,
-                    collapsible: true,
-                    title: 'Status',
-                    margins: '0 0 0 0',
-                }, {
-                    region: 'west',
-                    id: 'west-panel', // see Ext.getCmp() below
-                    title: 'Data Objects',
-                    split: true,
-                    width: 200,
-                    minSize: 175,
-                    maxSize: 400,
-                    collapsible: true,
-                    margins: '0 0 0 5',
-                    layout: {
-                        type: 'anchor',
+    viewport = new Ext.Viewport({
+        layout: 'border',
+        items: [
+		// lazily created panel (xtype:'panel' is default)
+            {
+                xtype: 'grid',
+                store: logging_store,
+                defaults: { width: 800 },
+                columns: [ {id:'record', 
+                    sortable: false,
+                    width:800} ],
+                autofill: true,
+                region: 'south',
+                id: "status-region",
+                cls: "status-logger",
+                split: true,
+                height: 100,
+                maxSize: 200,
+                collapsible: true,
+                title: 'Status',
+                margins: '0 0 0 0',
+            }, {
+                region: 'west',
+                id: 'west-panel', // see Ext.getCmp() below
+                title: 'Data Objects',
+                split: true,
+                width: 200,
+                minSize: 175,
+                maxSize: 400,
+                collapsible: true,
+                margins: '0 0 0 5',
+                layout: {
+                    type: 'anchor',
+                },
+                items: [{
+                        xtype: 'toolbar',
+                        items: [ main_menu ],
                     },
-                    items: [
-                        {xtype: 'toolbar',
-                          items: [ main_menu ],
-                        },
-                        treePanel,
-                    ]
+                    treePanel,
+                ]
 		  // in this instance the TabPanel is not wrapped by another panel
 		  // since no title is needed, this Panel is added directly
 		  // as a Container
-                },{
-                    xtype: 'tabpanel',
-                    region: 'center', 
-                    id: 'center-panel',
-                    deferredRender: false,
-                    activeTab: 0,     
-                    items: [
-                        {
-                            title: 'YT',
-                            id: 'notebook',
-                            layout: 'vbox',
-                            layoutConfig: {align:'stretch'},
-                            closable: false,
-                            autoScroll: false,
-                            iconCls: 'console',
-                            items: [repl_input, OutputContainer]
-                        }, 
-//                        PlotPanel
-                    ]
-                }
-            ]
-        });
+            },{
+                xtype: 'tabpanel',
+                region: 'center', 
+                id: 'center-panel',
+                deferredRender: false,
+                activeTab: 0,     
+                items: [{
+                        title: 'YT',
+                        id: 'notebook',
+                        layout: 'vbox',
+                        layoutConfig: {align:'stretch'},
+                        closable: false,
+                        autoScroll: false,
+                        iconCls: 'console',
+                        items: [repl_input, OutputContainer]
+                    }, 
+                ]
+            }
+        ]
+    });
 
 // get a reference to the HTML element with id "hideit" and add a click listener to it 
-    console.log('Mitchell!\nPardon me! Mitchell!')
+    if (typeof(console) != "undefined") {
+        console.log('Mitchell!\nPardon me! Mitchell!')
+    }
     Ext.get("hideit").on('click', function(){
 // get a reference to the Panel that was created with id = 'west-panel' 
 	    var w = Ext.getCmp('west-panel');
@@ -335,4 +299,4 @@
 
     task_runner.start(heartbeat);
                          
-    });
+});


--- a/yt/gui/reason/html/js/widget_plotwindow.js	Tue Apr 19 18:30:12 2011 -0400
+++ b/yt/gui/reason/html/js/widget_plotwindow.js	Tue Apr 19 18:32:01 2011 -0400
@@ -42,6 +42,13 @@
         );
     }
 
+    this.widget_keys = new Ext.KeyMap(document, [
+        {key: 'z', fn: function(){control_panel.get("zoom10x").handler();}}
+    ]);
+    var widget_keys = this.widget_keys;
+    widget_keys.disable();
+    widget_keys.varname = python_varname;
+
     viewport.get("center-panel").add(
         {
             xtype: 'panel',
@@ -51,6 +58,13 @@
             autoScroll: true,
             layout:'absolute',
             closable: true,
+            listeners: {activate: function(p){
+                                widget_keys.enable();
+                            },
+                        deactivate: function(p){
+                                widget_keys.disable();
+                            }
+                        },
             items: [ 
                 {
                     xtype:'panel',
@@ -168,6 +182,7 @@
                 {
                     xtype: 'button',
                     text: 'Zoom In 10x',
+                    id: "zoom10x",
                     x: 10,
                     y: 160,
                     width: 80,
@@ -260,11 +275,14 @@
     );
 
     viewport.get("center-panel").activate("pw_" + this.id);
+    viewport.get("center-panel").doLayout();
     viewport.doLayout();
     this.panel = viewport.get("center-panel").get("pw_" + python_varname);
     this.panel.doLayout();
+    this.panel.show();
     this.image_panel = this.panel.get("image_panel_"+python_varname);
     var image_dom = this.image_panel.el.dom;
+    var control_panel = this.panel;
 
     this.accept_results = function(payload) {
         this.image_panel.el.dom.src = "data:image/png;base64," + payload['image_data'];


--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/yt/gui/reason/html/js/widget_progressbar.js	Tue Apr 19 18:32:01 2011 -0400
@@ -0,0 +1,51 @@
+/**********************************************************************
+The Plot Window Widget
+
+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/>.
+***********************************************************************/
+
+
+
+var WidgetProgressBar = function(python_varname, widget_data) {
+    this.id = 'pbar_top';
+
+    Ext.MessageBox.show({
+        title: 'yt is working ...',
+        msg: widget_data.title,
+        progressText: 'Progress',
+        width: 300,
+        progress: true,
+        closable: false,
+    });
+
+    this.accept_results = function(payload) {
+        var i = payload['value'];
+        if (i == -1) {
+            Ext.MessageBox.hide();
+        } else {
+            Ext.MessageBox.updateProgress(i, Math.round(100*i)+'% completed');
+        }
+    }
+
+}
+
+widget_types['progressbar'] = WidgetProgressBar;


--- a/yt/utilities/command_line.py	Tue Apr 19 18:30:12 2011 -0400
+++ b/yt/utilities/command_line.py	Tue Apr 19 18:32:01 2011 -0400
@@ -953,7 +953,10 @@
         hr = ExtDirectREPL(base_extjs_path)
         if opts.find:
             # We just have to find them and store references to them.
-            hr.execute("pfs = list(all_pfs(max_depth=2))")
+            command_line = ["pfs = []"]
+            for fn in sorted(glob.glob("*/*.hierarchy")):
+                command_line.append("pfs.append(load('%s'))" % fn[:-10])
+            hr.execute("\n".join(command_line))
         bottle.debug()
         uuid_serve_functions(open_browser=opts.open_browser,
                     port=int(opts.port), repl=hr)


--- a/yt/visualization/plot_window.py	Tue Apr 19 18:30:12 2011 -0400
+++ b/yt/visualization/plot_window.py	Tue Apr 19 18:32:01 2011 -0400
@@ -33,6 +33,7 @@
 from fixed_resolution import \
     FixedResolutionBuffer
 import matplotlib.pyplot
+from .plot_modifications import get_smallest_appropriate_unit
 
 def invalidate_data(f):
     def newfunc(*args, **kwargs):
@@ -300,6 +301,12 @@
             print "writing %s" % nm
             write_image(self._frb[field],nm)
 
+_metadata_template = """
+X Field of View     %(x_width)0.3f %(unit)s
+Y Field of View     %(y_width)0.3f %(unit)s
+Extrema             %(mi)0.3e - %(ma)0.3e
+"""
+
 class PWViewerExtJS(PWViewer):
     """A viewer for the web interface.
 
@@ -321,13 +328,24 @@
             addl_keys = {}
         for field in fields:
             tf = tempfile.TemporaryFile()
-            to_plot = apply_colormap(self._frb[field],func = self._field_transform[field])
+            fval = self._frb[field]
+            to_plot = apply_colormap(fval, func = self._field_transform[field])
             write_png_to_file(to_plot, tf)
             tf.seek(0)
             img_data = base64.b64encode(tf.read())
             tf.close()
+            mi = fval.min()
+            ma = fval.max()
+            x_width = self.xlim[1] - self.xlim[0]
+            y_width = self.ylim[1] - self.ylim[0]
+            unit = get_smallest_appropriate_unit(x_width, self._frb.pf)
+            md = _metadata_template % dict(
+                    x_width = x_width*self._frb.pf[unit],
+                    y_width = y_width*self._frb.pf[unit],
+                    unit = unit, mi = mi, ma = ma)
             payload = {'type':'png_string',
-                       'image_data':img_data}
+                       'image_data':img_data,
+                       'metadata_string': md}
             payload.update(addl_keys)
             ph.add_payload(payload)
 


http://bitbucket.org/yt_analysis/yt/changeset/48714745f1b3/
changeset:   r4170:48714745f1b3
branch:      yt
user:        samskillman
date:        2011-04-20 00:58:52
summary:     Get the streamline colors from the magnitude of the vector field being streamlined.
affected #:  1 file (101 bytes)

--- a/yt/gui/reason/extdirect_repl.py	Tue Apr 19 18:32:01 2011 -0400
+++ b/yt/gui/reason/extdirect_repl.py	Tue Apr 19 18:58:52 2011 -0400
@@ -448,7 +448,7 @@
         pos_dx = na.random.random((N,3))*scale-scale/2.
         pos = c+pos_dx
         
-        SL = Streamlines(pf,pos,'x-velocity', 'y-velocity', 'z-velocity', length=1.0)
+        SL = Streamlines(pf,pos,'x-velocity', 'y-velocity', 'z-velocity', length=1.0, get_magnitude=True)
         SL.integrate_through_volume()
         streamlist=[]
         stream_lengths = []
@@ -456,7 +456,10 @@
             stream_lengths.append( stream[na.all(stream != 0.0, axis=1)].shape[0])
         streamlist = SL.streamlines.flatten()
         streamlist = streamlist[streamlist!=0.0].tolist()
-        stream_colors = apply_colormap(na.array(streamlist)[::3]*1., cmap_name='algae', color_bounds=[0.,1.])
+
+        stream_colors = SL.magnitudes.flatten()
+        stream_colors = na.log10(stream_colors[stream_colors > 0.0])
+        stream_colors = apply_colormap(stream_colors, cmap_name='algae')
         stream_colors = stream_colors*1./255.
         stream_colors[:,:,3] = 0.8
         stream_colors = stream_colors.flatten().tolist()


http://bitbucket.org/yt_analysis/yt/changeset/d0cb8ec188a9/
changeset:   r4171:d0cb8ec188a9
branch:      yt
user:        samskillman
date:        2011-04-20 04:38:03
summary:     Trying to get the clipping to work correctly.  I think it is just
hitting numerical accuracy when you zoom in so far.  It dies out right
around float point precision.  Maybe we should come up with a
rescaling capability.  Fixing indentation because it was driving me
insane.
affected #:  1 file (373 bytes)

--- a/yt/gui/reason/html/js/widget_gridviewer.js	Tue Apr 19 18:58:52 2011 -0400
+++ b/yt/gui/reason/html/js/widget_gridviewer.js	Tue Apr 19 22:38:03 2011 -0400
@@ -25,7 +25,17 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ***********************************************************************/
 
-
+// shim layer with setTimeout fallback
+window.requestAnimFrame = (function(){
+    return  window.requestAnimationFrame       || 
+        window.webkitRequestAnimationFrame || 
+        window.mozRequestAnimationFrame    || 
+        window.oRequestAnimationFrame      || 
+        window.msRequestAnimationFrame     || 
+        function(/* function */ callback, /* DOMElement */ element){
+            window.setTimeout(callback, 1000 / 60);
+        };
+})();
 
 var WidgetGridViewer = function(python_varname, widget_data) {
     this.id = python_varname;
@@ -36,140 +46,156 @@
         this.curY = 0;
         this.dist = 0;
         function updateBasedOnOffset(camera, offset){
-        camera.position.x = camera.target.x + offset.x;
-        camera.position.y = camera.target.y + offset.y;
-        camera.position.z = camera.target.z + offset.z;
+            camera.position.x = camera.target.x + offset.x;
+            camera.position.y = camera.target.y + offset.y;
+            camera.position.z = camera.target.z + offset.z;
         }
         function camGetOffset(camera){
-        return PhiloGL.Vec3.sub(camera.position, camera.target)
-            }
+            return PhiloGL.Vec3.sub(camera.position, camera.target)
+        }
         PhiloGL('canvas_' + python_varname, {
             camera: {
-            position: {
-                x: 0.5, y: 0.5, z: 5
+		position: {
+                    x: 0.5, y: 0.5, z: 5
+		},
+                target: {
+                    x: 0.5, y: 0.5, z: 0.5
                 },
-                target: {
-                x: 0.5, y: 0.5, z: 0.5
-                },
-                },
+            },
             program: {
-            from: 'ids',
+		from: 'ids',
                 vs: 'gv-shader-vs',
                 fs: 'gv-shader-fs'
-                },    
+            },    
             events: {
-            onDragStart: function(e) {
-                pos = {
-                x: e.x,
-                y: e.y
-                };
-                this.curX = e.x;
-                this.curY = e.y;
-                this.dist = camGetOffset(this.camera).norm();
-            },
+		onDragStart: function(e) {
+                    pos = {
+			x: e.x,
+			y: e.y
+                    };
+                    this.curX = e.x;
+                    this.curY = e.y;
+                    this.dist = camGetOffset(this.camera).norm();
+		},
                 onDragEnd: function(e) {
-                pos = {
-                x: e.x,
-                y: e.y
-                };
-            },
+                    pos = {
+			x: e.x,
+			y: e.y
+                    };
+  		},
                 onDragMove: function(e) {
-                var c = this.camera;
-                var off = camGetOffset(c);
-                // Get Horizontal vector
-                var horiz = PhiloGL.Vec3.cross(c.up, 
-                               camGetOffset(c))
-                horiz.$scale(1./horiz.norm());
+                    var c = this.camera;
+                    var off = camGetOffset(c);
 
-                if (e.event.button == 0){ // Rotation
-                // Do vertical rotation about horizontal vector
-                var vert_rot = new PhiloGL.Mat4();
-                vert_rot.id();
-                vert_rot.$rotateAxis((e.y-this.curY)/100., horiz);
-                PhiloGL.Mat4.$mulVec3(vert_rot, off);
-                PhiloGL.Mat4.$mulVec3(vert_rot, c.up);
-                c.up.$scale(1./c.up.norm());
+                    // Get Horizontal vector
+                    var horiz = PhiloGL.Vec3.cross(c.up, 
+						   camGetOffset(c))
+                    horiz.$scale(1./horiz.norm());
 
-                // Do horizontal rotation about up vector
-                var side_rot = new PhiloGL.Mat4();
-                side_rot.id();
-                side_rot.$rotateAxis(-(e.x-this.curX)/100., c.up);
-                side_rot.$mulVec3(off);
-        
-                // Update current positions
-                this.curX = e.x;
-                this.curY = e.y;
-                this.dist = off.norm();
-                updateBasedOnOffset(c, off);
-                c.update();
-                } else if (e.event.button = 2){ // Right click - transpose
-		    var tscale = 1.0*off.norm()/512.;
-		    var move_up = c.up.scale(-(e.y-this.curY)*tscale);
-		    var move_over = horiz.scale(-(e.x-this.curX)*tscale);
-                c.position.$add(move_up);
-                c.position.$add(move_over);
-                c.target.$add(move_up);
-                c.target.$add(move_over);
-                // Update current positions
-                this.curX = e.x;
-                this.curY = e.y;
-                c.update();
-                }
-    
-            },
+                    if (e.event.button == 0){ // Rotation
+			// Do vertical rotation about horizontal vector
+			var vert_rot = new PhiloGL.Mat4();
+			vert_rot.id();
+			vert_rot.$rotateAxis((e.y-this.curY)/100., horiz);
+			PhiloGL.Mat4.$mulVec3(vert_rot, off);
+			PhiloGL.Mat4.$mulVec3(vert_rot, c.up);
+			c.up.$scale(1./c.up.norm());
+
+			// Do horizontal rotation about up vector
+			var side_rot = new PhiloGL.Mat4();
+			side_rot.id();
+			side_rot.$rotateAxis(-(e.x-this.curX)/100., c.up);
+			side_rot.$mulVec3(off);
+			
+			// Update current positions
+			this.curX = e.x;
+			this.curY = e.y;
+			this.dist = off.norm();
+			updateBasedOnOffset(c, off);
+			this.camera.near = this.dist/100000.0;
+			this.camera.far = this.dist*2.0;
+			c.update();
+                    } else if (e.event.button = 2){ // Right click - transpose
+			var tscale = 1.0*off.norm()/512.;
+			var move_up = c.up.scale(-(e.y-this.curY)*tscale);
+			var move_over = horiz.scale(-(e.x-this.curX)*tscale);
+			c.position.$add(move_up);
+			c.position.$add(move_over);
+			c.target.$add(move_up);
+			c.target.$add(move_over);
+			// Update current positions
+			this.curX = e.x;
+			this.curY = e.y;
+			this.dist = off.norm();
+			this.camera.near = this.dist/100000.0;
+			this.camera.far = this.dist*2.0;
+			c.update();
+                    }
+		    
+		},
                 onMouseWheel: function(e){
-                e.stop();
-                var offset = PhiloGL.Vec3.scale(camGetOffset(this.camera),
-                                1.0 - e.wheel/10.);
-                updateBasedOnOffset(this.camera, offset);
-                this.camera.update();
-            }
+                    e.stop();
+                    var offset = PhiloGL.Vec3.scale(camGetOffset(this.camera),
+						    1.0 - e.wheel/10.);
+                    updateBasedOnOffset(this.camera, offset);
+		    var dist = offset.norm()
+                    this.camera.near = offset.norm()/100000.0;
+                    this.camera.far = offset.norm()*2.0;
+                    this.camera.update();
+
+		}
             },
             onError: function() {
-            alert("An error ocurred while loading the application");
+		alert("An error ocurred while loading the application");
             },
             onLoad: function(app) {
-            var gl = app.gl,
+		var gl = app.gl,
                 canvas = app.canvas,
                 program = app.program,
                 scene = app.scene,
                 camera = app.camera;
+		
+		gl.viewport(0, 0, canvas.width, canvas.height);
+		gl.clearColor(0, 0, 0, 1);
+		//gl.clearDepth(1);
+		gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
+		gl.enable(gl.BLEND);
+		//gl.disable(gl.DEPTH_TEST);
+		program.setUniform('alpha',0.8);
+		gl.depthFunc(gl.LEQUAL);
+		examine = camera;
+		program.setBuffers({
+	    	    'shapeset': {
+	    		attribute: 'aVertexPosition',
+			value: new Float32Array(widget_data['vertex_positions']),
+	    		size: 3
+	    	    },
+	    	    'shapesetColors': {
+	    		attribute: 'aVertexColor',
+			value: new Float32Array(widget_data['vertex_colors']),
+	    		size: 4
+	    	    },
+		    
+		});
 
-	    gl.viewport(0, 0, canvas.width, canvas.height);
-	    gl.clearColor(0, 0, 0, 1);
-	    gl.clearDepth(1);
-            gl.blendFunc(gl.SRC_ALPHA, gl.ONE);
-            gl.enable(gl.BLEND);
-            gl.disable(gl.DEPTH_TEST);
-            program.setUniform('alpha',0.8);
-	    gl.depthFunc(gl.LEQUAL);
-
-	    program.setBuffers({
-	    	'shapeset': {
-	    	    attribute: 'aVertexPosition',
-                    value: new Float32Array(widget_data['vertex_positions']),
-	    	    size: 3
-	    	},
-	    	'shapesetColors': {
-	    	    attribute: 'aVertexColor',
-                    value: new Float32Array(widget_data['vertex_colors']),
-	    	    size: 4
-	    	},
+		camera.modelView.id();
+		camera.update();
+		draw();
 		
-	    });
-
-	    camera.modelView.id();
-	    camera.update()
-	    setInterval(draw, 100/60);
-	    //Draw the scene
-	    function draw() {
-		gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
-		program.setUniform('uMVMatrix', camera.modelView);
-		program.setUniform('uPMatrix', camera.projection);
-		program.setBuffer('shapeset');
-		program.setBuffer('shapesetColors');
-                gl.drawArrays(gl.LINES, 0, widget_data['n_vertices']);        
-	    }
+		(function animloop(){
+		    draw();
+		    requestAnimFrame(animloop, canvas);
+		})();
+		
+		//Draw the scene
+		function draw() {
+	    	    gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+	    	    program.setUniform('uMVMatrix', camera.modelView);
+	    	    program.setUniform('uPMatrix', camera.projection);
+	    	    program.setBuffer('shapeset');
+	    	    program.setBuffer('shapesetColors');
+                    gl.drawArrays(gl.LINES, 0, widget_data['n_vertices']);
+		}
 	    }
         });  
     }        
@@ -186,10 +212,10 @@
             items: [
                 { xtype:'panel',
                   autoEl: {
-                    tag: 'canvas',
-                    id: 'canvas_' + python_varname,
-                    style: 'border: none;',
-                    width: 512, height:512
+                      tag: 'canvas',
+                      id: 'canvas_' + python_varname,
+                      style: 'border: none;',
+                      width: 512, height:512
                   },
                   width: 512,
                   height: 512


http://bitbucket.org/yt_analysis/yt/changeset/2910ea47b354/
changeset:   r4172:2910ea47b354
branch:      yt
user:        MatthewTurk
date:        2011-04-20 12:57:36
summary:     Adding a read-only zoom scroll bar.
affected #:  2 files (727 bytes)

--- a/yt/gui/reason/html/js/widget_plotwindow.js	Tue Apr 19 22:38:03 2011 -0400
+++ b/yt/gui/reason/html/js/widget_plotwindow.js	Wed Apr 20 06:57:36 2011 -0400
@@ -79,9 +79,15 @@
                     y: 10,
                     width: 400,
                     height: 400,
-                }, 
+                }, {   xtype: 'multislider',
+                    id: 'slider_' + python_varname,
+                    minValue: 0,
+                    maxValue: 100,
+                    increment: 0.1,
+                    x: 100, y: 410,
+                    width: 400,
+                }, {
                 /* the single buttons for 10% pan*/
-                {
                     xtype:'button',
                     iconCls: 'singleuparrow',
                     //text: 'North',
@@ -281,11 +287,14 @@
     this.panel.doLayout();
     this.panel.show();
     this.image_panel = this.panel.get("image_panel_"+python_varname);
+    this.zoom_scroll = this.panel.get("slider_" + python_varname);
     var image_dom = this.image_panel.el.dom;
     var control_panel = this.panel;
+    examine = this.zoom_scroll;
 
     this.accept_results = function(payload) {
         this.image_panel.el.dom.src = "data:image/png;base64," + payload['image_data'];
+        this.zoom_scroll.setValue(0, payload['zoom'], true);
     }
 
     yt_rpc.ExtDirectREPL.execute(


--- a/yt/visualization/plot_window.py	Tue Apr 19 22:38:03 2011 -0400
+++ b/yt/visualization/plot_window.py	Wed Apr 20 06:57:36 2011 -0400
@@ -326,6 +326,7 @@
         else:
             fields = self._frb.data.keys()
             addl_keys = {}
+        min_zoom = 200*self._frb.pf.h.get_smallest_dx() * self._frb.pf['unitary']
         for field in fields:
             tf = tempfile.TemporaryFile()
             fval = self._frb[field]
@@ -343,9 +344,13 @@
                     x_width = x_width*self._frb.pf[unit],
                     y_width = y_width*self._frb.pf[unit],
                     unit = unit, mi = mi, ma = ma)
+            # We scale the width between 200*min_dx and 1.0
+            zoom_fac = na.log10(x_width*self._frb.pf['unitary'])/na.log10(min_zoom)
+            zoom_fac = 100.0*max(0.0, zoom_fac)
             payload = {'type':'png_string',
                        'image_data':img_data,
-                       'metadata_string': md}
+                       'metadata_string': md,
+                       'zoom': zoom_fac}
             payload.update(addl_keys)
             ph.add_payload(payload)
 


http://bitbucket.org/yt_analysis/yt/changeset/73c53917b34b/
changeset:   r4173:73c53917b34b
branch:      yt
user:        MatthewTurk
date:        2011-04-20 13:10:52
summary:     Scroll bar is no longer read-only.  Had to fix the set_width method in
PlotWindow.
affected #:  2 files (945 bytes)

--- a/yt/gui/reason/html/js/widget_plotwindow.js	Wed Apr 20 06:57:36 2011 -0400
+++ b/yt/gui/reason/html/js/widget_plotwindow.js	Wed Apr 20 07:10:52 2011 -0400
@@ -86,6 +86,16 @@
                     increment: 0.1,
                     x: 100, y: 410,
                     width: 400,
+                    listeners: {
+                        /* Only changecomplete; don't want too many render
+                        events */
+                        changecomplete: function(slider, newValue, thumb) {
+                            yt_rpc.ExtDirectREPL.execute(
+                                {code:python_varname + ".scroll_zoom(" +
+                                      newValue + ")",
+                                 hide:true}, cell_finished);
+                        }
+                    }
                 }, {
                 /* the single buttons for 10% pan*/
                     xtype:'button',


--- a/yt/visualization/plot_window.py	Wed Apr 20 06:57:36 2011 -0400
+++ b/yt/visualization/plot_window.py	Wed Apr 20 07:10:52 2011 -0400
@@ -202,10 +202,10 @@
         Wx, Wy = self.width
         centerx = self.xlim[0] + Wx*0.5
         centery = self.ylim[0] + Wy*0.5
-        self.xlim[0] = centerx - new_width/2.
-        self.xlim[1] = centerx + new_width/2.
-        self.ylim[0] = centery - new_width/2.
-        self.ylim[1] = centery + new_width/2.
+        self.xlim = (centerx - new_width/2.,
+                     centerx + new_width/2.)
+        self.ylim = (centery - new_width/2.,
+                     centery + new_width/2.)
 
     @invalidate_data
     def set_center(self, new_center):
@@ -354,6 +354,16 @@
             payload.update(addl_keys)
             ph.add_payload(payload)
 
+    # This calls an invalidation routine from within
+    def scroll_zoom(self, value):
+        # We accept value from 0..100, and assume it has been set from the
+        # scroll bar.  In that case, we undo the logic for calcualting
+        # 'zoom_fac' from above.
+        min_val = 200*self._frb.pf.h.get_smallest_dx()
+        unit = self._frb.pf['unitary']
+        width = (min_val**(value/100.0))/unit
+        self.set_width(width)
+
     def get_metadata(self):
         pass
 


http://bitbucket.org/yt_analysis/yt/changeset/085b9ff54759/
changeset:   r4174:085b9ff54759
branch:      yt
user:        MatthewTurk
date:        2011-04-20 13:25:09
summary:     Adding metadata display.  Captions and titles for imgur don't seem to work,
even though imgur gives them back in its response.
affected #:  3 files (730 bytes)

--- a/yt/gui/reason/extdirect_repl.py	Wed Apr 20 07:10:52 2011 -0400
+++ b/yt/gui/reason/extdirect_repl.py	Wed Apr 20 07:25:09 2011 -0400
@@ -278,11 +278,12 @@
         return {'status': 'SUCCESS', 'site': site}
 
     _api_key = 'f62d550859558f28c4c214136bc797c7'
-    def upload_image(self, image_data):
+    def upload_image(self, image_data, caption):
         if not image_data.startswith("data:"): return {'uploaded':False}
         prefix = "data:image/png;base64,"
         image_data = image_data[len(prefix):]
-        parameters = {'key':self._api_key, 'image':image_data, type:'base64'}
+        parameters = {'key':self._api_key, 'image':image_data, type:'base64',
+                      'caption': caption, 'title': "Uploaded Image from reason"}
         data = urllib.urlencode(parameters)
         req = urllib2.Request('http://api.imgur.com/2/upload.json', data)
         try:


--- a/yt/gui/reason/html/js/widget_plotwindow.js	Wed Apr 20 07:10:52 2011 -0400
+++ b/yt/gui/reason/html/js/widget_plotwindow.js	Wed Apr 20 07:25:09 2011 -0400
@@ -253,7 +253,8 @@
                     handler: function(b,e) {
                         img_data = image_dom.src;
                         yt_rpc.ExtDirectREPL.upload_image(
-                            {image_data:img_data},
+                            {image_data:img_data,
+                             caption:metadata_string},
                         function(rv) {
                             var alert_text;
                             if(rv['uploaded'] == false) {
@@ -285,6 +286,14 @@
                                 newValue + '")', hide:true},
                             cell_finished);
                     }}
+                },{
+                    xtype: 'textarea',
+                    readOnly: true,
+                    id: 'metadata_' + python_varname,
+                    width: 300,
+                    height: 200,
+                    style: {fontFamily: 'monospace'},
+                    x: 510, y: 10,
                 }
             ]
         }
@@ -297,14 +306,18 @@
     this.panel.doLayout();
     this.panel.show();
     this.image_panel = this.panel.get("image_panel_"+python_varname);
+    this.metadata_panel = this.panel.get("metadata_" + python_varname);
     this.zoom_scroll = this.panel.get("slider_" + python_varname);
     var image_dom = this.image_panel.el.dom;
     var control_panel = this.panel;
     examine = this.zoom_scroll;
+    var metadata_string;
 
     this.accept_results = function(payload) {
         this.image_panel.el.dom.src = "data:image/png;base64," + payload['image_data'];
         this.zoom_scroll.setValue(0, payload['zoom'], true);
+        this.metadata_panel.setValue(payload['metadata_string']);
+        metadata_string = payload['metadata_string'];
     }
 
     yt_rpc.ExtDirectREPL.execute(


--- a/yt/visualization/plot_window.py	Wed Apr 20 07:10:52 2011 -0400
+++ b/yt/visualization/plot_window.py	Wed Apr 20 07:25:09 2011 -0400
@@ -302,6 +302,7 @@
             write_image(self._frb[field],nm)
 
 _metadata_template = """
+                    %(pf)s
 X Field of View     %(x_width)0.3f %(unit)s
 Y Field of View     %(y_width)0.3f %(unit)s
 Extrema             %(mi)0.3e - %(ma)0.3e
@@ -341,6 +342,7 @@
             y_width = self.ylim[1] - self.ylim[0]
             unit = get_smallest_appropriate_unit(x_width, self._frb.pf)
             md = _metadata_template % dict(
+                    pf = self._frb.pf,
                     x_width = x_width*self._frb.pf[unit],
                     y_width = y_width*self._frb.pf[unit],
                     unit = unit, mi = mi, ma = ma)


http://bitbucket.org/yt_analysis/yt/changeset/0ea6f5e77174/
changeset:   r4175:0ea6f5e77174
branch:      yt
user:        MatthewTurk
date:        2011-04-21 01:31:04
summary:     Merging
affected #:  1 file (770 bytes)

--- a/yt/analysis_modules/halo_profiler/multi_halo_profiler.py	Wed Apr 20 07:25:09 2011 -0400
+++ b/yt/analysis_modules/halo_profiler/multi_halo_profiler.py	Wed Apr 20 19:31:04 2011 -0400
@@ -295,8 +295,8 @@
         self.__check_directory(my_output_dir)
 
         # Profile all halos.
+        updated_halos = []
         for halo in self._get_objs('all_halos', round_robin=True):
-
             # Apply prefilters to avoid profiling unwanted halos.
             filter_result = True
             haloQuantities = {}
@@ -331,6 +331,17 @@
 
                 self.filtered_halos.append(haloQuantities)
 
+            # If we've gotten this far down, this halo is good and we want
+            # to keep it. But we need to communicate the recentering changes
+            # to all processors (the root one in particular) without having
+            # one task clobber the other.
+            updated_halos.append(halo)
+        
+        # And here is where we bring it all together.
+        updated_halos = self._mpi_catlist(updated_halos)
+        updated_halos.sort(key = lambda a:a['id'])
+        self.all_halos = updated_halos
+
         self.filtered_halos = self._mpi_catlist(self.filtered_halos)
         self.filtered_halos.sort(key = lambda a:a['id'])
 
@@ -372,14 +383,15 @@
                 if new_x < self.pf.domain_left_edge[0] or \
                         new_y < self.pf.domain_left_edge[1] or \
                         new_z < self.pf.domain_left_edge[2]:
-                    mylog.info("Recentering moves too far, skipping halo %d" % \
+                    mylog.info("Recentering rejected, skipping halo %d" % \
                         halo['id'])
                     return None
                 halo['center'] = [new_x, new_y, new_z]
-                d = periodic_dist(old, halo['center'],
-                    self.pf.domain_right_edge - self.pf.domain_left_edge) * \
-                    self.pf['kpc']
-                mylog.info("Recentered %1.3e kpc away." % d)
+                d = self.pf['kpc'] * periodic_dist(old, halo['center'],
+                    self.pf.domain_right_edge - self.pf.domain_left_edge)
+                mylog.info("Recentered halo %d %1.3e kpc away." % (halo['id'], d))
+                # Expand the halo to account for recentering. 
+                halo['r_max'] += d / 1000 # d is in kpc -> want mpc
                 new_sphere = True
 
             if new_sphere:
@@ -396,7 +408,7 @@
                     if self.velocity_center[1] == 'halo':
                         sphere.set_field_parameter('bulk_velocity', halo['velocity'])
                     elif self.velocity_center[1] == 'sphere':
-                        sphere.set_field_parameter('bulk_velocity', sphere.quantities['BulkVelocity']())
+                        sphere.set_field_parameter('bulk_velocity', sphere.quantities['BulkVelocity'](lazy_reader=False, preload=False))
                     else:
                         mylog.error("Invalid parameter: VelocityCenter.")
                 elif self.velocity_center[0] == 'max':
@@ -409,7 +421,8 @@
             try:
                 profile = BinnedProfile1D(sphere, self.n_profile_bins, "RadiusMpc",
                                                 r_min, halo['r_max'],
-                                                log_space=True, lazy_reader=False)
+                                                log_space=True, lazy_reader=False,
+                                                end_collect=True)
             except EmptyProfileData:
                 mylog.error("Caught EmptyProfileData exception, returning None for this halo.")
                 return None

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list