Changeset 5789654 in sasview for guitools/fitDialog.py


Ignore:
Timestamp:
Apr 7, 2008 4:31:09 PM (16 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:
8742751
Parents:
fcaada5
Message:

modied fitdialog property dialog added fittings , modified plottables

File:
1 edited

Legend:

Unmodified
Added
Removed
  • guitools/fitDialog.py

    r1bde57a r5789654  
    8989        # new data for the fit  
    9090        self.file_data1 = Theory1D(x=[], y=[], dy=None) 
    91         self.file_data1.name = "y= exp(A + bx**2)" 
     91        self.file_data1.name = "Fit" 
    9292         
    9393    def _onFit(self ,event): 
     
    9595        print "we are on fit" 
    9696        temp =[] 
    97         tempdx =[] 
    98         tempdy =[] 
    9997        xmin = self._checkVal(self.tcXmin.GetValue()) 
    10098        xmax = self._checkVal(self.tcXmax.GetValue()) 
    101         #x= self.plottable.view.x 
    102         x=self.plottable.returnXvalueOfView() 
    103         print "x value :" ,x 
     99         
     100        #store the values of View in x,y, dx,dy 
     101        x,y,dx,dy=self.plottable.returnValuesOfView() 
     102        
    104103        if x != []: 
    105104            if xmin !=None  and xmax != None: 
     
    107106                    if x[j]>xmin and x[j]<xmax: 
    108107                        temp.append(self.model.run(x[j])) 
    109                         #tempdx.append(math.sqrt(x[j])) 
     108                     
    110109                        for y_i in temp: 
    111110                            tempdy.append(math.sqrt(y_i))  
     
    114113                for x_i in x: 
    115114                    temp.append(self.model.run(x_i)) 
    116                     tempdx.append(math.sqrt(x_i)) 
    117                 for y_i in temp: 
    118                     tempdy.append(math.sqrt(y_i)) 
     115         
    119116                    self.tcXmin.SetValue(str(min(x))) 
    120117                    self.tcXmax.SetValue(str(max(x))) 
     
    124121            self.file_data1.x =x 
    125122            self.file_data1.y =temp 
    126             #self.file_data1.dx=tempdx 
     123           
    127124            self.file_data1.dx=None 
    128             #self.file_data1.dy=tempdy 
    129125            self.file_data1.dy=None 
    130              
     126            self.file_data1.reset_view() 
    131127         
    132128            # Display the fittings values 
     
    136132            cstB  = fittings.Parameter(self.model, 'B', default_B)         
    137133            chisqr, out, cov = fittings.sansfit(self.model,  
    138                 [cstA, cstB], self.plottable.view.x,  
    139                 self.plottable.view.y, self.plottable.view.dy,xmin,xmax) 
    140             # Create new data plottable with result 
     134               [cstA, cstB],x, y,dy,min(x),max(x)) 
    141135             
    142             self.file_data1.y = [] 
    143             #for x_i in self.file_data1.x: 
    144             for x_i in self.file_data1.x: 
    145                 self.file_data1.y.append(self.model.run(x_i)) 
    146                  
    147             self.push_data(self.file_data1) 
     136            
     137            #Check that cov and out are iterable before displaying them 
    148138            if cov ==None: 
    149139                errA =str(0.0) 
     
    158148                cstA=str(out[0]) 
    159149                cstB=str(out[1]) 
     150            
     151            self.model.setParam('A', float(cstA)) 
     152            self.model.setParam('B', float(cstB)) 
     153             # Create new data plottable with result 
     154            self.file_data1.y = [] 
     155            
     156            for x_i in x: 
     157                self.file_data1.y.append(self.model.run(x_i)) 
     158            #Send the data to display to the PlotPanel 
     159            self.file_data1.reset_view() 
     160            self.push_data(self.file_data1) 
     161            # Display the fitting value on the Fit Dialog 
    160162            self._onsetValues(cstA, cstB, errA,errB,str(chisqr)) 
    161163        
Note: See TracChangeset for help on using the changeset viewer.