Ignore:
Timestamp:
08/03/10 11:41:13 (14 years ago)
Author:
Malte Marquarding
Message:

Tidy up of imports (now imported from asap.). Also fixed some whitespace/tab issues

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/interactivemask.py

    r1819 r1826  
    1 from asap import rcParams
    2 from asap import _n_bools, mask_and, mask_or
     1from asap.parameters import rcParams
     2from asap.utils import _n_bools, mask_and, mask_or
    33from asap.scantable import scantable
    44
     
    1515           my_mask.finish_selection(callback=func)
    1616           mask=my_mask.get_mask()
    17            
    18         Modify mask region by selecting a region on a plot with mouse. 
     17
     18        Modify mask region by selecting a region on a plot with mouse.
    1919        """
    2020
     
    2222                """
    2323                Create a interactive masking object.
    24                 Either or both 'plotter' or/and 'scan' should be defined. 
     24                Either or both 'plotter' or/and 'scan' should be defined.
    2525
    2626                Parameters:
     
    6363                self.ydataold=None
    6464                self._polygons=[]
    65        
     65
    6666
    6767        def set_basemask(self,masklist=[],invert=False):
    6868                """
    6969                Set initial channel mask.
    70                
     70
    7171                Parameters:
    7272                    masklist:  [[min, max], [min2, max2], ...]
    73                                A list of pairs of start/end points (inclusive) 
     73                               A list of pairs of start/end points (inclusive)
    7474                               specifying the regions to be masked
    7575                    invert:    optional argument. If specified as True,
     
    7777                               specified are excluded
    7878                You can reset the mask selection by running this method with
    79                 the default parameters. 
     79                the default parameters.
    8080                """
    8181                # Verify input parameters
     
    9797                """
    9898                Inherit an event from the parent function.
    99                
     99
    100100                Parameters:
    101101                    event: 'button_press_event' object to be inherited to
    102                            start interactive region selection . 
     102                           start interactive region selection .
    103103                """
    104104                from matplotlib.backend_bases import MouseEvent
    105                 if isinstance(event,MouseEvent) and event.name=='button_press_event': 
     105                if isinstance(event,MouseEvent) and event.name=='button_press_event':
    106106                        self.event=event
    107107                else:
    108108                        msg="Invalid event."
    109                         raise TypeError(msg)   
     109                        raise TypeError(msg)
    110110
    111111        def set_callback(self,callback):
    112112                """
    113                 Set callback function to run when finish_selection() is executed. 
     113                Set callback function to run when finish_selection() is executed.
    114114                    callback: The post processing function to run after
    115115                              the mask selections are completed.
     
    123123                Do interactive mask selection.
    124124                Modify masks interactively by adding/deleting regions with
    125                 mouse drawing.(left-button: mask; right-button: UNmask) 
    126                 Note that the interactive region selection is available only 
    127                 when GUI plotter is active. 
     125                mouse drawing.(left-button: mask; right-button: UNmask)
     126                Note that the interactive region selection is available only
     127                when GUI plotter is active.
    128128
    129129                Parameters:
    130130                    once:     If specified as True, you can modify masks only
    131                               once. Else if False, you can modify them repeatedly. 
     131                              once. Else if False, you can modify them repeatedly.
    132132                    showmask: If specified as True, the masked regions are plotted
    133133                              on the plotter.
    134134                              Note this parameter is valid only when once=True.
    135                               Otherwise, maskes are forced to be plotted for reference. 
     135                              Otherwise, maskes are forced to be plotted for reference.
    136136                """
    137137                # Return if GUI is not active
     
    181181                if self.event != None:
    182182                        self._region_start(self.event)
    183                 else: 
     183                else:
    184184                        self.p._plotter.register('button_press',None)
    185185                        self.p._plotter.register('button_press',self._region_start)
     
    205205        def _region_draw(self,event):
    206206                sameaxes=(event.inaxes == self.rect['axes'])
    207                 if sameaxes: 
     207                if sameaxes:
    208208                        xnow=event.x
    209209                        ynow=event.y
     
    224224                # Delete the rubber band
    225225                self.p._plotter.figmgr.toolbar.release(event)
    226                
    227                 if event.inaxes == self.rect['axes']: 
     226
     227                if event.inaxes == self.rect['axes']:
    228228                        xend=event.x
    229229                        yend=event.y
     
    235235                        xdataend=self.xdataold
    236236                        ydataend=self.ydataold
    237                        
     237
    238238                self.rect['world'][2:4] = [xdataend, ydataend]
    239239                self.rect['pixel'][2:4] = [xend, yend]
     
    300300                                if len(ifs) > 1:
    301301                                        for k in xrange(len(ifs)-1):
    302                                                 self._polygons.append(self.p._plotter.subplots[j]['axes'].axvspan(projs[k][i][0],projs[k][i][1],facecolor='#aaaaaa'))                   
     302                                                self._polygons.append(self.p._plotter.subplots[j]['axes'].axvspan(projs[k][i][0],projs[k][i][1],facecolor='#aaaaaa'))
    303303                                self._polygons.append(self.p._plotter.subplots[j]['axes'].axvspan(msks[i][0],msks[i][1],facecolor='yellow'))
    304304                self.p._plotter.canvas.draw()
     
    314314                              Specifying the callback function here will overwrite
    315315                              the one set by set_callback(func)
    316                
     316
    317317                Note this function is automatically called at the end of
    318                 select_mask() if once=True. 
     318                select_mask() if once=True.
    319319                """
    320320                if callback: self.callback=callback
     
    324324                if not self.newplot:
    325325                        self.clear_polygon()
    326                 else: 
     326                else:
    327327                        self.p._plotter.unmap()
    328328                        self.p._plotter = None
     
    334334        def clear_polygon(self):
    335335                """
    336                 Erase masks plots from the plotter. 
     336                Erase masks plots from the plotter.
    337337                """
    338338                if len(self._polygons)>0:
     
    347347                Get the interactively selected channel mask.
    348348                Returns:
    349                     A list of channel mask. 
     349                    A list of channel mask.
    350350                """
    351351                return self.mask
    352 
    353 
Note: See TracChangeset for help on using the changeset viewer.