Changeset d902cf0 in sasview


Ignore:
Timestamp:
Apr 21, 2009 11:25:24 AM (15 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
2501cf7
Parents:
70cf5d3
Message:

selecting data for fit allow for some data only

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansview/perspectives/fitting/fitting.py

    r513115c rd902cf0  
    167167        self.graph=graph 
    168168        for item in graph.plottables: 
    169             if hasattr(item,"is_data"): 
    170                 if item.is_data== False: 
    171                     return [] 
    172             
    173169            if item.__class__.__name__ is "Data2D": 
     170                if hasattr(item,"is_data"): 
     171                    if item.is_data: 
     172                        return [["Select data  for Fitting", \ 
     173                         "Dialog with fitting parameters ", self._onSelect]] 
     174                    else: 
     175                        return []  
    174176                return [["Select data  for Fitting",\ 
    175177                          "Dialog with fitting parameters ", self._onSelect]]  
    176178            else: 
    177                 
    178179                if item.name==graph.selected_plottable : 
    179                     if not hasattr(item, "group_id"): 
    180                         return [] 
    181                     return [["Select data  for Fitting", \ 
    182                              "Dialog with fitting parameters ", self._onSelect]]  
     180                    if hasattr(item, "group_id"): 
     181                        if hasattr(item,"is_data"): 
     182                            if item.is_data: 
     183                                return [["Select data  for Fitting", \ 
     184                                 "Dialog with fitting parameters ", self._onSelect]] 
     185                            else: 
     186                                return []  
     187                        else: 
     188                            return [["Select data  for Fitting", \ 
     189                                 "Dialog with fitting parameters ", self._onSelect]]  
    183190        return []    
    184191 
     
    234241 
    235242 
    236     def copy_data(self, item, dy): 
     243    def copy_data(self, item, dy=None): 
    237244        """ 
    238245            receive a data 1D and the list of errors on dy 
     
    260267             
    261268        from sans.guiframe import dataFitting  
    262          
    263269        data= dataFitting.Data1D(x=item.x, y=item.y, dy=dy, dxl=dxl, dxw=dxw) 
    264270         
     
    273279        ## to save  data 1D as cansas xml file 
    274280        data.info= info 
    275         is_data=False 
    276         if hasattr(item, "is_data"): 
    277             is_data= item.is_data 
    278         data.is_data = is_data 
    279281        ## If the data file does not tell us what the axes are, just assume... 
    280282        data.xaxis(copy.deepcopy(item._xaxis),copy.deepcopy(item._xunit)) 
     
    583585             
    584586            if plottable.name == self.panel.graph.selected_plottable: 
    585                 if not hasattr(plottable, "is_data")or \ 
    586                     plottable.__class__.__name__=="Theory1D": 
     587                #if not hasattr(plottable, "is_data"): 
     588                     
     589                if  plottable.__class__.__name__=="Theory1D": 
    587590                    dy=numpy.zeros(len(plottable.y)) 
    588591                    if hasattr(plottable, "dy"): 
    589592                        dy= copy.deepcopy(plottable.dy) 
     593                         
    590594                    item= self.copy_data(plottable, dy) 
    591595                    item.group_id += "data1D" 
     
    595599                    wx.PostEvent(self.parent, NewPlotEvent(plot=item, title=str(title))) 
    596600                else: 
    597                     item= copy.deepcopy(plottable)   
     601                    item= self.copy_data(plottable, plottable.dy)   
     602                    item.is_data=True 
     603                     
    598604                ## put the errors values back to the model if the errors were hiden 
    599605                ## before sending them to the fit engine 
     
    602608                        dy= self.err_dy[item.name] 
    603609                        data= self.copy_data(item, dy) 
     610                        data.is_data= item.is_data 
    604611                    else: 
    605                         data= copy.deepcopy(item) 
     612                        data= self.copy_data(item) 
     613                        data.is_data= item.is_data 
     614                         
     615                        
    606616                else: 
    607617                    if item.dy==None: 
    608618                        dy= numpy.zeros(len(item.y)) 
    609619                        data= self.copy_data(item, dy) 
     620                        data.is_data=item.is_data 
    610621                    else: 
    611                         data= copy.deepcopy(item) 
     622                        data= self.copy_data(item) 
     623                        data.is_data=item.is_data 
     624                        
    612625            else: 
    613626                ## Data2D case 
     
    624637                    item= copy.deepcopy(plottable ) 
    625638                    data= copy.deepcopy(plottable ) 
     639                    item.is_data=True 
     640                    data.is_data=True 
    626641            ## create anew page                    
    627642            if item.name == self.panel.graph.selected_plottable or\ 
     
    643658                        wx.PostEvent(self.parent, StatusEvent(status="Page was already Created")) 
    644659                except: 
    645                     wx.PostEvent(self.parent, StatusEvent(status="Creating Fit page: %s"\ 
    646                     %sys.exc_value)) 
    647                     return 
     660                    raise 
     661                    #wx.PostEvent(self.parent, StatusEvent(status="Creating Fit page: %s"\ 
     662                    #%sys.exc_value)) 
     663                    #return 
    648664    def _updateFit(self): 
    649665        """ 
     
    667683       
    668684        try: 
     685            if numpy.any(result.pvec ==None )or not numpy.all(numpy.isfinite(result.pvec) ): 
     686                msg= "Fitting did not converge!!!" 
     687                wx.PostEvent(self.parent, StatusEvent(status=msg,type="stop")) 
     688                return 
    669689            for page, value in self.page_finder.iteritems(): 
    670690                if page==cpage : 
     
    972992                    new_plot.id += "Model" 
    973993                new_plot.is_data =False  
    974             # Pass the reset flag to let the plotting event handler 
    975             # know that we are replacing the whole plot 
     994            
    976995            from DataLoader.data_info import Data1D 
    977996            info= Data1D(x= new_plot.x, y=new_plot.y) 
     
    9811000            info.yaxis( new_plot._yaxis, new_plot._yunit) 
    9821001            new_plot.info = info 
     1002            # Pass the reset flag to let the plotting event handler 
     1003            # know that we are replacing the whole plot 
    9831004            if title== None: 
    9841005                title = "Analytical model 1D " 
Note: See TracChangeset for help on using the changeset viewer.