[yt-svn] commit/yt: MatthewTurk: Contours are working for me now with Reason.

Bitbucket commits-noreply at bitbucket.org
Sun Feb 19 18:35:03 PST 2012


1 new commit in yt:


https://bitbucket.org/yt_analysis/yt/changeset/d3ce12ae7a52/
changeset:   d3ce12ae7a52
branch:      yt
user:        MatthewTurk
date:        2012-02-17 23:34:02
summary:     Contours are working for me now with Reason.
affected #:  3 files

diff -r 3d61c62199f55f7b7c0d6202b434fcd5a787ca55 -r d3ce12ae7a52a0cdb7766155a46473e797236b3d yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -3613,6 +3613,7 @@
         input_right = (self._old_global_endindex - 0.5) * rf
         output_left = self.global_startindex + 0.5
         output_right = self.global_endindex - 0.5
+        print input_left, input_right, output_left, output_right
         output_dims = (output_right - output_left + 1).astype('int32')
 
         self._cur_dims = output_dims


diff -r 3d61c62199f55f7b7c0d6202b434fcd5a787ca55 -r d3ce12ae7a52a0cdb7766155a46473e797236b3d yt/gui/reason/html/js/widget_plotwindow.js
--- a/yt/gui/reason/html/js/widget_plotwindow.js
+++ b/yt/gui/reason/html/js/widget_plotwindow.js
@@ -448,6 +448,7 @@
                           height: 200,
                         }, {
                           xtype: 'tabpanel',
+                          id: 'editor_panel',
                           flex: 1,
                           activeTab: 0,
                           items: [
@@ -549,31 +550,60 @@
                                width : 160,
                                xtype: 'combo',
                                editable: false,
+                               id: 'field',
                                triggerAction: 'all',
                                validateOnBlur: false,
+                               value:widget_data['initial_field'],
                                store: widget_data['fields'],
-                               listeners: {select: function(combo, record, index){ 
-                               }}
-                             },
-                             {
+                             }, {
                                x: 10,
                                y: 60,
                                width: 70,
                                xtype: 'label',
                                text: 'Levels',
-                             },
-                             {
+                             }, {
                                x: 80,
                                y: 60,
                                width : 160,
                                xtype: 'slider',
+                               id: 'ncont',
                                minValue: 0,
                                maxValue: 10,
-                               value: 0,
+                               value: 5,
                                increment: 1,
                                plugins: new Ext.slider.Tip(),
-                               listeners: {select: function(combo, record, index){ 
-                               }}
+                             }, {
+                               x: 10,
+                               y: 100,
+                               width: 70,
+                               xtype: 'label',
+                               text: 'Logspaced',
+                             }, {
+                               x: 80,
+                               y: 100,
+                               width : 160,
+                               xtype: 'checkbox',
+                               id: 'logit',
+                               checked: true,
+                             }, {
+                               x: 10,
+                               y: 180,
+                               width: 80,
+                               xtype: 'button',
+                               text: 'Apply',
+                               handler: function(b, e) {
+                                  field = contour_window.get('field').getValue();
+                                  ncont = contour_window.get('ncont').getValue();
+                                  logit = contour_window.get('logit').getValue();
+                                  if (logit == false) logit = 'False';
+                                  else if (logit == true) logit = 'True';
+                                  yt_rpc.ExtDirectREPL.execute(
+                                      {code:python_varname
+                                       + '.set_contour_info("' + field + '", '
+                                       + ncont + ', ' + logit + ')',
+                                        hide:false},
+                                      cell_finished);
+                               }
                              }
                           ]
                         }
@@ -596,6 +626,9 @@
     var colorbar = this.panel.get("colorbar_"+python_varname);
     this.metadata_panel = this.panel.get("rhs_panel_" + python_varname).get("metadata_" + python_varname);
     this.zoom_scroll = this.panel.get("slider_" + python_varname);
+    var contour_window = this.panel.get("rhs_panel_" + python_varname);
+    contour_window = contour_window.get("editor_panel");
+    contour_window = contour_window.get("contour_edit");
     var image_dom = this.image_panel.el.dom;
     var control_panel = this.panel;
     var metadata_string;
@@ -603,7 +636,6 @@
     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);
-        examine = this.metadata_panel;
         this.metadata_panel.update(payload['metadata_string']);
         metadata_string = payload['metadata_string'];
         ticks.removeAll();


diff -r 3d61c62199f55f7b7c0d6202b434fcd5a787ca55 -r d3ce12ae7a52a0cdb7766155a46473e797236b3d yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -268,7 +268,7 @@
     @invalidate_plot
     def set_contour_info(self, field_name, n_cont = 8, colors = None,
                          logit = True):
-        if field_name == "None":
+        if field_name == "None" or n_cont == 0:
             self._contour_info = None
             return
         self._contour_info = (field_name, n_cont, colors, logit)
@@ -389,8 +389,7 @@
             to_plot = apply_colormap(self._frb[field],
                 func = self._field_transform[field],
                 cmap_name = self._colormaps[field])
-            self._apply_modifications(to_plot)
-            pngs = write_png_to_string(to_plot)
+            pngs = self._apply_modifications(to_plot)
             img_data = base64.b64encode(pngs)
             # We scale the width between 200*min_dx and 1.0
             x_width = self.xlim[1] - self.xlim[0]
@@ -406,12 +405,12 @@
             ph.add_payload(payload)
 
     def _apply_modifications(self, img):
+        if self._contour_info is None:
+            return write_png_to_string(img)
         from matplotlib.figure import Figure
         from yt.visualization._mpl_imports import \
             FigureCanvasAgg, FigureCanvasPdf, FigureCanvasPS
         from yt.utilities.delaunay.triangulate import Triangulation as triang
-
-        if self._contour_info is None: return img
         plot_args = {}
         field, number, colors, logit = self._contour_info
         if colors is not None: plot_args['colors'] = colors
@@ -421,13 +420,13 @@
         # Now we need to get our field values
         raw_data = self._frb.data_source
         b = self._frb.bounds
-        xi = na.mgrid[b[0]:b[1]:(vi / 8) * 1j]
-        yi = na.mgrid[b[2]:b[3]:(vj / 8) * 1j]
+        xi, yi = na.mgrid[b[0]:b[1]:(vi / 8) * 1j,
+                          b[2]:b[3]:(vj / 8) * 1j]
         x = raw_data['px']
         y = raw_data['py']
         z = raw_data[field]
         if logit: z = na.log10(z)
-        fvals = triang(x,y).nn_interpolator(z)(xi,yi)
+        fvals = triang(x,y).nn_interpolator(z)(xi,yi).transpose()
 
         fig = Figure((vi/100.0, vj/100.0), dpi = 100)
         fig.figimage(img)
@@ -436,7 +435,7 @@
         ax.patch.set_alpha(0.0)
 
         # Now contour it
-        ax.contour(fvals, colors='w')
+        ax.contour(fvals, number, colors='w')
         canvas = FigureCanvasAgg(fig)
         f = cStringIO.StringIO()
         canvas.print_figure(f)

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