Changeset 121f72c in sasview


Ignore:
Timestamp:
Mar 3, 2015 2:20:19 PM (9 years ago)
Author:
Doucet, Mathieu <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:
26500ec
Parents:
d00294b
Message:

pylint fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/plottools/PlotPanel.py

    r79492222 r121f72c  
    11""" 
     2    Plot panel. 
    23""" 
    34import logging 
     
    3132import numpy 
    3233 
     34from sas.guiframe.events import StatusEvent 
    3335 
    3436def show_tree(obj, d=0): 
     
    3638    print "%s%s" % ("-"*d, obj.__class__.__name__) 
    3739    if 'get_children' in dir(obj): 
    38         for a in obj.get_children(): show_tree(a, d+1) 
    39       
     40        for a in obj.get_children(): show_tree(a, d + 1) 
     41 
    4042from unitConverter import UnitConvertion as convertUnit 
    4143 
    4244 
    4345def _rescale(lo, hi, step, pt=None, bal=None, scale='linear'): 
    44         """ 
     46    """ 
    4547        Rescale (lo,hi) by step, returning the new (lo,hi) 
    4648        The scaling is centered on pt, with positive values of step 
    4749        driving lo/hi away from pt and negative values pulling them in. 
    4850        If bal is given instead of point, it is already in [0,1] coordinates. 
    49      
     51 
    5052        This is a helper function for step-based zooming. 
    51          
    52         """ 
    53         # Convert values into the correct scale for a linear transformation 
    54         # TODO: use proper scale transformers 
    55         loprev = lo 
    56         hiprev = hi 
    57         if scale == 'log': 
    58             assert lo > 0 
    59             if lo > 0: 
    60                 lo = math.log10(lo) 
    61             if hi > 0: 
    62                 hi = math.log10(hi) 
    63             if pt is not None: 
    64                 pt = math.log10(pt) 
    65          
    66         # Compute delta from axis range * %, or 1-% if persent is negative 
    67         if step > 0: 
    68             delta = float(hi - lo) * step / 100 
     53 
     54    """ 
     55    # Convert values into the correct scale for a linear transformation 
     56    # TODO: use proper scale transformers 
     57    loprev = lo 
     58    hiprev = hi 
     59    if scale == 'log': 
     60        assert lo > 0 
     61        if lo > 0: 
     62            lo = math.log10(lo) 
     63        if hi > 0: 
     64            hi = math.log10(hi) 
     65        if pt is not None: 
     66            pt = math.log10(pt) 
     67 
     68    # Compute delta from axis range * %, or 1-% if persent is negative 
     69    if step > 0: 
     70        delta = float(hi - lo) * step / 100 
     71    else: 
     72        delta = float(hi - lo) * step / (100 - step) 
     73 
     74    # Add scale factor proportionally to the lo and hi values, 
     75    # preserving the 
     76    # point under the mouse 
     77    if bal is None: 
     78        bal = float(pt - lo) / (hi - lo) 
     79    lo = lo - (bal * delta) 
     80    hi = hi + (1 - bal) * delta 
     81 
     82    # Convert transformed values back to the original scale 
     83    if scale == 'log': 
     84        if (lo <= -250) or (hi >= 250): 
     85            lo = loprev 
     86            hi = hiprev 
    6987        else: 
    70             delta = float(hi - lo) * step / (100 - step) 
    71      
    72         # Add scale factor proportionally to the lo and hi values, 
    73         # preserving the 
    74         # point under the mouse 
    75         if bal is None: 
    76             bal = float(pt - lo) / (hi - lo) 
    77         lo = lo - (bal * delta) 
    78         hi = hi + (1 - bal) * delta 
    79      
    80         # Convert transformed values back to the original scale 
    81         if scale == 'log': 
    82             if (lo <= -250) or (hi >= 250): 
    83                 lo = loprev 
    84                 hi = hiprev 
    85             else: 
    86                 lo, hi = math.pow(10., lo), math.pow(10., hi) 
    87         return (lo, hi) 
     88            lo, hi = math.pow(10., lo), math.pow(10., hi) 
     89    return (lo, hi) 
    8890 
    8991 
     
    9698    bmp = wx.BitmapDataObject() 
    9799    bmp.SetBitmap(canvas.bitmap) 
    98      
     100 
    99101    wx.TheClipboard.Open() 
    100102    wx.TheClipboard.SetData(bmp) 
     
    104106class PlotPanel(wx.Panel): 
    105107    """ 
    106     The PlotPanel has a Figure and a Canvas. OnSize events simply set a  
     108    The PlotPanel has a Figure and a Canvas. OnSize events simply set a 
    107109    flag, and the actually redrawing of the 
    108110    figure is triggered by an Idle event. 
    109      
    110111    """ 
    111112    def __init__(self, parent, id=-1, xtransform=None, 
    112                   ytransform=None, scale='log_{10}', 
    113                   color=None, dpi=None, **kwargs): 
     113                 ytransform=None, scale='log_{10}', 
     114                 color=None, dpi=None, **kwargs): 
    114115        """ 
    115116        """ 
     
    128129        self.canvas = FigureCanvas(self, -1, self.figure) 
    129130        self.SetColor(color) 
    130         #self.SetBackgroundColour(parent.GetBackgroundColour()) 
    131131        self._resizeflag = True 
    132132        self._SetSize() 
     
    142142        self.add_toolbar() 
    143143        self.SetSizer(self.sizer) 
    144          
     144 
    145145        # Graph object to manage the plottables 
    146146        self.graph = Graph() 
    147          
     147 
    148148        #Boolean value to keep track of whether current legend is 
    149149        #visible or not 
     
    154154        self.position = None 
    155155        self._loc_labels = self.get_loc_label() 
    156        
     156 
    157157        self.Bind(wx.EVT_CONTEXT_MENU, self.onContextMenu) 
    158          
     158 
    159159        # Define some constants 
    160         self.colorlist = ['b','g','r','c','m','y','k'] 
    161         self.symbollist = ['o','x','^','v','<','>','+', 
    162                            's','d','D','h','H','p', '-'] 
    163          
     160        self.colorlist = ['b', 'g', 'r', 'c', 'm', 'y', 'k'] 
     161        self.symbollist = ['o', 'x', '^', 'v', '<', '>', '+', 
     162                           's', 'd', 'D', 'h', 'H', 'p', '-'] 
     163 
    164164        #List of texts currently on the plot 
    165165        self.textList = [] 
     
    180180        self.scroll_id = self.canvas.mpl_connect('scroll_event', self.onWheel) 
    181181        #taking care of dragging 
    182         self.motion_id = self.canvas.mpl_connect('motion_notify_event',  
     182        self.motion_id = self.canvas.mpl_connect('motion_notify_event', 
    183183                                                 self.onMouseMotion) 
    184         self.press_id = self.canvas.mpl_connect('button_press_event',  
     184        self.press_id = self.canvas.mpl_connect('button_press_event', 
    185185                                                self.onLeftDown) 
    186186        self.pick_id = self.canvas.mpl_connect('pick_event', self.onPick) 
    187         self.release_id = self.canvas.mpl_connect('button_release_event',  
     187        self.release_id = self.canvas.mpl_connect('button_release_event', 
    188188                                                  self.onLeftUp) 
    189          
     189 
    190190        wx.EVT_RIGHT_DOWN(self, self.onLeftDown) 
    191191        # to turn axis off whenn resizing the panel 
    192192        self.resizing = False 
    193          
     193 
    194194        self.leftdown = False 
    195195        self.leftup = False 
     
    201201        self.connect = BindArtist(self.subplot.figure) 
    202202        #self.selected_plottable = None 
    203          
     203 
    204204        # new data for the fit 
    205205        self.fit_result = Data1D(x=[], y=[], dy=None) 
     
    221221        self.ErrBvalue = None 
    222222        self.Chivalue = None 
    223          
     223 
    224224        # for 2D scale 
    225225        if scale != 'linear': 
     
    237237        self.zmin_2D = None 
    238238        self.zmax_2D = None 
    239          
     239 
    240240        #index array 
    241241        self.index_x = None 
    242242        self.index_y = None 
    243          
     243 
    244244        #number of bins 
    245245        self.x_bins = None 
    246246        self.y_bins = None 
    247          
     247 
    248248        ## default color map 
    249249        self.cmap = DEFAULT_CMAP 
    250         
     250 
    251251        # Dragging info 
    252252        self.begDrag = False 
     
    255255        self.xFinal = None 
    256256        self.yFinal = None 
    257          
     257 
    258258        #axes properties 
    259259        self.xaxis_font = None 
     
    267267        self.yaxis_color = 'black' 
    268268        self.yaxis_tick = None 
    269          
     269 
    270270        # check if zoomed. 
    271271        self.is_zoomed = False 
    272272        # Plottables 
    273273        self.plots = {} 
    274          
     274 
    275275        # Default locations 
    276276        self._default_save_location = os.getcwd() 
     
    289289        self.canvas.SetSize(pixels) 
    290290        self.figure.set_size_inches(pixels[0] / self.figure.get_dpi(), 
    291          pixels[1] / self.figure.get_dpi(), forward=True) 
    292            
     291                                    pixels[1] / self.figure.get_dpi(), forward=True) 
     292 
    293293    def On_Paint(self, event): 
    294294        """ 
     
    306306            self.parent.send_focus_to_datapanel(self.window_caption) 
    307307        self.draw() 
    308          
     308 
    309309    def on_kill_focus(self, event): 
    310310        """ 
     
    315315        self.figure.set_edgecolor(self.color) 
    316316        self.draw() 
    317             
     317 
    318318    def set_resizing(self, resizing=False): 
    319319        """ 
     
    321321        """ 
    322322        pass  # Not implemented 
    323      
     323 
    324324    def schedule_full_draw(self, func='append'): 
    325325        """ 
     
    327327        """ 
    328328        pass  # Not implemented 
    329      
     329 
    330330    def add_toolbar(self): 
    331331        """ 
     
    352352        self.toolbar.SetSize(wx.Size(fw, th)) 
    353353        self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND) 
    354          
     354 
    355355        # update the axes menu on the toolbar 
    356356        self.toolbar.update() 
    357          
     357 
    358358    def onLeftDown(self, event): 
    359359        """ 
    360360        left button down and ready to drag 
    361          
    362361        """ 
    363362        # Check that the LEFT button was pressed 
     
    386385            self.mousemotion = False 
    387386            self.leftup = True 
    388              
     387 
    389388        #release the legend 
    390389        if self.gotLegend == 1: 
    391390            self.gotLegend = 0 
    392391            self.set_legend_alpha(1) 
    393              
     392 
    394393    def set_legend_alpha(self, alpha=1): 
    395394        """ 
     
    398397        if self.legend != None: 
    399398            self.legend.legendPatch.set_alpha(alpha) 
    400          
     399 
    401400    def onPick(self, event): 
    402401        """ 
     
    416415            self.gotLegend = 1 
    417416            self.set_legend_alpha(0.5) 
    418      
     417 
    419418    def _on_legend_motion(self, event): 
    420419        """ 
     
    450449        self.canvas.set_resizing(self.resizing) 
    451450        self.canvas.draw() 
    452             
     451 
    453452    def onMouseMotion(self, event): 
    454453        """ 
     
    456455        computer delta for x and y coordinates and then calls draghelper 
    457456        to perform the drag 
    458          
    459457        """ 
    460458        self.cusor_line(event) 
     
    474472                    self.xInit = self.xFinal 
    475473                    self.yInit = self.yFinal 
    476                      
     474 
    477475                xdelta = self.xFinal - self.xInit 
    478476                ydelta = self.yFinal - self.yInit 
    479                  
     477 
    480478                if self.xscale == 'log': 
    481479                    xdelta = math.log10(self.xFinal) - math.log10(self.xInit) 
     
    500498            if self._scale_yhi is not None and self._scale_ylo is not None: 
    501499                ax.set_ylim(self._scale_ylo, self._scale_yhi) 
    502              
     500 
    503501    def _dragHelper(self, xdelta, ydelta): 
    504502        """ 
    505503        dragging occurs here 
    506          
    507504        """ 
    508505        # Event occurred inside a plotting area 
    509506        for ax in self.axes: 
    510507            lo, hi = ax.get_xlim() 
    511             #print "x lo %f and x hi %f"%(lo,hi) 
    512508            newlo, newhi = lo - xdelta, hi - xdelta 
    513509            if self.xscale == 'log': 
     
    524520                self._scale_xhi = newhi 
    525521                ax.set_xlim(newlo, newhi) 
    526             #print "new lo %f and new hi %f"%(newlo,newhi) 
    527              
     522 
    528523            lo, hi = ax.get_ylim() 
    529             #print "y lo %f and y hi %f"%(lo,hi) 
    530524            newlo, newhi = lo - ydelta, hi - ydelta 
    531525            if self.yscale == 'log': 
     
    534528                if hi > 0: 
    535529                    newhi = math.log10(hi) - ydelta 
    536                 #print "new lo %f and new hi %f"%(newlo,newhi) 
    537530            if  self.yscale == 'log': 
    538531                self._scale_ylo = math.pow(10, newlo) 
     
    548541        """ 
    549542        For fit Dialog initial display 
    550          
    551543        """ 
    552544        self.xmin = 0.0 
     
    563555        self.ErrBvalue = None 
    564556        self.Chivalue = None 
    565      
     557 
    566558    def onWheel(self, event): 
    567559        """ 
    568560        Process mouse wheel as zoom events 
    569          
     561 
    570562        :param event: Wheel event 
    571          
     563 
    572564        """ 
    573565        ax = event.inaxes 
     
    578570            lo, hi = ax.get_xlim() 
    579571            lo, hi = _rescale(lo, hi, step, 
    580                              pt=event.xdata, scale=ax.get_xscale()) 
     572                              pt=event.xdata, scale=ax.get_xscale()) 
    581573            if not self.xscale == 'log' or lo > 0: 
    582574                self._scale_xlo = lo 
    583575                self._scale_xhi = hi 
    584                 ax.set_xlim((lo,hi)) 
     576                ax.set_xlim((lo, hi)) 
    585577 
    586578            lo, hi = ax.get_ylim() 
    587579            lo, hi = _rescale(lo, hi, step, pt=event.ydata, 
    588                              scale=ax.get_yscale()) 
     580                              scale=ax.get_yscale()) 
    589581            if not self.yscale == 'log' or lo > 0: 
    590582                self._scale_ylo = lo 
     
    595587            xdata, ydata = None, None 
    596588            x, y = event.x, event.y 
    597             
     589 
    598590            for ax in self.axes: 
    599591                insidex, _ = ax.xaxis.contains(event) 
     
    625617        Return values and labels used by Fit Dialog 
    626618        """ 
    627         return self.xLabel, self.yLabel, self.Avalue, self.Bvalue,\ 
     619        return self.xLabel, self.yLabel, self.Avalue, self.Bvalue, \ 
    628620                self.ErrAvalue, self.ErrBvalue, self.Chivalue 
    629      
     621 
    630622    def setTrans(self, xtrans, ytrans): 
    631623        """ 
    632          
     624 
    633625        :param xtrans: set x transformation on Property dialog 
    634626        :param ytrans: set y transformation on Property dialog 
    635          
     627 
    636628        """ 
    637629        self.prevXtrans = xtrans 
    638630        self.prevYtrans = ytrans 
    639     
     631 
    640632    def onFitting(self, event): 
    641633        """ 
     
    654646            list = plotlist 
    655647        from fitDialog import LinearFit 
    656          
     648 
    657649        if len(list.keys()) > 0: 
    658650            first_item = list.keys()[0] 
     
    661653                            transform=self.returnTrans, 
    662654                            title='Linear Fit') 
    663             
     655 
    664656            if (self.xmin != 0.0)and (self.xmax != 0.0)\ 
    665657                and(self.xminView != 0.0)and (self.xmaxView != 0.0): 
     
    667659                                self.xmin, self.xmax) 
    668660            dlg.ShowModal() 
    669              
     661 
    670662    def set_selected_from_menu(self, menu, id): 
    671663        """ 
    672664        Set selected_plottable from context menu selection 
    673          
     665 
    674666        :param menu: context menu item 
    675667        :param id: menu item id 
     
    682674                self.graph.selected_plottable = plot.id 
    683675                break 
    684              
     676 
    685677    def linear_plottable_fit(self, plot): 
    686678        """ 
    687679            when clicking on linear Fit on context menu, display Fitting Dialog 
    688              
     680 
    689681            :param plot: PlotPanel owning the graph 
    690              
     682 
    691683        """ 
    692684        from fitDialog import LinearFit 
     
    694686            return 
    695687        self._fit_dialog = LinearFit(None, plot, self.onFitDisplay, 
    696                                       self.returnTrans, -1, 'Linear Fit') 
    697         # Set the zoom area  
     688                                     self.returnTrans, -1, 'Linear Fit') 
     689        # Set the zoom area 
    698690        if self._scale_xhi is not None and self._scale_xlo is not None: 
    699691            self._fit_dialog.set_fit_region(self._scale_xlo, self._scale_xhi) 
     
    708700        """ 
    709701        self._fit_dialog = None 
    710          
     702 
    711703    def _onProperties(self, event): 
    712704        """ 
     
    719711            self._fit_dialog.Destroy() 
    720712            self._fit_dialog = None 
    721         list = [] 
    722         list = self.graph.returnPlottable() 
    723         if len(list.keys()) > 0: 
    724             first_item = list.keys()[0] 
     713        plot_list = self.graph.returnPlottable() 
     714        if len(plot_list.keys()) > 0: 
     715            first_item = plot_list.keys()[0] 
    725716            if first_item.x != []: 
    726717                from PropertyDialog import Properties 
     
    751742                    self._onEVT_FUNC_PROPERTY() 
    752743                dial.Destroy() 
    753             
     744 
    754745    def set_yscale(self, scale='linear'): 
    755746        """ 
    756747        Set the scale on Y-axis 
    757          
     748 
    758749        :param scale: the scale of y-axis 
    759          
     750 
    760751        """ 
    761752        self.subplot.set_yscale(scale, nonposy='clip') 
    762753        self.yscale = scale 
    763          
     754 
    764755    def get_yscale(self): 
    765756        """ 
    766          
     757 
    767758        :return: Y-axis scale 
    768          
     759 
    769760        """ 
    770761        return self.yscale 
    771      
     762 
    772763    def set_xscale(self, scale='linear'): 
    773764        """ 
    774765        Set the scale on x-axis 
    775          
     766 
    776767        :param scale: the scale of x-axis 
    777          
     768 
    778769        """ 
    779770        self.subplot.set_xscale(scale) 
    780771        self.xscale = scale 
    781         
     772 
    782773    def get_xscale(self): 
    783774        """ 
    784          
     775 
    785776        :return: x-axis scale 
    786          
     777 
    787778        """ 
    788779        return self.xscale 
     
    791782        """ 
    792783        Set figure and canvas colours to be the same 
    793          
     784 
    794785        """ 
    795786        if not rgbtuple: 
    796787            rgbtuple = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE).Get() 
    797         col = [c/255.0 for c in rgbtuple] 
     788        col = [c / 255.0 for c in rgbtuple] 
    798789        self.figure.set_facecolor(col) 
    799790        self.figure.set_edgecolor(self.color) 
     
    817808        This method can be called to force the Plot to be a desired size, 
    818809         which defaults to the ClientSize of the panel 
    819           
     810 
    820811        """ 
    821812        if not pixels: 
     
    828819        """ 
    829820        Where the actual drawing happens 
    830          
     821 
    831822        """ 
    832823        self.figure.canvas.draw_idle() 
    833          
     824 
    834825    def legend_picker(self, legend, event): 
    835826        """ 
     
    837828        """ 
    838829        return self.legend.legendPatch.contains(event) 
    839          
     830 
    840831    def get_loc_label(self): 
    841832        """ 
     
    866857        _labels['center'] = i 
    867858        return _labels 
    868          
     859 
    869860    def onSaveImage(self, evt): 
    870861        """ 
     
    872863        """ 
    873864        self.toolbar.save(evt) 
    874         
     865 
    875866    def onContextMenu(self, event): 
    876867        """ 
    877868        Default context menu for a plot panel 
    878          
     869 
    879870        """ 
    880871        # Slicer plot popup menu 
     
    883874        slicerpop.Append(id, '&Save image', 'Save image as PNG') 
    884875        wx.EVT_MENU(self, id, self.onSaveImage) 
    885          
     876 
    886877        id = wx.NewId() 
    887878        slicerpop.Append(id, '&Printer setup', 'Set image size') 
    888879        wx.EVT_MENU(self, id, self.onPrinterSetup) 
    889          
     880 
    890881        id = wx.NewId() 
    891882        slicerpop.Append(id, '&Printer Preview', 'Set image size') 
    892883        wx.EVT_MENU(self, id, self.onPrinterPreview) 
    893      
     884 
    894885        id = wx.NewId() 
    895886        slicerpop.Append(id, '&Print image', 'Print image ') 
    896887        wx.EVT_MENU(self, id, self.onPrint) 
    897          
     888 
    898889        id = wx.NewId() 
    899890        slicerpop.Append(id, '&Copy', 'Copy to the clipboard') 
     
    903894        #slicerpop.Append(id, '&Load 1D data file') 
    904895        #wx.EVT_MENU(self, id, self._onLoad1DData) 
    905         
     896 
    906897        id = wx.NewId() 
    907898        slicerpop.AppendSeparator() 
    908899        slicerpop.Append(id, '&Properties') 
    909900        wx.EVT_MENU(self, id, self._onProperties) 
    910          
     901 
    911902        id = wx.NewId() 
    912903        slicerpop.AppendSeparator() 
    913904        slicerpop.Append(id, '&Linear Fit') 
    914905        wx.EVT_MENU(self, id, self.onFitting) 
    915          
     906 
    916907        id = wx.NewId() 
    917908        slicerpop.AppendSeparator() 
    918909        slicerpop.Append(id, '&Toggle Legend On/Off', 'Toggle Legend On/Off') 
    919910        wx.EVT_MENU(self, id, self.onLegend) 
    920          
     911 
    921912        loc_menu = wx.Menu() 
    922913        for label in self._loc_labels: 
     
    926917        id = wx.NewId() 
    927918        slicerpop.AppendMenu(id, '&Modify Legend Location', loc_menu) 
    928          
     919 
    929920        id = wx.NewId() 
    930921        slicerpop.Append(id, '&Modify Y Axis Label') 
     
    933924        slicerpop.Append(id, '&Modify X Axis Label') 
    934925        wx.EVT_MENU(self, id, self._on_xaxis_label) 
    935          
     926 
    936927        try: 
    937928            # mouse event 
     
    942933            pos_x, pos_y = self.toolbar.GetPositionTuple() 
    943934            pos = (pos_x, pos_y + 5) 
    944              
     935 
    945936        self.PopupMenu(slicerpop, pos) 
    946          
     937 
    947938    def onToolContextMenu(self, event): 
    948939        """ 
    949940        ContextMenu from toolbar 
    950          
     941 
    951942        :param event: toolbar event 
    952943        """ 
     
    955946        if self.graph.selected_plottable != None: 
    956947            self.graph.selected_plottable = None 
    957          
     948 
    958949        self.onContextMenu(event) 
    959          
     950 
    960951# modified kieranrcampbell ILL june2012 
    961     def onLegend(self,legOnOff): 
     952    def onLegend(self, legOnOff): 
    962953        """ 
    963954        Toggles whether legend is visible/not visible 
     
    975966            self.line_collections_list = handles2 
    976967            self.legend = self.subplot.legend(handles2, labels2, 
    977                             prop=FontProperties(size=10), 
    978                             loc=self.legendLoc) 
     968                                              prop=FontProperties(size=10), 
     969                                              loc=self.legendLoc) 
    979970            if self.legend != None: 
    980971                self.legend.set_picker(self.legend_picker) 
    981972                self.legend.set_axes(self.subplot) 
    982973                self.legend.set_zorder(20) 
    983          
     974 
    984975        self.subplot.figure.canvas.draw_idle() 
    985976 
     
    989980        """ 
    990981        menu = event.GetEventObject() 
    991         id = event.GetId() 
    992         label = menu.GetLabel(id) 
     982        label = menu.GetLabel(event.GetId()) 
    993983        self.ChangeLegendLoc(label) 
    994984 
     
    1006996        self.line_collections_list = handles2 
    1007997        self.legend = self.subplot.legend(handles2, labels2, 
    1008                             prop=FontProperties(size=10), 
    1009                             loc=self.legendLoc) 
     998                                          prop=FontProperties(size=10), 
     999                                          loc=self.legendLoc) 
    10101000        if self.legend != None: 
    10111001            self.legend.set_picker(self.legend_picker) 
     
    10221012            ax = gca() 
    10231013        ax.legend_ = None 
    1024          
     1014 
    10251015    def _on_addtext(self, event): 
    10261016        """ 
     
    10491039                if len(label) > 0 and xpos > 0 and ypos > 0: 
    10501040                    new_text = self.subplot.text(str(xpos), str(ypos), label, 
    1051                                                    fontproperties=font, 
    1052                                                    color=colour) 
     1041                                                 fontproperties=font, 
     1042                                                 color=colour) 
    10531043                    self.textList.append(new_text) 
    10541044                    self.subplot.figure.canvas.draw_idle() 
    10551045            except: 
    10561046                if self.parent != None: 
    1057                     from sas.guiframe.events import StatusEvent  
    10581047                    msg = "Add Text: Error. Check your property values..." 
    1059                     wx.PostEvent(self.parent, StatusEvent(status = msg )) 
     1048                    wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    10601049                else: 
    10611050                    raise 
     
    10651054        #based on this and plot it at user designated coordinates 
    10661055 
    1067     def onGridOnOff(self,gridon_off): 
     1056    def onGridOnOff(self, gridon_off): 
    10681057        """ 
    10691058        Allows ON/OFF Grid 
     
    10721061 
    10731062        self.subplot.figure.canvas.draw_idle() 
    1074          
     1063 
    10751064    def _on_xaxis_label(self, event): 
    10761065        """ 
    10771066        Allows you to add text to the plot 
    10781067        """ 
    1079         xaxis_label, xaxis_unit, xaxis_font, xaxis_color,\ 
     1068        xaxis_label, xaxis_unit, xaxis_font, xaxis_color, \ 
    10801069                     is_ok, is_tick = self._on_axis_label(axis='x') 
    10811070        if not is_ok: 
    10821071            return 
    1083          
     1072 
    10841073        self.xaxis_label = xaxis_label 
    10851074        self.xaxis_unit = xaxis_unit 
     
    10881077        if is_tick: 
    10891078            self.xaxis_tick = xaxis_font 
    1090          
     1079 
    10911080        if self.data != None: 
    10921081            # 2D 
    1093             self.xaxis(self.xaxis_label, self.xaxis_unit,\ 
     1082            self.xaxis(self.xaxis_label, self.xaxis_unit, \ 
    10941083                        self.xaxis_font, self.xaxis_color, self.xaxis_tick) 
    10951084            self.subplot.figure.canvas.draw_idle() 
     
    10971086            # 1D 
    10981087            self._check_zoom_plot() 
    1099      
     1088 
    11001089    def _check_zoom_plot(self): 
    11011090        """ 
     
    11191108    def is_zoomed(self, value): 
    11201109        self._is_zoomed = value 
    1121                     
     1110 
    11221111    def _on_yaxis_label(self, event): 
    11231112        """ 
    11241113        Allows you to add text to the plot 
    11251114        """ 
    1126         yaxis_label, yaxis_unit, yaxis_font, yaxis_color,\ 
     1115        yaxis_label, yaxis_unit, yaxis_font, yaxis_color, \ 
    11271116                        is_ok, is_tick = self._on_axis_label(axis='y') 
    11281117        if not is_ok: 
     
    11381127        if self.data != None: 
    11391128            # 2D 
    1140             self.yaxis(self.yaxis_label, self.yaxis_unit,\ 
     1129            self.yaxis(self.yaxis_label, self.yaxis_unit, \ 
    11411130                        self.yaxis_font, self.yaxis_color, self.yaxis_tick) 
    11421131            self.subplot.figure.canvas.draw_idle() 
     
    11441133            # 1D 
    11451134            self._check_zoom_plot() 
    1146              
     1135 
    11471136    def _on_axis_label(self, axis='x'): 
    11481137        """ 
    11491138        Modify axes labels 
    1150          
     1139 
    11511140        :param axis: x or y axis [string] 
    11521141        """ 
     
    11761165                if label_temp.count("\%s" % "\\") > 0: 
    11771166                    if self.parent != None: 
    1178                         from sas.guiframe.events import StatusEvent  
    11791167                        msg = "Add Label: Error. Can not use double '\\' " 
    11801168                        msg += "characters..." 
     
    11841172            except: 
    11851173                if self.parent != None: 
    1186                     from sas.guiframe.events import StatusEvent 
    11871174                    msg = "Add Label: Error. Check your property values..." 
    11881175                    wx.PostEvent(self.parent, StatusEvent(status=msg)) 
     
    11941181        textdial.Destroy() 
    11951182        return label, unit, font, colour, is_ok, is_tick 
    1196          
     1183 
    11971184    def _on_removetext(self, event): 
    11981185        """ 
     
    12031190        if num_text < 1: 
    12041191            if self.parent != None: 
    1205                 from sas.guiframe.events import StatusEvent 
    1206                 msg= "Remove Text: Nothing to remove.  " 
     1192                msg = "Remove Text: Nothing to remove.  " 
    12071193                wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    12081194            else: 
    12091195                raise 
    12101196            return 
    1211         txt = self.textList[num_text-1] 
     1197        txt = self.textList[num_text - 1] 
    12121198        try: 
    12131199            text_remove = txt.get_text() 
    12141200            txt.remove() 
    12151201            if self.parent != None: 
    1216                 from sas.guiframe.events import StatusEvent 
    1217                 msg= "Removed Text: '%s'. " % text_remove 
     1202                msg = "Removed Text: '%s'. " % text_remove 
    12181203                wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    12191204        except: 
    12201205            if self.parent != None: 
    1221                 from sas.guiframe.events import StatusEvent 
    1222                 msg= "Remove Text: Error occurred. " 
     1206                msg = "Remove Text: Error occurred. " 
    12231207                wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    12241208            else: 
    12251209                raise 
    12261210        self.textList.remove(txt) 
    1227              
     1211 
    12281212        self.subplot.figure.canvas.draw_idle() 
    12291213 
     
    12321216        Set some properties of the graph. 
    12331217        The set of properties is not yet determined. 
    1234          
     1218 
    12351219        """ 
    12361220        # The particulars of how they are stored and manipulated (e.g., do 
     
    12521236        self.subplot.clear() 
    12531237        self.subplot.hold(True) 
    1254      
     1238 
    12551239    def render(self): 
    12561240        """Commit the plot after all objects are drawn""" 
     
    12671251                self.line_collections_list = handles2 
    12681252                self.legend = ax.legend(handles2, labels2, 
    1269                                 prop=FontProperties(size=10), 
    1270                                 loc=self.legendLoc) 
     1253                                        prop=FontProperties(size=10), 
     1254                                        loc=self.legendLoc) 
    12711255                if self.legend != None: 
    12721256                    self.legend.set_picker(self.legend_picker) 
    12731257                    self.legend.set_axes(self.subplot) 
    12741258                    self.legend.set_zorder(20) 
    1275                  
     1259 
    12761260            except: 
    12771261                self.legend = ax.legend(prop=FontProperties(size=10), 
    12781262                                        loc=self.legendLoc) 
    1279                  
     1263 
    12801264    def xaxis(self, label, units, font=None, color='black', t_font=None): 
    12811265        """xaxis label and units. 
    1282          
     1266 
    12831267        Axis labels know about units. 
    1284          
     1268 
    12851269        We need to do this so that we can detect when axes are not 
    12861270        commesurate.  Currently this is ignored other than for formatting 
    12871271        purposes. 
    1288          
     1272 
    12891273        """ 
    12901274 
     
    13071291            self.subplot.set_xlabel(label, color=color) 
    13081292        pass 
    1309      
     1293 
    13101294    def yaxis(self, label, units, font=None, color='black', t_font=None): 
    13111295        """yaxis label and units.""" 
     
    13371321 
    13381322    def interactive_points(self, x, y, dx=None, dy=None, name='', color=0, 
    1339                            symbol=0, markersize=5, zorder=1, id=None,  
     1323                           symbol=0, markersize=5, zorder=1, id=None, 
    13401324                           label=None, hide_error=False): 
    13411325        """Draw markers with error bars""" 
     
    13481332        if p.markersize != None: 
    13491333            markersize = p.markersize 
    1350         p.points(x, y, dx=dx, dy=dy, color=color, symbol=symbol, zorder=zorder,  
     1334        p.points(x, y, dx=dx, dy=dy, color=color, symbol=symbol, zorder=zorder, 
    13511335                 markersize=markersize, label=label, hide_error=hide_error) 
    1352          
     1336 
    13531337        self.subplot.set_yscale(self.yscale, nonposy='clip') 
    13541338        self.subplot.set_xscale(self.xscale) 
    1355         
     1339 
    13561340    def interactive_curve(self, x, y, dy=None, name='', color=0, 
    13571341                          symbol=0, zorder=1, id=None, label=None): 
     
    13641348        p = PointInteractor(self, self.subplot, zorder=zorder, id=id) 
    13651349        p.curve(x, y, dy=dy, color=color, symbol=symbol, zorder=zorder, 
    1366                  label=label) 
    1367          
     1350                label=label) 
     1351 
    13681352        self.subplot.set_yscale(self.yscale, nonposy='clip') 
    13691353        self.subplot.set_xscale(self.xscale) 
    1370          
     1354 
    13711355    def plottable_selected(self, id): 
    13721356        """ 
     
    13801364               id=None, hide_error=False): 
    13811365        """Draw markers with error bars""" 
    1382          
     1366 
    13831367        # Convert tuple (lo,hi) to array [(x-lo),(hi-x)] 
    13841368        if dx != None and type(dx) == type(()): 
    1385             dx = nx.vstack((x-dx[0], dx[1]-x)).transpose() 
     1369            dx = nx.vstack((x - dx[0], dx[1] - x)).transpose() 
    13861370        if dy != None and type(dy) == type(()): 
    1387             dy = nx.vstack((y-dy[0], dy[1]-y)).transpose() 
     1371            dy = nx.vstack((y - dy[0], dy[1] - y)).transpose() 
    13881372        if dx == None and dy == None: 
    1389             h = self.subplot.plot(x, y, color=self._color(color), 
    1390                                    marker=self._symbol(symbol), markersize=marker_size, 
    1391                                    linestyle='', 
    1392                                    label=label) 
     1373            self.subplot.plot(x, y, color=self._color(color), 
     1374                              marker=self._symbol(symbol), 
     1375                              markersize=marker_size, 
     1376                              linestyle='', 
     1377                              label=label) 
    13931378        else: 
    13941379            col = self._color(color) 
    13951380            if hide_error: 
    1396                 h = self.subplot.plot(x, y, color=col, 
    1397                                    marker=self._symbol(symbol), 
    1398                                    markersize=marker_size, 
    1399                                    linestyle='', 
    1400                                    label=label) 
    1401             else: 
    1402                 h = self.subplot.errorbar(x, y, yerr=dy, xerr=None, 
    1403                                   ecolor=col, capsize=2, linestyle='', 
    1404                                   barsabove=False, 
    1405                                   mec=col, mfc=col, 
     1381                self.subplot.plot(x, y, color=col, 
    14061382                                  marker=self._symbol(symbol), 
    14071383                                  markersize=marker_size, 
    1408                                   lolims=False, uplims=False, 
    1409                                   xlolims=False, xuplims=False, label=label) 
    1410         
     1384                                  linestyle='', 
     1385                                  label=label) 
     1386            else: 
     1387                self.subplot.errorbar(x, y, yerr=dy, xerr=None, 
     1388                                      ecolor=col, capsize=2, linestyle='', 
     1389                                      barsabove=False, 
     1390                                      mec=col, mfc=col, 
     1391                                      marker=self._symbol(symbol), 
     1392                                      markersize=marker_size, 
     1393                                      lolims=False, uplims=False, 
     1394                                      xlolims=False, xuplims=False, label=label) 
     1395 
    14111396        self.subplot.set_yscale(self.yscale, nonposy='clip') 
    14121397        self.subplot.set_xscale(self.xscale) 
    1413          
     1398 
    14141399    def _onToggleScale(self, event): 
    14151400        """ 
    14161401        toggle axis and replot image 
    1417          
     1402 
    14181403        """ 
    14191404        zmin_2D_temp = self.zmin_2D 
     
    14351420            if not self.zmax_2D is None: 
    14361421                zmax_2D_temp = math.log10(self.zmax_2D) 
    1437                   
     1422 
    14381423        self.image(data=self.data, qx_data=self.qx_data, 
    14391424                   qy_data=self.qy_data, xmin=self.xmin_2D, 
     
    14421427                   cmap=self.cmap, zmin=zmin_2D_temp, 
    14431428                   zmax=zmax_2D_temp) 
    1444        
     1429 
    14451430    def image(self, data, qx_data, qy_data, xmin, xmax, ymin, ymax, 
    14461431              zmin, zmax, color=0, symbol=0, markersize=0, 
     
    14481433        """ 
    14491434        Render the current data 
    1450          
     1435 
    14511436        """ 
    14521437        self.data = data 
     
    14721457                if  self.zmin_2D <= 0  and len(output[output > 0]) > 0: 
    14731458                    zmin_temp = self.zmin_2D 
    1474                     output[output>0] = numpy.log10(output[output>0]) 
     1459                    output[output > 0] = numpy.log10(output[output > 0]) 
    14751460                    #In log scale Negative values are not correct in general 
    14761461                    #output[output<=0] = math.log(numpy.min(output[output>0])) 
    14771462                elif self.zmin_2D <= 0: 
    14781463                    zmin_temp = self.zmin_2D 
    1479                     output[output>0] = numpy.zeros(len(output)) 
    1480                     output[output<=0] = -32 
    1481                 else:  
     1464                    output[output > 0] = numpy.zeros(len(output)) 
     1465                    output[output <= 0] = -32 
     1466                else: 
    14821467                    zmin_temp = self.zmin_2D 
    1483                     output[output>0] = numpy.log10(output[output>0]) 
     1468                    output[output > 0] = numpy.log10(output[output > 0]) 
    14841469                    #In log scale Negative values are not correct in general 
    14851470                    #output[output<=0] = math.log(numpy.min(output[output>0])) 
     
    14871472                #Too many problems in 2D plot with scale 
    14881473                pass 
    1489                        
     1474 
    14901475        else: 
    14911476            zmin_temp = self.zmin_2D 
     
    14941479            #Re-adjust colorbar 
    14951480            self.subplot.figure.subplots_adjust(left=0.2, right=.8, bottom=.2) 
    1496              
     1481 
    14971482            im = self.subplot.imshow(output, interpolation='nearest', 
    14981483                                     origin='lower', 
     
    15001485                                     cmap=self.cmap, 
    15011486                                     extent=(self.xmin_2D, self.xmax_2D, 
    1502                                                 self.ymin_2D, self.ymax_2D)) 
    1503              
    1504             cbax = self.subplot.figure.add_axes([0.84,0.2,0.02,0.7]) 
     1487                                             self.ymin_2D, self.ymax_2D)) 
     1488 
     1489            cbax = self.subplot.figure.add_axes([0.84, 0.2, 0.02, 0.7]) 
    15051490        else: 
    15061491            # clear the previous 2D from memory 
     
    15131498            Y = self.y_bins[0:-1] 
    15141499            X, Y = numpy.meshgrid(X, Y) 
    1515              
     1500 
    15161501            try: 
    15171502                # mpl >= 1.0.0 
    15181503                ax = self.subplot.figure.gca(projection='3d') 
    15191504                #ax.disable_mouse_rotation() 
    1520                 cbax = self.subplot.figure.add_axes([0.84,0.1,0.02,0.8]) 
     1505                cbax = self.subplot.figure.add_axes([0.84, 0.1, 0.02, 0.8]) 
    15211506                if len(X) > 60: 
    15221507                    ax.disable_mouse_rotation() 
     
    15341519            self.subplot.figure.canvas.resizing = False 
    15351520            im = ax.plot_surface(X, Y, output, rstride=1, cstride=1, cmap=cmap, 
    1536                                    linewidth=0, antialiased=False) 
     1521                                 linewidth=0, antialiased=False) 
    15371522            self.subplot.set_axis_off() 
    1538              
     1523 
    15391524        if cbax == None: 
    15401525            ax.set_frame_on(False) 
     
    15481533        else: 
    15491534            self.figure.canvas.draw() 
    1550      
     1535 
    15511536    def _build_matrix(self): 
    15521537        """ 
     
    15561541        self.data, self.qx_data, and self.qy_data 
    15571542        where each one corresponds to z, x, or y axis values 
    1558          
     1543 
    15591544        """ 
    15601545        # No qx or qy given in a vector format 
     
    15631548            # do we need deepcopy here? 
    15641549            return copy.deepcopy(self.data) 
    1565       
     1550 
    15661551        # maximum # of loops to fillup_pixels 
    15671552        # otherwise, loop could never stop depending on data 
     
    15701555        self._get_bins() 
    15711556        # set zero to None 
    1572          
     1557 
    15731558        #Note: Can not use scipy.interpolate.Rbf: 
    15741559        # 'cause too many data points (>10000)<=JHC. 
     
    15801565        weights, xedges, yedges = numpy.histogram2d(x=self.qy_data, 
    15811566                                                    y=self.qx_data, 
    1582                                             bins=[self.y_bins, self.x_bins], 
    1583                                             weights=weights_data) 
     1567                                                    bins=[self.y_bins, self.x_bins], 
     1568                                                    weights=weights_data) 
    15841569        # get histogram of data, all points into a bin in a way of summing 
    15851570        image, xedges, yedges = numpy.histogram2d(x=self.qy_data, 
    15861571                                                  y=self.qx_data, 
    1587                                             bins=[self.y_bins, self.x_bins], 
    1588                                             weights=self.data) 
     1572                                                  bins=[self.y_bins, self.x_bins], 
     1573                                                  weights=self.data) 
    15891574        # Now, normalize the image by weights only for weights>1:  
    15901575        # If weight == 1, there is only one data point in the bin so 
    15911576        # that no normalization is required. 
    1592         image[weights > 1] = image[weights>1]/weights[weights>1] 
     1577        image[weights > 1] = image[weights > 1] / weights[weights > 1] 
    15931578        # Set image bins w/o a data point (weight==0) as None (was set to zero 
    15941579        # by histogram2d.) 
     
    15981583        #one None point exists 
    15991584        loop = 0 
    1600          
     1585 
    16011586        # do while loop until all vacant bins are filled up up 
    16021587        #to loop = max_loop 
    1603         while(not(numpy.isfinite(image[weights == 0])).all()): 
     1588        while not(numpy.isfinite(image[weights == 0])).all(): 
    16041589            if loop >= max_loop:  # this protects never-ending loop 
    16051590                break 
    16061591            image = self._fillup_pixels(image=image, weights=weights) 
    16071592            loop += 1 
    1608                 
     1593 
    16091594        return image 
    1610      
     1595 
    16111596    def _get_bins(self): 
    16121597        """ 
     
    16231608            # do we need deepcopy here? 
    16241609            return copy.deepcopy(self.data) 
    1625          
     1610 
    16261611        # find max and min values of qx and qy 
    16271612        xmax = self.qx_data.max() 
     
    16291614        ymax = self.qy_data.max() 
    16301615        ymin = self.qy_data.min() 
    1631          
     1616 
    16321617        # calculate the range of qx and qy: this way, it is a little 
    16331618        # more independent 
    16341619        x_size = xmax - xmin 
    16351620        y_size = ymax - ymin 
    1636          
     1621 
    16371622        # estimate the # of pixels on each axes 
    16381623        npix_y = int(math.floor(math.sqrt(len(self.qy_data)))) 
     
    16481633        ymax = ymax + ystep / 2.0 
    16491634        ymin = ymin - ystep / 2.0 
    1650          
     1635 
    16511636        # store x and y bin centers in q space 
    16521637        x_bins = numpy.linspace(xmin, xmax, npix_x) 
    16531638        y_bins = numpy.linspace(ymin, ymax, npix_y) 
    1654         #x_bins = numpy.arange(xmin, xmax + xstep / 10.0, xstep) 
    1655         #y_bins = numpy.arange(ymin, ymax + ystep / 10.0, ystep) 
    1656        
     1639 
    16571640        #set x_bins and y_bins 
    16581641        self.x_bins = x_bins 
     
    16631646        Fill z values of the empty cells of 2d image matrix 
    16641647        with the average over up-to next nearest neighbor points 
    1665          
     1648 
    16661649        :param image: (2d matrix with some zi = None) 
    1667          
     1650 
    16681651        :return: image (2d array ) 
    1669          
     1652 
    16701653        :TODO: Find better way to do for-loop below 
    1671          
     1654 
    16721655        """ 
    16731656        # No image matrix given 
     
    16901673                    # find 4 nearest neighbors 
    16911674                    # check where or not it is at the corner 
    1692                     if n_y != 0 and numpy.isfinite(image[n_y-1][n_x]): 
    1693                         temp_image[n_y][n_x] += image[n_y-1][n_x] 
     1675                    if n_y != 0 and numpy.isfinite(image[n_y - 1][n_x]): 
     1676                        temp_image[n_y][n_x] += image[n_y - 1][n_x] 
    16941677                        weit[n_y][n_x] += 1 
    1695                     if n_x != 0 and numpy.isfinite(image[n_y][n_x-1]): 
    1696                         temp_image[n_y][n_x] += image[n_y][n_x-1] 
     1678                    if n_x != 0 and numpy.isfinite(image[n_y][n_x - 1]): 
     1679                        temp_image[n_y][n_x] += image[n_y][n_x - 1] 
    16971680                        weit[n_y][n_x] += 1 
    1698                     if n_y != len_y -1 and numpy.isfinite(image[n_y+1][n_x]): 
    1699                         temp_image[n_y][n_x] += image[n_y+1][n_x]   
     1681                    if n_y != len_y - 1 and numpy.isfinite(image[n_y + 1][n_x]): 
     1682                        temp_image[n_y][n_x] += image[n_y + 1][n_x] 
    17001683                        weit[n_y][n_x] += 1 
    1701                     if n_x != len_x -1 and numpy.isfinite(image[n_y][n_x+1]): 
    1702                         temp_image[n_y][n_x] += image[n_y][n_x+1] 
     1684                    if n_x != len_x - 1 and numpy.isfinite(image[n_y][n_x + 1]): 
     1685                        temp_image[n_y][n_x] += image[n_y][n_x + 1] 
    17031686                        weit[n_y][n_x] += 1 
    17041687                    # go 4 next nearest neighbors when no non-zero 
    17051688                    # neighbor exists 
    17061689                    if n_y != 0 and n_x != 0 and\ 
    1707                          numpy.isfinite(image[n_y-1][n_x-1]): 
    1708                         temp_image[n_y][n_x] += image[n_y-1][n_x-1] 
     1690                         numpy.isfinite(image[n_y - 1][n_x - 1]): 
     1691                        temp_image[n_y][n_x] += image[n_y - 1][n_x - 1] 
    17091692                        weit[n_y][n_x] += 1 
    1710                     if n_y != len_y -1 and n_x != 0 and \ 
    1711                         numpy.isfinite(image[n_y+1][n_x-1]): 
    1712                         temp_image[n_y][n_x] += image[n_y+1][n_x-1] 
     1693                    if n_y != len_y - 1 and n_x != 0 and \ 
     1694                        numpy.isfinite(image[n_y + 1][n_x - 1]): 
     1695                        temp_image[n_y][n_x] += image[n_y + 1][n_x - 1] 
    17131696                        weit[n_y][n_x] += 1 
    1714                     if n_y != len_y and n_x != len_x -1 and \ 
    1715                         numpy.isfinite(image[n_y-1][n_x+1]): 
    1716                         temp_image[n_y][n_x] += image[n_y-1][n_x+1]   
     1697                    if n_y != len_y and n_x != len_x - 1 and \ 
     1698                        numpy.isfinite(image[n_y - 1][n_x + 1]): 
     1699                        temp_image[n_y][n_x] += image[n_y - 1][n_x + 1] 
    17171700                        weit[n_y][n_x] += 1 
    1718                     if n_y != len_y -1 and n_x != len_x -1 and \ 
    1719                         numpy.isfinite(image[n_y+1][n_x+1]): 
    1720                         temp_image[n_y][n_x] += image[n_y+1][n_x+1] 
     1701                    if n_y != len_y - 1 and n_x != len_x - 1 and \ 
     1702                        numpy.isfinite(image[n_y + 1][n_x + 1]): 
     1703                        temp_image[n_y][n_x] += image[n_y + 1][n_x + 1] 
    17211704                        weit[n_y][n_x] += 1 
    17221705 
     
    17241707        ind = (weit > 0) 
    17251708        image[ind] = temp_image[ind] / weit[ind] 
    1726          
     1709 
    17271710        return image 
    1728           
     1711 
    17291712    def curve(self, x, y, dy=None, color=0, symbol=0, label=None): 
    17301713        """Draw a line on a graph, possibly with confidence intervals.""" 
     
    17321715        self.subplot.set_yscale('linear') 
    17331716        self.subplot.set_xscale('linear') 
    1734          
     1717 
    17351718        self.subplot.plot(x, y, color=c, marker='', 
    17361719                          linestyle='-', label=label) 
     
    17451728        """Return a particular symbol""" 
    17461729        return self.symbollist[s % len(self.symbollist)] 
    1747     
     1730 
    17481731    def _replot(self, remove_fit=False): 
    17491732        """ 
    17501733        Rescale the plottables according to the latest 
    17511734        user selection and update the plot 
    1752          
     1735 
    17531736        :param remove_fit: Fit line will be removed if True 
    1754          
     1737 
    17551738        """ 
    17561739        self.graph.reset_scale() 
     
    17601743        self.graph.render(self) 
    17611744        self.subplot.figure.canvas.draw_idle() 
    1762     
     1745 
    17631746    def _onEVT_FUNC_PROPERTY(self, remove_fit=True, show=True): 
    17641747        """ 
     
    17711754        if remove_fit: 
    17721755            self.graph.delete(self.fit_result) 
    1773         self.ly = None  
    1774         self.q_ctrl = None    
    1775         list = [] 
     1756        self.ly = None 
     1757        self.q_ctrl = None 
    17761758        list = self.graph.returnPlottable() 
    17771759        # Changing the scale might be incompatible with 
     
    17861768        for item in list: 
    17871769            item.setLabel(self.xLabel, self.yLabel) 
    1788              
     1770 
    17891771            # control axis labels from the panel itself 
    17901772            yname, yunits = item.get_yaxis() 
     
    18031785                self.xaxis_unit = xunits 
    18041786            # Goes through all possible scales 
    1805             if(self.xLabel == "x"): 
     1787            if self.xLabel == "x": 
    18061788                item.transformX(transform.toX, transform.errToX) 
    18071789                self.graph._xaxis_transformed("%s" % xname, "%s" % xunits) 
    1808             if(self.xLabel == "x^(2)"): 
     1790            if self.xLabel == "x^(2)": 
    18091791                item.transformX(transform.toX2, transform.errToX2) 
    18101792                xunits = convertUnit(2, xunits) 
    18111793                self.graph._xaxis_transformed("%s^{2}" % xname, "%s" % xunits) 
    1812             if(self.xLabel == "x^(4)"): 
     1794            if self.xLabel == "x^(4)": 
    18131795                item.transformX(transform.toX4, transform.errToX4) 
    18141796                xunits = convertUnit(4, xunits) 
    18151797                self.graph._xaxis_transformed("%s^{4}" % xname, "%s" % xunits) 
    1816             if(self.xLabel == "ln(x)"): 
     1798            if self.xLabel == "ln(x)": 
    18171799                item.transformX(transform.toLogX, transform.errToLogX) 
    18181800                self.graph._xaxis_transformed("\ln\\ %s" % xname, "%s" % xunits) 
    1819             if(self.xLabel == "log10(x)"): 
     1801            if self.xLabel == "log10(x)": 
    18201802                item.transformX(transform.toX_pos, transform.errToX_pos) 
    18211803                _xscale = 'log' 
    18221804                self.graph._xaxis_transformed("%s" % xname, "%s" % xunits) 
    1823             if(self.xLabel == "log10(x^(4))"): 
     1805            if self.xLabel == "log10(x^(4))": 
    18241806                item.transformX(transform.toX4, transform.errToX4) 
    18251807                xunits = convertUnit(4, xunits) 
    18261808                self.graph._xaxis_transformed("%s^{4}" % xname, "%s" % xunits) 
    18271809                _xscale = 'log' 
    1828             if(self.yLabel == "ln(y)"): 
     1810            if self.yLabel == "ln(y)": 
    18291811                item.transformY(transform.toLogX, transform.errToLogX) 
    18301812                self.graph._yaxis_transformed("\ln\\ %s" % yname, "%s" % yunits) 
    1831             if(self.yLabel == "y"): 
     1813            if self.yLabel == "y": 
    18321814                item.transformY(transform.toX, transform.errToX) 
    18331815                self.graph._yaxis_transformed("%s" % yname, "%s" % yunits) 
    1834             if(self.yLabel == "log10(y)"): 
     1816            if self.yLabel == "log10(y)": 
    18351817                item.transformY(transform.toX_pos, transform.errToX_pos) 
    18361818                _yscale = 'log' 
    18371819                self.graph._yaxis_transformed("%s" % yname, "%s" % yunits) 
    1838             if(self.yLabel == "y^(2)"): 
     1820            if self.yLabel == "y^(2)": 
    18391821                item.transformY(transform.toX2, transform.errToX2) 
    18401822                yunits = convertUnit(2, yunits) 
    18411823                self.graph._yaxis_transformed("%s^{2}" % yname, "%s" % yunits) 
    1842             if(self.yLabel == "1/y"): 
     1824            if self.yLabel == "1/y": 
    18431825                item.transformY(transform.toOneOverX, transform.errOneOverX) 
    18441826                yunits = convertUnit(-1, yunits) 
    18451827                self.graph._yaxis_transformed("1/%s" % yname, "%s" % yunits) 
    1846             if(self.yLabel == "y*x^(4)"): 
     1828            if self.yLabel == "y*x^(4)": 
    18471829                item.transformY(transform.toYX4, transform.errToYX4) 
    18481830                xunits = convertUnit(4, self.xaxis_unit) 
    18491831                self.graph._yaxis_transformed("%s \ \ %s^{4}" % (yname, xname), 
    1850                                                "%s%s" % (yunits, xunits)) 
    1851             if(self.yLabel == "1/sqrt(y)"): 
     1832                                              "%s%s" % (yunits, xunits)) 
     1833            if self.yLabel == "1/sqrt(y)": 
    18521834                item.transformY(transform.toOneOverSqrtX, 
    18531835                                transform.errOneOverSqrtX) 
     
    18551837                self.graph._yaxis_transformed("1/\sqrt{%s}" % yname, 
    18561838                                              "%s" % yunits) 
    1857             if(self.yLabel == "ln(y*x)"): 
     1839            if self.yLabel == "ln(y*x)": 
    18581840                item.transformY(transform.toLogXY, transform.errToLogXY) 
    18591841                self.graph._yaxis_transformed("\ln (%s \ \ %s)" % (yname, xname), 
    1860                                             "%s%s" % (yunits, self.xaxis_unit)) 
    1861             if(self.yLabel == "ln(y*x^(2))"): 
    1862                 item.transformY( transform.toLogYX2, transform.errToLogYX2)  
     1842                                              "%s%s" % (yunits, self.xaxis_unit)) 
     1843            if self.yLabel == "ln(y*x^(2))": 
     1844                item.transformY(transform.toLogYX2, transform.errToLogYX2) 
    18631845                xunits = convertUnit(2, self.xaxis_unit) 
    18641846                self.graph._yaxis_transformed("\ln (%s \ \ %s^{2})" % (yname, xname), 
    1865                                                "%s%s" % (yunits, xunits)) 
    1866             if(self.yLabel == "ln(y*x^(4))"): 
     1847                                              "%s%s" % (yunits, xunits)) 
     1848            if self.yLabel == "ln(y*x^(4))": 
    18671849                item.transformY(transform.toLogYX4, transform.errToLogYX4) 
    18681850                xunits = convertUnit(4, self.xaxis_unit) 
    18691851                self.graph._yaxis_transformed("\ln (%s \ \ %s^{4})" % (yname, xname), 
    1870                                                "%s%s" % (yunits, xunits)) 
    1871             if(self.yLabel == "log10(y*x^(4))"): 
     1852                                              "%s%s" % (yunits, xunits)) 
     1853            if self.yLabel == "log10(y*x^(4))": 
    18721854                item.transformY(transform.toYX4, transform.errToYX4) 
    18731855                xunits = convertUnit(4, self.xaxis_unit) 
    18741856                _yscale = 'log' 
    18751857                self.graph._yaxis_transformed("%s \ \ %s^{4}" % (yname, xname), 
    1876                                                "%s%s" % (yunits, xunits)) 
    1877             if(self.viewModel == "Guinier lny vs x^(2)"): 
     1858                                              "%s%s" % (yunits, xunits)) 
     1859            if self.viewModel == "Guinier lny vs x^(2)": 
    18781860                item.transformX(transform.toX2, transform.errToX2) 
    18791861                xunits = convertUnit(2, xunits) 
    18801862                self.graph._xaxis_transformed("%s^{2}" % xname, "%s" % xunits) 
    1881                 item.transformY(transform.toLogX,transform.errToLogX) 
     1863                item.transformY(transform.toLogX, transform.errToLogX) 
    18821864                self.graph._yaxis_transformed("\ln\ \ %s" % yname, "%s" % yunits) 
    1883             if(self.viewModel == "Porod y*x^(4) vs x^(4)"): 
     1865            if self.viewModel == "Porod y*x^(4) vs x^(4)": 
    18841866                item.transformX(transform.toX4, transform.errToX4) 
    18851867                xunits = convertUnit(4, self.xaxis_unit) 
     
    18871869                item.transformY(transform.toYX4, transform.errToYX4) 
    18881870                self.graph._yaxis_transformed("%s \ \ %s^{4}" % (yname, xname), 
    1889                                                "%s%s" % (yunits, xunits)) 
     1871                                              "%s%s" % (yunits, xunits)) 
    18901872            item.transformView() 
    1891    
     1873 
    18921874        # set new label and units 
    18931875        yname = self.graph.prop["ylabel"] 
     
    18951877        xname = self.graph.prop["xlabel"] 
    18961878        xunits = '' 
    1897                  
     1879 
    18981880        self.resetFitView() 
    18991881        self.prevXtrans = self.xLabel 
     
    19021884        self.set_xscale(_xscale) 
    19031885        self.set_yscale(_yscale) 
    1904          
     1886 
    19051887        self.xaxis(xname, xunits, self.xaxis_font, 
    19061888                   self.xaxis_color, self.xaxis_tick) 
     
    19101892        if show: 
    19111893            self.subplot.figure.canvas.draw_idle() 
    1912          
     1894 
    19131895    def onFitDisplay(self, tempx, tempy, xminView, 
    19141896                     xmaxView, xmin, xmax, func): 
     
    19161898        Add a new plottable into the graph .In this case this plottable 
    19171899        will be used to fit some data 
    1918          
     1900 
    19191901        :param tempx: The x data of fit line 
    19201902        :param tempy: The y data of fit line 
     
    19231905        :param xmin: the lowest value of data to fit to the line 
    19241906        :param xmax: the highest value of data to fit to the line 
    1925          
     1907 
    19261908        """ 
    19271909        # Saving value to redisplay in Fit Dialog when it is opened again 
     
    19641946        if dial.ShowModal() == wx.ID_OK: 
    19651947            new_caption = dial.getText() 
    1966            
     1948 
    19671949            # send to guiframe to change the panel caption 
    19681950            caption = self.parent.on_change_caption(self.window_name, 
    19691951                                                    old_caption, new_caption) 
    1970              
     1952 
    19711953            # also set new caption in plot_panels list 
    19721954            self.parent.plot_panels[self.uid].window_caption = caption 
    19731955            # set new caption 
    19741956            self.window_caption = caption 
    1975              
     1957 
    19761958        dial.Destroy() 
    1977           
     1959 
    19781960    def onResetGraph(self, event): 
    19791961        """ 
     
    19881970        self.is_zoomed = False 
    19891971        self.toolbar.update() 
    1990          
     1972 
    19911973    def onPrinterSetup(self, event=None): 
    19921974        """ 
     
    20031985        except: 
    20041986            pass 
    2005          
     1987 
    20061988    def onPrint(self, event=None): 
    20071989        """ 
     
    20121994        except: 
    20131995            pass 
    2014       
     1996 
    20151997    def OnCopyFigureMenu(self, evt): 
    20161998        """ 
     
    20222004            print "Error in copy Image" 
    20232005 
    2024   
     2006 
    20252007#--------------------------------------------------------------- 
    20262008class NoRepaintCanvas(FigureCanvasWxAgg): 
     
    20292011    the draw method is only called for the first two paint events. After that, 
    20302012    the canvas will only be redrawn when it is resized. 
    2031      
     2013 
    20322014    """ 
    20332015    def __init__(self, *args, **kwargs): 
     
    20402022        """ 
    20412023        Called when wxPaintEvt is generated 
    2042          
     2024 
    20432025        """ 
    20442026        if not self._isRealized: 
Note: See TracChangeset for help on using the changeset viewer.