Changeset 0997158f in sasview for DataLoader/readers
- Timestamp:
- Jun 1, 2010 3:20:09 PM (15 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:
- a45622a
- Parents:
- 54180f9
- 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 1 13 """ 2 14 IGOR 2D reduced file reader 3 """4 5 """6 This software was developed by the University of Tennessee as part of the7 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 to11 publication, we ask that you acknowledge the use of the software with the12 following sentence:13 14 "This work benefited from DANSE software developed under NSF award DMR-0520547."15 16 copyright 2008, University of Tennessee17 15 """ 18 16 -
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 ###################################################################### 10 8 11 9 import numpy … … 21 19 class Reader: 22 20 """ 23 21 Class to load IGOR reduced .ABS files 24 22 """ 25 23 ## File type … … 32 30 def read(self, path): 33 31 """ 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 40 40 """ 41 41 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 10 14 11 15 import numpy … … 22 26 class Reader: 23 27 """ 24 Class to load ascii files (2, 3 or 4 columns)28 Class to load ascii files (2, 3 or 4 columns). 25 29 """ 26 30 ## File type … … 39 43 def read(self, path): 40 44 """ 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 47 53 """ 48 54 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 the3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE)4 project funded by the US National Science Foundation.5 1 6 See the license text in license.txt7 2 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 10 14 11 15 """ 12 13 14 16 Module to associate default readers to file extensions. 17 The module reads an xml file to get the readers for each file extension. 18 The readers are tried in order they appear when reading a file. 15 19 """ 16 20 … … 26 30 def read_associations(loader, settings='defaults.xml'): 27 31 """ 28 29 30 31 @param loader: Loader object32 @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] 33 37 """ 34 38 reader_dir = os.path.dirname(__file__) … … 69 73 def register_readers(registry_function): 70 74 """ 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. 75 77 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 77 81 """ 78 82 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 10 14 # Known issue: reader not compatible with multiple SASdata entries 11 15 # within a single SASentry. Will raise a runtime error. … … 37 41 def write_node(doc, parent, name, value, attr={}): 38 42 """ 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 45 50 """ 46 51 if value is not None: … … 55 60 def get_content(location, node): 56 61 """ 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 62 68 """ 63 69 nodes = node.xpath(location, namespaces={'ns': CANSAS_NS}) … … 70 76 def get_float(location, node): 71 77 """ 72 73 74 @param location: xpath location75 @param node: node to start at78 Get the content of a node as a float 79 80 :param location: xpath location 81 :param node: node to start at 76 82 """ 77 83 nodes = node.xpath(location, namespaces={'ns': CANSAS_NS}) … … 96 102 class Reader: 97 103 """ 98 99 100 101 104 Class to load cansas 1D XML files 105 106 :Dependencies: 107 The CanSas reader requires PyXML 0.8.4 or later. 102 108 """ 103 109 ## CanSAS version … … 116 122 def read(self, path): 117 123 """ 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 126 134 """ 127 135 output = [] … … 162 170 def _parse_entry(self, dom): 163 171 """ 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 168 177 """ 169 178 x = numpy.zeros(0) … … 510 519 def _to_xml_doc(self, datainfo): 511 520 """ 512 513 514 @param datainfo: Data1D object521 Create an XML document to contain the content of a Data1D 522 523 :param datainfo: Data1D object 515 524 """ 516 525 … … 696 705 def write(self, filename, datainfo): 697 706 """ 698 699 700 @param filename: name of the file to write701 @param datainfo: Data1D object707 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 702 711 """ 703 712 # Create XML document … … 710 719 def _store_float(self, location, node, variable, storage, optional=True): 711 720 """ 712 713 714 715 716 717 718 719 720 @param location: xpath location to fetch721 @param node: node to read the data from722 @param variable: name of the data member to store it in [string]723 @param storage: data object that has the 'variable' data member724 @param optional: if True, no exception will be raised if unit conversion can't be done725 726 @raise ValueError: raised when the units are not recognized721 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 727 736 """ 728 737 entry = get_content(location, node) … … 767 776 def _store_content(self, location, node, variable, storage): 768 777 """ 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 780 790 """ 781 791 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 1 14 """ 2 15 DANSE/SANS file reader 3 """4 5 """6 This software was developed by the University of Tennessee as part of the7 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 to11 publication, we ask that you acknowledge the use of the software with the12 following sentence:13 14 "This work benefited from DANSE software developed under NSF award DMR-0520547."15 16 copyright 2008, University of Tennessee17 16 """ 18 17 … … 34 33 class Reader: 35 34 """ 36 35 Example data manipulation 37 36 """ 38 37 ## File type … … 45 44 def read(self, filename=None): 46 45 """ 47 48 46 Open and read the data in a file 47 @param file: path of the file 49 48 """ 50 49 … … 215 214 216 215 217 # Store all data ######################################216 # Store all data 218 217 # Store wavelength 219 218 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 the3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE)4 project funded by the US National Science Foundation.5 1 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 ###################################################################### 10 9 11 10 import numpy … … 22 21 class Reader(object): 23 22 """ 24 23 Class to load HFIR 1D 4-column files 25 24 """ 26 25 ## File type … … 33 32 def read(self, path): 34 33 """ 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 41 42 """ 42 43 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 1 10 """ 2 11 TXT/IGOR 2D Q Map file reader 3 12 """ 4 13 5 """6 This software was developed by the University of Tennessee as part of the7 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 to11 publication, we ask that you acknowledge the use of the software with the12 following sentence:13 14 "This work benefited from DANSE software developed under NSF award DMR-0520547."15 16 copyright 2008, University of Tennessee17 """18 14 19 15 import 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 ###################################################################### 1 10 """ 2 11 Image reader. Untested. 3 12 """ 4 13 5 """6 This software was developed by the University of Tennessee as part of the7 Distributed Data Analysis of Neutron Scattering Experiments (DANSE)8 project funded by the US National Science Foundation.9 14 10 See the license text in license.txt11 12 copyright 2008, University of Tennessee13 """14 15 #TODO: load and check data and orientation of the image (needs rendering) 15 16 … … 20 21 class Reader: 21 22 """ 22 23 Example data manipulation 23 24 """ 24 25 ## File type … … 33 34 def read(self, filename=None): 34 35 """ 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 37 39 """ 38 40 try:
Note: See TracChangeset
for help on using the changeset viewer.