[Yt-svn] commit/yt: MatthewTurk: Adding the colorbar. Right now it doesn't change, or have any text, it just
Bitbucket
commits-noreply at bitbucket.org
Fri Apr 22 16:34:57 PDT 2011
1 new changeset in yt:
http://bitbucket.org/yt_analysis/yt/changeset/3c166563d179/
changeset: r4191:3c166563d179
branch: yt
user: MatthewTurk
date: 2011-04-23 01:34:15
summary: Adding the colorbar. Right now it doesn't change, or have any text, it just
shows the colormap.
affected #: 3 files (1.2 KB)
--- a/yt/gui/reason/extdirect_repl.py Fri Apr 22 19:04:31 2011 -0400
+++ b/yt/gui/reason/extdirect_repl.py Fri Apr 22 19:34:15 2011 -0400
@@ -355,9 +355,11 @@
_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)
_twidget_data = {'fields': _tfield_list,
'initial_field': _tfield,
- 'title': "%%s Projection" %% (_tpf)}
+ 'title': "%%s Projection" %% (_tpf),
+ 'colorbar': _tcb}
""" % dict(pfname = pfname,
axis = inv_axis_names[axis],
weight = weight,
@@ -393,9 +395,11 @@
_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)
_twidget_data = {'fields': _tfield_list,
'initial_field': _tfield,
- 'title': "%%s Slice" %% (_tpf)}
+ 'title': "%%s Slice" %% (_tpf),
+ 'colorbar': _tcb}
""" % dict(pfname = pfname,
center_string = center_string,
axis = inv_axis_names[axis],
--- a/yt/gui/reason/html/js/widget_plotwindow.js Fri Apr 22 19:04:31 2011 -0400
+++ b/yt/gui/reason/html/js/widget_plotwindow.js Fri Apr 22 19:34:15 2011 -0400
@@ -94,6 +94,22 @@
});
}
}
+ }, {
+ 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: 510,
+ y: 10,
+ width: 30,
+ height: 400,
}, { xtype: 'multislider',
id: 'slider_' + python_varname,
minValue: 0,
@@ -310,7 +326,7 @@
id: 'rhs_panel_' + python_varname,
width: 300,
height: 460,
- x: 510, y: 10,
+ x: 590, y: 10,
layoutConfig: {
align: 'stretch',
pack: 'start',
--- a/yt/visualization/plot_window.py Fri Apr 22 19:04:31 2011 -0400
+++ b/yt/visualization/plot_window.py Fri Apr 22 19:34:15 2011 -0400
@@ -22,18 +22,19 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
+import base64
+import tempfile
+import matplotlib.pyplot
-import tempfile
import numpy as na
-import color_maps
-from image_writer import \
+from .image_writer import \
write_image, apply_colormap
+from .fixed_resolution import \
+ FixedResolutionBuffer
+from .plot_modifications import get_smallest_appropriate_unit
+
from yt.funcs import *
from yt.utilities.amr_utils import write_png_to_file
-from fixed_resolution import \
- FixedResolutionBuffer
-import matplotlib.pyplot
-from .plot_modifications import get_smallest_appropriate_unit
def invalidate_data(f):
def newfunc(*args, **kwargs):
@@ -316,9 +317,10 @@
_ext_widget_id = None
_current_field = None
_widget_name = "plot_window"
+ cmap = 'algae'
+
def _setup_plots(self):
from yt.gui.reason.bottle_mods import PayloadHandler
- import base64
ph = PayloadHandler()
if self._current_field is not None \
and self._ext_widget_id is not None:
@@ -347,6 +349,19 @@
payload.update(addl_keys)
ph.add_payload(payload)
+ def get_colorbar(self, field, height = 400, width = 40):
+ # Right now there's just the single 'cmap', but that will eventually
+ # change. I think?
+ vals = na.mgrid[0:1: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
+
# 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
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