Changeset 5e326a6 in sasview


Ignore:
Timestamp:
Feb 18, 2015 5:32:58 PM (9 years ago)
Author:
jhbakker
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:
66f21cd
Parents:
cbe8c5c
Message:

added sesans_reader for SESANS analysis

Location:
src/sas/dataloader
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • src/sas/dataloader/data_info.py

    r7eaf9f2 r5e326a6  
    2626import math 
    2727 
    28  
    2928class plottable_sesans1D: 
    3029    """ 
    3130    SESANS is a place holder for 1D SESANS plottables. 
    3231     
    33     #TODO: This was directly copied from the plottables_1D. 
    34     #TODO: The class has not been updated from there. 
     32    #TODO: This was directly copied from the plottables_1D. Modified Somewhat. 
     33    #Class has been updated. 
    3534    """ 
    3635    # The presence of these should be mutually 
     
    3837    x = None 
    3938    y = None 
     39    lam = None 
    4040    dx = None 
    4141    dy = None 
     42    dlam = None 
    4243    ## Slit smearing length 
    4344    dxl = None 
     
    5152    _yunit = '' 
    5253     
    53     def __init__(self, x, y, dx=None, dy=None, dxl=None, dxw=None): 
     54    def __init__(self, x, y, lam, dx=None, dy=None, dlam=None): 
     55#        print "SESANS plottable working" 
    5456        self.x = numpy.asarray(x) 
    5557        self.y = numpy.asarray(y) 
     58        self.lam = numpy.asarray(lam) 
    5659        if dx is not None: 
    5760            self.dx = numpy.asarray(dx) 
    5861        if dy is not None: 
    5962            self.dy = numpy.asarray(dy) 
    60         if dxl is not None: 
    61             self.dxl = numpy.asarray(dxl) 
    62         if dxw is not None:  
    63             self.dxw = numpy.asarray(dxw) 
    64  
     63        if dlam is not None: 
     64            self.dlam = numpy.asarray(dlam) 
     65#        if dxl is not None: 
     66#            self.dxl = numpy.asarray(dxl) 
     67#        if dxw is not None:  
     68#            self.dxw = numpy.asarray(dxw) 
     69#        print "SESANS plottable init fin" 
    6570    def xaxis(self, label, unit): 
    6671        """ 
     
    6974        self._xaxis = label 
    7075        self._xunit = unit 
    71          
     76        print "xaxis active" 
     77        print label 
     78        print unit 
    7279    def yaxis(self, label, unit): 
    7380        """ 
    7481        set the y axis label and unit 
    7582        """ 
     83        print "yaxis active" 
     84        print label 
     85        print unit 
     86         
    7687        self._yaxis = label 
    7788        self._yunit = unit 
     
    750761        """ 
    751762        return self._perform_union(other) 
    752                  
     763   
     764class SESANSData1D(plottable_sesans1D, DataInfo): 
     765    """ 
     766    SESANS 1D data class 
     767    """ 
     768    x_unit = 'nm' 
     769    y_unit = 'a.u.' 
     770     
     771    def __init__(self, x=None, y=None, lam=None, dy=None, dx=None, dlam=None): 
     772#        print "dat init" 
     773        DataInfo.__init__(self) 
     774#        print "dat init fin" 
     775        plottable_sesans1D.__init__(self, x, y, lam, dx, dy, dlam) 
     776#        print "SESANSdata1D init" 
     777    def __str__(self): 
     778        """ 
     779        Nice printout 
     780        """ 
     781#        print "string printer active" 
     782        _str =  "%s\n" % DataInfo.__str__(self) 
     783     
     784        _str += "Data:\n" 
     785        _str += "   Type:         %s\n" % self.__class__.__name__ 
     786        _str += "   X-axis:       %s\t[%s]\n" % (self._xaxis, self._xunit) 
     787        _str += "   Y-axis:       %s\t[%s]\n" % (self._yaxis, self._yunit) 
     788        _str += "   Length:       %g\n" % len(self.x) 
     789#        print _str 
     790        return _str 
     791# 
     792#    def is_slit_smeared(self): 
     793#        """ 
     794#        Check whether the data has slit smearing information 
     795#         
     796#        :return: True is slit smearing info is present, False otherwise 
     797#         
     798#        """ 
     799#        def _check(v): 
     800#            if (v.__class__ == list or v.__class__ == numpy.ndarray) \ 
     801#                and len(v) > 0 and min(v) > 0: 
     802#                return True 
     803#             
     804#            return False 
     805#         
     806#        return _check(self.dxl) or _check(self.dxw) 
     807         
     808    def clone_without_data(self, length=0, clone=None): 
     809        """ 
     810        Clone the current object, without copying the data (which 
     811        will be filled out by a subsequent operation). 
     812        The data arrays will be initialized to zero. 
     813         
     814        :param length: length of the data array to be initialized 
     815        :param clone: if provided, the data will be copied to clone 
     816        """ 
     817        from copy import deepcopy 
     818#        print " SESANS data 1D clone active" 
     819        if clone is None or not issubclass(clone.__class__, Data1D): 
     820            x  = numpy.zeros(length) 
     821            dx = numpy.zeros(length) 
     822            lam  = numpy.zeros(length) 
     823            dlam = numpy.zeros(length) 
     824            y  = numpy.zeros(length) 
     825            dy = numpy.zeros(length) 
     826            clone = Data1D(x, y, dx=dx, dy=dy) 
     827         
     828        clone.title          = self.title 
     829        clone.run            = self.run 
     830        clone.filename       = self.filename 
     831        clone.instrument     = self.instrument 
     832        clone.notes          = deepcopy(self.notes) 
     833        clone.process        = deepcopy(self.process) 
     834        clone.detector       = deepcopy(self.detector) 
     835        clone.sample         = deepcopy(self.sample) 
     836        clone.source         = deepcopy(self.source) 
     837        clone.collimation    = deepcopy(self.collimation) 
     838        clone.trans_spectrum = deepcopy(self.trans_spectrum) 
     839        clone.meta_data      = deepcopy(self.meta_data) 
     840        clone.errors         = deepcopy(self.errors) 
     841#        print "SESANS Data 1Dclone done" 
     842        return clone 
     843               
    753844class Data1D(plottable_1D, DataInfo): 
    754845    """ 
     
    9911082         
    9921083         
    993 class SESANSData1D(plottable_sesans1D, DataInfo): 
    994     """ 
    995     SESANS 1D data class 
    996     """ 
    997     x_unit = '1/A' 
    998     y_unit = '1/cm' 
    999      
    1000     def __init__(self, x, y, dx=None, dy=None): 
    1001         DataInfo.__init__(self) 
    1002         plottable_sesans1D.__init__(self, x, y, dx, dy) 
    1003          
    1004     def __str__(self): 
    1005         """ 
    1006         Nice printout 
    1007         """ 
    1008         _str =  "%s\n" % DataInfo.__str__(self) 
    1009      
    1010         _str += "Data:\n" 
    1011         _str += "   Type:         %s\n" % self.__class__.__name__ 
    1012         _str += "   X-axis:       %s\t[%s]\n" % (self._xaxis, self._xunit) 
    1013         _str += "   Y-axis:       %s\t[%s]\n" % (self._yaxis, self._yunit) 
    1014         _str += "   Length:       %g\n" % len(self.x) 
    1015  
    1016         return _str 
    1017  
    1018     def is_slit_smeared(self): 
    1019         """ 
    1020         Check whether the data has slit smearing information 
    1021          
    1022         :return: True is slit smearing info is present, False otherwise 
    1023          
    1024         """ 
    1025         def _check(v): 
    1026             if (v.__class__ == list or v.__class__ == numpy.ndarray) \ 
    1027                 and len(v) > 0 and min(v) > 0: 
    1028                 return True 
    1029              
    1030             return False 
    1031          
    1032         return _check(self.dxl) or _check(self.dxw) 
    1033          
    1034     def clone_without_data(self, length=0, clone=None): 
    1035         """ 
    1036         Clone the current object, without copying the data (which 
    1037         will be filled out by a subsequent operation). 
    1038         The data arrays will be initialized to zero. 
    1039          
    1040         :param length: length of the data array to be initialized 
    1041         :param clone: if provided, the data will be copied to clone 
    1042         """ 
    1043         from copy import deepcopy 
    1044          
    1045         if clone is None or not issubclass(clone.__class__, Data1D): 
    1046             x  = numpy.zeros(length) 
    1047             dx = numpy.zeros(length) 
    1048             y  = numpy.zeros(length) 
    1049             dy = numpy.zeros(length) 
    1050             clone = Data1D(x, y, dx=dx, dy=dy) 
    1051          
    1052         clone.title          = self.title 
    1053         clone.run            = self.run 
    1054         clone.filename       = self.filename 
    1055         clone.instrument     = self.instrument 
    1056         clone.notes          = deepcopy(self.notes) 
    1057         clone.process        = deepcopy(self.process) 
    1058         clone.detector       = deepcopy(self.detector) 
    1059         clone.sample         = deepcopy(self.sample) 
    1060         clone.source         = deepcopy(self.source) 
    1061         clone.collimation    = deepcopy(self.collimation) 
    1062         clone.trans_spectrum = deepcopy(self.trans_spectrum) 
    1063         clone.meta_data      = deepcopy(self.meta_data) 
    1064         clone.errors         = deepcopy(self.errors) 
    1065          
    1066         return clone 
    1067      
    1068      
    10691084class Data2D(plottable_2D, DataInfo): 
    10701085    """ 
  • src/sas/dataloader/loader.py

    r79492222 r5e326a6  
    363363        :return: DataInfo object 
    364364        """ 
     365        print self.__registry.extensions 
    365366        return self.__registry.load(file, format) 
    366367     
  • src/sas/dataloader/readers/associations.py

    r5dfdfa7 r5e326a6  
    9191    #import tiff_reader 
    9292    import nexus_reader 
    93  
     93    import sesans_reader 
     94    registry_function(sesans_reader) 
    9495    registry_function(abs_reader) 
    9596    registry_function(ascii_reader) 
  • src/sas/dataloader/readers/defaults.json

    r5dfdfa7 r5e326a6  
    55            "-extension":".xml", 
    66            "-reader":"cansas_reader" 
     7         }, 
     8         { 
     9            "-extension":".ses", 
     10            "-reader":"sesans_reader" 
    711         }, 
    812         { 
Note: See TracChangeset for help on using the changeset viewer.