Changeset 0997158f in sasview for DataLoader/readers


Ignore:
Timestamp:
Jun 1, 2010 3:20:09 PM (14 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:
a45622a
Parents:
54180f9
Message:

working on documentation

Location:
DataLoader/readers
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • DataLoader/readers/IgorReader.py

    readf1f9 r0997158f  
     1 
     2############################################################################ 
     3#This software was developed by the University of Tennessee as part of the 
     4#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     5#project funded by the US National Science Foundation.  
     6#If you use DANSE applications to do scientific research that leads to  
     7#publication, we ask that you acknowledge the use of the software with the  
     8#following sentence: 
     9#This work benefited from DANSE software developed under NSF award DMR-0520547.  
     10#copyright 2008, University of Tennessee 
     11############################################################################# 
     12 
    113""" 
    214    IGOR 2D reduced file reader 
    3 """ 
    4  
    5 """ 
    6 This software was developed by the University of Tennessee as part of the 
    7 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    8 project funded by the US National Science Foundation.  
    9  
    10 If you use DANSE applications to do scientific research that leads to  
    11 publication, we ask that you acknowledge the use of the software with the  
    12 following sentence: 
    13  
    14 "This work benefited from DANSE software developed under NSF award DMR-0520547."  
    15  
    16 copyright 2008, University of Tennessee 
    1715""" 
    1816 
  • DataLoader/readers/abs_reader.py

    rfe78c7b r0997158f  
    1 """ 
    2 This software was developed by the University of Tennessee as part of the 
    3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    4 project funded by the US National Science Foundation.  
    5  
    6 See the license text in license.txt 
    7  
    8 copyright 2008, University of Tennessee 
    9 """ 
     1##################################################################### 
     2#This software was developed by the University of Tennessee as part of the 
     3#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     4#project funded by the US National Science Foundation.  
     5#See the license text in license.txt 
     6#copyright 2008, University of Tennessee 
     7###################################################################### 
    108 
    119import numpy 
     
    2119class Reader: 
    2220    """ 
    23         Class to load IGOR reduced .ABS files 
     21    Class to load IGOR reduced .ABS files 
    2422    """ 
    2523    ## File type 
     
    3230    def read(self, path): 
    3331        """  
    34             Load data file 
    35              
    36             @param path: file path 
    37             @return: Data1D object, or None 
    38             @raise RuntimeError: when the file can't be opened 
    39             @raise ValueError: when the length of the data vectors are inconsistent 
     32        Load data file. 
     33         
     34        :param path: file path 
     35         
     36        :return: Data1D object, or None 
     37         
     38        :raise RuntimeError: when the file can't be opened 
     39        :raise ValueError: when the length of the data vectors are inconsistent 
    4040        """ 
    4141        if os.path.isfile(path): 
  • DataLoader/readers/ascii_reader.py

    rc7c5ef8 r0997158f  
    1 """ 
    2 This software was developed by the University of Tennessee as part of the 
    3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    4 project funded by the US National Science Foundation.  
    5  
    6 See the license text in license.txt 
    7  
    8 copyright 2008, University of Tennessee 
    9 """ 
     1 
     2 
     3############################################################################ 
     4#This software was developed by the University of Tennessee as part of the 
     5#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     6#project funded by the US National Science Foundation.  
     7#If you use DANSE applications to do scientific research that leads to  
     8#publication, we ask that you acknowledge the use of the software with the  
     9#following sentence: 
     10#This work benefited from DANSE software developed under NSF award DMR-0520547.  
     11#copyright 2008, University of Tennessee 
     12############################################################################# 
     13 
    1014 
    1115import numpy 
     
    2226class Reader: 
    2327    """ 
    24         Class to load ascii files (2, 3 or 4 columns) 
     28    Class to load ascii files (2, 3 or 4 columns). 
    2529    """ 
    2630    ## File type 
     
    3943    def read(self, path): 
    4044        """  
    41             Load data file 
    42              
    43             @param path: file path 
    44             @return: Data1D object, or None 
    45             @raise RuntimeError: when the file can't be opened 
    46             @raise ValueError: when the length of the data vectors are inconsistent 
     45        Load data file 
     46         
     47        :param path: file path 
     48         
     49        :return: Data1D object, or None 
     50         
     51        :raise RuntimeError: when the file can't be opened 
     52        :raise ValueError: when the length of the data vectors are inconsistent 
    4753        """ 
    4854        if os.path.isfile(path): 
  • DataLoader/readers/associations.py

    rded62ce r0997158f  
    1 """ 
    2 This software was developed by the University of Tennessee as part of the 
    3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    4 project funded by the US National Science Foundation.  
    51 
    6 See the license text in license.txt 
    72 
    8 copyright 2009, University of Tennessee 
    9 """ 
     3############################################################################ 
     4#This software was developed by the University of Tennessee as part of the 
     5#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     6#project funded by the US National Science Foundation.  
     7#If you use DANSE applications to do scientific research that leads to  
     8#publication, we ask that you acknowledge the use of the software with the  
     9#following sentence: 
     10#This work benefited from DANSE software developed under NSF award DMR-0520547.  
     11#copyright 2009, University of Tennessee 
     12############################################################################# 
     13 
    1014 
    1115""" 
    12     Module to associate default readers to file extensions. 
    13     The module reads an xml file to get the readers for each file extension. 
    14     The readers are tried in order they appear when reading a file. 
     16Module to associate default readers to file extensions. 
     17The module reads an xml file to get the readers for each file extension. 
     18The readers are tried in order they appear when reading a file. 
    1519""" 
    1620 
     
    2630def read_associations(loader, settings='defaults.xml'): 
    2731    """ 
    28         Read the specified settings file to associate 
    29         default readers to file extension. 
    30          
    31         @param loader: Loader object 
    32         @param settings: path to the XML settings file [string] 
     32    Read the specified settings file to associate 
     33    default readers to file extension. 
     34     
     35    :param loader: Loader object 
     36    :param settings: path to the XML settings file [string] 
    3337    """ 
    3438    reader_dir = os.path.dirname(__file__) 
     
    6973def register_readers(registry_function): 
    7074    """ 
    71         Function called by the registry/loader object to register 
    72         all default readers using a call back function. 
    73          
    74         WARNING: this method is now obsolete 
     75    Function called by the registry/loader object to register 
     76    all default readers using a call back function. 
    7577     
    76         @param registry_function: function to be called to register each reader 
     78    :WARNING: this method is now obsolete 
     79 
     80    :param registry_function: function to be called to register each reader 
    7781    """ 
    7882    logging.info("register_readers is now obsolete: use read_associations()") 
  • DataLoader/readers/cansas_reader.py

    rfe78c7b r0997158f  
    1 """ 
    2 This software was developed by the University of Tennessee as part of the 
    3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    4 project funded by the US National Science Foundation.  
    5  
    6 See the license text in license.txt 
    7  
    8 copyright 2008, 2009, University of Tennessee 
    9 """ 
     1 
     2 
     3############################################################################ 
     4#This software was developed by the University of Tennessee as part of the 
     5#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     6#project funded by the US National Science Foundation.  
     7#If you use DANSE applications to do scientific research that leads to  
     8#publication, we ask that you acknowledge the use of the software with the  
     9#following sentence: 
     10#This work benefited from DANSE software developed under NSF award DMR-0520547.  
     11#copyright 2008,2009 University of Tennessee 
     12############################################################################# 
     13 
    1014# Known issue: reader not compatible with multiple SASdata entries 
    1115# within a single SASentry. Will raise a runtime error. 
     
    3741def write_node(doc, parent, name, value, attr={}): 
    3842    """ 
    39         @param doc: document DOM 
    40         @param parent: parent node 
    41         @param name: tag of the element 
    42         @param value: value of the child text node 
    43         @param attr: attribute dictionary 
    44         @return: True if something was appended, otherwise False 
     43    :param doc: document DOM 
     44    :param parent: parent node 
     45    :param name: tag of the element 
     46    :param value: value of the child text node 
     47    :param attr: attribute dictionary 
     48     
     49    :return: True if something was appended, otherwise False 
    4550    """ 
    4651    if value is not None: 
     
    5560def get_content(location, node): 
    5661    """ 
    57         Get the first instance of the content of a xpath location 
    58          
    59         @param location: xpath location 
    60         @param node: node to start at 
    61         @return: Element, or None 
     62    Get the first instance of the content of a xpath location. 
     63     
     64    :param location: xpath location 
     65    :param node: node to start at 
     66     
     67    :return: Element, or None 
    6268    """ 
    6369    nodes = node.xpath(location, namespaces={'ns': CANSAS_NS}) 
     
    7076def get_float(location, node): 
    7177    """ 
    72         Get the content of a node as a float  
    73          
    74         @param location: xpath location 
    75         @param node: node to start at 
     78    Get the content of a node as a float  
     79     
     80    :param location: xpath location 
     81    :param node: node to start at 
    7682    """ 
    7783    nodes = node.xpath(location, namespaces={'ns': CANSAS_NS}) 
     
    96102class Reader: 
    97103    """ 
    98         Class to load cansas 1D XML files 
    99          
    100         Dependencies: 
    101             The CanSas reader requires PyXML 0.8.4 or later. 
     104    Class to load cansas 1D XML files 
     105     
     106    :Dependencies: 
     107        The CanSas reader requires PyXML 0.8.4 or later. 
    102108    """ 
    103109    ## CanSAS version 
     
    116122    def read(self, path): 
    117123        """  
    118             Load data file 
    119              
    120             @param path: file path 
    121             @return: Data1D object if a single SASentry was found,  
    122                         or a list of Data1D objects if multiple entries were found, 
    123                         or None of nothing was found 
    124             @raise RuntimeError: when the file can't be opened 
    125             @raise ValueError: when the length of the data vectors are inconsistent 
     124        Load data file 
     125         
     126        :param path: file path 
     127         
     128        :return: Data1D object if a single SASentry was found,  
     129                    or a list of Data1D objects if multiple entries were found, 
     130                    or None of nothing was found 
     131                     
     132        :raise RuntimeError: when the file can't be opened 
     133        :raise ValueError: when the length of the data vectors are inconsistent 
    126134        """ 
    127135        output = [] 
     
    162170    def _parse_entry(self, dom): 
    163171        """ 
    164             Parse a SASentry 
    165              
    166             @param node: SASentry node 
    167             @return: Data1D object 
     172        Parse a SASentry 
     173         
     174        :param node: SASentry node 
     175         
     176        :return: Data1D object 
    168177        """ 
    169178        x = numpy.zeros(0) 
     
    510519    def _to_xml_doc(self, datainfo): 
    511520        """ 
    512             Create an XML document to contain the content of a Data1D 
    513              
    514             @param datainfo: Data1D object 
     521        Create an XML document to contain the content of a Data1D 
     522         
     523        :param datainfo: Data1D object 
    515524        """ 
    516525         
     
    696705    def write(self, filename, datainfo): 
    697706        """ 
    698             Write the content of a Data1D as a CanSAS XML file 
    699              
    700             @param filename: name of the file to write 
    701             @param datainfo: Data1D object 
     707        Write the content of a Data1D as a CanSAS XML file 
     708         
     709        :param filename: name of the file to write 
     710        :param datainfo: Data1D object 
    702711        """ 
    703712        # Create XML document 
     
    710719    def _store_float(self, location, node, variable, storage, optional=True): 
    711720        """ 
    712             Get the content of a xpath location and store 
    713             the result. Check that the units are compatible 
    714             with the destination. The value is expected to 
    715             be a float. 
    716              
    717             The xpath location might or might not exist. 
    718             If it does not exist, nothing is done 
    719              
    720             @param location: xpath location to fetch 
    721             @param node: node to read the data from 
    722             @param variable: name of the data member to store it in [string] 
    723             @param storage: data object that has the 'variable' data member 
    724             @param optional: if True, no exception will be raised if unit conversion can't be done 
    725      
    726             @raise ValueError: raised when the units are not recognized 
     721        Get the content of a xpath location and store 
     722        the result. Check that the units are compatible 
     723        with the destination. The value is expected to 
     724        be a float. 
     725         
     726        The xpath location might or might not exist. 
     727        If it does not exist, nothing is done 
     728         
     729        :param location: xpath location to fetch 
     730        :param node: node to read the data from 
     731        :param variable: name of the data member to store it in [string] 
     732        :param storage: data object that has the 'variable' data member 
     733        :param optional: if True, no exception will be raised if unit conversion can't be done 
     734 
     735        :raise ValueError: raised when the units are not recognized 
    727736        """ 
    728737        entry = get_content(location, node) 
     
    767776    def _store_content(self, location, node, variable, storage): 
    768777        """ 
    769             Get the content of a xpath location and store 
    770             the result. The value is treated as a string. 
    771              
    772             The xpath location might or might not exist. 
    773             If it does not exist, nothing is done 
    774              
    775             @param location: xpath location to fetch 
    776             @param node: node to read the data from 
    777             @param variable: name of the data member to store it in [string] 
    778             @param storage: data object that has the 'variable' data member 
    779             @return: return a list of errors 
     778        Get the content of a xpath location and store 
     779        the result. The value is treated as a string. 
     780         
     781        The xpath location might or might not exist. 
     782        If it does not exist, nothing is done 
     783         
     784        :param location: xpath location to fetch 
     785        :param node: node to read the data from 
     786        :param variable: name of the data member to store it in [string] 
     787        :param storage: data object that has the 'variable' data member 
     788         
     789        :return: return a list of errors 
    780790        """ 
    781791        entry = get_content(location, node) 
  • DataLoader/readers/danse_reader.py

    readf1f9 r0997158f  
     1 
     2 
     3############################################################################ 
     4#This software was developed by the University of Tennessee as part of the 
     5#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     6#project funded by the US National Science Foundation.  
     7#If you use DANSE applications to do scientific research that leads to  
     8#publication, we ask that you acknowledge the use of the software with the  
     9#following sentence: 
     10#This work benefited from DANSE software developed under NSF award DMR-0520547.  
     11#copyright 2008, University of Tennessee 
     12############################################################################# 
     13 
    114""" 
    215    DANSE/SANS file reader 
    3 """ 
    4  
    5 """ 
    6 This software was developed by the University of Tennessee as part of the 
    7 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    8 project funded by the US National Science Foundation.  
    9  
    10 If you use DANSE applications to do scientific research that leads to  
    11 publication, we ask that you acknowledge the use of the software with the  
    12 following sentence: 
    13  
    14 "This work benefited from DANSE software developed under NSF award DMR-0520547."  
    15  
    16 copyright 2008, University of Tennessee 
    1716""" 
    1817 
     
    3433class Reader: 
    3534    """ 
    36         Example data manipulation 
     35    Example data manipulation 
    3736    """ 
    3837    ## File type 
     
    4544    def read(self, filename=None): 
    4645        """ 
    47             Open and read the data in a file 
    48             @param file: path of the file 
     46        Open and read the data in a file 
     47        @param file: path of the file 
    4948        """ 
    5049         
     
    215214                 
    216215                 
    217             # Store all data ###################################### 
     216            # Store all data  
    218217            # Store wavelength 
    219218            if has_converter==True and output.source.wavelength_unit != 'A': 
  • DataLoader/readers/hfir1d_reader.py

    rfe78c7b r0997158f  
    1 """ 
    2 This software was developed by the University of Tennessee as part of the 
    3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    4 project funded by the US National Science Foundation.  
    51 
    6 See the license text in license.txt 
    7  
    8 copyright 2008, University of Tennessee 
    9 """ 
     2##################################################################### 
     3#This software was developed by the University of Tennessee as part of the 
     4#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     5#project funded by the US National Science Foundation.  
     6#See the license text in license.txt 
     7#copyright 2008, University of Tennessee 
     8###################################################################### 
    109 
    1110import numpy 
     
    2221class Reader(object): 
    2322    """ 
    24         Class to load HFIR 1D 4-column files 
     23    Class to load HFIR 1D 4-column files 
    2524    """ 
    2625    ## File type 
     
    3332    def read(self, path): 
    3433        """  
    35             Load data file 
    36              
    37             @param path: file path 
    38             @return: Data1D object, or None 
    39             @raise RuntimeError: when the file can't be opened 
    40             @raise ValueError: when the length of the data vectors are inconsistent 
     34        Load data file 
     35         
     36        :param path: file path 
     37         
     38        :return: Data1D object, or None 
     39         
     40        :raise RuntimeError: when the file can't be opened 
     41        :raise ValueError: when the length of the data vectors are inconsistent 
    4142        """ 
    4243        if os.path.isfile(path): 
  • DataLoader/readers/red2d_reader.py

    r59a2dab r0997158f  
     1 
     2##################################################################### 
     3#This software was developed by the University of Tennessee as part of the 
     4#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     5#project funded by the US National Science Foundation.  
     6#See the license text in license.txt 
     7#copyright 2008, University of Tennessee 
     8###################################################################### 
     9 
    110""" 
    211    TXT/IGOR 2D Q Map file reader 
    312""" 
    413 
    5 """ 
    6 This software was developed by the University of Tennessee as part of the 
    7 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    8 project funded by the US National Science Foundation.  
    9  
    10 If you use DANSE applications to do scientific research that leads to  
    11 publication, we ask that you acknowledge the use of the software with the  
    12 following sentence: 
    13  
    14 "This work benefited from DANSE software developed under NSF award DMR-0520547."  
    15  
    16 copyright 2008, University of Tennessee 
    17 """ 
    1814 
    1915import os, sys 
  • DataLoader/readers/tiff_reader.py

    rfe78c7b r0997158f  
     1 
     2 
     3##################################################################### 
     4#This software was developed by the University of Tennessee as part of the 
     5#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     6#project funded by the US National Science Foundation.  
     7#See the license text in license.txt 
     8#copyright 2008, University of Tennessee 
     9###################################################################### 
    110""" 
    211    Image reader. Untested.  
    312""" 
    413 
    5 """ 
    6 This software was developed by the University of Tennessee as part of the 
    7 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    8 project funded by the US National Science Foundation.  
    914 
    10 See the license text in license.txt 
    11  
    12 copyright 2008, University of Tennessee 
    13 """ 
    1415#TODO: load and check data and orientation of the image (needs rendering) 
    1516 
     
    2021class Reader: 
    2122    """ 
    22         Example data manipulation 
     23    Example data manipulation 
    2324    """ 
    2425    ## File type 
     
    3334    def read(self, filename=None): 
    3435        """ 
    35             Open and read the data in a file 
    36             @param file: path of the file 
     36        Open and read the data in a file 
     37         
     38        :param file: path of the file 
    3739        """ 
    3840        try: 
Note: See TracChangeset for help on using the changeset viewer.