本文整理汇总了Python中enthought.chaco.api.HPlotContainer.remove方法的典型用法代码示例。如果您正苦于以下问题:Python HPlotContainer.remove方法的具体用法?Python HPlotContainer.remove怎么用?Python HPlotContainer.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类enthought.chaco.api.HPlotContainer
的用法示例。
在下文中一共展示了HPlotContainer.remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TemplatePicker
# 需要导入模块: from enthought.chaco.api import HPlotContainer [as 别名]
# 或者: from enthought.chaco.api.HPlotContainer import remove [as 别名]
#.........这里部分代码省略.........
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=[]
for idx in xrange(self.numfiles):
self.CC = cv_funcs.xcorr(self.sig.data[self.top:self.top+self.tmp_size,
self.left:self.left+self.tmp_size,self.tmp_img_idx],
self.sig.data[:,:,idx])
# peak finder needs peaks greater than 1. Multiply by 255 to scale them.
pks=pc.two_dim_findpeaks(self.CC*255, peak_width=self.peak_width, medfilt_radius=None)
pks[:,2]=pks[:,2]/255.
peaks.append(pks)
self.peaks=peaks
def mask_peaks(self,idx):
thresh=self.cbar_selection.selection
if thresh==[]:
thresh=(0,1)
mpeaks=np.ma.asarray(self.peaks[idx])
mpeaks[:,2]=np.ma.masked_outside(mpeaks[:,2],thresh[0],thresh[1])
return mpeaks
@on_trait_change("peaks")
def redraw_plots(self):
oldplot=self.img_plot
self.container.remove(oldplot)
newplot=self.render_image()
self.container.add(newplot)
self.img_plot=newplot
try:
# if these haven't been created before, this will fail. wrap in try to prevent that.
oldscat=self.scatplot
self.container.remove(oldscat)
oldcolorbar = self.colorbar
self.img_container.remove(oldcolorbar)
except:
pass
if self.numpeaks_img>0:
newscat=self.render_scatplot()
self.container.add(newscat)
self.scatplot=newscat
colorbar = self.draw_colorbar()
self.img_container.add(colorbar)
self.colorbar=colorbar
self.container.request_redraw()
self.img_container.request_redraw()
def crop_cells_stack(self):
from eelslab.signals.aggregate import AggregateCells
if self.numfiles==1:
self.crop_sig=self.crop_cells()
return
else:
crop_agg=[]
for idx in xrange(self.numfiles):
crop_agg.append(self.crop_cells(idx))
self.crop_sig=AggregateCells(*crop_agg)
return
def crop_cells(self,idx=0):
print "cropping cells..."
from hyperspy.signals.image import Image
# filter the peaks that are outside the selected threshold
peaks=np.ma.compress_rows(self.mask_peaks(idx))
tmp_sz=self.tmp_size
data=np.zeros((tmp_sz,tmp_sz,peaks.shape[0]))
if not hasattr(self.sig.mapped_parameters,"original_files"):
parent=self.sig
else:
parent=self.sig.mapped_parameters.original_files[self.titles[idx]]
for i in xrange(peaks.shape[0]):
# crop the cells from the given locations
data[:,:,i]=self.sig.data[peaks[i,1]:peaks[i,1]+tmp_sz,peaks[i,0]:peaks[i,0]+tmp_sz,idx]
crop_sig=Image({'data':data,
'mapped_parameters':{
'name':'Cropped cells from %s'%self.titles[idx],
'record_by':'image',
'locations':peaks,
'parent':parent,
}
})
return crop_sig
# attach a class member that has the locations from which the images were cropped
print "Complete. "