Changeset 3d3a0e5 in sasview for guitools/plottables.py


Ignore:
Timestamp:
Apr 9, 2008 6:19:25 PM (16 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
7a03e65
Parents:
f52bea1
Message:

CHANGE PLOTPANEL PLOTTABLE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • guitools/plottables.py

    rf52bea1 r3d3a0e5  
    391391        self.view.transform_y(func, errfunc, self.y, self.dy) 
    392392         
     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) 
     399         
    393400    def returnValuesOfView(self): 
    394401         
     
    460467                 else: 
    461468                     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. 
     472                 
     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]) 
    462506                      
    463507        def returnXview(self): 
Note: See TracChangeset for help on using the changeset viewer.