Ignore:
Timestamp:
07/23/12 18:28:01 (12 years ago)
Author:
Kana Sugimoto
Message:

New Development: No

JIRA Issue: Yes (CAS-3616, Trac-274)

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s): flagplotter, sdflag

Description: fixed misc bugs in flagplotter.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/flagplotter.py

    r2605 r2606  
    3232        self.set_stacking('scan')
    3333        self._ismodified = False
    34         self._showflag = True #False
     34        self._showflagged = False
    3535        self.set_colors("blue gray",False)
    3636
     
    5151            asaplog.post("ERROR")
    5252
    53     def set_showflag(self, show):
     53    def set_showflagged(self, show):
    5454        """ Whether or not plotting flagged data"""
    5555        if type(show) == bool:
    56             self._showflag = show
     56            self._showflagged = show
     57            print "self._showflagged =", str(show)
     58        else:
     59            raise TypeError, "Input parameter should be a bool."
    5760
    5861    @asaplog_post_dec
     
    130133        if self._is_new_scan(scan):
    131134            self._ismodified = False
    132         if not self._showflag:
     135        if not self._showflagged:
    133136            self.set_legend(mode=None,refresh=False)
    134137        elif not self._legendloc:
     
    139142    @asaplog_post_dec
    140143    def _plot(self, scan):
    141         self._plot_with_flag(scan,self._showflag)
     144        self._plot_with_flag(scan,self._showflagged)
     145        #asapplotter._plot(self,scan)
    142146        # rescale x-range of subplots 5% margins
    143147        ganged = (self._plotter.axes._sharex != None)
     
    156160
    157161    @asaplog_post_dec
    158     def _plot_with_flag(self, scan, showflag=True):
     162    def _plot_with_flag(self, scan, showflag=False):
    159163        # total number of panles to plot as a whole
    160164        nptot = scan.nrow()
     
    180184        nr = scan.nrow()
    181185        panelcount = 0
    182 
     186        allylim = []
     187        allxlim = []
     188       
    183189        while r < nr:
    184190            # always plot to new panel
     
    205211            # Now get data to plot
    206212            y = scan._getspectrum(r)
    207             #flag row
     213            # Check for FLAGROW column
    208214            mr = scan._getflagrow(r)
    209215            from numpy import ma, array
     
    225231            if self._offset:
    226232                x += self._offset
    227             llbl = self._get_label(scan, r, mode='legend', userlabel=self._lmap)
    228             if type(llbl) in (list, tuple):
    229                         llbl = llbl[0]
    230             self._plotter.set_line(label=llbl)
    231             plotit = self._plotter.plot
    232             if self._hist: plotit = self._plotter.hist
    233             plotit(x,ys)
     233            #llbl = self._get_label(scan, r, mode='legend', userlabel=self._lmap)
     234            #if type(llbl) in (list, tuple):
     235            #    llbl = llbl[0]
     236            #self._plotter.set_line(label=llbl)
     237            self._plotter.set_line(label="data")
     238            #plotit = self._plotter.plot
     239            #if self._hist: plotit = self._plotter.hist
     240            self._plotter.plot(x,ys)
    234241            if showflag:
    235242                self._plotter.set_line(label="flagged")
    236                 plotit(x,yf)
     243                self._plotter.plot(x,yf)
     244                ylim = self._minmaxy or [min(y),max(y)]
     245                xlim= self._minmaxx or [min(x),max(x)]
     246            elif mr or ys.mask.all():
     247                ylim = self._minmaxy or []
     248                xlim = self._minmaxx or []
     249            else:
     250                ylim = self._minmaxy or [ma.minimum(ys),ma.maximum(ys)]
     251                xlim= self._minmaxx or [min(x),max(x)]
     252            allylim += ylim
     253            allxlim += xlim
    237254            if (panelcount == n) or (r == nr-1):
    238255                break
    239256            r+=1 # next row
    240        
     257
     258        # Set x- and y- limts of subplots
     259        if ganged:
     260            xlim = None
     261            ylim = None
     262            if len(allylim) > 0:
     263                allylim.sort()
     264                ylim = allylim[0],allylim[-1]
     265            if len(allxlim) > 0:
     266                allxlim.sort()
     267                xlim = allxlim[0],allxlim[-1]
     268            self._plotter.set_limits(xlim=xlim,ylim=ylim)
    241269
    242270        # save the current counter for multi-page plotting
Note: See TracChangeset for help on using the changeset viewer.