- Timestamp:
- May 5, 2008 2:44:40 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:
- edce46e
- Parents:
- 2d06beb
- Location:
- guitools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
guitools/PlotPanel.py
r150c04a rb43a009 116 116 self.symbollist = ['o','x','^','v','<','>','+','s','d','D','h','H','p'] 117 117 #User scale 118 self.x scales="x"119 self.y scales="log10(y)"118 self.xLabel ="x" 119 self.yLabel ="log10(y)" 120 120 self.viewModel ="--" 121 121 # keep track if the previous transformation of x and y in Property dialog … … 128 128 #self.fit_result = Data1D(x=[], y=[],dx=None, dy=None) 129 129 self.fit_result.name = "Fit" 130 # For fit Dialog initial display 130 131 self.xmin=0.0 131 132 self.xmax=0.0 132 133 self.xminView=0.0 133 134 self.xmaxView=0.0 135 self.Avalue=None 136 self.Bvalue=None 137 self.ErrAvalue=None 138 self.ErrBvalue=None 139 self.Chivalue=None 140 def resetFitView(self): 141 # For fit Dialog initial display 142 self.xmin=0.0 143 self.xmax=0.0 144 self.xminView=0.0 145 self.xmaxView=0.0 146 self.Avalue=None 147 self.Bvalue=None 148 self.ErrAvalue=None 149 self.ErrBvalue=None 150 self.Chivalue=None 134 151 def onWheel(self, event): 135 152 """ … … 175 192 176 193 def returnTrans(self): 177 return self.xscales,self.yscales 194 return self.xLabel,self.yLabel, self.Avalue, self.Bvalue,\ 195 self.ErrAvalue,self.ErrBvalue,self.Chivalue 178 196 179 197 def setTrans(self,xtrans,ytrans): … … 196 214 first_item = list.keys()[0] 197 215 dlg = LinearFit( None, first_item, self.onFitDisplay,self.returnTrans, -1, 'Fitting') 216 198 217 if (self.xmin !=0.0 )and ( self.xmax !=0.0)\ 199 218 and(self.xminView !=0.0 )and ( self.xmaxView !=0.0): … … 215 234 dial.setValues( self.prevXtrans, self.prevYtrans,self.viewModel ) 216 235 if dial.ShowModal() == wx.ID_OK: 217 self.x scales, self.yscales,self.viewModel = dial.getValues()236 self.xLabel, self.yLabel,self.viewModel = dial.getValues() 218 237 if self.viewModel =="Guinier lny vs x^(2)": 219 self.x scales="x^(2)"220 self.y scales="ln(y)"238 self.xLabel="x^(2)" 239 self.yLabel="ln(y)" 221 240 self.viewModel = "--" 222 dial.setValues( self.x scales, self.yscales,self.viewModel )241 dial.setValues( self.xLabel, self.yLabel,self.viewModel ) 223 242 self._onEVT_FUNC_PROPERTY() 224 243 dial.Destroy() … … 456 475 457 476 for item in list: 458 item. getTransform(self.xscales,self.yscales)459 if ( self.x scales=="x" ):460 item. returnTransformationx(transform.toX,transform.errToX)477 item.setLabel(self.xLabel,self.yLabel) 478 if ( self.xLabel=="x" ): 479 item.transformX(transform.toX,transform.errToX) 461 480 self.set_xscale("linear") 462 481 name, units = item.get_xaxis() 463 482 self.graph.xaxis("%s" % name, "%s^{-1}" % units) 464 483 465 if ( self.x scales=="x^(2)" ):466 item. returnTransformationx(transform.toX2,transform.errToX2)484 if ( self.xLabel=="x^(2)" ): 485 item.transformX(transform.toX2,transform.errToX2) 467 486 self.set_xscale('linear') 468 487 name, units = item.get_xaxis() 469 488 self.graph.xaxis("%s^{2}" % name, "%s^{-2}" % units) 470 489 471 if (self.x scales=="log10(x)" ):472 item. returnTransformationx(transform.toX,transform.errToX)490 if (self.xLabel=="log10(x)" ): 491 item.transformX(transform.toX,transform.errToX) 473 492 self.set_xscale("log") 474 493 name, units = item.get_xaxis() 475 494 self.graph.xaxis("\log_{10}\ \ %s" % name, "%s^{-1}" % units) 476 495 477 if ( self.y scales=="ln(y)" ):478 item. returnTransformationy(transform.toLogX,transform.errToLogX)496 if ( self.yLabel=="ln(y)" ): 497 item.transformY(transform.toLogX,transform.errToLogX) 479 498 self.set_yscale("linear") 480 499 name, units = item.get_yaxis() 481 500 self.graph.yaxis("log\ \ %s" % name, "%s^{-1}" % units) 482 501 483 if ( self.y scales=="y" ):484 item. returnTransformationy(transform.toX,transform.errToX)502 if ( self.yLabel=="y" ): 503 item.transformY(transform.toX,transform.errToX) 485 504 self.set_yscale("linear") 486 505 name, units = item.get_yaxis() 487 506 self.graph.yaxis("%s" % name, "%s^{-1}" % units) 488 507 489 if ( self.y scales=="log10(y)" ):490 item. returnTransformationy(transform.toX,transform.errToX)508 if ( self.yLabel=="log10(y)" ): 509 item.transformY(transform.toX,transform.errToX) 491 510 self.set_yscale("log") 492 511 name, units = item.get_yaxis() 493 512 self.graph.yaxis("\log_{10}\ \ %s" % name, "%s^{-1}" % units) 494 513 495 if ( self.y scales=="y^(2)" ):496 item. returnTransformationy( transform.toX2,transform.errToX2 )514 if ( self.yLabel=="y^(2)" ): 515 item.transformY( transform.toX2,transform.errToX2 ) 497 516 self.set_yscale("linear") 498 517 name, units = item.get_yaxis() 499 518 self.graph.yaxis("%s^{2}" % name, "%s^{-2}" % units) 500 519 501 if ( self.y scales=="1/y"):502 item. returnTransformationy(transform.toOneOverX,transform.errOneOverX )520 if ( self.yLabel =="1/y"): 521 item.transformY(transform.toOneOverX,transform.errOneOverX ) 503 522 self.set_yscale("linear") 504 523 name, units = item.get_yaxis() 505 524 self.graph.yaxis("%s" % name, "\ \%s" % units) 506 525 507 if ( self.y scales=="1/sqrt(y)" ):508 item. returnTransformationy(transform.toOneOverSqrtX,transform.errOneOverSqrtX )526 if ( self.yLabel =="1/sqrt(y)" ): 527 item.transformY(transform.toOneOverSqrtX,transform.errOneOverSqrtX ) 509 528 self.set_yscale("linear") 510 529 name, units = item.get_yaxis() 511 530 self.graph.yaxis("\sqrt{%s}" %name, "%s" % units) 512 531 513 if ( self.y scales=="ln(y*x)"):514 item. returnTransformationy( transform.toLogXY,transform.errToLogXY)532 if ( self.yLabel =="ln(y*x)"): 533 item.transformY( transform.toLogXY,transform.errToLogXY) 515 534 self.set_yscale("linear") 516 535 yname, yunits = item.get_yaxis() … … 518 537 self.graph.yaxis("log\ %s %s" % (yname,xname), "%s^{-1}%s^{-1}" % (yunits,xunits)) 519 538 520 if ( self.y scales=="ln(y*x^(2))"):521 item. returnTransformationy( transform.toLogYX2,transform.errToLogYX2)539 if ( self.yLabel =="ln(y*x^(2))"): 540 item.transformY( transform.toLogYX2,transform.errToLogYX2) 522 541 self.set_yscale("linear") 523 542 yname, yunits = item.get_yaxis() … … 525 544 self.graph.yaxis("Log %s%s^{2}" % (yname,xname), "%s^{-1}%s^{-2}" % (yunits,xunits)) 526 545 527 if ( self.y scales=="ln(y*x^(4))"):528 item. returnTransformationy(transform.toLogYX4,transform.errToLogYX4)546 if ( self.yLabel =="ln(y*x^(4))"): 547 item.transformY(transform.toLogYX4,transform.errToLogYX4) 529 548 self.set_yscale("linear") 530 549 yname, yunits = item.get_yaxis() … … 533 552 534 553 if ( self.viewModel == "Guinier lny vs x^(2)"): 535 item.returnTransformationx(transform.toX2,transform.errToX2) 554 555 item.transformX(transform.toX2,transform.errToX2) 536 556 self.set_xscale('linear') 537 557 name, units = item.get_xaxis() 538 558 self.graph.xaxis("%s^{2}" % name, "%s^{-2}" % units) 539 item.returnTransformationy(transform.toLogX,transform.errToLogX ) 559 560 item.transformY(transform.toLogX,transform.errToLogX ) 540 561 self.set_yscale("linear") 541 562 name, units = item.get_yaxis() 542 563 self.graph.yaxis("$Log %s$" % name, "%s^{-1}" % units) 564 543 565 item.transformView() 544 #item.name = self.yscales+" vs " +self.xscales 566 567 #item.name = self.yLabel+" vs " +self.xLabel 545 568 self.xmin=0.0 546 569 self.xmax=0.0 547 570 self.xminView=0.0 548 571 self.xmaxView=0.0 549 self.prevXtrans = self.x scales550 self.prevYtrans = self.y scales572 self.prevXtrans = self.xLabel 573 self.prevYtrans = self.yLabel 551 574 self.graph.render(self) 552 575 self.subplot.figure.canvas.draw_idle() 553 576 554 def onFitDisplay(self, tempx,tempy,xminView,xmaxView,xmin,xmax ):577 def onFitDisplay(self, tempx,tempy,xminView,xmaxView,xmin,xmax,func): 555 578 """ 556 579 Add a new plottable into the graph .In this case this plottable will be used … … 558 581 @param plottable: the plottable to plot 559 582 """ 560 583 self.Avalue,self.Bvalue,self.ErrAvalue,self.ErrBvalue,self.Chivalue=func 561 584 562 585 list =[] -
guitools/fitDialog.py
r416223d rb43a009 11 11 12 12 class LinearFit(wx.Dialog): 13 #def __init__(self, parent, id, title):14 13 def __init__(self, parent, plottable, push_data,transform, id, title): 15 14 wx.Dialog.__init__(self, parent, id, title, size=(450, 400)) 16 15 """ 17 for the fit window 16 Dialog window pops- up when select Linear fit on Context menu 17 Displays fitting parameters 18 18 """ 19 19 self.parent = parent … … 22 22 self.push_data = push_data 23 23 #dialog self plottable 24 24 25 self.plottable = plottable 25 26 # Receive transformations of x and y 26 self.xtrans,self.ytrans= self.transform() 27 self.xLabel,self.yLabel,self.Avalue,self.Bvalue,\ 28 self.ErrAvalue,self.ErrBvalue,self.Chivalue= self.transform() 27 29 #Dialog interface 28 30 panel = wx.Panel(self, -1, style=wx.SIMPLE_BORDER) … … 91 93 ix += 2 92 94 sizer.Add(self.PXmax, (iy, ix),(1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 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 98 ix = 0 99 sizer.Add(wx.StaticText(panel, -1, 'Fit Range'),(iy, ix),(1,1),\ 95 96 iy += 1 97 ix = 0 98 sizer.Add(wx.StaticText(panel, -1, 'Fit Range of '+self.xLabel),(iy, ix),(1,1),\ 100 99 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 101 100 ix += 1 … … 138 137 139 138 # Set default value of parameter in fit dialog 140 self.tcA.SetLabel(str(self.default_A)) 141 self.tcB.SetLabel(str(self.default_B)) 142 self.tcErrA.SetLabel(str(0.0)) 143 self.tcErrB.SetLabel(str(0.0)) 144 self.tcChi.SetLabel(str(0.0)) 145 139 140 if self.Avalue==None: 141 self.tcA.SetLabel(str(self.default_A)) 142 else : 143 self.tcA.SetLabel(str(self.Avalue)) 144 if self.Bvalue==None: 145 self.tcB.SetLabel(str(self.default_B)) 146 else: 147 self.tcB.SetLabel(str(self.Bvalue)) 148 if self.ErrAvalue==None: 149 self.tcErrA.SetLabel(str(0.0)) 150 else: 151 self.tcErrA.SetLabel(str(self.ErrAvalue)) 152 if self.ErrBvalue==None: 153 self.tcErrB.SetLabel(str(0.0)) 154 else: 155 self.tcErrB.SetLabel(str(self.ErrBvalue)) 156 if self.Chivalue==None: 157 self.tcChi.SetLabel(str(0.0)) 158 else: 159 self.tcChi.SetLabel(str(self.Chivalue)) 146 160 if self.plottable.x !=[]: 147 161 self.mini =min(self.plottable.x) … … 186 200 xminView=self.floatTransform(xmin) 187 201 xmaxView=self.floatTransform(xmax) 188 if (self.x trans=="log10(x)"):202 if (self.xLabel=="log10(x)"): 189 203 self.FXmin.SetValue(str(math.log10(xminView))) 190 204 self.FXmax.SetValue(str(math.log10(xmaxView))) … … 195 209 self.FXmax.Disable() 196 210 # Store the transformed values of view x, y,dy in variables before the fit 197 if self.y trans.lower() == "log10(y)":198 if (self.x trans.lower() == "log10(x)"):211 if self.yLabel.lower() == "log10(y)": 212 if (self.xLabel.lower() == "log10(x)"): 199 213 for i in range(len(x)): 200 214 if x[i]>= math.log10(xmin): … … 209 223 tempdy = dy 210 224 211 if (self.x trans.lower() == "log10(x)"):225 if (self.xLabel.lower() == "log10(x)"): 212 226 for x_i in x: 213 227 if x_i >= math.log10(xmin): … … 215 229 else: 216 230 tempx = x 217 218 #for y_i in y: 219 # dy = math.sqrt(math.fabs(y_i)) 220 # if dy >= y_i: 221 # dy = 0.9*y_i 222 # tempdy.append(dy) 223 231 224 232 #Find the fitting parameters 225 233 226 if (self.x trans.lower() == "log10(x)"):234 if (self.xLabel.lower() == "log10(x)"): 227 235 chisqr, out, cov = fittings.sansfit(self.model, [self.cstA, self.cstB], 228 236 tempx, tempy,tempdy,math.log10(xmin),math.log10(xmax)) … … 230 238 chisqr, out, cov = fittings.sansfit(self.model, 231 239 [self.cstA, self.cstB],tempx, tempy,tempdy,xminView,xmaxView) 232 print "this out",out240 #print "this out",out 233 241 #Check that cov and out are iterable before displaying them 234 242 if cov ==None: … … 253 261 # load tempy with the minimum transformation 254 262 255 if self.x trans== "log10(x)":263 if self.xLabel == "log10(x)": 256 264 y_model = self.model.run(math.log10(xmin)) 257 265 tempx.append(xmin) … … 260 268 tempx.append(xminView) 261 269 262 if self.y trans== "log10(y)":270 if self.yLabel == "log10(y)": 263 271 tempy.append(math.pow(10,y_model)) 264 272 print "tempy",tempy … … 267 275 268 276 # load tempy with the maximum transformation 269 if self.x trans== "log10(x)":277 if self.xLabel == "log10(x)": 270 278 y_model = self.model.run(math.log10(xmax)) 271 279 tempx.append(xmax) … … 274 282 tempx.append(xmaxView) 275 283 276 if self.y trans== "log10(y)":284 if self.yLabel == "log10(y)": 277 285 tempy.append(math.pow(10,y_model)) 278 286 else: 279 287 tempy.append(y_model) 280 281 self.push_data(tempx,tempy,xminView,xmaxView,xmin,xmax) 288 self.Avalue=cstA 289 self.Bvalue=cstB 290 self.ErrAvalue=errA 291 self.ErrBvalue=errB 292 self.Chivalue=chisqr 293 self.push_data(tempx,tempy,xminView,xmaxView,xmin,xmax,self._ongetValues()) 282 294 283 295 # Display the fitting value on the Fit Dialog 284 296 self._onsetValues(cstA, cstB, errA,errB,chisqr) 297 298 285 299 286 300 def _onsetValues(self,cstA,cstB,errA,errB,Chi): … … 293 307 self.tcErrB.SetValue(str(errB)) 294 308 self.tcChi.SetValue(str(Chi)) 309 310 def _ongetValues(self): 311 """ 312 Display the value on fit Dialog 313 """ 314 return self.Avalue, self.Bvalue,self.ErrAvalue,self.ErrBvalue,self.Chivalue 295 315 296 316 def _returnPlottable(self): … … 322 342 not in x 323 343 """ 324 if ( self.x trans=="x" ):344 if ( self.xLabel=="x" ): 325 345 return transform.toX(x) 326 346 327 if ( self.x trans=="x^(2)" ):347 if ( self.xLabel=="x^(2)" ): 328 348 return transform.toX2(x) 329 349 330 if (self.x trans=="log10(x)" ):350 if (self.xLabel=="log10(x)" ): 331 351 if x >0: 332 352 return x … … 341 361 value = item.GetValue() 342 362 # Check for possible values entered 343 if (self.x trans=="log10(x)"):363 if (self.xLabel=="log10(x)"): 344 364 if (float(value) > 0): 345 365 item.SetBackgroundColour(wx.WHITE) … … 353 373 354 374 def setFitRange(self,xmin,xmax,Reelxmin,Reelxmax): 355 if (self.x trans=="log10(x)"):375 if (self.xLabel=="log10(x)"): 356 376 self.FXmin.SetValue(str(math.log10(xmin))) 357 377 self.FXmax.SetValue(str(math.log10(xmax))) -
guitools/plottables.py
r150c04a rb43a009 53 53 if not cond: return False 54 54 return True 55 def error_msg(msg, parent=None): 56 """ 57 Signal an error condition -- in a GUI, popup a error dialog 58 """ 59 # Code brought with minor podifications from mpl.backends.backend_wx 60 # Copyright (C) Jeremy O'Donoghue & John Hunter, 2003-4 61 dialog =wx.MessageDialog(parent = parent, 62 message = msg, 63 caption = 'Polplot error', 64 style=wx.OK | wx.CENTRE) 65 dialog.ShowModal() 66 dialog.Destroy() 67 return None 55 68 56 # Graph structure for holding multiple plottables 69 57 class Graph: … … 204 192 "title":""} 205 193 self.plottables = {} 206 def setGraph(self,listofplottable):207 self.plottables = listofplottable194 195 208 196 def _make_labels(self): 209 197 # Find groups of related plottables … … 223 211 224 212 def returnPlottable(self): 213 """ 214 This method returns a dictionary of plottables contained in graph 215 It is just by Plotpanel to interact with the complete list of plottables 216 inside the graph. 217 """ 225 218 return self.plottables 226 219 … … 234 227 plot.render() 235 228 236 def clear(self,plot): 237 plot.clear() 229 238 230 239 231 def __init__(self,**kw): … … 376 368 ##Use the following if @classmethod doesn't work 377 369 # labels = classmethod(labels) 378 def getTransform(self,transx,transy): 379 self.view.transx = transx 380 self.view.transy = transy 370 def setLabel(self,labelx,labely): 371 """ 372 It takes a label of the x and y transformation and set View parameters 373 @param transx: The label of x transformation is sent by Properties Dialog 374 @param transy: The label of y transformation is sent Properties Dialog 375 """ 376 self.view.xLabel= labelx 377 self.view.yLabel = labely 381 378 382 379 def __init__(self): … … 418 415 419 416 def transformView(self): 420 417 """ 418 It transforms x, y before displaying 419 """ 421 420 self.view.transform( self.x, self.y, self.dx,self.dy) 422 421 423 422 def returnValuesOfView(self): 423 """ 424 Return View parameters and it is used by Fit Dialog 425 """ 424 426 return self.view.returnXview() 425 427 426 428 def check_data_PlottableX(self): 429 """ 430 Since no transformation is made for log10(x), check that 431 no negative values is plot in log scale 432 """ 427 433 self.view.check_data_logX() 428 434 429 435 def check_data_PlottableY(self): 436 """ 437 Since no transformation is made for log10(y), check that 438 no negative values is plot in log scale 439 """ 430 440 self.view.check_data_logY() 431 441 432 def returnTransformationx(self,transx,transdx): 433 self.view.returntransformx(transx,transdx) 434 435 def returnTransformationy(self,transy,transdy): 436 self.view.returntransformy(transy,transdy) 442 def transformX(self,transx,transdx): 443 """ 444 Receive pointers to function that transform x and dx 445 and set corresponding View pointers 446 @param transx: pointer to function that transforms x 447 @param transdx: pointer to function that transforms dx 448 """ 449 self.view.setTransformX(transx,transdx) 450 451 def transformY(self,transy,transdy): 452 """ 453 Receive pointers to function that transform y and dy 454 and set corresponding View pointers 455 @param transy: pointer to function that transforms y 456 @param transdy: pointer to function that transforms dy 457 """ 458 self.view.setTransformY(transy,transdy) 459 437 460 def onReset(self): 461 """ 462 Reset x, y, dx, dy view with its parameters 463 """ 438 464 self.view.onResetView() 465 439 466 def onFitRange(self,xmin=None,xmax=None): 467 """ 468 It limits View data range to plot from min to max 469 @param xmin: the minimum value of x to plot. 470 @param xmax: the maximum value of x to plot 471 """ 440 472 self.view.onFitRangeView(xmin,xmax) 473 441 474 class View: 442 475 """ … … 454 487 self.dx = dx 455 488 self.dy = dy 456 # to change x range to the reel range489 # To change x range to the reel range 457 490 self.Xreel = self.x 458 491 self.Yreel = self.y 459 492 self.DXreel = self.dx 460 493 self.DYreel = self.dy 461 462 self. transx=""463 self. transy=""464 # function to transform x andy494 # Labels of x and y received from Properties Dialog 495 self.xLabel ="" 496 self.yLabel ="" 497 # Function to transform x, y, dx and dy 465 498 self.funcx= None 466 499 self.funcy= None … … 469 502 def transform(self, x=None,y=None,dx=None, dy=None): 470 503 """ 471 Transforms the x and dx vectors and stores the output. 472 473 @param func: function to apply to the data 504 Transforms the x,y,dx and dy vectors and stores the output in View parameters 505 474 506 @param x: array of x values 475 @param dx: array of error values 476 @param errfunc: function to apply to errors 507 @param y: array of y values 508 @param dx: array of errors values on x 509 @param dy: array of error values on y 477 510 """ 478 511 479 512 # Sanity check 480 if (x!=None) and (y!=None): 513 # Do the transofrmation only when x and y are empty 514 if (x!=None) and (y!=None): 481 515 if dx and not len(x)==len(dx): 482 516 raise ValueError, "Plottable.View: Given x and dx are not of the same length" … … 522 556 and(len(self.x)==len(self.y))and(len(self.y)==len(self.dy)) : 523 557 raise ValueError, "Plottable.View: Given x,y,dy and dx are not of the same length" 558 # Check that negative values are not plot on x and y axis for log10 transformation 524 559 self.check_data_logX() 525 560 self.check_data_logY() 561 # Store x ,y dx,and dy in their full range for reset 526 562 self.Xreel = self.x 527 563 self.Yreel = self.y 528 564 self.DXreel = self.dx 529 565 self.DYreel = self.dy 566 567 568 530 569 def onResetView(self): 531 self.x=self.Xreel 532 self.y=self.Yreel 533 self.dx=self.DXreel 534 self.dy=self.DYreel 535 def returntransformx(self,funcx,funcdx): 570 """ 571 Reset x,y,dx and y in their full range and in the initial scale 572 in case their previous range has changed 573 """ 574 self.x = self.Xreel 575 self.y = self.Yreel 576 self.dx = self.DXreel 577 self.dy = self.DYreel 578 579 def setTransformX(self,funcx,funcdx): 580 """ 581 Receive pointers to function that transform x and dx 582 and set corresponding View pointers 583 @param transx: pointer to function that transforms x 584 @param transdx: pointer to function that transforms dx 585 """ 536 586 self.funcx= funcx 537 587 self.funcdx= funcdx 538 588 539 def returntransformy(self,funcy,funcdy): 589 def setTransformY(self,funcy,funcdy): 590 """ 591 Receive pointers to function that transform y and dy 592 and set corresponding View pointers 593 @param transx: pointer to function that transforms y 594 @param transdx: pointer to function that transforms dy 595 """ 540 596 self.funcy= funcy 541 597 self.funcdy= funcdy 542 598 543 599 def returnXview(self): 600 """ 601 Return View x,y,dx,dy 602 """ 544 603 return self.x,self.y,self.dx,self.dy 545 604 546 605 547 606 def check_data_logX(self): 607 """ 608 Remove negative value in x vector 609 to avoid plotting negative value of Log10 610 """ 548 611 tempx=[] 549 612 tempdx=[] … … 554 617 if self.dy==None: 555 618 self.dy=numpy.zeros(len(self.y)) 556 if self. transx=="log10(x)" :619 if self.xLabel=="log10(x)" : 557 620 for i in range(len(self.x)): 558 621 try: … … 568 631 pass 569 632 570 self.x=[] 571 self.dx=[] 572 self.y=[] 573 self.dy=[] 574 self.x=tempx 575 self.y=tempy 576 self.dx=tempdx 577 self.dy=tempdy 633 self.x = tempx 634 self.y = tempy 635 self.dx = tempdx 636 self.dy = tempdy 578 637 579 638 def check_data_logY(self): 639 """ 640 Remove negative value in y vector 641 to avoid plotting negative value of Log10 642 """ 580 643 tempx=[] 581 644 tempdx=[] … … 586 649 if self.dy==None: 587 650 self.dy=numpy.zeros(len(self.y)) 588 if (self. transy== "log10(y)" ):651 if (self.yLabel == "log10(y)" ): 589 652 for i in range(len(self.x)): 590 653 try: … … 598 661 print sys.exc_value 599 662 pass 600 601 self.x=[] 602 self.dx=[] 603 self.y=[] 604 self.dy=[] 605 self.x=tempx 606 self.y=tempy 607 self.dx=tempdx 608 self.dy=tempdy 663 664 self.x = tempx 665 self.y = tempy 666 self.dx = tempdx 667 self.dy = tempdy 609 668 610 669 def onFitRangeView(self,xmin=None,xmax=None): 670 """ 671 It limits View data range to plot from min to max 672 @param xmin: the minimum value of x to plot. 673 @param xmax: the maximum value of x to plot 674 """ 611 675 tempx=[] 612 676 tempdx=[] … … 676 740 The title is the name that will show up on the legend. 677 741 """ 678 self.name= "theo "742 self.name= "theory" 679 743 self.x = x 680 744 self.y = y … … 683 747 self.yaxis( 'intensity', 'cm') 684 748 self.view = self.View(self.x, self.y, None, self.dy) 749 685 750 def render(self,plot,**kw): 686 751 #plot.curve(self.x,self.y,dy=self.dy,**kw)
Note: See TracChangeset
for help on using the changeset viewer.