Ignore:
Timestamp:
Mar 5, 2015 2:49:03 PM (9 years ago)
Author:
Mathieu Doucet <doucetm@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
7d56795
Parents:
824e488
Message:

pylint fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/guiframe/local_perspectives/plotting/boxMask.py

    r79492222 rb5de88e  
    1  
    2  
    3  
    41import math 
    5 #import wx 
    6 #from copy import deepcopy 
    72from BaseInteractor import _BaseInteractor 
    83from boxSum import PointInteractor 
    94from boxSum import VerticalDoubleLine 
    105from boxSum import HorizontalDoubleLine 
    11 #from sas.guiframe.events import SlicerParamUpdateEvent 
    126 
    137 
     
    159    """ 
    1610    BoxMask Class: determine 2 rectangular area to find the pixel of 
    17     a Data inside of box.  
    18      
     11    a Data inside of box. 
     12 
    1913    Uses PointerInteractor , VerticalDoubleLine,HorizontalDoubleLine. 
    20      
     14 
    2115    :param zorder:  Artists with lower zorder values are drawn first. 
    2216    :param x_min: the minimum value of the x coordinate 
     
    2620 
    2721    """ 
    28     def __init__(self, base, axes, color='black', zorder=3, side=None,  
    29                    x_min=0.008, x_max=0.008, y_min=0.0025, y_max=0.0025): 
     22    def __init__(self, base, axes, color='black', zorder=3, side=None, 
     23                 x_min=0.008, x_max=0.008, y_min=0.0025, y_max=0.0025): 
    3024        """ 
    3125        """ 
    3226        _BaseInteractor.__init__(self, base, axes, color=color) 
    33         ## class initialization 
    34         ## list of Boxmask markers 
     27        # # class initialization 
     28        # # list of Boxmask markers 
    3529        self.markers = [] 
    3630        self.axes = axes 
    3731        self.mask = None 
    3832        self.is_inside = side 
    39         ## connect the artist for the motion 
     33        # # connect the artist for the motion 
    4034        self.connect = self.base.connect 
    41         ## when qmax is reached the selected line is reset  
    42         #the its previous value 
     35        # # when qmax is reached the selected line is reset 
     36        # the its previous value 
    4337        self.qmax = min(self.base.data.xmax, self.base.data.xmin) 
    44         ## Define the box limits 
     38        # # Define the box limits 
    4539        self.xmin = -1 * 0.5 * min(math.fabs(self.base.data.xmax), 
    46                                  math.fabs(self.base.data.xmin)) 
     40                                   math.fabs(self.base.data.xmin)) 
    4741        self.ymin = -1 * 0.5 * min(math.fabs(self.base.data.xmax), 
    4842                                   math.fabs(self.base.data.xmin)) 
    4943        self.xmax = 0.5 * min(math.fabs(self.base.data.xmax), 
    5044                              math.fabs(self.base.data.xmin)) 
    51         self.ymax =  0.5 * min(math.fabs(self.base.data.xmax), 
    52                                math.fabs(self.base.data.xmin)) 
    53         ## center of the box 
     45        self.ymax = 0.5 * min(math.fabs(self.base.data.xmax), 
     46                              math.fabs(self.base.data.xmin)) 
     47        # # center of the box 
    5448        self.center_x = 0.0002 
    5549        self.center_y = 0.0003 
    56         ## Number of points on the plot 
     50        # # Number of points on the plot 
    5751        self.nbins = 20 
    58         ## Define initial result the summation  
     52        # # Define initial result the summation 
    5953        self.count = 0 
    6054        self.error = 0 
    6155        self.data = self.base.data 
    62         ## Flag to determine if the current figure has moved 
    63         ## set to False == no motion , set to True== motion 
     56        # # Flag to determine if the current figure has moved 
     57        # # set to False == no motion , set to True== motion 
    6458        self.has_move = False 
    65         ## Create Box edges  
     59        # # Create Box edges 
    6660        self.horizontal_lines = HorizontalDoubleLine(self, 
    6761                                                     self.base.subplot, 
    6862                                                     color='blue', 
    69                                                       zorder=zorder, 
    70                                                       y=self.ymax, 
    71                                                       x=self.xmax, 
    72                                                       center_x=self.center_x, 
    73                                                       center_y=self.center_y) 
     63                                                     zorder=zorder, 
     64                                                     y=self.ymax, 
     65                                                     x=self.xmax, 
     66                                                     center_x=self.center_x, 
     67                                                     center_y=self.center_y) 
    7468        self.horizontal_lines.qmax = self.qmax 
    75          
     69 
    7670        self.vertical_lines = VerticalDoubleLine(self, 
    77                                                 self.base.subplot, 
    78                                                 color='grey', 
    79                                                 zorder=zorder, 
    80                                                 y=self.ymax, 
    81                                                 x=self.xmax, 
    82                                                 center_x=self.center_x, 
    83                                                 center_y=self.center_y) 
     71                                                 self.base.subplot, 
     72                                                 color='grey', 
     73                                                 zorder=zorder, 
     74                                                 y=self.ymax, 
     75                                                 x=self.xmax, 
     76                                                 center_x=self.center_x, 
     77                                                 center_y=self.center_y) 
    8478        self.vertical_lines.qmax = self.qmax 
    85          
     79 
    8680        self.center = PointInteractor(self, 
    87                                       self.base.subplot,color='grey', 
    88                                     zorder=zorder, 
    89                                     center_x=self.center_x, 
    90                                     center_y=self.center_y) 
    91         ## Save the name of the slicer panel associate with this slicer  
    92         self.panel_name = ""     
    93         ## Update and post slicer parameters   
     81                                      self.base.subplot, color='grey', 
     82                                      zorder=zorder, 
     83                                      center_x=self.center_x, 
     84                                      center_y=self.center_y) 
     85        # # Save the name of the slicer panel associate with this slicer 
     86        self.panel_name = "" 
     87        # # Update and post slicer parameters 
    9488        self.update() 
    9589        self._post_data() 
    96      
     90 
    9791    def clear(self): 
    9892        """ 
     
    10498        self.center.clear() 
    10599        self.base.connect.clearall() 
    106         #self.base.Unbind(EVT_SLICER_PARS) 
    107      
     100 
    108101    def update(self): 
    109102        """ 
     
    111104        resetting the widgets. 
    112105        """ 
    113         # check if the center point has moved and update the figure accordingly  
     106        # check if the center point has moved and update the figure accordingly 
    114107        if self.center.has_move: 
    115108            self.center.update() 
    116109            self.horizontal_lines.update(center=self.center) 
    117110            self.vertical_lines.update(center=self.center) 
    118         ## check if the horizontal lines have moved and update 
    119         # the figure accordingly     
     111        # # check if the horizontal lines have moved and update 
     112        # the figure accordingly 
    120113        if self.horizontal_lines.has_move: 
    121114            self.horizontal_lines.update() 
     
    123116                                       y2=self.horizontal_lines.y2, 
    124117                                       height=self.horizontal_lines.half_height) 
    125         ## check if the vertical lines have moved and update 
    126         # the figure accordingly     
     118        # # check if the vertical lines have moved and update 
     119        # the figure accordingly 
    127120        if self.vertical_lines.has_move: 
    128121            self.vertical_lines.update() 
     
    130123                                         x2=self.vertical_lines.x2, 
    131124                                         width=self.vertical_lines.half_width) 
    132         #if self.is_inside != None: 
     125        # if self.is_inside != None: 
    133126        out = self._post_data() 
    134127        return out 
    135          
     128 
    136129    def save(self, ev): 
    137130        """ 
     
    143136        self.vertical_lines.save(ev) 
    144137        self.center.save(ev) 
    145          
     138 
    146139    def _post_data(self): 
    147140        """ 
     
    150143        """ 
    151144        from sas.dataloader.manipulations import Boxcut 
    152         ## Data 2D for which the pixel will be summed 
     145        # # Data 2D for which the pixel will be summed 
    153146        data = self.base.data 
    154147        mask = data.mask 
    155         ## the region of the summation 
    156         x_min = self.horizontal_lines.x2  
    157         x_max = self.horizontal_lines.x1  
     148        # # the region of the summation 
     149        x_min = self.horizontal_lines.x2 
     150        x_max = self.horizontal_lines.x1 
    158151        y_min = self.vertical_lines.y2 
    159152        y_max = self.vertical_lines.y1 
     
    164157        else: 
    165158            out = (mask(data)) 
    166         #self.base.data.mask=out 
     159        # self.base.data.mask=out 
    167160        self.mask = mask 
    168         return out   
    169                
     161        return out 
     162 
    170163    def moveend(self, ev): 
    171164        """ 
    172165        After a dragging motion this function is called to compute 
    173         the error and the sum of pixel of a given data 2D  
     166        the error and the sum of pixel of a given data 2D 
    174167        """ 
    175168        self.base.thaw_axes() 
    176         ## post 
     169        # # post 
    177170        self._post_data() 
    178              
     171 
    179172    def restore(self): 
    180173        """ 
     
    184177        self.vertical_lines.restore() 
    185178        self.center.restore() 
    186          
     179 
    187180    def move(self, x, y, ev): 
    188181        """ 
     
    190183        """ 
    191184        pass 
    192      
     185 
    193186    def set_cursor(self, x, y): 
    194187        pass 
    195          
     188 
    196189    def get_params(self): 
    197190        """ 
    198191        Store a copy of values of parameters of the slicer into a dictionary. 
    199          
     192 
    200193        :return params: the dictionary created 
    201          
     194 
    202195        """ 
    203196        params = {} 
    204197        params["Width"] = math.fabs(self.vertical_lines.half_width) * 2 
    205         params["Height"] = math.fabs(self.horizontal_lines.half_height) * 2  
     198        params["Height"] = math.fabs(self.horizontal_lines.half_height) * 2 
    206199        params["center_x"] = self.center.x 
    207200        params["center_y"] = self.center.y 
    208201        return params 
    209      
     202 
    210203    def get_mask(self): 
    211204        """ 
     
    214207        mask = self.mask 
    215208        return mask 
    216      
     209 
    217210    def set_params(self, params): 
    218211        """ 
    219         Receive a dictionary and reset the slicer with values contained  
     212        Receive a dictionary and reset the slicer with values contained 
    220213        in the values of the dictionary. 
    221          
    222         :param params: a dictionary containing name of slicer parameters and  
     214 
     215        :param params: a dictionary containing name of slicer parameters and 
    223216           values the user assigned to the slicer. 
    224217        """ 
    225         x_max = math.fabs(params["Width"] )/2 
    226         y_max = math.fabs(params["Height"])/2 
    227          
    228         self.center_x = params["center_x"]  
     218        x_max = math.fabs(params["Width"]) / 2 
     219        y_max = math.fabs(params["Height"]) / 2 
     220 
     221        self.center_x = params["center_x"] 
    229222        self.center_y = params["center_y"] 
    230         #update the slicer given values of params 
     223        # update the slicer given values of params 
    231224        self.center.update(center_x=self.center_x, center_y=self.center_y) 
    232         self.horizontal_lines.update(center=self.center, 
    233                                      width=x_max, 
    234                                      height=y_max) 
    235         self.vertical_lines.update(center=self.center, 
    236                                     width=x_max, 
    237                                     height=y_max) 
    238         #compute the new error and sum given values of params 
     225        self.horizontal_lines.update(center=self.center, width=x_max, height=y_max) 
     226        self.vertical_lines.update(center=self.center, width=x_max, height=y_max) 
     227        # compute the new error and sum given values of params 
    239228        self._post_data() 
    240                 
     229 
    241230    def freeze_axes(self): 
    242231        self.base.freeze_axes() 
    243          
     232 
    244233    def thaw_axes(self): 
    245234        self.base.thaw_axes() 
     
    248237        self.base.update() 
    249238 
    250 class inner_BoxMask(BoxMask):    
    251     def __call__(self):      
    252         self.base.data.mask = (self._post_data()==False) 
    253        
    254     
     239class inner_BoxMask(BoxMask): 
     240    def __call__(self): 
     241        self.base.data.mask = (self._post_data() == False) 
Note: See TracChangeset for help on using the changeset viewer.