Changeset 2110 for branches


Ignore:
Timestamp:
04/06/11 15:58:02 (13 years ago)
Author:
Kana Sugimoto
Message:

merged bug fixes in trunk (r2108)

Location:
branches/casa-prerelease/pre-asap/python
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/casa-prerelease/pre-asap/python

  • branches/casa-prerelease/pre-asap/python/interactivemask.py

    r1826 r2110  
    22from asap.utils import _n_bools, mask_and, mask_or
    33from asap.scantable import scantable
     4from asap.logging import asaplog, asaplog_post_dec
    45
    56class interactivemask:
     
    3031                # Return if GUI is not active
    3132                if not rcParams['plotter.gui']:
    32                         print 'GUI plotter is disabled.\n'
    33                         print 'Exit interactive mode.'
     33                        msg = 'GUI plotter is disabled.\n'
     34                        msg += 'Exit interactive mode.'
     35                        asaplog.push(msg)
     36                        asaplog.post("ERROR")
    3437                        return
    3538                # Verify input parameters
     
    7073
    7174                Parameters:
    72                     masklist:  [[min, max], [min2, max2], ...]
    73                                A list of pairs of start/end points (inclusive)
    74                                specifying the regions to be masked
    75                     invert:    optional argument. If specified as True,
    76                                return an inverted mask, i.e. the regions
    77                                specified are excluded
     75                        masklist:  [[min, max], [min2, max2], ...]
     76                                           A list of pairs of start/end points (inclusive)
     77                                                           specifying the regions to be masked
     78                        invert: optional argument. If specified as True,
     79                                           return an inverted mask, i.e. the regions
     80                                   specified are excluded
    7881                You can reset the mask selection by running this method with
    7982                the default parameters.
     
    8891                if ( len(masklist) > 0 ):
    8992                        self.mask=self.scan.create_mask(masklist,invert=invert)
    90                 elif invert==True:
     93                elif invert==True:
    9194                        self.mask=_n_bools(self.scan.nchan(),False)
    9295                else:
     
    99102
    100103                Parameters:
    101                     event: 'button_press_event' object to be inherited to
    102                            start interactive region selection .
     104                        event: 'button_press_event' object to be inherited to
     105                                   start interactive region selection .
    103106                """
    104107                from matplotlib.backend_bases import MouseEvent
     
    112115                """
    113116                Set callback function to run when finish_selection() is executed.
    114                     callback: The post processing function to run after
    115                               the mask selections are completed.
    116                               This will be overwritten if callback is defined in
    117                               finish_selection(callback=func)
     117                        callback: The post processing function to run after
     118                                          the mask selections are completed.
     119                                  This will be overwritten if callback is defined in
     120                                  finish_selection(callback=func)
    118121                """
    119122                self.callback=callback
     
    128131
    129132                Parameters:
    130                     once:    If specified as True, you can modify masks only
    131                               once. Else if False, you can modify them repeatedly.
    132                     showmask: If specified as True, the masked regions are plotted
    133                               on the plotter.
    134                               Note this parameter is valid only when once=True.
    135                               Otherwise, maskes are forced to be plotted for reference.
     133                        once:    If specified as True, you can modify masks only
     134                                          once. Else if False, you can modify them repeatedly.
     135                        showmask: If specified as True, the masked regions are plotted
     136                                          on the plotter.
     137                                  Note this parameter is valid only when once=True.
     138                                  Otherwise, maskes are forced to be plotted for reference.
    136139                """
    137140                # Return if GUI is not active
    138141                if not rcParams['plotter.gui']:
    139                         print 'GUI plotter is disabled.\n'
    140                         print 'Exit interactive mode.'
     142                        msg = 'GUI plotter is disabled.\n'
     143                        msg += 'Exit interactive mode.'
     144                        asaplog.push(msg)
     145                        asaplog.post("ERROR")
    141146                        return
    142147
     
    145150                        self.showmask=showmask
    146151                else:
    147                         if not showmask: print 'Warning: showmask spcification is ignored. Mask regions are plotted anyway.'
     152                        if not showmask:
     153                                asaplog.post()
     154                                asaplog.push('showmask spcification is ignored. Mask regions are plotted anyway.')
     155                                asaplog.post("WARN")
    148156                        self.showmask=True
    149157
    150158                #if not self.p._plotter or self.p._plotter.is_dead:
    151159                if not self.p or self.p._plotter.is_dead:
    152                         print 'A new ASAP plotter will be loaded'
     160                        asaplog.push('A new ASAP plotter will be loaded')
     161                        asaplog.post()
    153162                        from asap.asapplotter import asapplotter
    154163                        self.p=asapplotter()
    155164                        self.newplot=True
    156165
    157                 # Plot selected spectra if needed
     166                # Plot selected spectra if needed
    158167                if self.scan != self.p._data:
     168                        if len(self.scan.getifnos()) > 16:
     169                                asaplog.post()
     170                                asaplog.push("Number of panels > 16. Plotting the first 16...")
     171                                asaplog.post("WARN")
    159172                        # Need replot
     173                        self.p._plotter.legend(1)
    160174                        self.p.plot(self.scan)
    161175                        # disable casa toolbar
    162                         if self.p._plotter.figmgr.casabar:  self.p._plotter.figmgr.casabar.disable_button()
     176                        if self.p._plotter.figmgr.casabar:
     177                                self.p._plotter.figmgr.casabar.disable_button()
     178                                self.p._plotter.figmgr.casabar.disable_prev()
     179                                self.p._plotter.figmgr.casabar.disable_next()
    163180                        for panel in self.p._plotter.subplots:
    164181                                xmin, xmax = panel['axes'].get_xlim()
     
    195212                # Select mask/unmask region with mask
    196213                self.rect = {'button': event.button, 'axes': event.inaxes,
    197                             'x': event.x, 'y': event.y,
    198                             'world': [event.xdata, event.ydata,
    199                                        event.xdata, event.ydata],
    200                             'pixel': [event.x, event.y,
    201                                        event.x, event.y]}
     214                                'x': event.x, 'y': event.y,
     215                                'world': [event.xdata, event.ydata,
     216                                           event.xdata, event.ydata],
     217                                'pixel': [event.x, event.y,
     218                                           event.x, event.y]}
    202219                self.p._plotter.register('motion_notify', self._region_draw)
    203220                self.p._plotter.register('button_release', self._region_end)
     
    261278                        invmask=True
    262279                        mflg='UNmask'
    263                 print mflg+': ',newlist
     280                asaplog.push(mflg+': '+str(newlist))
     281                asaplog.post()
    264282                newmask=self.scan.create_mask(newlist,invert=invmask)
    265283                # Logic operation to update mask
     
    274292        # Plot masked regions
    275293        def _plot_mask(self):
    276                 msks = []
    277                 msks = self.scan.get_masklist(self.mask,row=0)
     294                msks = []
     295                msks = self.scan.get_masklist(self.mask,row=0)
    278296                # Get projection masks for multi-IF
    279297                ifs=self.scan.getifnos()
     
    287305                                                projs.append(self.scan.get_masklist(self.mask,row=row))
    288306                                                break
    289                 if len(self._polygons)>0:
     307                if len(self._polygons)>0:
    290308                        # Remove old polygons
    291309                        for polygon in self._polygons: polygon.remove()
     
    310328
    311329                Parameters:
    312                     callback: The post processing function to run after
    313                               the mask selections are completed.
    314                               Specifying the callback function here will overwrite
    315                               the one set by set_callback(func)
     330                        callback: The post processing function to run after
     331                                          the mask selections are completed.
     332                                  Specifying the callback function here will overwrite
     333                                  the one set by set_callback(func)
    316334
    317335                Note this function is automatically called at the end of
     
    336354                Erase masks plots from the plotter.
    337355                """
    338                 if len(self._polygons)>0:
     356                if len(self._polygons)>0:
    339357                        # Remove old polygons
    340358                        for polygon in self._polygons: polygon.remove()
     
    347365                Get the interactively selected channel mask.
    348366                Returns:
    349                     A list of channel mask.
     367                        A list of channel mask.
    350368                """
    351369                return self.mask
Note: See TracChangeset for help on using the changeset viewer.