本文整理汇总了Python中chaco.api.HPlotContainer.request_redraw方法的典型用法代码示例。如果您正苦于以下问题:Python HPlotContainer.request_redraw方法的具体用法?Python HPlotContainer.request_redraw怎么用?Python HPlotContainer.request_redraw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chaco.api.HPlotContainer
的用法示例。
在下文中一共展示了HPlotContainer.request_redraw方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _load_image_data
# 需要导入模块: from chaco.api import HPlotContainer [as 别名]
# 或者: from chaco.api.HPlotContainer import request_redraw [as 别名]
def _load_image_data(self, data):
cont = HPlotContainer()
pd = ArrayPlotData()
plot = Plot(data=pd, padding=[30, 5, 5, 30], default_origin="top left")
pd.set_data("img", data)
img_plot = plot.img_plot("img")[0]
self._add_inspector(img_plot)
self._add_tools(img_plot)
cont.add(plot)
cont.request_redraw()
self.image_container.container = cont
示例2: ImageViewer
# 需要导入模块: from chaco.api import HPlotContainer [as 别名]
# 或者: from chaco.api.HPlotContainer import request_redraw [as 别名]
class ImageViewer(HasTraits):
container = Instance(HPlotContainer, ())
plot = Any
def load_image(self, path):
if os.path.isfile(path):
with open(path, 'r') as fp:
self.set_image(fp)
def set_image(self, buf):
'''
buf is a file-like object
'''
self.container = HPlotContainer()
pd = ArrayPlotData(x=[0, 640],
y=[0, 480])
padding = [30, 5, 5, 30]
plot = Plot(data=pd, padding=padding,
# default_origin=''
)
self.plot = plot.plot(('x', 'y'),)[0]
self.plot.index.sort_order = 'ascending'
imo = ImageUnderlay(self.plot,
padding=padding,
path=buf)
self.plot.overlays.append(imo)
self._add_tools(self.plot)
self.container.add(plot)
self.container.request_redraw()
def _add_tools(self, plot):
inspector = XYInspector(plot)
plot.tools.append(inspector)
plot.overlays.append(XYInspectorOverlay(inspector=inspector,
component=plot,
align='ul',
bgcolor=0xFFFFD2
))
示例3: ImageGUI
# 需要导入模块: from chaco.api import HPlotContainer [as 别名]
# 或者: from chaco.api.HPlotContainer import request_redraw [as 别名]
#.........这里部分代码省略.........
# Create a container and add sub-containers and components
self.column_density = HPlotContainer(padding=40, fill_padding=True,
bgcolor = "white", use_backbuffer=False)
inner_cont = VPlotContainer(padding=0, use_backbuffer=True)
inner_cont.add(self.cross_plot)
self.imgplot.padding =20
inner_cont.add(self.imgplot)
self.column_density.add(self.colorbar)
self.column_density.add(inner_cont)
self.column_density.add(self.cross_plot2)
def update(self):
#print self.cursor.current_index
#self.cursor.current_position = 100.,100.
self.shots = self.populate_shot_list()
print self.selectedshot
imgdata, self.report = self.load_imagedata()
if imgdata is not None:
self.minz = imgdata.min()
self.maxz = imgdata.max()
self.colorbar.index_mapper.range.low = self.minz
self.colorbar.index_mapper.range.high = self.maxz
xs=numpy.linspace(0,imgdata.shape[0],imgdata.shape[0]+1)
ys=numpy.linspace(0,imgdata.shape[1],imgdata.shape[1]+1)
#print xs
#print ys
self._image_index.set_data(xs,ys)
self._image_value.data = imgdata
self.pd.set_data("line_index", xs)
self.pd.set_data("line_index2",ys)
self.column_density.invalidate_draw()
self.column_density.request_redraw()
def populate_shot_list(self):
try:
shot_list = os.listdir(self.shotdir)
fun = lambda x: iscol(x,self.namefilter)
shot_list = filter( fun, shot_list)
shot_list = sorted(shot_list)
except ValueError:
print " *** Not a valid directory path ***"
return shot_list
def load_imagedata(self):
try:
directory = self.shotdir
if self.selectedshot == []:
filename = self.shots[0]
else:
filename = self.selectedshot[0]
#shotnum = filename[filename.rindex('_')+1:filename.rindex('.ascii')]
shotnum = filename[:filename.index('_')]
except ValueError:
print " *** Not a valid path *** "
return None
# Set data path
# Prepare PlotData object
print "Loading file #%s from %s" % (filename,directory)
return import_data.load(directory,filename), import_data.load_report(directory,shotnum)
#---------------------------------------------------------------------------
# Event handlers
#---------------------------------------------------------------------------
示例4: PlotUI
# 需要导入模块: from chaco.api import HPlotContainer [as 别名]
# 或者: from chaco.api.HPlotContainer import request_redraw [as 别名]
#.........这里部分代码省略.........
self.cross_plot.index_range = self.polyplot.index_range.x_range
self.pd.set_data("line_index2", array([]))
self.pd.set_data("line_value2", array([]))
self.pd.set_data("scatter_index2", array([]))
self.pd.set_data("scatter_value2", array([]))
self.pd.set_data("scatter_color2", array([]))
self.cross_plot2 = Plot(self.pd, width = 140, orientation="v",
resizable="v", padding=20, padding_bottom=160)
self.cross_plot2.plot(("line_index2", "line_value2"),
line_style="dot")
self.cross_plot2.plot(("scatter_index2",
"scatter_value2",
"scatter_color2"),
type="cmap_scatter",
name="dot",
color_mapper=self._cmap(image_value_range),
marker="circle",
marker_size=8)
self.cross_plot2.index_range = self.polyplot.index_range.y_range
# Create a container and add components
self.container = HPlotContainer(padding=40, fill_padding=True,
bgcolor = "white", use_backbuffer=False)
inner_cont = VPlotContainer(padding=0, use_backbuffer=True)
inner_cont.add(self.cross_plot)
inner_cont.add(contour_container)
self.container.add(self.colorbar)
self.container.add(inner_cont)
self.container.add(self.cross_plot2)
def update(self, model):
self.minz = model.minz
self.maxz = model.maxz
self.colorbar.index_mapper.range.low = self.minz
self.colorbar.index_mapper.range.high = self.maxz
self._image_index.set_data(model.xs, model.ys)
self._image_value.data = model.zs
self.pd.update_data(line_index=model.xs, line_index2=model.ys)
self.container.invalidate_draw()
self.container.request_redraw()
#---------------------------------------------------------------------------
# Event handlers
#---------------------------------------------------------------------------
def _metadata_changed(self, old, new):
""" This function takes out a cross section from the image data, based
on the line inspector selections, and updates the line and scatter
plots."""
self.cross_plot.value_range.low = self.minz
self.cross_plot.value_range.high = self.maxz
self.cross_plot2.value_range.low = self.minz
self.cross_plot2.value_range.high = self.maxz
if self._image_index.metadata.has_key("selections"):
x_ndx, y_ndx = self._image_index.metadata["selections"]
if y_ndx and x_ndx:
xdata, ydata = self._image_index.get_data()
xdata, ydata = xdata.get_data(), ydata.get_data()
self.pd.update_data(
line_value=self._image_value.data[y_ndx,:],
line_value2=self._image_value.data[:,x_ndx],
scatter_index=array([xdata[x_ndx]]),
scatter_index2=array([ydata[y_ndx]]),
scatter_value=array([self._image_value.data[y_ndx, x_ndx]]),
scatter_value2=array([self._image_value.data[y_ndx, x_ndx]]),
scatter_color=array([self._image_value.data[y_ndx, x_ndx]]),
scatter_color2=array([self._image_value.data[y_ndx, x_ndx]])
)
else:
self.pd.update_data({"scatter_value": array([]),
"scatter_value2": array([]), "line_value": array([]),
"line_value2": array([])})
def _colormap_changed(self):
self._cmap = default_colormaps.color_map_name_dict[self.colormap]
if self.polyplot is not None:
value_range = self.polyplot.color_mapper.range
self.polyplot.color_mapper = self._cmap(value_range)
value_range = self.cross_plot.color_mapper.range
self.cross_plot.color_mapper = self._cmap(value_range)
# FIXME: change when we decide how best to update plots using
# the shared colormap in plot object
self.cross_plot.plots["dot"
][0].color_mapper = self._cmap(value_range)
self.cross_plot2.plots["dot"
][0].color_mapper = self._cmap(value_range)
self.container.request_redraw()
def _num_levels_changed(self):
if self.num_levels > 3:
self.polyplot.levels = self.num_levels
self.lineplot.levels = self.num_levels
示例5: CellCropper
# 需要导入模块: from chaco.api import HPlotContainer [as 别名]
# 或者: from chaco.api.HPlotContainer import request_redraw [as 别名]
#.........这里部分代码省略.........
elif self.csr.current_position[1]>self.max_pos_y:
self.left,self.top=self.csr.current_position[0],self.max_pos_y
else:
self.left,self.top=self.csr.current_position
@on_trait_change('left, top, tmp_size')
def update_tmp_plot(self):
self.template = self.data[self.top:self.top+self.tmp_size,self.left:self.left+self.tmp_size]
self.tmp_plotdata.set_data("imagedata", self.template)
grid_data_source = self.tmp_plot.range2d.sources[0]
grid_data_source.set_data(np.arange(self.tmp_size), np.arange(self.tmp_size))
self.tmp_img_idx=self.img_idx
if self.numpeaks_total>0:
print "clearing peaks"
self.peaks=[np.array([[0,0,-1]])]
self.update_CC()
return
def update_CC(self):
if self.ShowCC:
self.CC = cv_funcs.xcorr(self.template, self.data)
self.img_plotdata.set_data("imagedata",self.CC)
@on_trait_change('cbar_selection:selection')
def update_thresh(self):
try:
thresh=self.cbar_selection.selection
self.thresh=thresh
self.cmap_renderer.color_data.metadata['selections']=thresh
self.thresh_lower=thresh[0]
self.thresh_upper=thresh[1]
#cmap_renderer.color_data.metadata['selection_masks']=self.thresh
self.cmap_renderer.color_data.metadata_changed={'selections':thresh}
self.container.request_redraw()
self.img_container.request_redraw()
except:
pass
@on_trait_change('thresh_upper,thresh_lower')
def manual_thresh_update(self):
self.thresh=[self.thresh_lower,self.thresh_upper]
self.cmap_renderer.color_data.metadata['selections']=self.thresh
self.cmap_renderer.color_data.metadata_changed={'selections':self.thresh}
self.container.request_redraw()
self.img_container.request_redraw()
@on_trait_change('peaks,cbar_selection:selection,img_idx')
def calc_numpeaks(self):
try:
thresh=self.cbar_selection.selection
self.thresh=thresh
except:
thresh=[]
if thresh==[] or thresh==() or thresh==None:
thresh=(-1,1)
self.numpeaks_total=int(np.sum([np.sum(np.ma.masked_inside(self.peaks[i][:,2],thresh[0],thresh[1]).mask) for i in xrange(len(self.peaks))]))
try:
self.numpeaks_img=int(np.sum(np.ma.masked_inside(self.peaks[self.img_idx][:,2],thresh[0],thresh[1]).mask))
except:
self.numpeaks_img=0
@on_trait_change('findpeaks')
def locate_peaks(self):
peaks=[]
progress = ProgressDialog(title="Peak finder progress", message="Finding peaks on %s images"%self.numfiles, max=self.numfiles, show_time=True, can_cancel=False)
progress.open()
示例6: TemplatePicker
# 需要导入模块: from chaco.api import HPlotContainer [as 别名]
# 或者: from chaco.api.HPlotContainer import request_redraw [as 别名]
#.........这里部分代码省略.........
else:
self.left,self.top=self.csr.current_position
@on_trait_change('left, top, tmp_size')
def update_tmp_plot(self):
self.tmp_plotdata.set_data("imagedata",
self.sig.data[self.img_idx,self.top:self.top+self.tmp_size,self.left:self.left+self.tmp_size])
grid_data_source = self.tmp_plot.range2d.sources[0]
grid_data_source.set_data(np.arange(self.tmp_size), np.arange(self.tmp_size))
self.tmp_img_idx=self.img_idx
if self.numpeaks_total>0:
print "clearing peaks"
self.peaks=[np.array([[0,0,-1]])]
return
@on_trait_change('left, top, tmp_size')
def update_CC(self):
if self.ShowCC:
self.CC = cv_funcs.xcorr(self.sig.data[self.tmp_img_idx,self.top:self.top+self.tmp_size,
self.left:self.left+self.tmp_size],
self.sig.data[self.img_idx,:,:])
self.img_plotdata.set_data("imagedata",self.CC)
@on_trait_change('cbar_selection:selection')
def update_thresh(self):
try:
thresh=self.cbar_selection.selection
self.thresh=thresh
self.cmap_renderer.color_data.metadata['selections']=thresh
self.thresh_lower=thresh[0]
self.thresh_upper=thresh[1]
#cmap_renderer.color_data.metadata['selection_masks']=self.thresh
self.cmap_renderer.color_data.metadata_changed={'selections':thresh}
self.container.request_redraw()
self.img_container.request_redraw()
except:
pass
@on_trait_change('thresh_upper,thresh_lower')
def manual_thresh_update(self):
self.thresh=[self.thresh_lower,self.thresh_upper]
self.cmap_renderer.color_data.metadata['selections']=self.thresh
self.cmap_renderer.color_data.metadata_changed={'selections':self.thresh}
self.container.request_redraw()
self.img_container.request_redraw()
@on_trait_change('peaks,cbar_selection:selection,img_idx')
def calc_numpeaks(self):
try:
thresh=self.cbar_selection.selection
self.thresh=thresh
except:
thresh=[]
if thresh==[] or thresh==() or thresh==None:
thresh=(0,1)
self.numpeaks_total=int(np.sum([np.sum(np.ma.masked_inside(self.peaks[i][:,2],thresh[0],thresh[1]).mask) for i in xrange(len(self.peaks))]))
try:
self.numpeaks_img=int(np.sum(np.ma.masked_inside(self.peaks[self.img_idx][:,2],thresh[0],thresh[1]).mask))
except:
self.numpeaks_img=0
@on_trait_change('findpeaks')
def locate_peaks(self):
from hyperspy import peak_char as pc
peaks=[]
"""from hyperspy.misc.progressbar import ProgressBar, \
示例7: Plotter2D
# 需要导入模块: from chaco.api import HPlotContainer [as 别名]
# 或者: from chaco.api.HPlotContainer import request_redraw [as 别名]
#.........这里部分代码省略.........
# Add pan and zoom tools to the colorbar
self.colorbar.tools.append(PanTool(self.colorbar,\
constrain_direction="y",\
constrain=True)
)
self.zoom_bar_colorbar = zoom_bar(self.colorbar,
box = False,
reset=True,
orientation = 'vertical'
)
# Add the range bar now that we are sure that we have a color_mapper
self.range_bar = RangeBar(self.plot)
self.x_axis_label = 'X'
self.y_axis_label = 'Y'
self.c_axis_label = 'C'
self.sync_trait('x_axis_label',self.range_bar,alias = 'x_name')
self.sync_trait('y_axis_label',self.range_bar,alias = 'y_name')
self.sync_trait('c_axis_label',self.range_bar,alias = 'c_name')
#Dynamically bing the update methods for trait likely to be updated
#from other thread
self.on_trait_change(self.new_x_label, 'x_axis_label',
dispatch = 'ui')
self.on_trait_change(self.new_y_label, 'y_axis_label',
dispatch = 'ui')
self.on_trait_change(self.new_c_label, 'c_axis_label',
dispatch = 'ui')
self.on_trait_change(self.new_x_axis_format, 'x_axis_formatter.+',
dispatch = 'ui')
self.on_trait_change(self.new_y_axis_format, 'y_axis_formatter.+',
dispatch = 'ui')
self.on_trait_change(self.new_c_axis_format, 'c_axis_formatter.+',
dispatch = 'ui')
self.on_trait_change(self._update_plots_index, 'update_index',
dispatch = 'ui')
#set the default colormap in the editor
self.colormap = 'Blues'
self.preference_init()
#@on_trait_change('x_axis_label', dispatch = 'ui')
def new_x_label(self,new):
self.plot.x_axis.title = new
#@on_trait_change('y_axis_label', dispatch = 'ui')
def new_y_label(self,new):
self.plot.y_axis.title = new
#@on_trait_change('c_axis_label', dispatch = 'ui')
def new_c_label(self,new):
self.colorbar._axis.title = new
@on_trait_change('colormap')
def new_colormap(self, new):
self._cmap = color_map_name_dict[new]
for plots in self.plot.plots.itervalues():
for plot in plots:
if isinstance(plot,ImagePlot) or\
isinstance(plot,CMapImagePlot) or\
isinstance(plot,ContourPolyPlot):
value_range = plot.color_mapper.range
plot.color_mapper = self._cmap(value_range)
self.plot.color_mapper = self._cmap(value_range)
self.container.request_redraw()
#@on_trait_change('x_axis_formatter', dispatch = 'ui')
def new_x_axis_format(self):
self.plot.x_axis._invalidate()
self.plot.invalidate_and_redraw()
#@on_trait_change('y_axis_formatter', dispatch = 'ui')
def new_y_axis_format(self):
self.plot.y_axis._invalidate()
self.plot.invalidate_and_redraw()
#@on_trait_change('y_axis_formatter', dispatch = 'ui')
def new_c_axis_format(self):
self.colorbar._axis._invalidate()
self.plot.invalidate_and_redraw()
def request_update_plots_index(self):
self.update_index = True
#@on_trait_change('update_index', dispatch = 'ui')
def _update_plots_index(self):
if 'c' in self.data.list_data():
array = self.data.get_data('c')
xs = linspace(self.x_min, self.x_max, array.shape[1] + 1)
ys = linspace(self.y_min, self.y_max, array.shape[0] + 1)
self.plot.range2d.remove(self.plot.index)
self.plot.index = GridDataSource(xs, ys,
sort_order=('ascending', 'ascending'))
self.plot.range2d.add(self.plot.index)
for plots in self.plot.plots.itervalues():
for plot in plots:
plot.index = GridDataSource(xs, ys,
sort_order=('ascending', 'ascending'))
示例8: Demo
# 需要导入模块: from chaco.api import HPlotContainer [as 别名]
# 或者: from chaco.api.HPlotContainer import request_redraw [as 别名]
#.........这里部分代码省略.........
plc.title = titles[i]
i += 1
#plc.plot(("index", "y0"), name="j_0", color="red", render_style="hold")
#plc.padding = 50
#plc.padding_top = 75
plc.tools.append(PanTool(plc))
zoom = ZoomTool(component=plc, tool_mode="box", always_on=False)
plc.overlays.append(zoom)
# Tweak some of the plot properties
plc.padding = 50
#zoom = ZoomTool(component=plot1, tool_mode="box", always_on=False)
#plot1.overlays.append(zoom)
# Attach some tools to the plot
#attach_tools(plc)
plc.bg_color = None
plc.fill_padding = True
def default_traits_view(self):
traits_view = View(
Group(
Item('plot',
editor=ComponentEditor(size=size),
show_label=False),
orientation="vertical"),
menubar=MenuBar(
Menu(Action(name="Save Plot", action="save"),
Action(name="Load Plot", action="load"),
Separator(), CloseAction,
name="File")),
resizable=True,
title=title,
handler=ImageFileController)
return traits_view
'''
def _plot_default(self):
# Create some x-y data series to plot
x = linspace(-2.0, 10.0, 400)
self.pd = pd = ArrayPlotData(index=x, y0=jn(0,x), default_origin="top left")
# Create some line plots of some of the data
plot1 = Plot(self.pd,
title="render_style = hold",
padding=50, border_visible=True, overlay_border=True)
plot1.legend.visible = True
plot1.plot(("index", "y0"), name="j_0", color="red", render_style="hold")
plot1.padding = 50
plot1.padding_top = 75
plot1.tools.append(PanTool(plot1))
#zoom = ZoomTool(component=plot1, tool_mode="box", always_on=False)
#plot1.overlays.append(zoom)
# Attach some tools to the plot
attach_tools(plot1)
# Create a second scatter plot of one of the datasets, linking its
# range to the first plot
plot2 = Plot(self.pd, range2d=plot1.range2d,
title="render_style = connectedhold",
padding=50, border_visible=True, overlay_border=True)
plot2.plot(('index', 'y0'), color="blue", render_style="connectedhold")
plot2.padding = 50
plot2.padding_top = 75
plot2.tools.append(PanTool(plot2))
#zoom = ZoomTool(component=plot2, tool_mode="box", always_on=False)
#plot2.overlays.append(zoom)
attach_tools(plot2)
# Create a container and add our plots
container = HPlotContainer()
container.add(plot1)
container.add(plot2)
return container
'''
def _save(self):
win_size = self.plot.outer_bounds
plot_gc = PlotGraphicsContext(win_size)
plot_gc.render_component(self.plot)
plot_gc.save(self._save_file)
def _load(self):
try:
image = ImageData.fromfile(self._load_file)
self.pd.set_data('imagedata', image._data)
self.plot.title = "YO DOGG: %s" % os.path.basename(self._load_file)
self.plot.request_redraw()
except Exception, exc:
print "YO DOGG: %s" % exc
示例9: Plot2D
# 需要导入模块: from chaco.api import HPlotContainer [as 别名]
# 或者: from chaco.api.HPlotContainer import request_redraw [as 别名]
#.........这里部分代码省略.........
self.renderer.color_mapper.range.set_bounds('auto', 'auto')
# For the time being stage is unused (will try to refine stuff if it is
# needed)
def update_data(self, stage):
"""
"""
exp = self.experiment
if self.c_info:
data = self.c_info.gather_data(exp)
if len(data.shape) == 2:
self.data.set_data('c', data.T)
self.update_plots_index()
def update_plots_index(self):
if 'c' in self.data.list_data():
array = self.data.get_data('c')
xs = linspace(self.x_min, self.x_max, array.shape[1] + 1)
ys = linspace(self.y_min, self.y_max, array.shape[0] + 1)
self.renderer.range2d.remove(self.renderer.index)
self.renderer.index = GridDataSource(xs, ys,
sort_order=('ascending',
'ascending'))
self.renderer.range2d.add(self.renderer.index)
for plots in self.renderer.plots.itervalues():
for plot in plots:
plot.index = GridDataSource(xs, ys,
sort_order=('ascending',
'ascending'))
@classmethod
def build_view(cls, plot):
"""
"""
return Plot2DItem(plot=plot)
def preferences_from_members(self):
"""
"""
d = super(Plot2D, self).preferences_from_members()
d['c_info'] = self.c_info.preferences_from_members()
return d
def update_members_from_preferences(self, config):
"""
"""
super(Plot2D, self).update_members_from_preferences(config)
c_config = config['c_info']
info = [c for c in DATA_INFOS
if c.__name__ == c_config['info_class']][0]()
info.update_members_from_preferences(c_config)
self.c_info = info
self.update_data(None)
def _post_setattr_x_axis(self, old, new):
self.renderer.x_axis.title = new
self.container.request_redraw()
def _post_setattr_y_axis(self, old, new):
self.renderer.y_axis.title = new
self.container.request_redraw()
def _post_setattr_c_axis(self, old, new):
self.colorbar._axis.title = new
self.container.request_redraw()
def _post_setattr_colormap(self, old, new):
self._cmap = color_map_name_dict[new]
for plots in self.renderer.plots.itervalues():
for plot in plots:
if isinstance(plot, ImagePlot) or\
isinstance(plot, CMapImagePlot) or\
isinstance(plot, ContourPolyPlot):
value_range = plot.color_mapper.range
plot.color_mapper = self._cmap(value_range)
self.renderer.color_mapper = self._cmap(value_range)
self.container.request_redraw()
def _post_setattr_x_min(self, old, new):
"""
"""
self.update_plots_index()
def _post_setattr_x_max(self, old, new):
"""
"""
self.update_plots_index()
def _post_setattr_y_min(self, old, new):
"""
"""
self.update_plots_index()
def _post_setattr_y_max(self, old, new):
"""
"""
self.update_plots_index()
示例10: ImageGUI
# 需要导入模块: from chaco.api import HPlotContainer [as 别名]
# 或者: from chaco.api.HPlotContainer import request_redraw [as 别名]
#.........这里部分代码省略.........
name="dot",
color_mapper=self._cmap(image_value_range),
marker="circle",
marker_size=8,
)
self.cross_plot2.index_range = self.imgplot.index_range.y_range
# Create a container and add components
self.container = HPlotContainer(padding=40, fill_padding=True, bgcolor="white", use_backbuffer=False)
inner_cont = VPlotContainer(padding=0, use_backbuffer=True)
inner_cont.add(self.cross_plot)
inner_cont.add(contour_container)
self.container.add(self.colorbar)
self.container.add(inner_cont)
self.container.add(self.cross_plot2)
def update(self):
imgdata = self.load_imagedata()
if imgdata is not None:
self.minz = imgdata.min()
self.maxz = imgdata.max()
self.colorbar.index_mapper.range.low = self.minz
self.colorbar.index_mapper.range.high = self.maxz
xs = numpy.linspace(0, imgdata.shape[0], imgdata.shape[0] + 1)
ys = numpy.linspace(0, imgdata.shape[1], imgdata.shape[1] + 1)
print xs
print ys
self._image_index.set_data(xs, ys)
self._image_value.data = imgdata
self.pd.set_data("line_index", xs)
self.pd.set_data("line_index2", ys)
self.container.invalidate_draw()
self.container.request_redraw()
def load_imagedata(self):
try:
dir = self.shot[self.shot.index(":\\") + 2 : self.shot.rindex("\\") + 1]
shotnum = self.shot[self.shot.rindex("_") + 1 : self.shot.rindex(".ascii")]
except ValueError:
print " *** Not a valid column density path *** "
return None
# Set data path
# Prepare PlotData object
print dir
print shotnum
return load(dir, shotnum)
# ---------------------------------------------------------------------------
# Event handlers
# ---------------------------------------------------------------------------
def _shot_changed(self):
self.update()
def _metadata_changed(self, old, new):
""" This function takes out a cross section from the image data, based
on the line inspector selections, and updates the line and scatter
plots."""
self.cross_plot.value_range.low = self.minz
self.cross_plot.value_range.high = self.maxz
self.cross_plot2.value_range.low = self.minz
self.cross_plot2.value_range.high = self.maxz
if self._image_index.metadata.has_key("selections"):
x_ndx, y_ndx = self._image_index.metadata["selections"]