Changeset f63f5ff in sasview for guitools/fitDialog.py


Ignore:
Timestamp:
Apr 3, 2008 10:43:04 AM (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:
d490a02
Parents:
f0c09d5
Message:

is working better

File:
1 edited

Legend:

Unmodified
Added
Removed
  • guitools/fitDialog.py

    r061775ff rf63f5ff  
    2626        vbox.Add(panel, 1, wx.EXPAND | wx.ALL) 
    2727  
    28         self.tcA = wx.TextCtrl(panel, -1,style=wx.SIMPLE_BORDER) 
    29         self.tcErrA = wx.TextCtrl(panel, -1,style=wx.SIMPLE_BORDER) 
    30         self.tcB = wx.TextCtrl(panel, -1,style=wx.SIMPLE_BORDER) 
    31         self.tcErrB = wx.TextCtrl(panel, -1,style=wx.SIMPLE_BORDER) 
    32         self.tcChi = wx.TextCtrl(panel, -1,style=wx.SIMPLE_BORDER) 
     28        self.tcA = wx.TextCtrl(panel, -1,size=(120,20),style=wx.SIMPLE_BORDER) 
     29        self.tcErrA = wx.TextCtrl(panel, -1,size=(120,20),style=wx.SIMPLE_BORDER) 
     30        self.tcB = wx.TextCtrl(panel, -1,size=(120,20),style=wx.SIMPLE_BORDER) 
     31        self.tcErrB = wx.TextCtrl(panel, -1,size=(120,20),style=wx.SIMPLE_BORDER) 
     32        self.tcChi = wx.TextCtrl(panel, -1,size=(120,20),style=wx.SIMPLE_BORDER) 
    3333        self.tcXmin = wx.TextCtrl(panel,-1,style=wx.SIMPLE_BORDER) 
    3434        self.tcXmax = wx.TextCtrl(panel,-1,style=wx.SIMPLE_BORDER) 
     
    9393        print "we are on fit" 
    9494        temp =[] 
    95         #tempdx =[] 
     95        tempdx =[] 
    9696        tempdy =[] 
    9797        xmin = self._checkVal(self.tcXmin.GetValue()) 
    9898        xmax = self._checkVal(self.tcXmax.GetValue()) 
    99         x= self.plottable.x 
    100         if x: 
     99        #x= self.plottable.view.x 
     100        x=self.plottable.returnXvalueOfView() 
     101        print "x value :" ,x 
     102        if x != []: 
    101103            if xmin !=None  and xmax != None: 
    102104                for j in range(len(x)): 
     
    113115                for y_i in temp: 
    114116                    tempdy.append(math.sqrt(y_i)) 
    115                     self.tcXmin.SetValue(str(min(self.plottable.x))) 
    116                     self.tcXmax.SetValue(str(max(self.plottable.x))) 
     117                    self.tcXmin.SetValue(str(min(x))) 
     118                    self.tcXmax.SetValue(str(max(x))) 
    117119                    xmin = self._checkVal(self.tcXmin.GetValue()) 
    118120                    xmax = self._checkVal(self.tcXmax.GetValue()) 
     
    132134            cstB  = fittings.Parameter(self.model, 'B', default_B)         
    133135            chisqr, out, cov = fittings.sansfit(self.model,  
    134                 [cstA, cstB], self.plottable.x,  
    135                 self.plottable.y, self.plottable.dy,xmin,xmax) 
     136                [cstA, cstB], self.plottable.view.x,  
     137                self.plottable.view.y, self.plottable.view.dy,xmin,xmax) 
    136138            # Create new data plottable with result 
    137139             
    138140            self.file_data1.y = [] 
     141            #for x_i in self.file_data1.x: 
    139142            for x_i in self.file_data1.x: 
    140143                self.file_data1.y.append(self.model.run(x_i)) 
    141144                 
    142145            self.push_data(self.file_data1) 
    143              
    144             self._onsetValues(str(out[0]),str(out[1]),\ 
    145             str(math.sqrt(cov[0][0])),str(math.sqrt(cov[1][1])),str(chisqr)) 
     146            if cov ==None: 
     147                errA =str(0.0) 
     148                errB =str(0.0) 
     149            else: 
     150                errA= str(math.sqrt(cov[0][0])) 
     151                errB= str(math.sqrt(cov[1][1])) 
     152            if out==None: 
     153                cstA=str(0.0) 
     154                cstB=str(0.0) 
     155            else: 
     156                cstA=str(out[0]) 
     157                cstB=str(out[1]) 
     158            self._onsetValues(cstA, cstB, errA,errB,str(chisqr)) 
    146159        
    147160    def _onsetValues(self,cstA,cstB,errA,errB,Chi): 
     
    149162         self.tcA.SetValue(cstA) 
    150163         self.tcB.SetValue(cstB) 
    151          self.tcErrA.SetValue(cstB) 
    152          self.tcErrB.SetValue(cstA) 
     164         self.tcErrA.SetValue(errA) 
     165         self.tcErrB.SetValue(errB) 
    153166         self.tcChi.SetValue(Chi) 
    154167          
Note: See TracChangeset for help on using the changeset viewer.