- Timestamp:
- May 1, 2008 6:43:06 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:
- 90640f2
- Parents:
- bbec827
- Location:
- guitools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
guitools/PlotPanel.py
rbbec827 rddff053 108 108 #self.fit_result = Data1D(x=[], y=[],dx=None, dy=None) 109 109 self.fit_result.name = "Fit" 110 self.fit_result.ID = "isFit" 111 110 self.xmin=0.0 111 self.xmax=0.0 112 self.xminView=0.0 113 self.xmaxView=0.0 112 114 def onWheel(self, event): 113 115 """ … … 115 117 """ 116 118 ax = event.inaxes 117 118 119 step = event.step 119 120 … … 175 176 first_item = list.keys()[0] 176 177 dlg = LinearFit( None, first_item, self.onFitDisplay,self.returnTrans, -1, 'Fitting') 178 if (self.xmin !=0.0 )and ( self.xmax !=0.0)\ 179 and(self.xminView !=0.0 )and ( self.xmaxView !=0.0): 180 dlg.setFitRange(self.xminView,self.xmaxView,self.xmin,self.xmax) 177 181 dlg.ShowModal() 178 182 … … 524 528 self.subplot.figure.canvas.draw_idle() 525 529 526 def onFitDisplay(self, tempx,tempy,xmin ,xmax):530 def onFitDisplay(self, tempx,tempy,xminView,xmaxView,xmin,xmax): 527 531 """ 528 532 Add a new plottable into the graph .In this case this plottable will be used … … 535 539 list = self.graph.returnPlottable() 536 540 for item in list: 537 item.onFitRange(xmin,xmax) 541 item.onFitRange(xminView,xmaxView) 542 self.xminView=xminView 543 self.xmaxView=xmaxView 544 self.xmin= xmin 545 self.xmax= xmax 538 546 # Create new data plottable with result 539 547 self.fit_result.x =[] -
guitools/fitDialog.py
rbbec827 rddff053 13 13 #def __init__(self, parent, id, title): 14 14 def __init__(self, parent, plottable, push_data,transform, id, title): 15 wx.Dialog.__init__(self, parent, id, title, size=(450, 300))15 wx.Dialog.__init__(self, parent, id, title, size=(450, 500)) 16 16 """ 17 17 for the fit window … … 23 23 #dialog self plottable 24 24 self.plottable = plottable 25 25 # Receive transformations of x and y 26 self.xtrans,self.ytrans= self.transform() 26 27 #Dialog interface 27 28 panel = wx.Panel(self, -1, style=wx.SIMPLE_BORDER) … … 38 39 self.FXmin = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER) 39 40 self.FXmax = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER) 41 self.FXminX = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER) 42 self.FXmaxX = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER) 40 43 self.PXmin = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER) 41 44 self.PXmax = wx.TextCtrl(panel,-1,size=(120,20),style=wx.SIMPLE_BORDER) … … 89 92 sizer.Add(self.PXmax, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 90 93 iy += 1 94 ix = 1 95 sizer.Add(wx.StaticText(panel, -1,"x transofrmation is: "+self.xtrans ),(iy, ix),(1,1),\ 96 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 97 iy += 1 91 98 ix = 0 92 99 sizer.Add(wx.StaticText(panel, -1, 'Fit Range'),(iy, ix),(1,1),\ … … 97 104 ix += 2 98 105 sizer.Add(self.FXmax, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 106 107 #iy += 1 108 #ix = 1 109 #sizer.Add(wx.StaticText(panel, -1,"x is: "),(iy, ix),(1,1),\ 110 # wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 111 iy += 1 112 ix = 0 113 sizer.Add(wx.StaticText(panel, -1, 'Fit Range of x'),(iy, ix),(1,1),\ 114 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 115 ix += 1 116 sizer.Add(self.FXminX, (iy, ix),(1,1),\ 117 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 118 ix += 2 119 sizer.Add(self.FXmaxX, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 99 120 iy += 1 100 121 ix = 1 … … 131 152 self.FXmin.SetLabel(str(self.mini)) 132 153 self.FXmax.SetLabel(str(self.maxi)) 133 154 self.FXminX.SetLabel(str(self.mini)) 155 self.FXmaxX.SetLabel(str(self.maxi)) 156 self.FXmin.Disable() 157 self.FXmax.Disable() 134 158 self.PXmin.SetValue(str(self.mini)) 135 159 self.PXmax.SetValue(str(self.maxi)) 136 160 self.PXmin.Disable() 137 161 self.PXmax.Disable() 138 162 139 163 # new data for the fit 140 164 #self.file_data1 = Theory1D(x=[], y=[], dy=None) … … 153 177 tempy=[] 154 178 tempdy = [] 155 179 156 180 #store the values of View in x,y, dx,dy 157 181 x,y,dx,dy=self.plottable.returnValuesOfView() … … 162 186 # makes transformation for y as a line to fit 163 187 if x != []: 188 189 164 190 if(self.checkFitValues(self.FXmin) == True): 165 191 #Check if the field of Fit Dialog contain values and use the x max and min of the user 166 xmin,xmax = self._checkVal(self.FXmin.GetValue(),self.FXmax.GetValue()) 192 xmin,xmax = self._checkVal(self.FXminX.GetValue(),self.FXmaxX.GetValue()) 193 167 194 xminView=self.floatTransform(xmin) 168 195 xmaxView=self.floatTransform(xmax) 169 196 self.FXmin.SetValue(str(xminView)) 197 self.FXmax.SetValue(str(xmaxView)) 198 self.FXmin.Disable() 199 self.FXmax.Disable() 170 200 # Store the transformed values of view x, y,dy in variables before the fit 171 201 if self.ytrans.lower() == "log10(y)": … … 197 227 198 228 #Find the fitting parameters 229 199 230 if (self.xtrans.lower() == "log10(x)"): 200 231 chisqr, out, cov = fittings.sansfit(self.model, [self.cstA, self.cstB], … … 251 282 else: 252 283 tempy.append(y_model) 253 254 # Create new data plottable with result 255 #self.file_data1.x =[] 256 #self.file_data1.y =[] 257 #self.file_data1.x =tempx 258 #self.file_data1.y =tempy 259 #self.file_data1.dx=None 260 #self.file_data1.dy=None 261 #Load the view with the new values 262 #self.file_data1.reset_view() 263 264 #Send the data to display to the PlotPanel 265 #self.push_data(self.file_data1,xminView,xmaxView) 266 self.push_data(tempx,tempy,xminView,xmaxView) 284 285 self.push_data(tempx,tempy,xminView,xmaxView,xmin,xmax) 267 286 268 287 # Display the fitting value on the Fit Dialog … … 289 308 if float(usermin) < float(usermax): 290 309 if float(usermin) >= float(self.mini) and float(usermin) < float(self.maxi): 291 self.FXmin .SetValue(str(usermin))310 self.FXminX.SetValue(str(usermin)) 292 311 else: 293 self.FXmin .SetValue(str(self.mini))312 self.FXminX.SetValue(str(self.mini)) 294 313 295 314 if float(usermax) > float(self.mini) and float(usermax) <= float(self.maxi): 296 self.FXmax .SetLabel(str(usermax))315 self.FXmaxX.SetLabel(str(usermax)) 297 316 else: 298 self.FXmax .SetLabel(str(self.maxi))299 300 mini =float(self.FXmin .GetValue())301 maxi =float(self.FXmax .GetValue())317 self.FXmaxX.SetLabel(str(self.maxi)) 318 319 mini =float(self.FXminX.GetValue()) 320 maxi =float(self.FXmaxX.GetValue()) 302 321 303 322 return mini, maxi … … 337 356 return flag 338 357 339 358 def setFitRange(self,xmin,xmax,Reelxmin,Reelxmax): 359 360 self.FXmin.SetValue(str(math.log10(xmin))) 361 self.FXmax.SetValue(str(math.log10(xmax))) 362 363 self.FXmin.SetValue(str(xmin)) 364 self.FXmax.SetValue(str(xmax)) 365 self.FXminX.SetValue(str(Reelxmin)) 366 self.FXmaxX.SetValue(str(Reelxmax)) 367 340 368 341 369 if __name__ == "__main__": -
guitools/plottables.py
rbbec827 rddff053 447 447 dx = None 448 448 dy = None 449 ID = "" 449 450 450 451 451 def __init__(self, x=None, y=None, dx=None, dy=None): … … 641 641 """ 642 642 self.name = "data" 643 self.ID= ""644 643 self.x = x 645 644 self.y = y … … 680 679 self.y = y 681 680 self.dy = dy 682 self.ID= ""683 681 self.xaxis( 'q', 'A') 684 682 self.yaxis( 'intensity', 'cm')
Note: See TracChangeset
for help on using the changeset viewer.