Changeset 6ed82c7 in sasview for sansview/perspectives


Ignore:
Timestamp:
Apr 17, 2009 12:44:58 PM (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:
41340860
Parents:
882a912
Message:

fitting model change

File:
1 edited

Legend:

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

    r3fef0a8 r6ed82c7  
    77from sans.guicomm.events import NewPlotEvent, StatusEvent   
    88from sans.guicomm.events import EVT_SLICER_PANEL,ERR_DATA 
    9  
     9from sans.guiframe import dataFitting 
    1010from sans.fit.AbstractFitEngine import Model,FitData1D,FitData2D 
     11 
    1112from fitproblem import FitProblem 
    1213from fitpanel import FitPanel 
     
    1415import models 
    1516import fitpage 
     17 
    1618 
    1719DEFAULT_BEAM = 0.005 
     
    254256             
    255257        from sans.guiframe import dataFitting  
    256         if item.__class__.__name__=="Data1D": 
    257             data= dataFitting.Data1D(x=item.x, y=item.y, dy=dy, dxl=dxl, dxw=dxw) 
    258         else: 
    259             data= dataFitting.Theory1D(x=item.x, y=item.y, dxl=dxl, dxw=dxw) 
     258         
     259        data= dataFitting.Data1D(x=item.x, y=item.y, dy=dy, dxl=dxl, dxw=dxw) 
     260         
    260261        data.name = item.name 
    261262        data.detector = detector 
     
    268269        ## to save  data 1D as cansas xml file 
    269270        data.info= info 
     271        is_data=False 
     272        if hasattr(item, "is_data"): 
     273            is_data= item.is_data 
     274        data.is_data = is_data 
    270275        ## If the data file does not tell us what the axes are, just assume... 
    271276        data.xaxis(copy.deepcopy(item._xaxis),copy.deepcopy(item._xunit)) 
     
    561566        """ 
    562567        self.panel = event.GetEventObject() 
    563         for item in self.panel.graph.plottables: 
    564              
    565             if item.name == self.panel.graph.selected_plottable: 
     568        for plottable in self.panel.graph.plottables: 
     569             
     570            if plottable.name == self.panel.graph.selected_plottable: 
     571                if not hasattr(plottable, "is_data")or \ 
     572                    plottable.__class__.__name__=="Theory1D": 
     573                    dy=numpy.zeros(len(plottable.y)) 
     574                    if hasattr(plottable, "dy"): 
     575                        dy= copy.deepcopy(plottable.dy) 
     576                    item= self.copy_data(plottable, dy) 
     577                    item.group_id += "data1D" 
     578                    item.id +="data1D" 
     579                    item.is_data= False 
     580                    title = item.name 
     581                    wx.PostEvent(self.parent, NewPlotEvent(plot=item, title=str(title))) 
     582                else: 
     583                    item= copy.deepcopy(plottable)   
    566584                ## put the errors values back to the model if the errors were hiden 
    567585                ## before sending them to the fit engine 
     
    579597                        data= copy.deepcopy(item) 
    580598            else: 
    581                 data= copy.deepcopy(item) 
     599                ## Data2D case 
     600                if not hasattr(plottable, "is_data"): 
     601                    item= copy.deepcopy(plottable) 
     602                    item.group_id += "data2D" 
     603                    item.id +="data2D" 
     604                    item.is_data= False 
     605                    title = item.name 
     606                    title += " Fit" 
     607                    data = item 
     608                    wx.PostEvent(self.parent, NewPlotEvent(plot=item, title=str(title))) 
     609                else: 
     610                    item= copy.deepcopy(plottable ) 
     611                    data= copy.deepcopy(plottable ) 
    582612            ## create anew page                    
    583613            if item.name == self.panel.graph.selected_plottable or\ 
     
    588618                    if page !=None:    
    589619                        #create a fitproblem storing all link to data,model,page creation 
    590                         self.page_finder[page]= FitProblem() 
     620                        if not page in self.page_finder.keys(): 
     621                            self.page_finder[page]= FitProblem() 
    591622                        ## item is almost the same as data but contains 
    592623                        ## axis info for plotting  
     
    930961            title= my_info.title 
    931962            if title== None: 
    932                 title="Analytical model 1D " 
     963                title = "Analytical model 1D " 
    933964                wx.PostEvent(self.parent, NewPlotEvent(plot=new_plot, 
    934965                             title= str(title), reset=True )) 
     
    9841015            theory.xmin= data.xmin 
    9851016            theory.xmax= data.xmax 
     1017        print "model comptele plot",theory.xmin,theory.xmax,theory.ymin,theory.ymin 
    9861018        
    9871019        ## plot 
Note: See TracChangeset for help on using the changeset viewer.