def _update_mask(self): # Min and Max for new mask xstart = self.rect['world'][0] xend = self.rect['world'][2] if xstart <= xend: newlist=[xstart,xend] else: newlist = [xend,xstart] # Mask or unmask invmask = None if self.rect['button'] == 1: invmask = False mflg = 'Mask' elif self.rect['button'] == 3: invmask = True mflg = 'UNmask' asaplog.push(mflg+': '+str(newlist)) asaplog.post() newmask = self.scan.create_mask(newlist,invert=invmask) # Logic operation to update mask if invmask: self.mask = mask_and(self.mask,newmask) else: self.mask = mask_or(self.mask,newmask) # Plot masked regions #if self.showmask or not self.once: self._plot_mask() if self.showmask: self._plot_mask()
def _subplot_stats(self,selection): statstr = ['max', 'min', 'median', 'mean', 'sum', 'std'] #'rms'] panelstr = selection['axes'].title.get_text() ssep = "-"*70 asaplog.push(ssep) asaplog.post() for line in selection['axes'].lines: # Don't include annotations if line.get_label().startswith("_"): continue label = panelstr + ", "+line.get_label() x = line.get_xdata() newmsk = None selmsk = self._create_flag_from_array(x, selection['worldx'], selection['invert']) ydat = None y = line.get_ydata() if numpy.ma.isMaskedArray(y): ydat = y.data basemsk = y.mask else: ydat = y basemsk = False if not isinstance(basemsk, bool): # should be ndarray newmsk = mask_or(selmsk, basemsk) elif basemsk: # the whole original spectrum is flagged newmsk = basemsk else: # no channel was flagged originally newmsk = selmsk mdata = numpy.ma.masked_array(ydat, mask=newmsk) statval = {} for stat in statstr: # need to get the stat functions from the ma module!!! statval[stat] = getattr(numpy.ma,stat)(mdata) self._print_stats(statval, statstr=statstr, label=label,\ mask=selection['worldx'],\ unmask=selection['invert']) asaplog.push(ssep) asaplog.post()