- Timestamp:
- May 5, 2008 4:07:20 PM (17 years ago)
- 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:
- 5e14aee
- Parents:
- 49c8dc5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
guitools/fitDialog.py
r49c8dc5 r83fe2cc 39 39 self.tcErrB = wx.TextCtrl(panel, -1,size=(120,20),style=wx.SIMPLE_BORDER) 40 40 self.tcChi = wx.TextCtrl(panel, -1,size=(120,20),style=wx.SIMPLE_BORDER) 41 self. FXmin= wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER)42 self. FXmax= wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER)43 self. FXminX= wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER)44 self. FXmaxX= wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER)45 self. PXmin = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER)46 self. PXmax = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER)41 self.xminFit = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER) 42 self.xmaxFit = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER) 43 self.xminTransFit = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER) 44 self.xmaxTransFit = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER) 45 self.initXmin = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER) 46 self.initXmax = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER) 47 47 self.btFit =wx.Button(panel,-1,'Fit',size=(120, 30)) 48 48 self.btClose =wx.Button(panel, wx.ID_CANCEL,'Close',size=(90, 30) ) … … 89 89 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 90 90 ix +=1 91 sizer.Add(self. PXmin, (iy, ix),(1,1),\91 sizer.Add(self.initXmin, (iy, ix),(1,1),\ 92 92 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 93 93 ix += 2 94 sizer.Add(self. PXmax, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)94 sizer.Add(self.initXmax, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 95 95 96 96 iy += 1 … … 99 99 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 100 100 ix += 1 101 sizer.Add(self. FXmin, (iy, ix),(1,1),\101 sizer.Add(self.xminTransFit, (iy, ix),(1,1),\ 102 102 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 103 103 ix += 2 104 sizer.Add(self. FXmax, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)104 sizer.Add(self.xmaxTransFit, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 105 105 106 106 iy += 1 … … 109 109 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 110 110 ix += 1 111 sizer.Add(self. FXminX, (iy, ix),(1,1),\111 sizer.Add(self.xminFit, (iy, ix),(1,1),\ 112 112 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 113 113 ix += 2 114 sizer.Add(self. FXmaxX, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)114 sizer.Add(self.xmaxFit, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 115 115 iy += 1 116 116 ix = 1 … … 161 161 self.mini =min(self.plottable.x) 162 162 self.maxi =max(self.plottable.x) 163 xView,yView,dxView,dyView= self.plottable.returnValuesOfView() 164 165 self.FXmin.SetLabel(str(min(xView))) 166 self.FXmax.SetLabel(str(max(xView))) 167 self.FXmin.Disable() 168 self.FXmax.Disable() 169 170 self.PXmin.SetValue(str(self.mini)) 171 self.PXmax.SetValue(str(self.maxi)) 172 self.PXmin.Disable() 173 self.PXmax.Disable() 174 175 self.FXminX.SetLabel(str(self.mini)) 176 self.FXmaxX.SetLabel(str(self.maxi)) 163 #store the values of View in self.x,self.y,self.dx,self.dy 164 self.x,self.y,self.dx,self.dy= self.plottable.returnValuesOfView() 165 166 self.xminTransFit.SetLabel(str(min(self.x))) 167 self.xmaxTransFit.SetLabel(str(max(self.x))) 168 self.xminTransFit.Disable() 169 self.xmaxTransFit.Disable() 170 171 self.initXmin.SetValue(str(self.mini)) 172 self.initXmax.SetValue(str(self.maxi)) 173 self.initXmin.Disable() 174 self.initXmax.Disable() 175 176 self.xminFit.SetLabel(str(self.mini)) 177 self.xmaxFit.SetLabel(str(self.maxi)) 177 178 178 179 … … 187 188 tempdy = [] 188 189 189 #store the values of View in x,y, dx,dy190 x,y,dx,dy=self.plottable.returnValuesOfView()190 191 191 192 192 193 # Check if View contains a x array .we online fit when x exits 193 194 # makes transformation for y as a line to fit 194 if x != []:195 196 197 if(self.checkFitValues(self. FXminX) == True):195 if self.x != []: 196 197 198 if(self.checkFitValues(self.xminFit) == True): 198 199 #Check if the field of Fit Dialog contain values and use the x max and min of the user 199 xmin,xmax = self._checkVal(self. FXminX.GetValue(),self.FXmaxX.GetValue())200 xmin,xmax = self._checkVal(self.xminFit.GetValue(),self.xmaxFit.GetValue()) 200 201 201 202 xminView=self.floatTransform(xmin) 202 203 xmaxView=self.floatTransform(xmax) 203 204 if (self.xLabel=="log10(x)"): 204 self. FXmin.SetValue(str(math.log10(xminView)))205 self. FXmax.SetValue(str(math.log10(xmaxView)))206 else: 207 self. FXmin.SetValue(str(xminView))208 self. FXmax.SetValue(str(xmaxView))209 self. FXmin.Disable()210 self. FXmax.Disable()205 self.xminTransFit.SetValue(str(math.log10(xminView))) 206 self.xmaxTransFit.SetValue(str(math.log10(xmaxView))) 207 else: 208 self.xminTransFit.SetValue(str(xminView)) 209 self.xmaxTransFit.SetValue(str(xmaxView)) 210 self.xminTransFit.Disable() 211 self.xmaxTransFit.Disable() 211 212 # Store the transformed values of view x, y,dy in variables before the fit 212 213 if self.yLabel.lower() == "log10(y)": 213 214 if (self.xLabel.lower() == "log10(x)"): 214 for i in range(len( x)):215 if x[i]>= math.log10(xmin):216 tempy.append(math.log10( y[i]))217 tempdy.append(transform.errToLogX( y[i],0,dy[i],0))215 for i in range(len(self.x)): 216 if self.x[i]>= math.log10(xmin): 217 tempy.append(math.log10(self.y[i])) 218 tempdy.append(transform.errToLogX(self.y[i],0,self.dy[i],0)) 218 219 else: 219 for i in range(len( y)):220 tempy.append(math.log10( y[i]))221 tempdy.append(transform.errToLogX( y[i],0,dy[i],0))222 else: 223 tempy = y224 tempdy = dy220 for i in range(len(self.y)): 221 tempy.append(math.log10(self.y[i])) 222 tempdy.append(transform.errToLogX(self.y[i],0,self.dy[i],0)) 223 else: 224 tempy = self.y 225 tempdy = self.dy 225 226 226 227 if (self.xLabel.lower() == "log10(x)"): 227 for x_i in x:228 for x_i in self.x: 228 229 if x_i >= math.log10(xmin): 229 230 tempx.append(math.log10(x_i)) 230 231 else: 231 tempx = x232 tempx = self.x 232 233 233 234 #Find the fitting parameters … … 287 288 else: 288 289 tempy.append(y_model) 290 #Set the fit parameter display when FitDialog is opened again 289 291 self.Avalue=cstA 290 292 self.Bvalue=cstB … … 315 317 return self.Avalue, self.Bvalue,self.ErrAvalue,self.ErrBvalue,self.Chivalue 316 318 317 def _returnPlottable(self):318 return self.file_data1319 319 320 320 def _checkVal(self,usermin, usermax): … … 325 325 if float(usermin) < float(usermax): 326 326 if float(usermin) >= float(self.mini) and float(usermin) < float(self.maxi): 327 self. FXminX.SetValue(str(usermin))327 self.xminFit.SetValue(str(usermin)) 328 328 else: 329 self. FXminX.SetValue(str(self.mini))329 self.xminFit.SetValue(str(self.mini)) 330 330 331 331 if float(usermax) > float(self.mini) and float(usermax) <= float(self.maxi): 332 self. FXmaxX.SetLabel(str(usermax))332 self.xmaxFit.SetLabel(str(usermax)) 333 333 else: 334 self. FXmaxX.SetLabel(str(self.maxi))335 336 mini =float(self. FXminX.GetValue())337 maxi =float(self. FXmaxX.GetValue())334 self.xmaxFit.SetLabel(str(self.maxi)) 335 336 mini =float(self.xminFit.GetValue()) 337 maxi =float(self.xmaxFit.GetValue()) 338 338 339 339 return mini, maxi … … 373 373 return flag 374 374 375 def setFitRange(self,xmin,xmax,Reelxmin,Reelxmax): 376 if (self.xLabel=="log10(x)"): 377 self.FXmin.SetValue(str(math.log10(xmin))) 378 self.FXmax.SetValue(str(math.log10(xmax))) 379 else: 380 self.FXmin.SetValue(str(xmin)) 381 self.FXmax.SetValue(str(xmax)) 382 self.FXminX.SetValue(str(Reelxmin)) 383 self.FXmaxX.SetValue(str(Reelxmax)) 375 def setFitRange(self,xmin,xmax,xminTrans,xmaxTrans): 376 """ 377 Set fit parameters 378 """ 379 self.xminFit.SetValue(str(xmin)) 380 self.xmaxFit.SetValue(str(xmax)) 381 self.xminTransFit.SetValue(str(xminTrans)) 382 self.xmaxTransFit.SetValue(str(xmaxTrans)) 384 383 385 384
Note: See TracChangeset
for help on using the changeset viewer.