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

Bitbucket commits-noreply at bitbucket.org
Tue Apr 26 12:57:47 PDT 2011


3 new changesets in yt:

http://bitbucket.org/yt_analysis/yt/changeset/310a34d907d7/
changeset:   r4204:310a34d907d7
branch:      yt
user:        MatthewTurk
date:        2011-04-26 15:34:40
summary:     More changes to the simple phase plot, including adding a loglocator.
affected #:  1 file (582 bytes)

--- a/yt/visualization/profile_plotter.py	Tue Apr 26 09:17:22 2011 -0400
+++ b/yt/visualization/profile_plotter.py	Tue Apr 26 09:34:40 2011 -0400
@@ -30,6 +30,7 @@
     BinnedProfile1D, \
     BinnedProfile2D
 from .plot_types import ProfilePlot, PhasePlot
+from .loglocator import LogLocator
 
 def invalidate_plot(f):
     @wraps(f)
@@ -46,13 +47,26 @@
     ticks = None
 
     def calculate_ticks(self):
-        pass
+        if self.scale == 'log':
+            locator = LogLocator()
+        else:
+            raise NotImplementedError
+        self.ticks = locator(*self.bounds)
 
 class ColorbarSpec(object):
     title = None
     bounds = None
     scale = None
     cmap = None
+    ticks = None
+
+    def calculate_ticks(self):
+        if self.scale == 'log':
+            locator = LogLocator()
+        else:
+            raise NotImplementedError
+        self.ticks = locator(*self.bounds)
+
 
 class ImagePlotContainer(object):
     x_spec = None
@@ -60,10 +74,9 @@
     image = None
     cmap = None
     cbar = None
-    transform = None
 
 class PhasePlotter(object):
-    _transform = lambda a: a
+    scale = None
     _current_field = None
 
     def __init__(self, data_source, field_x, field_y, field_z,
@@ -183,30 +196,37 @@
         profile.add_fields(field_z, weight=weight, accumulation=accumulation, fractional=fractional)
         self._current_field = field_z
         self.profile = profile
-        if data_source.pf.field_info[field_z].take_log:
-            self._transform = na.log10
+        self.scale = {True:'log', False:'linear'}.get(
+                data_source.pf.field_info[field_z], "log")
         self._setup_plot()
 
     def _setup_plot(self):
         xax = AxisSpec()
         xax.title = self.profile.x_bin_field
         xax.bounds = (self.profile._x_bins[0],
-                      self.profile._x_bins[1])
+                      self.profile._x_bins[-1])
         xax.scale = {True: 'log', False: 'linear'}[self.profile._x_log]
         xax.calculate_ticks()
 
         yax = AxisSpec()
         yax.title = self.profile.y_bin_field
         yax.bounds = (self.profile._y_bins[0],
-                      self.profile._y_bins[1])
+                      self.profile._y_bins[-1])
         yax.scale = {True: 'log', False: 'linear'}[self.profile._y_log]
         yax.calculate_ticks()
 
         cbar = ColorbarSpec()
         cbar.title = self._current_field
-        cbar.bounds = (self.profile[self._current_field].min(),
-                       self.profile[self._current_field].max())
+        if self.scale == 'log':
+            nz = (self.profile[self._current_field] > 0)
+            mi = self.profile[self._current_field][nz].min()
+        else:
+            mi = self.profile[self._current_field][nz].min()
+        ma = self.profile[self._current_field].max()
+        cbar.bounds = (mi, ma)
         cbar.cmap = 'algae'
+        cbar.scale = self.scale
+        cbar.calculate_ticks()
 
         self.plot = ImagePlotContainer()
         self.plot.image = self.profile[self._current_field]
@@ -214,4 +234,3 @@
         self.plot.y_spec = yax
         self.plot.cmap = 'algae'
         self.plot.cbar = cbar
-        self.plot.transform = self._transform


http://bitbucket.org/yt_analysis/yt/changeset/64080dc087cc/
changeset:   r4205:64080dc087cc
branch:      yt
user:        MatthewTurk
date:        2011-04-26 20:18:36
summary:     The simple phase plotter now (correctly?) generates replicatable, small
collections of data that can be transformed into plots.  I've added an ext
widget payload type for this.
affected #:  4 files (2.4 KB)

--- a/yt/gui/reason/extdirect_repl.py	Tue Apr 26 09:34:40 2011 -0400
+++ b/yt/gui/reason/extdirect_repl.py	Tue Apr 26 14:18:36 2011 -0400
@@ -362,7 +362,7 @@
         _tpw._field_transform["%(field)s"] = na.log
         _tfield_list = list(set(_tpf.h.field_list + _tpf.h.derived_field_list))
         _tfield_list.sort()
-        _tcb = _tpw.get_colorbar(_tfield)
+        _tcb = _tpw._get_cbar_image()
         _twidget_data = {'fields': _tfield_list,
                          'initial_field': _tfield,
                          'title': "%%s Projection" %% (_tpf),
@@ -402,7 +402,7 @@
         _tpw.set_log(_tfield, True)
         _tfield_list = list(set(_tpf.h.field_list + _tpf.h.derived_field_list))
         _tfield_list.sort()
-        _tcb = _tpw.get_colorbar(_tfield)
+        _tcb = _tpw._get_cbar_image()
         _twidget_data = {'fields': _tfield_list,
                          'initial_field': _tfield,
                          'title': "%%s Slice" %% (_tpf),


--- a/yt/visualization/image_writer.py	Tue Apr 26 09:34:40 2011 -0400
+++ b/yt/visualization/image_writer.py	Tue Apr 26 14:18:36 2011 -0400
@@ -209,6 +209,8 @@
         mi = na.nanmin(image[~na.isinf(image)])
         ma = na.nanmax(image[~na.isinf(image)])
         color_bounds = mi, ma
+    else:
+        color_bounds = [func(c) for c in color_bounds]
     image = (image - color_bounds[0])/(color_bounds[1] - color_bounds[0])
     to_plot = map_to_colors(image, cmap_name)
     to_plot = na.clip(to_plot, 0, 255)


--- a/yt/visualization/plot_window.py	Tue Apr 26 09:34:40 2011 -0400
+++ b/yt/visualization/plot_window.py	Tue Apr 26 14:18:36 2011 -0400
@@ -369,7 +369,7 @@
             #print v1, v2, mi, ma, height, p
         return ticks
 
-    def get_colorbar(self, field, height = 400, width = 40):
+    def _get_cbar_image(self, height = 400, width = 40):
         # Right now there's just the single 'cmap', but that will eventually
         # change.  I think?
         vals = na.mgrid[1:0:height * 1j] * na.ones(width)[:,None]


--- a/yt/visualization/profile_plotter.py	Tue Apr 26 09:34:40 2011 -0400
+++ b/yt/visualization/profile_plotter.py	Tue Apr 26 14:18:36 2011 -0400
@@ -23,9 +23,16 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
 
+import tempfile
+import base64
+
 from functools import wraps
 import numpy as na
 
+from .image_writer import \
+    write_image, apply_colormap
+from yt.utilities.amr_utils import \
+    write_png_to_file
 from yt.data_objects.profiles import \
     BinnedProfile1D, \
     BinnedProfile2D
@@ -53,26 +60,13 @@
             raise NotImplementedError
         self.ticks = locator(*self.bounds)
 
-class ColorbarSpec(object):
-    title = None
-    bounds = None
-    scale = None
+class ColorbarSpec(AxisSpec):
     cmap = None
-    ticks = None
-
-    def calculate_ticks(self):
-        if self.scale == 'log':
-            locator = LogLocator()
-        else:
-            raise NotImplementedError
-        self.ticks = locator(*self.bounds)
-
 
 class ImagePlotContainer(object):
     x_spec = None
     y_spec = None
     image = None
-    cmap = None
     cbar = None
 
 class PhasePlotter(object):
@@ -232,5 +226,73 @@
         self.plot.image = self.profile[self._current_field]
         self.plot.x_spec = xax
         self.plot.y_spec = yax
-        self.plot.cmap = 'algae'
         self.plot.cbar = cbar
+
+class PhasePlotterExtWidget(PhasePlotter):
+    _ext_widget_id = None
+
+    def _setup_plot(self):
+        PhasePlotter._setup_plot(self)
+        # Now self.plot exists
+        #from yt.gui.reason.bottle_mods import PayloadHandler
+        #ph = PayloadHandler()
+        # We set up an x axis, y axis, colorbar, and image
+        xax = self._convert_axis(self.plot.x_spec)
+        yax = self._convert_axis(self.plot.y_spec)
+        cbar = self._convert_axis(self.plot.cbar)
+        cbar['cmap_image'] = self._get_cbar_image()
+        # This is a historical artifact
+        raw_data = self.plot.image.transpose() 
+
+        if self.plot.cbar.scale == 'log':
+            func = na.log10
+        else:
+            func = lambda a: a
+        to_plot = apply_colormap(raw_data, self.plot.cbar.bounds,
+                                 self.plot.cbar.cmap, func)
+        if self.plot.cbar.scale == 'log':
+            # Now we white-out all those regions
+            #import pdb;pdb.set_trace()
+            to_plot[raw_data == 0.0,:] = 255
+        tf = tempfile.TemporaryFile()
+        write_png_to_file(to_plot, tf)
+        tf.seek(0)
+        img_data = base64.b64encode(tf.read())
+        tf.close()
+        payload = {'xax':xax, 'yax':yax, 'cbar':cbar,
+                   'type': 'widget_payload', 'widget_id': self._ext_widget_id,
+                   'image_data': img_data}
+        return payload
+
+    def _convert_ticks(self, tick_locs, bounds, func, height = 400):
+        # height can be a length too; doesn't quite matter.
+        mi, ma = func(bounds)
+        ticks = []
+        for v1,v2 in zip(tick_locs, func(tick_locs)):
+            if v2 < mi or v2 > ma: continue
+            p = height - height * (v2 - mi)/(ma - mi)
+            ticks.append((p,v1,v2))
+            #print v1, v2, mi, ma, height, p
+        return ticks
+
+    def _convert_axis(self, spec):
+        func = lambda a: a
+        if spec.scale == 'log': func = na.log10
+        tick_info = self._convert_ticks(spec.ticks, spec.bounds, func)
+        ax = {'ticks':tick_info,
+              'title': spec.title}
+        return ax
+
+    def _get_cbar_image(self, height = 400, width = 40):
+        # Right now there's just the single 'cmap', but that will eventually
+        # change.  I think?
+        vals = na.mgrid[1:0:height * 1j] * na.ones(width)[:,None]
+        vals = vals.transpose()
+        to_plot = apply_colormap(vals)
+        tf = tempfile.TemporaryFile()
+        write_png_to_file(to_plot, tf)
+        tf.seek(0)
+        img_data = base64.b64encode(tf.read())
+        tf.close()
+        return img_data
+


http://bitbucket.org/yt_analysis/yt/changeset/bec11ac983c0/
changeset:   r4206:bec11ac983c0
branch:      yt
user:        MatthewTurk
date:        2011-04-26 21:55:45
summary:     First pass at a phase plot widget.  No labels on the ticks yet, or the
colorbar.  I believe the x_ticks are correctly positioned, but I am still not
quite sure yet.
affected #:  6 files (14.3 KB)

--- a/yt/gui/reason/extdirect_repl.py	Tue Apr 26 14:18:36 2011 -0400
+++ b/yt/gui/reason/extdirect_repl.py	Tue Apr 26 15:55:45 2011 -0400
@@ -340,6 +340,28 @@
         return command
 
     @lockit
+    def create_phase(self, objname, field_x, field_y, field_z, weight):
+        if weight == "None": weight = None
+        else: weight = "'%s'" % (weight)
+        funccall = """
+        _tfield_x = "%(field_x)s"
+        _tfield_y = "%(field_y)s"
+        _tfield_z = "%(field_z)s"
+        _tweight = %(weight)s
+        _tobj = %(objname)s
+        _tpf = _tobj.pf
+        from yt.visualization.profile_plotter import PhasePlotterExtWidget
+        _tpp = PhasePlotterExtWidget(_tobj, _tfield_x, _tfield_y, _tfield_z, _tweight)
+        _tfield_list = list(set(_tpf.h.field_list + _tpf.h.derived_field_list))
+        _tfield_list.sort()
+        _twidget_data = {'title': "%%s Phase Plot" %% (_tobj)}
+        """ % dict(objname = objname, field_x = field_x, field_y = field_y,
+                   field_z = field_z, weight = weight)
+        funccall = "\n".join(line.strip() for line in funccall.splitlines())
+        self.execute(funccall, hide=True)
+        self.execute(self._add_widget('_tpp', '_twidget_data'), hide=True)
+
+    @lockit
     def create_proj(self, pfname, axis, field, weight, onmax):
         if weight == "None": weight = None
         else: weight = "'%s'" % (weight)


--- a/yt/gui/reason/html/index.html	Tue Apr 26 14:18:36 2011 -0400
+++ b/yt/gui/reason/html/index.html	Tue Apr 26 15:55:45 2011 -0400
@@ -110,6 +110,9 @@
     <!-- THE GRID DATA VIEWER FUNCTIONS --><script type="text/javascript" src="js/widget_griddata.js"></script>
 
+    <!-- THE PHASE PLOT VIEWER FUNCTIONS -->
+    <script type="text/javascript" src="js/widget_phaseplot.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 26 14:18:36 2011 -0400
+++ b/yt/gui/reason/html/js/functions.js	Tue Apr 26 15:55:45 2011 -0400
@@ -142,11 +142,13 @@
             iconCls: 'pf_icon'}));
         this_pf = treePanel.root.lastChild
         Ext.each(pf.objects, function(obj, obj_index) {
+            examine = this_pf;
             this_pf.appendChild(new Ext.tree.TreeNode(
                 {text: obj.name,
                  leaf: true,
                  iconCls: 'data_obj',
-                 objdata: {varname: obj.varname, type: 'obj'},
+                 objdata: {varname: obj.varname, type: 'obj',
+                           pfdata: this_pf.attributes.objdata},
                  }));
         });
     });
@@ -313,6 +315,90 @@
         {code: fcall}, cell_finished);
 }
 
+function getPhasePlotHandler(node){
+function phasePlotHandler(item,pressed){
+    var win = new Ext.Window({
+        layout:'fit',
+        width:370,
+        height:220,
+        modal:true,
+        resizable:false,
+        draggable:false,
+        border:false,
+        title:'Phase Plot Details for ' + node,
+        items: [{
+            xtype: 'form', // FormPanel
+            labelWidth:80,
+            frame:true,
+            items: [ {
+                xtype:'combo',
+                fieldLabel: 'X Field',
+                id: 'x_field',
+                store:node.attributes.objdata.pfdata.field_list,
+                width: 230,
+                allowBlank:false,
+                triggerAction: 'all',
+                value: 'Density'
+            },{
+                xtype:'combo',
+                fieldLabel: 'Y Field',
+                id: 'y_field',
+                store:node.attributes.objdata.pfdata.field_list,
+                width: 230,
+                allowBlank:false,
+                triggerAction: 'all',
+                value: 'Temperature'
+            },{
+                xtype:'combo',
+                fieldLabel: 'Z Field',
+                id: 'z_field',
+                store:node.attributes.objdata.pfdata.field_list,
+                width: 230,
+                allowBlank:false,
+                triggerAction: 'all',
+                value: 'CellMassMsun'
+            },{
+                xtype:'combo',
+                fieldLabel: 'Weight Field',
+                id: 'weight',
+                store:['None'].concat(node.attributes.objdata.pfdata.field_list),
+                width: 230,
+                allowBlank:false,
+                triggerAction: 'all',
+                value: 'None'
+            }],
+            buttons: [
+                {
+                    text: 'Calculate',
+                    handler: function(b, e){
+                        var x_field = Ext.get("x_field").getValue();
+                        var y_field = Ext.get("y_field").getValue();
+                        var z_field = Ext.get("z_field").getValue();
+                        var weight = Ext.get("weight").getValue();
+                        yt_rpc.ExtDirectREPL.create_phase({
+                                objname: node.attributes.objdata.varname,
+                                /* Mirror image varnames ... */
+                                field_x: x_field,
+                                field_y: y_field,
+                                field_z: z_field,
+                                weight: weight,
+                                },
+                              handle_result);
+                        disable_input();
+                        win.close();
+                    }
+                },{
+                    text: 'Cancel',
+                    handler: function(b, e){win.close()}
+                }
+            ]
+        }]
+    });
+    win.show(this);
+}
+return phasePlotHandler;
+}
+
 function getProjectionHandler(node){
 function projectionHandler(item,pressed){
     var win = new Ext.Window({


--- a/yt/gui/reason/html/js/reason.js	Tue Apr 26 14:18:36 2011 -0400
+++ b/yt/gui/reason/html/js/reason.js	Tue Apr 26 15:55:45 2011 -0400
@@ -143,27 +143,38 @@
         },
         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: 'View Grid Data',
-                            handler: getGridDataViewerHandler(node),
-                        }, {
-                            text: 'Open slice',
-                            handler: getSliceHandler(node),
-                        }, {
-                            text: 'Open projection',
-                            handler: getProjectionHandler(node),
-                        }, {
-                            text: 'View Streamlines',
-                            handler: getStreamlineViewerHandler(node),
-                        }
-                    ]
-                });
+                var rightclickMenu;
+                if (node.attributes.objdata.type == 'obj') {
+                  rightClickMenu = new Ext.menu.Menu({
+                      items: [
+                          {
+                              text: 'Phase Plot',
+                              handler: getPhasePlotHandler(node),
+                          }, 
+                      ]
+                  });
+                } else if (node.attributes.objdata.type == 'pf') {
+                  rightClickMenu = new Ext.menu.Menu({
+                      items: [
+                          {
+                              text: 'View Grids',
+                              handler: getGridViewerHandler(node),
+                          }, {
+                              text: 'View Grid Data',
+                              handler: getGridDataViewerHandler(node),
+                          }, {
+                              text: 'Open slice',
+                              handler: getSliceHandler(node),
+                          }, {
+                              text: 'Open projection',
+                              handler: getProjectionHandler(node),
+                          }, {
+                              text: 'View Streamlines',
+                              handler: getStreamlineViewerHandler(node),
+                          }
+                      ]
+                  });
+                }
                 rightClickMenu.showAt(event.xy);
             }
         }


--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/yt/gui/reason/html/js/widget_phaseplot.js	Tue Apr 26 15:55:45 2011 -0400
@@ -0,0 +1,239 @@
+/**********************************************************************
+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 WidgetPhasePlot = function(python_varname, widget_data) {
+    this.id = python_varname;
+    this.widget_data = widget_data;
+
+    viewport.get("center-panel").add(
+        {
+            xtype: 'panel',
+            id: "pp_" + this.id,
+            title: widget_data['title'],
+            iconCls: 'graph',
+            autoScroll: true,
+            layout:'absolute',
+            closable: true,
+            items: [ 
+                {
+                    xtype: 'panel',
+                    id: 'y_ticks_' + python_varname,
+                    layout: 'absolute',
+                    y: 10,
+                    x: 100,
+                    width: 40,
+                    height: 400,
+                    items : [],
+                    border: false,
+                }, {
+                    xtype: 'panel',
+                    id: 'x_ticks_' + python_varname,
+                    layout: 'absolute',
+                    y: 410,
+                    x: 140,
+                    width: 400,
+                    height: 40,
+                    items : [],
+                    border: false,
+                }, {
+                    xtype:'panel',
+                    id: 'image_panel_' + this.id,
+                    autoEl: {
+                        tag: 'img',
+                        id: "img_" + this.id,
+                        width: 400,
+                        height: 400,
+                        style: 'border: 1px solid #000000',
+                    },
+                    x: 138,
+                    y: 8,
+                    width: 400,
+                    height: 400,
+                }, {
+                    xtype:'panel',
+                    id: 'colorbar_' + python_varname,
+                    autoEl: {
+                        tag: 'img',
+                        id: "cb_" + python_varname,
+                        src: "data:image/png;base64," +
+                             widget_data['colorbar'],
+                        width: 28,
+                        height: 398,
+                        style: 'border: 1px solid #000000;',
+                    },
+                    x: 560,
+                    y: 10,
+                    width: 30,
+                    height: 400,
+                }, {
+                    xtype: 'panel',
+                    id: 'ticks_' + python_varname,
+                    layout: 'absolute',
+                    y: 10,
+                    x: 590,
+                    width: 40,
+                    height: 400,
+                    items : [],
+                    border: false,
+                },{
+                    xtype: 'button',
+                    text: 'Upload Image',
+                    x: 10,
+                    y: 285,
+                    width: 80,
+                    tooltip: "Upload the current image to " +
+                             "<a href='http://imgur.com'>imgur.com</a>",
+                    handler: function(b,e) {
+                        img_data = image_dom.src;
+                        yt_rpc.ExtDirectREPL.upload_image(
+                            {image_data:img_data,
+                             caption:metadata_string},
+                        function(rv) {
+                            var alert_text;
+                            if(rv['uploaded'] == false) {
+                                alert_text = "Failure uploading image!";
+                            } else {
+                                alert_text = "Uploaded to " +
+                                        rv['upload']['links']['imgur_page'];
+                            }
+                            Ext.Msg.alert('imgur.com', alert_text);
+                            var record = new logging_store.recordType(
+                                {record: alert_text });
+                            logging_store.add(record, number_log_records++);
+                        }); 
+                    }
+                },{
+                    xtype: 'panel',
+                    layout: 'vbox',
+                    id: 'rhs_panel_' + python_varname,
+                    width: 300,
+                    height: 460,
+                    x: 640, y: 10,
+                    layoutConfig: {
+                        align: 'stretch',
+                        pack: 'start',
+                    },
+                    items: [
+                        {
+                          xtype: 'panel',
+                          title: 'Plot MetaData',
+                          id: 'metadata_' + python_varname,
+                          style: {fontFamily: '"Inconsolata", monospace'},
+                          html: 'Welcome to the Plot Window.',
+                          height: 200,
+                        }, {
+                          xtype: 'panel',
+                          title: 'Plot Editor',
+                          id: 'plot_edit',
+                          flex: 1,
+                        }]
+                }
+            ]
+        }
+    );
+
+    viewport.get("center-panel").activate("pp_" + this.id);
+    viewport.get("center-panel").doLayout();
+    viewport.doLayout();
+    this.panel = viewport.get("center-panel").get("pp_" + python_varname);
+    this.panel.doLayout();
+    this.panel.show();
+    this.image_panel = this.panel.get("image_panel_"+python_varname);
+    this.ticks = this.panel.get("ticks_"+python_varname);
+    var x_ticks = this.panel.get("x_ticks_"+python_varname);
+    var y_ticks = this.panel.get("y_ticks_"+python_varname);
+    var ticks = this.ticks;
+    this.metadata_panel = this.panel.get("rhs_panel_" + python_varname).get("metadata_" + python_varname);
+    var image_dom = this.image_panel.el.dom;
+    var control_panel = this.panel;
+    var metadata_string;
+    var colorbar = this.panel.get("colorbar_"+python_varname);
+
+    this.accept_results = function(payload) {
+        this.image_panel.el.dom.src = "data:image/png;base64," + payload['image_data'];
+        examine = this.metadata_panel;
+        this.metadata_panel.update(payload['metadata_string']);
+        metadata_string = payload['metadata_string'];
+        ticks.removeAll();
+        colorbar.el.dom.src = "data:image/png;base64," +
+                              payload['cbar']['cmap_image'];
+        Ext.each(payload['yax']['ticks'], function(tick, index) {
+            examine = tick;
+            y_ticks.add({xtype:'panel',
+                       width: 20, height:15,
+                       border: false,
+                       style: 'font-family: "Inconsolata", monospace;' +
+                              'font-size: 12px; text-align: right;' +
+                              'padding-right: 5px;',
+                       html: ' ' + tick[2] + ' ',
+                       x:0, y: tick[0]-6});
+            y_ticks.add({xtype:'panel',
+                       width: 20, height:1,
+                       style: 'background-color: #000000;',
+                       html:' ',
+                       x:20, y: tick[0]});
+        });
+        y_ticks.doLayout();
+        Ext.each(payload['xax']['ticks'], function(tick, index) {
+            examine = tick;
+            x_ticks.add({xtype:'panel',
+                       width: 1, height:20,
+                       style: 'background-color: #000000;',
+                       html:' ',
+                       x:(400 - tick[0]) + 10, y: 0});
+            x_ticks.add({xtype:'panel',
+                       width: 20, height:20,
+                       border: false,
+                       style: 'font-family: "Inconsolata", monospace;' +
+                              'font-size: 12px; text-align: center;',
+                       html: ' ' + tick[2] + ' ',
+                       x: (400 - tick[0]), y: 20});
+        });
+        x_ticks.doLayout();
+        Ext.each(payload['cbar']['ticks'], function(tick, index) {
+            ticks.add({xtype:'panel',
+                       width: 10, height:1,
+                       style: 'background-color: #000000;',
+                       html:' ',
+                       x:0, y: tick[0]});
+            ticks.add({xtype:'panel',
+                       width: 30, height:15,
+                       border: false,
+                       style: 'font-family: "Inconsolata", monospace;' +
+                              'font-size: 12px;',
+                       html: ' ' + tick[2] + ' ',
+                       x:18, y: tick[0]-6});
+        });
+        ticks.doLayout();
+        x_ticks.doLayout();
+    }
+    yt_rpc.ExtDirectREPL.execute(
+        {code:python_varname + '._setup_plot()', hide:true},
+        cell_finished);
+}
+
+widget_types['phase_plot'] = WidgetPhasePlot;


--- a/yt/visualization/profile_plotter.py	Tue Apr 26 14:18:36 2011 -0400
+++ b/yt/visualization/profile_plotter.py	Tue Apr 26 15:55:45 2011 -0400
@@ -77,9 +77,7 @@
                  weight="CellMassMsun", accumulation=False,
                  x_bins=128, x_log=True, x_bounds=None,
                  y_bins=128, y_log=True, y_bounds=None,
-                 lazy_reader=True, id=None,
-                 axes = None, figure = None,
-                 fractional=False):
+                 lazy_reader=True, fractional=False):
         r"""From an existing object, create a 2D, binned profile.
 
         This function will accept an existing `AMRData` source and from that,
@@ -135,15 +133,6 @@
             any processing occurs.  It defaults to true, and grids are binned
             on a one-by-one basis.  Note that parallel computation requires
             this to be true.
-        id : int, optional
-            If specified, this will be the "semi-unique id" of the resultant
-            plot.  This should not be set.
-        figure : `matplotlib.figure.Figure`, optional
-            The figure onto which the axes will be placed.  Typically not used
-            unless *axes* is also specified.
-        axes : `matplotlib.axes.Axes`, optional
-            The axes object which will be used to create the image plot.
-            Typically used for things like multiplots and the like.
         fractional : boolean
             If true, the plot will be normalized to the sum of all the binned
             values.
@@ -230,12 +219,14 @@
 
 class PhasePlotterExtWidget(PhasePlotter):
     _ext_widget_id = None
+    _widget_name = "phase_plot"
 
     def _setup_plot(self):
+        if self._ext_widget_id is None: return
         PhasePlotter._setup_plot(self)
         # Now self.plot exists
-        #from yt.gui.reason.bottle_mods import PayloadHandler
-        #ph = PayloadHandler()
+        from yt.gui.reason.bottle_mods import PayloadHandler
+        ph = PayloadHandler()
         # We set up an x axis, y axis, colorbar, and image
         xax = self._convert_axis(self.plot.x_spec)
         yax = self._convert_axis(self.plot.y_spec)
@@ -262,7 +253,7 @@
         payload = {'xax':xax, 'yax':yax, 'cbar':cbar,
                    'type': 'widget_payload', 'widget_id': self._ext_widget_id,
                    'image_data': img_data}
-        return payload
+        ph.add_payload(payload)
 
     def _convert_ticks(self, tick_locs, bounds, func, height = 400):
         # height can be a length too; doesn't quite matter.

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