Changeset 7a03e65 in sasview for guitools/plottables.py
- Timestamp:
- Apr 10, 2008 4:29:17 PM (16 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:
- 370e587
- Parents:
- 3d3a0e5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
guitools/plottables.py
r3d3a0e5 r7a03e65 382 382 383 383 """ 384 self.view.transform_x(func, errfunc, self.x, self.dx)384 self.view.transform_x(func, errfunc, x=self.x, y=self.y, dx=self.dx, dy=self.dy) 385 385 386 386 def transform_y(self, func, errfunc): … … 389 389 390 390 """ 391 self.view.transform_y(func, errfunc, self.y, self.dy) 392 393 def transform_xy(self,func,errfunc): 394 """ 395 @param func: reference to y transformation function 396 397 """ 398 self.view.transform_xy(func, errfunc, self.x, self.y,self.dx,self.dy) 391 self.view.transform_y(func, errfunc, self.y, self.x, self.dx, self.dy) 392 399 393 400 394 def returnValuesOfView(self): … … 418 412 self.dy = dy 419 413 420 def transform_x(self, func, errfunc, x, dx):414 def transform_x(self, func, errfunc, x,y=None,dx=None, dy=None): 421 415 """ 422 416 Transforms the x and dx vectors and stores the output. … … 429 423 import copy 430 424 import numpy 425 431 426 # Sanity check 427 has_y = False 432 428 if dx and not len(x)==len(dx): 433 raise ValueError, "Plottable.View: Given x and dx are not of the same length" 434 429 raise ValueError, "Plottable.View: Given x and dx are not of the same length" 430 # Check length of y array 431 if not y==None: 432 if not len(y)==len(x): 433 raise ValueError, "Plottable.View: Given y and x are not of the same length" 434 else: 435 has_y = True 436 if dy and not len(y)==len(dy): 437 raise ValueError, "Plottable.View: Given y and dy are not of the same length" 435 438 436 439 self.x = numpy.zeros(len(x)) … … 438 441 439 442 for i in range(len(x)): 440 self.x[i] = func(x[i]) 441 if dx !=None: 442 self.dx[i] = errfunc(x[i], dx[i]) 443 if has_y: 444 self.x[i] = func(x[i],y[i]) 445 if (dx!=None) and (dy !=None): 446 self.dx[i] = errfunc(x[i], y[i], dx[i], dy[i]) 447 elif (dx != None): 448 self.dx[i] = errfunc(x[i], y[i], dx[i],0) 449 elif (dy != None): 450 self.dx[i] = errfunc(x[i], y[i],0,dy[i]) 451 else: 452 self.dx[i] = errfunc(x[i],y[i],0, 0) 443 453 else: 444 self.dx[i] = errfunc(x[i]) 445 def transform_y(self, func, errfunc, y, dy): 454 self.x[i] = func(x[i]) 455 if (dx != None): 456 self.dx[i] = errfunc(x[i], dx[i]) 457 else: 458 self.dx[i] = errfunc(x[i],None) 459 460 461 def transform_y(self, func, errfunc, y, x=None,dx=None,dy=None): 446 462 """ 447 Transforms the x and dxvectors and stores the output.463 Transforms the y and dy vectors and stores the output. 448 464 449 @param func: function to apply to the data 465 @param func: function to apply to the data y 466 @param x: array of x values 467 @param dx: array of error values 450 468 @param y: array of y values 451 469 @param dy: array of error values 452 @param errfunc: function to apply to errors 470 @param errfunc: function to apply to errors dy 453 471 """ 454 472 import copy 455 473 import numpy 456 474 # Sanity check 475 has_x = False 457 476 if dy and not len(y)==len(dy): 458 477 raise ValueError, "Plottable.View: Given y and dy are not of the same length" 478 # Check length of x array 479 if not x==None: 480 if not len(y)==len(x): 481 raise ValueError, "Plottable.View: Given y and x are not of the same length" 482 else: 483 has_x = True 484 if dx and not len(x)==len(dx): 485 raise ValueError, "Plottable.View: Given x and dx are not of the same length" 459 486 460 487 self.y = numpy.zeros(len(y)) … … 462 489 463 490 for i in range(len(y)): 464 self.y[i] = func(y[i]) 465 if dy !=None: 466 self.dy[i] = errfunc(y[i], dy[i]) 491 492 if has_x: 493 self.y[i] = func(y[i],x[i]) 494 if (dx!=None) and (dy !=None): 495 self.dy[i] = errfunc(y[i], x[i], dy[i], dx[i]) 496 elif (dx != None): 497 self.dy[i] = errfunc(y[i], x[i], 0, dx[i]) 498 elif (dy != None): 499 self.dy[i] = errfunc(y[i], x[i], dy[i], 0) 500 else: 501 self.dy[i] = errfunc(y[i], None) 467 502 else: 468 self.dy[i] = errfunc(y[i]) 469 def transform_xy(self, func, errfunc, x, y, dx, dy): 470 """ 471 Transforms the x, y, dx,and dy vectors and stores the output. 503 self.y[i] = func(y[i]) 504 if (dy != None): 505 self.dy[i] = errfunc( y[i],dy[i]) 506 else: 507 self.dy[i] = errfunc( y[i],None) 472 508 473 @param func: function to apply to the data 474 @param x: array of x values 475 @param dx: array of error values 476 @param y: array of y values 477 @param dy: array of error values 478 @param errfunc: function to apply to errors 479 """ 480 import copy 481 import numpy 482 # Sanity check 483 if dx and not len(x)==len(dx): 484 raise ValueError, "Plottable.View: Given x and dx are not of the same length" 485 if dy and not len(y)==len(dy): 486 raise ValueError, "Plottable.View: Given y and dy are not of the same length" 487 if not len(x)==len(y): 488 raise ValueError, "Plottable.View: Given x and y are not of the same length" 489 490 self.x = numpy.zeros(len(x)) 491 self.dx = numpy.zeros(len(x)) 492 self.y = numpy.zeros(len(y)) 493 self.dy = numpy.zeros(len(y)) 494 495 496 for i in range(len(y)): 497 self.y[i] = func(x[i],y[i]) 498 if (dx!=None) and (dy !=None): 499 self.dy[i] = errfunc(x[i], y[i], dx[i], dy[i]) 500 elif (dx != None): 501 self.dy[i] = errfunc(x[i], y[i], dx[i]) 502 elif (dy != None): 503 self.dy[i] = errfunc(x[i], y[i],dy[i]) 504 else: 505 self.dy[i] = errfunc(x[i], y[i]) 506 509 507 510 def returnXview(self): 508 511 return self.x,self.y,self.dx,self.dy
Note: See TracChangeset
for help on using the changeset viewer.