Changeset 05da1f89 in sasview
- Timestamp:
- May 29, 2008 12:18:32 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:
- b6972a0f
- Parents:
- e39640f
- Location:
- guitools
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
guitools/PlotPanel.py
r34ab06d r05da1f89 15 15 #from plottables import Data1D 16 16 #TODO: make the plottables interactive 17 18 DEBUG = False 17 19 18 20 from plottables import Graph … … 147 149 self.ErrBvalue=None 148 150 self.Chivalue=None 151 149 152 def onWheel(self, event): 150 153 """ 151 Process mouse wheel as zoom events 154 Process mouse wheel as zoom events 155 @param event: Wheel event 152 156 """ 153 157 ax = event.inaxes … … 157 161 # Event occurred inside a plotting area 158 162 lo,hi = ax.get_xlim() 159 lo,hi = _rescale(lo,hi,step,pt=event.xdata) 160 ax.set_xlim((lo,hi)) 163 lo,hi = _rescale(lo,hi,step,pt=event.xdata,scale=ax.get_xscale()) 164 if not self.xscale=='log' or lo>0: 165 ax.set_xlim((lo,hi)) 161 166 162 167 lo,hi = ax.get_ylim() 163 lo,hi = _rescale(lo,hi,step,pt=event.ydata) 164 ax.set_ylim((lo,hi)) 168 lo,hi = _rescale(lo,hi,step,pt=event.ydata,scale=ax.get_yscale()) 169 if not self.yscale=='log' or lo>0: 170 ax.set_ylim((lo,hi)) 165 171 else: 166 172 # Check if zoom happens in the axes … … 172 178 if insidex: 173 179 xdata,_ = ax.transAxes.inverse_xy_tup((x,y)) 174 print "xaxis",x,"->",xdata175 180 insidey,_ = ax.yaxis.contains(event) 176 181 if insidey: 177 182 _,ydata = ax.transAxes.inverse_xy_tup((x,y)) 178 print "yaxis",y,"->",ydata179 183 if xdata is not None: 180 184 lo,hi = ax.get_xlim() 181 185 lo,hi = _rescale(lo,hi,step,bal=xdata,scale=ax.get_xscale()) 182 ax.set_xlim((lo,hi)) 186 if not self.xscale=='log' or lo>0: 187 ax.set_xlim((lo,hi)) 183 188 if ydata is not None: 184 189 lo,hi = ax.get_ylim() 185 190 lo,hi = _rescale(lo,hi,step,bal=ydata,scale=ax.get_yscale()) 186 ax.set_ylim((lo,hi)) 191 if not self.yscale=='log' or lo>0: 192 ax.set_ylim((lo,hi)) 187 193 188 194 self.canvas.draw_idle() … … 214 220 if len(list.keys())>0: 215 221 first_item = list.keys()[0] 216 dlg = LinearFit( None, first_item, self.onFitDisplay,self.returnTrans, -1, ' Fitting')222 dlg = LinearFit( None, first_item, self.onFitDisplay,self.returnTrans, -1, 'Linear Fit') 217 223 218 224 if (self.xmin !=0.0 )and ( self.xmax !=0.0)\ … … 493 499 self.set_xscale("log") 494 500 name, units = item.get_xaxis() 495 self.graph.xaxis("\log_{10}\ \ %s" % name, "%s^{-1}" % units)501 self.graph.xaxis("\log_{10}\ \ (%s)" % name, "%s^{-1}" % units) 496 502 497 503 if ( self.yLabel=="ln(y)" ): … … 511 517 self.set_yscale("log") 512 518 name, units = item.get_yaxis() 513 self.graph.yaxis("\log_{10}\ \ %s" % name, "%s^{-1}" % units)519 self.graph.yaxis("\log_{10}\ \ (%s)" % name, "%s^{-1}" % units) 514 520 515 521 if ( self.yLabel=="y^(2)" ): … … 523 529 self.set_yscale("linear") 524 530 name, units = item.get_yaxis() 525 self.graph.yaxis(" %s" % name, "\ \%s" % units)531 self.graph.yaxis("1/%s" % name, "\ \%s" % units) 526 532 527 533 if ( self.yLabel =="1/sqrt(y)" ): … … 529 535 self.set_yscale("linear") 530 536 name, units = item.get_yaxis() 531 self.graph.yaxis(" \sqrt{%s}" %name, "%s" % units)537 self.graph.yaxis("1/\sqrt{%s}" %name, "%s" % units) 532 538 533 539 if ( self.yLabel =="ln(y*x)"): … … 536 542 yname, yunits = item.get_yaxis() 537 543 xname, xunits = item.get_xaxis() 538 self.graph.yaxis("log\ %s %s" % (yname,xname), "%s^{-1}%s^{-1}" % (yunits,xunits))544 self.graph.yaxis("log\ (%s \ \ %s)" % (yname,xname), "%s^{-1}%s^{-1}" % (yunits,xunits)) 539 545 540 546 if ( self.yLabel =="ln(y*x^(2))"): … … 543 549 yname, yunits = item.get_yaxis() 544 550 xname, xunits = item.get_xaxis() 545 self.graph.yaxis("Log %s%s^{2}" % (yname,xname), "%s^{-1}%s^{-2}" % (yunits,xunits))551 self.graph.yaxis("Log (%s \ \ %s^{2})" % (yname,xname), "%s^{-1}%s^{-2}" % (yunits,xunits)) 546 552 547 553 if ( self.yLabel =="ln(y*x^(4))"): … … 550 556 yname, yunits = item.get_yaxis() 551 557 xname, xunits = item.get_xaxis() 552 self.graph.yaxis("Log %s%s^{4}" % (yname,xname), "%s^{-1}%s^{-4}" % (yunits,xunits))558 self.graph.yaxis("Log (%s \ \ %s^{4})" % (yname,xname), "%s^{-1}%s^{-4}" % (yunits,xunits)) 553 559 554 560 if ( self.viewModel == "Guinier lny vs x^(2)"): -
guitools/fitDialog.py
r2e07e8f r05da1f89 9 9 import transform 10 10 11 def format_number(value, high=False): 12 """ 13 Return a float in a standardized, human-readable formatted string 14 """ 15 if high: 16 return "%-6.4g" % value 17 else: 18 return "%-5.3g" % value 19 11 20 12 21 class LinearFit(wx.Dialog): 13 22 def __init__(self, parent, plottable, push_data,transform, id, title): 14 wx.Dialog.__init__(self, parent, id, title, size=(450, 400)) 23 wx.Dialog.__init__(self, parent, id, title, size=(400, 380)) 24 15 25 """ 16 26 Dialog window pops- up when select Linear fit on Context menu … … 19 29 self.parent = parent 20 30 self.transform = transform 31 21 32 #dialog panel self call function to plot the fitting function 22 33 self.push_data = push_data 23 34 #dialog self plottable 24 25 35 self.plottable = plottable 36 26 37 # Receive transformations of x and y 27 38 self.xLabel,self.yLabel,self.Avalue,self.Bvalue,\ 28 39 self.ErrAvalue,self.ErrBvalue,self.Chivalue= self.transform() 40 29 41 #Dialog interface 30 panel = wx.Panel(self, -1, style=wx.SIMPLE_BORDER)31 42 vbox = wx.BoxSizer(wx.VERTICAL) 32 43 sizer = wx.GridBagSizer(5,5) 33 44 34 vbox.Add(panel, 1, wx.EXPAND | wx.ALL)45 _BOX_WIDTH = 100 35 46 36 self.tcA = wx.TextCtrl(panel, -1,size=(120,20),style=wx.SIMPLE_BORDER) 37 self.tcErrA = wx.TextCtrl(panel, -1,size=(120,20),style=wx.SIMPLE_BORDER) 38 self.tcB = wx.TextCtrl(panel, -1,size=(120,20),style=wx.SIMPLE_BORDER) 39 self.tcErrB = wx.TextCtrl(panel, -1,size=(120,20),style=wx.SIMPLE_BORDER) 40 self.tcChi = 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 self.btFit =wx.Button(panel,-1,'Fit',size=(120, 30)) 48 self.btClose =wx.Button(panel, wx.ID_CANCEL,'Close',size=(90, 30) ) 49 self.static_line_1 = wx.StaticLine(panel, -1) 47 self.tcA = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) 48 self.tcA.SetToolTipString("Fit value for the slope parameter.") 49 self.tcErrA = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) 50 self.tcErrA.SetToolTipString("Error on the slope parameter.") 51 self.tcB = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) 52 self.tcA.SetToolTipString("Fit value for the constant parameter.") 53 self.tcErrB = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) 54 self.tcErrB.SetToolTipString("Error on the constant parameter.") 55 self.tcChi = wx.TextCtrl(self, -1,size=(_BOX_WIDTH,20)) 56 self.tcChi.SetToolTipString("Chi^2 over degrees of freedom.") 57 self.xminFit = wx.TextCtrl(self,-1,size=(_BOX_WIDTH,20)) 58 self.xminFit.SetToolTipString("Enter the minimum value on the axis to be included in the fit.") 59 self.xmaxFit = wx.TextCtrl(self,-1,size=(_BOX_WIDTH,20)) 60 self.xmaxFit.SetToolTipString("Enter the maximum value on the axis to be included in the fit.") 61 self.xminTransFit = wx.TextCtrl(self,-1,size=(_BOX_WIDTH,20)) 62 self.xmaxTransFit = wx.TextCtrl(self,-1,size=(_BOX_WIDTH,20)) 63 self.initXmin = wx.TextCtrl(self,-1,size=(_BOX_WIDTH,20)) 64 self.initXmax = wx.TextCtrl(self,-1,size=(_BOX_WIDTH,20)) 65 66 # Make the info box not editable 67 #_BACKGROUND_COLOR = '#ffdf85' 68 _BACKGROUND_COLOR = self.GetBackgroundColour() 69 self.xminTransFit.SetEditable(False) 70 self.xminTransFit.SetBackgroundColour(_BACKGROUND_COLOR) 71 self.xmaxTransFit.SetEditable(False) 72 self.xmaxTransFit.SetBackgroundColour(_BACKGROUND_COLOR) 73 self.initXmin.SetEditable(False) 74 self.initXmin.SetBackgroundColour(_BACKGROUND_COLOR) 75 self.initXmax.SetEditable(False) 76 self.initXmax.SetBackgroundColour(_BACKGROUND_COLOR) 77 78 79 # Buttons on the bottom 80 self.static_line_1 = wx.StaticLine(self, -1) 81 self.btFit =wx.Button(self,-1,'Fit') 82 self.btFit.Bind(wx.EVT_BUTTON, self._onFit) 83 self.btFit.SetToolTipString("Perform fit.") 84 self.btClose =wx.Button(self, wx.ID_CANCEL,'Close') 85 86 # Intro 87 explanation = "Perform fit for y(x) = Ax + B" 88 89 vbox.Add(sizer) 50 90 51 91 ix = 0 52 92 iy = 1 53 sizer.Add(wx.StaticText(panel, -1, 'y = Ax +B'),(iy, ix),(1,1),\ 93 sizer.Add(wx.StaticText(self, -1, explanation),(iy, ix),\ 94 (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 95 iy += 2 96 sizer.Add(wx.StaticText(self, -1, 'Parameter A'),(iy, ix),\ 97 (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 98 ix += 1 99 sizer.Add(self.tcA,(iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 100 ix += 1 101 sizer.Add(wx.StaticText(self, -1, '+/-'),(iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 102 ix += 1 103 sizer.Add(self.tcErrA, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 104 iy += 1 105 ix = 0 106 sizer.Add(wx.StaticText(self, -1, 'Parameter B'),(iy, ix),(1,1),\ 54 107 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 55 iy+=1 56 sizer.Add(wx.StaticText(panel, -1, 'Param A'),(iy, ix),\ 57 (1,1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 58 ix += 1 59 sizer.Add(self.tcA,(iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 60 ix += 1 61 sizer.Add(wx.StaticText(panel, -1, '+/-'),(iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 62 ix += 1 63 sizer.Add(self.tcErrA, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 64 iy += 1 65 ix = 0 66 sizer.Add(wx.StaticText(panel, -1, 'Param B'),(iy, ix),(1,1),\ 108 ix += 1 109 sizer.Add(self.tcB, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 110 ix += 1 111 sizer.Add(wx.StaticText(self, -1, '+/-'),(iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 112 ix += 1 113 sizer.Add(self.tcErrB, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 114 iy += 1 115 ix = 0 116 sizer.Add(wx.StaticText(self, -1, 'Chi2/dof'),(iy, ix),(1,1),\ 67 117 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 68 118 ix += 1 69 sizer.Add(self.tcB, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)70 ix += 171 sizer.Add(wx.StaticText(panel, -1, '+/-'),(iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)72 ix += 173 sizer.Add(self.tcErrB, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)74 iy += 175 ix = 076 sizer.Add(wx.StaticText(panel, -1, 'Chi ^{2}'),(iy, ix),(1,1),\77 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15)78 ix += 179 119 sizer.Add(self.tcChi, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 80 iy += 1120 iy += 2 81 121 ix = 1 82 sizer.Add(wx.StaticText( panel, -1, 'Xmin'),(iy, ix),(1,1),\122 sizer.Add(wx.StaticText(self, -1, 'Min'),(iy, ix),(1,1),\ 83 123 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 84 124 ix += 2 85 sizer.Add(wx.StaticText( panel, -1, 'Xmax'),(iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0)86 iy += 1 87 ix = 0 88 sizer.Add(wx.StaticText( panel, -1, 'Plotted Range'),(iy, ix),(1,1),\125 sizer.Add(wx.StaticText(self, -1, 'Max'),(iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 126 iy += 1 127 ix = 0 128 sizer.Add(wx.StaticText(self, -1, 'Plotted Range'),(iy, ix),(1,1),\ 89 129 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 90 130 ix +=1 … … 96 136 iy += 1 97 137 ix = 0 98 sizer.Add(wx.StaticText( panel, -1, 'Fit Range of '+self.xLabel),(iy, ix),(1,1),\138 sizer.Add(wx.StaticText(self, -1, 'Fit Range of '+self.xLabel),(iy, ix),(1,1),\ 99 139 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 100 140 ix += 1 … … 106 146 iy += 1 107 147 ix = 0 108 sizer.Add(wx.StaticText( panel, -1, 'Fit Range of x'),(iy, ix),(1,1),\148 sizer.Add(wx.StaticText(self, -1, 'Fit Range of x'),(iy, ix),(1,1),\ 109 149 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 110 150 ix += 1 … … 116 156 ix = 1 117 157 158 vbox.Add(self.static_line_1, 0, wx.EXPAND, 0) 159 160 sizer_button = wx.BoxSizer(wx.HORIZONTAL) 161 sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) 162 sizer_button.Add(self.btFit, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 163 sizer_button.Add(self.btClose, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) 164 vbox.Add(sizer_button, 0, wx.EXPAND|wx.BOTTOM|wx.TOP, 10) 165 166 167 118 168 sizer.Add(self.btFit, (iy, ix),(1,1), wx.LEFT|wx.ADJUST_MINSIZE, 0) 119 self.btFit.Bind(wx.EVT_BUTTON, self._onFit) 120 ix += 2 121 sizer.Add(self.btClose, (iy, ix),(1,1),\ 122 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 0) 123 124 panel.SetSizer(sizer) 169 170 171 #panel.SetSizer(sizer) 125 172 self.SetSizer(vbox) 126 173 self.Centre() … … 164 211 self.x,self.y,self.dx,self.dy= self.plottable.returnValuesOfView() 165 212 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)) 213 214 self.xminTransFit.SetLabel(format_number(min(self.x))) 215 self.xmaxTransFit.SetLabel(format_number(max(self.x))) 216 217 self.initXmin.SetValue(format_number(self.mini)) 218 self.initXmax.SetValue(format_number(self.maxi)) 219 220 self.xminFit.SetLabel(format_number(self.mini)) 221 self.xmaxFit.SetLabel(format_number(self.maxi)) 178 222 179 223 … … 203 247 xmaxView=self.floatTransform(xmax) 204 248 if (self.xLabel=="log10(x)"): 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() 249 self.xminTransFit.SetValue(format_number(math.log10(xminView))) 250 self.xmaxTransFit.SetValue(format_number(math.log10(xmaxView))) 251 else: 252 self.xminTransFit.SetValue(format_number(xminView)) 253 self.xmaxTransFit.SetValue(format_number(xmaxView)) 212 254 # Store the transformed values of view x, y,dy in variables before the fit 213 255 if self.yLabel.lower() == "log10(y)": … … 240 282 chisqr, out, cov = fittings.sansfit(self.model, 241 283 [self.cstA, self.cstB],tempx, tempy,tempdy,xminView,xmaxView) 242 #print "this out",out 284 285 # Use chi2/dof 286 if len(tempx)>0: 287 chisqr = chisqr/len(tempx) 288 243 289 #Check that cov and out are iterable before displaying them 244 290 if cov ==None: … … 305 351 Display the value on fit Dialog 306 352 """ 307 self.tcA.SetValue( str(cstA))308 self.tcB.SetValue( str(cstB))309 self.tcErrA.SetValue( str(errA))310 self.tcErrB.SetValue( str(errB))311 self.tcChi.SetValue( str(Chi))353 self.tcA.SetValue(format_number(cstA)) 354 self.tcB.SetValue(format_number(cstB)) 355 self.tcErrA.SetValue(format_number(errA)) 356 self.tcErrB.SetValue(format_number(errB)) 357 self.tcChi.SetValue(format_number(Chi)) 312 358 313 359 def _ongetValues(self): … … 325 371 if float(usermin) < float(usermax): 326 372 if float(usermin) >= float(self.mini) and float(usermin) < float(self.maxi): 327 self.xminFit.SetValue( str(usermin))373 self.xminFit.SetValue(format_number(float(usermin))) 328 374 else: 329 self.xminFit.SetValue( str(self.mini))375 self.xminFit.SetValue(format_number(float(self.mini))) 330 376 331 377 if float(usermax) > float(self.mini) and float(usermax) <= float(self.maxi): 332 self.xmaxFit.SetLabel( str(usermax))378 self.xmaxFit.SetLabel(format_number(float(usermax))) 333 379 else: 334 self.xmaxFit.SetLabel( str(self.maxi))380 self.xmaxFit.SetLabel(format_number(float(self.maxi))) 335 381 336 382 mini =float(self.xminFit.GetValue()) … … 377 423 Set fit parameters 378 424 """ 379 self.xminFit.SetValue(str(xmin)) 380 self.xmaxFit.SetValue(str(xmax)) 381 self.xminTransFit.SetValue(str(xminTrans)) 382 self.xmaxTransFit.SetValue(str(xmaxTrans)) 383 384 385 if __name__ == "__main__": 386 app = wx.App() 387 dialog=LinearFit(None, -1, 'Fitting') 388 dialog.ShowModal() 425 self.xminFit.SetValue(format_number(xmin)) 426 self.xmaxFit.SetValue(format_number(xmax)) 427 self.xminTransFit.SetValue(format_number(xminTrans)) 428 self.xmaxTransFit.SetValue(format_number(xmaxTrans)) 429 430 431 class MyApp(wx.App): 432 def OnInit(self): 433 wx.InitAllImageHandlers() 434 plot = Theory1D([],[]) 435 dialog = LinearFit(None, plot, self.onFitDisplay,self.returnTrans, -1, 'Linear Fit') 436 if dialog.ShowModal() == wx.ID_OK: 437 pass 438 dialog.Destroy() 439 440 return 1 441 442 def onFitDisplay(self, tempx,tempy,xminView,xmaxView,xmin,xmax,func): 443 pass 444 445 def returnTrans(self): 446 return '','',0,0,0,0,0 447 448 # end of class MyApp 449 450 if __name__ == "__main__": 451 app = MyApp(0) 389 452 app.MainLoop() 390 391 -
guitools/plottables.py
rb43a009 r05da1f89 710 710 self.dx = dx 711 711 self.dy = dy 712 self.xaxis( ' q', 'A')713 self.yaxis( ' intensity', 'cm')712 self.xaxis( '', '') 713 self.yaxis( '', '') 714 714 self.view = self.View(self.x, self.y, self.dx, self.dy) 715 715 … … 744 744 self.y = y 745 745 self.dy = dy 746 self.xaxis( ' q', 'A')747 self.yaxis( ' intensity', 'cm')746 self.xaxis( '', '') 747 self.yaxis( '', '') 748 748 self.view = self.View(self.x, self.y, None, self.dy) 749 749 -
guitools/requirements.txt
r88e7d08 r05da1f89 104 104 ALINA 105 105 1- Would like to change the y axis label display 106 107 108 Cleaning up for deployment: 109 110 - When zooming, check that the new lower bound is positive if on a log scale [DONE] 111 - Fixed bug with the zooming dependency on scale [DONE] 112 - Improved look of Fit dialog [DONE] 113 114 - Improve labels 115 116 - Problem scales: 117 - x vs 1/y 118 -
guitools/transform.py
r2e07e8f r05da1f89 27 27 else: 28 28 return math.sqrt(x) 29 29 30 def toLogX(x,y=None): 30 31 """ … … 43 44 else: 44 45 raise ValueError,"cannot divide by zero" 46 45 47 def toOneOverSqrtX(y , x=None): 46 if y!=None: 47 if y > 0: 48 return 1/math.sqrt(y) 49 else: 50 raise ValueError,"cannot be computed" 48 if y > 0: 49 return 1/math.sqrt(y) 50 else: 51 raise ValueError,"transform.toOneOverSqrtX: cannot be computed" 51 52 52 53 … … 55 56 return math.log(y*(x**2)) 56 57 else: 57 raise ValueError," cannot be computed"58 raise ValueError,"transform.toLogYX2: cannot be computed" 58 59 59 60 … … 61 62 if math.pow(x,4)*y > 0: 62 63 return math.log(math.pow(x,4)*y) 64 else: 65 raise ValueError,"transform.toLogYX4: input error" 63 66 64 67 def toLogXY(y,x): … … 94 97 if dx != None: 95 98 err = 2*x*dx 96 if math.fabs(err) >= math.fabs(x):97 err = 0.9*x98 99 return math.fabs(err) 99 100 else: 100 101 return 0.0 102 101 103 def errFromX2(x,y=None,dx=None,dy=None): 102 104 """ … … 110 112 else: 111 113 err = 0 112 if math.fabs(err) >= math.fabs(x):113 err = 0.9*x114 else:115 err = 0.9*x116 117 114 return math.fabs(err) 115 else: 116 raise ValueError, "transform.errFromX2: can't compute error of negative x" 117 118 118 def errToLog10X(x,y=None,dx=None,dy=None): 119 119 """ … … 129 129 raise ValueError, "errToLogX: divide by zero" 130 130 131 if math.fabs(dx) >= math.fabs(x):132 dx = 0.9*x133 134 131 return dx 135 132 … … 146 143 else: 147 144 raise ValueError, "errToLogX: divide by zero" 148 149 if math.fabs(dx) >= math.fabs(x):150 dx = 0.9*x151 145 152 146 return dx … … 160 154 dy=0 161 155 err =math.sqrt((2*x*y*dx)**2 +((x**2)*dy)**2) 162 #if err >= math.fabs(x):163 # err =0.9*x164 156 return err 165 157 … … 174 166 dy = 0 175 167 err = (dx/x)**2 + (dy/y)**2 176 #if math.sqrt(math.fabs(err)) >= math.fabs(x):177 # err= 0.9*x178 168 else: 179 169 raise ValueError, "cannot compute this error" … … 190 180 if (dy == None): 191 181 dy = 0 192 err = (2*dx/x)**2 + (dy/y)**2 193 #if math.fabs(err) >= math.fabs(x): 194 # err =0.9*x 182 err = (2.0*dx/x)**2 + (dy/y)**2 195 183 else: 196 184 raise ValueError, "cannot compute this error" … … 205 193 if dx ==None: 206 194 dx= 0 207 err = -(dx)**2/x**2195 err = dx/x**2 208 196 else: 209 197 raise ValueError,"Cannot compute this error" 210 198 211 if math.fabs(err)>= math.fabs(x):212 err= 0.9*x213 199 return math.fabs(err) 214 200 … … 220 206 if dx==None: 221 207 dx =0 222 err= -1/2*math.pow(x, -3/2)* dx 223 #if math.fabs(err)>= math.fabs(x): 224 # err=0.9*x 208 err= -1/2*math.pow(x, -3.0/2.0)* dx 225 209 else: 226 210 raise ValueError, "Cannot compute this error" 227 211 228 212 return math.fabs(err) 213 229 214 def errToLogYX4(x,y=None,dx=None,dy=None): 230 215 """ … … 236 221 if dy==None: 237 222 dy=0 238 err =math.sqrt((4*dx/x)**2 +(dy/y)**2) 239 #if err >= math.fabs(x): 240 #err =0.9*x 223 err =math.sqrt((4.0*dx/x)**2 +(dy/y)**2) 241 224 return err 242 225
Note: See TracChangeset
for help on using the changeset viewer.