Changeset b39c817 in sasview for DataLoader/data_info.py


Ignore:
Timestamp:
Aug 4, 2008 10:39:43 AM (16 years ago)
Author:
Mathieu Doucet <doucetm@…>
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:
ccb560a
Parents:
cfe97ea
Message:

Added unit converter for CanSAS format reader

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DataLoader/data_info.py

    r9198b83 rb39c817  
    1818copyright 2008, University of Tennessee 
    1919""" 
     20 
     21#TODO: Keep track of data manipulation in the 'process' data structure. 
    2022 
    2123from sans.guitools.plottables import Data1D as plottable_1D 
     
    7173    ## Sample to detector distance [float] [mm] 
    7274    distance = None 
    73     distance_unit = 'm' 
     75    distance_unit = 'mm' 
    7476    ## Offset of this detector position in X, Y, (and Z if necessary) [Vector] [mm]  
    7577    offset = Vector() 
    76     offset_unit = 'mm' 
     78    offset_unit = 'm' 
    7779    ## Orientation (rotation) of this detector in roll, pitch, and yaw [Vector] [degrees] 
    7880    orientation = Vector() 
     
    280282    errors = [] 
    281283             
     284    # Private method to perform operation. Not implemented for DataInfo, 
     285    # but should be implemented for each data class inherited from DataInfo 
     286    # that holds actual data (ex.: Data1D) 
     287    def _perform_operation(self, other, operation): return NotImplemented 
     288 
     289    def __add__(self, other): 
     290        """ 
     291            Add two data sets 
     292             
     293            @param other: data set to add to the current one 
     294            @return: new data set 
     295            @raise ValueError: raised when two data sets are incompatible 
     296        """ 
     297        def operation(a, b): return a+b 
     298        return self._perform_operation(other, operation) 
     299         
     300    def __radd__(self, other): 
     301        """ 
     302            Add two data sets 
     303             
     304            @param other: data set to add to the current one 
     305            @return: new data set 
     306            @raise ValueError: raised when two data sets are incompatible 
     307        """ 
     308        def operation(a, b): return b+a 
     309        return self._perform_operation(other, operation) 
     310         
     311    def __sub__(self, other): 
     312        """ 
     313            Subtract two data sets 
     314             
     315            @param other: data set to subtract from the current one 
     316            @return: new data set 
     317            @raise ValueError: raised when two data sets are incompatible 
     318        """ 
     319        def operation(a, b): return a-b 
     320        return self._perform_operation(other, operation) 
     321         
     322    def __rsub__(self, other): 
     323        """ 
     324            Subtract two data sets 
     325             
     326            @param other: data set to subtract from the current one 
     327            @return: new data set 
     328            @raise ValueError: raised when two data sets are incompatible 
     329        """ 
     330        def operation(a, b): return b-a 
     331        return self._perform_operation(other, operation) 
     332         
     333    def __mul__(self, other): 
     334        """ 
     335            Multiply two data sets 
     336             
     337            @param other: data set to subtract from the current one 
     338            @return: new data set 
     339            @raise ValueError: raised when two data sets are incompatible 
     340        """ 
     341        def operation(a, b): return a*b 
     342        return self._perform_operation(other, operation) 
     343         
     344    def __rmul__(self, other): 
     345        """ 
     346            Multiply two data sets 
     347             
     348            @param other: data set to subtract from the current one 
     349            @return: new data set 
     350            @raise ValueError: raised when two data sets are incompatible 
     351        """ 
     352        def operation(a, b): return b*a 
     353        return self._perform_operation(other, operation) 
     354         
     355    def __div__(self, other): 
     356        """ 
     357            Divided a data set by another 
     358             
     359            @param other: data set that the current one is divided by 
     360            @return: new data set 
     361            @raise ValueError: raised when two data sets are incompatible 
     362        """ 
     363        def operation(a, b): return a/b 
     364        return self._perform_operation(other, operation) 
     365         
     366    def __rdiv__(self, other): 
     367        """ 
     368            Divided a data set by another 
     369             
     370            @param other: data set that the current one is divided by 
     371            @return: new data set 
     372            @raise ValueError: raised when two data sets are incompatible 
     373        """ 
     374        def operation(a, b): return b/a 
     375        return self._perform_operation(other, operation)             
     376             
    282377class Data1D(plottable_1D, DataInfo): 
    283378    """ 
     
    309404            _str += "%s\n" % str(item) 
    310405         
    311          
    312406        _str += "Data:\n" 
    313407        _str += "   Type:         %s\n" % self.__class__.__name__ 
     
    319413 
    320414    def clone_without_data(self, length=0): 
     415        """ 
     416            Clone the current object, without copying the data (which 
     417            will be filled out by a subsequent operation). 
     418            The data arrays will be initialized to zero. 
     419             
     420            @param length: length of the data array to be initialized 
     421        """ 
    321422        from copy import deepcopy 
    322423         
     
    401502        return result 
    402503         
    403  
    404     def __add__(self, other): 
    405         """ 
    406             Add two data sets 
    407              
    408             @param other: data set to add to the current one 
    409             @return: new data set 
    410             @raise ValueError: raised when two data sets are incompatible 
    411         """ 
    412         def operation(a, b): return a+b 
    413         return self._perform_operation(other, operation) 
    414          
    415     def __radd__(self, other): 
    416         """ 
    417             Add two data sets 
    418              
    419             @param other: data set to add to the current one 
    420             @return: new data set 
    421             @raise ValueError: raised when two data sets are incompatible 
    422         """ 
    423         def operation(a, b): return b+a 
    424         return self._perform_operation(other, operation) 
    425          
    426     def __sub__(self, other): 
    427         """ 
    428             Subtract two data sets 
    429              
    430             @param other: data set to subtract from the current one 
    431             @return: new data set 
    432             @raise ValueError: raised when two data sets are incompatible 
    433         """ 
    434         def operation(a, b): return a-b 
    435         return self._perform_operation(other, operation) 
    436          
    437     def __rsub__(self, other): 
    438         """ 
    439             Subtract two data sets 
    440              
    441             @param other: data set to subtract from the current one 
    442             @return: new data set 
    443             @raise ValueError: raised when two data sets are incompatible 
    444         """ 
    445         def operation(a, b): return b-a 
    446         return self._perform_operation(other, operation) 
    447          
    448     def __mul__(self, other): 
    449         """ 
    450             Multiply two data sets 
    451              
    452             @param other: data set to subtract from the current one 
    453             @return: new data set 
    454             @raise ValueError: raised when two data sets are incompatible 
    455         """ 
    456         def operation(a, b): return a*b 
    457         return self._perform_operation(other, operation) 
    458          
    459     def __rmul__(self, other): 
    460         """ 
    461             Multiply two data sets 
    462              
    463             @param other: data set to subtract from the current one 
    464             @return: new data set 
    465             @raise ValueError: raised when two data sets are incompatible 
    466         """ 
    467         def operation(a, b): return b*a 
    468         return self._perform_operation(other, operation) 
    469          
    470     def __div__(self, other): 
    471         """ 
    472             Divided a data set by another 
    473              
    474             @param other: data set that the current one is divided by 
    475             @return: new data set 
    476             @raise ValueError: raised when two data sets are incompatible 
    477         """ 
    478         def operation(a, b): return a/b 
    479         return self._perform_operation(other, operation) 
    480          
    481     def __rdiv__(self, other): 
    482         """ 
    483             Divided a data set by another 
    484              
    485             @param other: data set that the current one is divided by 
    486             @return: new data set 
    487             @raise ValueError: raised when two data sets are incompatible 
    488         """ 
    489         def operation(a, b): return b/a 
    490         return self._perform_operation(other, operation) 
    491          
    492  
    493  
Note: See TracChangeset for help on using the changeset viewer.