sas.sascalc.dataloader.readers package

Submodules

sas.sascalc.dataloader.readers.abs_reader module

IGOR 1D data reader

class sas.sascalc.dataloader.readers.abs_reader.Reader[source]

Bases: sas.sascalc.dataloader.file_reader_base_class.FileReader

Class to load IGOR reduced .ABS files

ext = ['.abs', '.cor']
get_file_contents()[source]

Get the contents of the file

Raises:
  • RuntimeError – when the file can’t be opened
  • ValueError – when the length of the data vectors are inconsistent
type = ['IGOR 1D files (*.abs)|*.abs', 'IGOR 1D USANS files (*.cor)|*.cor']
type_name = 'IGOR 1D'

sas.sascalc.dataloader.readers.anton_paar_saxs_reader module

CanSAS 2D data reader for reading HDF5 formatted CanSAS files.

class sas.sascalc.dataloader.readers.anton_paar_saxs_reader.Reader(xml=None, schema=None)[source]

Bases: sas.sascalc.dataloader.readers.xml_reader.XMLreader

A class for reading in Anton Paar .pdh files

allow_all = False
errors = None
ext = ['.pdh', '.PDH']
get_file_contents()[source]

This is the general read method that all SasView data_loaders must have.

Parameters:filename – A path for an XML formatted Anton Paar SAXSess data file.
Returns:List of Data1D objects or a list of errors.
logging = None
parent_list = None
raw_data = None
read_data()[source]
reset_state()[source]

Resets the class state to a base case when loading a new data file so previous data files do not appear a second time

type = ['Anton Paar SAXSess Files (*.pdh)|*.pdh']
type_name = 'Anton Paar SAXSess'

sas.sascalc.dataloader.readers.ascii_reader module

Generic multi-column ASCII data reader

class sas.sascalc.dataloader.readers.ascii_reader.Reader[source]

Bases: sas.sascalc.dataloader.file_reader_base_class.FileReader

Class to load ascii files (2, 3 or 4 columns).

allow_all = True
ext = ['.txt', '.dat', '.abs', '.csv']
get_file_contents()[source]

Get the contents of the file

min_data_pts = 5
type = ['ASCII files (*.txt)|*.txt', 'ASCII files (*.dat)|*.dat', 'ASCII files (*.abs)|*.abs', 'CSV files (*.csv)|*.csv']
type_name = 'ASCII'

sas.sascalc.dataloader.readers.associations module

Module to associate default readers to file extensions. The module reads an xml file to get the readers for each file extension. The readers are tried in order they appear when reading a file.

sas.sascalc.dataloader.readers.associations.get_generic_readers(settings={'.h5': 'cansas_reader_HDF5', '.txt': 'ascii_reader', '.xml': 'cansas_reader'})[source]

Find and load the default loaders used by the program :param settings: path to the json settings file [string] :return: list of default loaders every file can potentially try to use

sas.sascalc.dataloader.readers.associations.read_associations(loader, settings={'.abs': 'abs_reader', '.cor': 'abs_reader', '.dat': 'red2d_reader', '.h5': 'cansas_reader_HDF5', '.hdf': 'cansas_reader_HDF5', '.nxs': 'cansas_reader_HDF5', '.pdh': 'anton_paar_saxs_reader', '.sans': 'danse_reader', '.ses': 'sesans_reader', '.txt': 'ascii_reader', '.xml': 'cansas_reader'})[source]

Read the specified settings file to associate default readers to file extension. :param loader: Loader object :param settings: path to the json settings file [string]

sas.sascalc.dataloader.readers.cansas_constants module

Information relating to the CanSAS data format. These constants are used in the cansas_reader.py file to read in any version of the cansas format.

class sas.sascalc.dataloader.readers.cansas_constants.CansasConstants[source]

Bases: object

The base class to define where all of the data is to be saved by cansas_reader.py.

ANY = {'storeas': 'content'}
CANSAS_FORMAT = {'SASentry': {'units_optional': True, 'storeas': 'content', 'attributes': {'name': {}}, 'children': {'Title': {}, 'Run': {'attributes': {'name': {}}}, 'SASdata': {'attributes': {'name': {}}, 'variable': None, 'children': {'Idata': {'attributes': {'name': {}, 'timestamp': {'storeas': 'timestamp'}}, 'children': {'Q': {'units_optional': False, 'storeas': 'float', 'unit': 'x_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'I': {'units_optional': False, 'storeas': 'float', 'unit': 'y_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'Idev': {'units_optional': False, 'storeas': 'float', 'unit': 'y_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'Qdev': {'units_optional': False, 'storeas': 'float', 'unit': 'x_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'dQw': {'units_optional': False, 'storeas': 'float', 'unit': 'x_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'dQl': {'units_optional': False, 'storeas': 'float', 'unit': 'x_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'Qmean': {'unit': 'x_unit', 'attributes': {'unit': {}}}, 'Shadowfactor': {}, '<any>': {'storeas': 'content'}}}, 'Sesans': {'storeas': 'content'}, 'zacceptance': {'storeas': 'float'}, 'yacceptance': {'storeas': 'float'}, '<any>': {'storeas': 'content'}}}, 'SAStransmission_spectrum': {'children': {'Tdata': {'children': {'Lambda': {'storeas': 'float', 'unit': 'wavelength_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'T': {'storeas': 'float', 'unit': 'transmission_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'Tdev': {'storeas': 'float', 'unit': 'transmission_deviation_unit', 'attributes': {'unit': {'storeas': 'content'}}}, '<any>': {'storeas': 'content'}}}, '<any>': {'storeas': 'content'}}, 'attributes': {'name': {}, 'timestamp': {}}}, 'SASsample': {'attributes': {'name': {}}, 'children': {'ID': {}, 'thickness': {'unit': 'thickness_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'transmission': {'storeas': 'float'}, 'temperature': {'unit': 'temperature_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'position': {'children': {'x': {'unit': 'position_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'y': {'unit': 'position_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'z': {'unit': 'position_unit', 'storeas': 'float', 'attributes': {'unit': {}}}}}, 'orientation': {'children': {'roll': {'unit': 'orientation_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'pitch': {'unit': 'orientation_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'yaw': {'unit': 'orientation_unit', 'storeas': 'float', 'attributes': {'unit': {}}}}}, 'details': {}, '<any>': {'storeas': 'content'}}}, 'SASinstrument': {'children': {'name': {}, 'SASsource': {'attributes': {'name': {}}, 'children': {'radiation': {}, 'beam_size': {'attributes': {'name': {}}, 'children': {'x': {'unit': 'beam_size_unit', 'storeas': 'float', 'attributes': {'unit': ''}}, 'y': {'unit': 'beam_size_unit', 'storeas': 'float', 'attributes': {'unit': ''}}, 'z': {'unit': 'beam_size_unit', 'storeas': 'float', 'attributes': {'unit': ''}}}}, 'beam_shape': {}, 'wavelength': {'unit': 'wavelength_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'wavelength_min': {'unit': 'wavelength_min_unit', 'storeas': 'float', 'attributes': {'unit': {'storeas': 'content'}}}, 'wavelength_max': {'unit': 'wavelength_max_unit', 'storeas': 'float', 'attributes': {'unit': {'storeas': 'content'}}}, 'wavelength_spread': {'unit': 'wavelength_spread_unit', 'storeas': 'float', 'attributes': {'unit': {'storeas': 'content'}}}}}, 'SAScollimation': {'attributes': {'name': {}}, 'children': {'length': {'unit': 'length_unit', 'storeas': 'float', 'attributes': {'storeas': 'content', 'unit': {}}}, 'aperture': {'attributes': {'name': {}, 'type': {}}, 'children': {'size': {'attributes': {'unit': {}}, 'children': {'storeas': 'float', 'x': {'unit': 'size_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'y': {'unit': 'size_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'z': {'unit': 'size_unit', 'storeas': 'float', 'attributes': {'unit': {}}}}}, 'distance': {'storeas': 'float', 'attributes': {'unit': {}}, 'unit': 'distance_unit'}}}}}, 'SASdetector': {'attributes': {'name': {'storeas': 'content'}}, 'children': {'name': {'storeas': 'content'}, 'SDD': {'storeas': 'float', 'unit': 'distance_unit', 'attributes': {'unit': {}}}, 'offset': {'children': {'x': {'storeas': 'float', 'unit': 'offset_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'y': {'storeas': 'float', 'unit': 'offset_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'z': {'storeas': 'float', 'unit': 'offset_unit', 'attributes': {'unit': {'storeas': 'content'}}}}}, 'orientation': {'children': {'roll': {'storeas': 'float', 'unit': 'orientation_unit', 'attributes': {}}, 'pitch': {'storeas': 'float', 'unit': 'orientation_unit', 'attributes': {}}, 'yaw': {'storeas': 'float', 'unit': 'orientation_unit', 'attributes': {}}}}, 'beam_center': {'children': {'x': {'storeas': 'float', 'unit': 'beam_center_unit', 'attributes': {'storeas': 'content'}}, 'y': {'storeas': 'float', 'unit': 'beam_center_unit', 'attributes': {'storeas': 'content'}}, 'z': {'storeas': 'float', 'unit': 'beam_center_unit', 'attributes': {'storeas': 'content'}}}}, 'pixel_size': {'children': {'x': {'storeas': 'float', 'unit': 'pixel_size_unit', 'attributes': {'storeas': 'content'}}, 'y': {'storeas': 'float', 'unit': 'pixel_size_unit', 'attributes': {'storeas': 'content'}}, 'z': {'storeas': 'float', 'unit': 'pixel_size_unit', 'attributes': {'storeas': 'content'}}}}, 'slit_length': {'storeas': 'float', 'unit': 'slit_length_unit', 'attributes': {'unit': {}}}}}}}, 'SASprocess': {'children': {'name': {}, 'date': {}, 'description': {}, 'term': {'attributes': {'unit': {}, 'name': {}}}, 'SASprocessnote': {'children': {'<any>': {'storeas': 'content'}}}, '<any>': {'storeas': 'content'}}}, 'SASnote': {}, '<any>': {'storeas': 'content'}}}}
CANSAS_NS = {'1.0': {'ns': 'cansas1d/1.0', 'schema': 'cansas1d_v1_0.xsd'}, '1.1': {'ns': 'urn:cansas1d:1.1', 'schema': 'cansas1d_v1_1.xsd'}}
RUN = {'attributes': {'name': {}}}
SASDATA = {'attributes': {'name': {}}, 'children': {'Idata': {'attributes': {'name': {}, 'timestamp': {'storeas': 'timestamp'}}, 'children': {'Q': {'units_optional': False, 'storeas': 'float', 'unit': 'x_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'I': {'units_optional': False, 'storeas': 'float', 'unit': 'y_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'Idev': {'units_optional': False, 'storeas': 'float', 'unit': 'y_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'Qdev': {'units_optional': False, 'storeas': 'float', 'unit': 'x_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'dQw': {'units_optional': False, 'storeas': 'float', 'unit': 'x_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'dQl': {'units_optional': False, 'storeas': 'float', 'unit': 'x_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'Qmean': {'unit': 'x_unit', 'attributes': {'unit': {}}}, 'Shadowfactor': {}, '<any>': {'storeas': 'content'}}}, 'Sesans': {'storeas': 'content'}, 'zacceptance': {'storeas': 'float'}, 'yacceptance': {'storeas': 'float'}, '<any>': {'storeas': 'content'}}, 'variable': None}
SASDATA_IDATA = {'attributes': {'name': {}, 'timestamp': {'storeas': 'timestamp'}}, 'children': {'Q': {'units_optional': False, 'storeas': 'float', 'unit': 'x_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'I': {'units_optional': False, 'storeas': 'float', 'unit': 'y_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'Idev': {'units_optional': False, 'storeas': 'float', 'unit': 'y_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'Qdev': {'units_optional': False, 'storeas': 'float', 'unit': 'x_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'dQw': {'units_optional': False, 'storeas': 'float', 'unit': 'x_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'dQl': {'units_optional': False, 'storeas': 'float', 'unit': 'x_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'Qmean': {'unit': 'x_unit', 'attributes': {'unit': {}}}, 'Shadowfactor': {}, '<any>': {'storeas': 'content'}}}
SASDATA_IDATA_DQL = {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'x_unit', 'units_optional': False}
SASDATA_IDATA_DQW = {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'x_unit', 'units_optional': False}
SASDATA_IDATA_I = {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'y_unit', 'units_optional': False}
SASDATA_IDATA_IDEV = {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'y_unit', 'units_optional': False}
SASDATA_IDATA_Q = {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'x_unit', 'units_optional': False}
SASDATA_IDATA_QDEV = {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'x_unit', 'units_optional': False}
SASDATA_IDATA_QMEAN = {'attributes': {'unit': {}}, 'unit': 'x_unit'}
SASDATA_IDATA_SHADOWFACTOR = {}
SASINSTR = {'children': {'name': {}, 'SASsource': {'attributes': {'name': {}}, 'children': {'radiation': {}, 'beam_size': {'attributes': {'name': {}}, 'children': {'x': {'unit': 'beam_size_unit', 'storeas': 'float', 'attributes': {'unit': ''}}, 'y': {'unit': 'beam_size_unit', 'storeas': 'float', 'attributes': {'unit': ''}}, 'z': {'unit': 'beam_size_unit', 'storeas': 'float', 'attributes': {'unit': ''}}}}, 'beam_shape': {}, 'wavelength': {'unit': 'wavelength_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'wavelength_min': {'unit': 'wavelength_min_unit', 'storeas': 'float', 'attributes': {'unit': {'storeas': 'content'}}}, 'wavelength_max': {'unit': 'wavelength_max_unit', 'storeas': 'float', 'attributes': {'unit': {'storeas': 'content'}}}, 'wavelength_spread': {'unit': 'wavelength_spread_unit', 'storeas': 'float', 'attributes': {'unit': {'storeas': 'content'}}}}}, 'SAScollimation': {'attributes': {'name': {}}, 'children': {'length': {'unit': 'length_unit', 'storeas': 'float', 'attributes': {'storeas': 'content', 'unit': {}}}, 'aperture': {'attributes': {'name': {}, 'type': {}}, 'children': {'size': {'attributes': {'unit': {}}, 'children': {'storeas': 'float', 'x': {'unit': 'size_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'y': {'unit': 'size_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'z': {'unit': 'size_unit', 'storeas': 'float', 'attributes': {'unit': {}}}}}, 'distance': {'storeas': 'float', 'attributes': {'unit': {}}, 'unit': 'distance_unit'}}}}}, 'SASdetector': {'attributes': {'name': {'storeas': 'content'}}, 'children': {'name': {'storeas': 'content'}, 'SDD': {'storeas': 'float', 'unit': 'distance_unit', 'attributes': {'unit': {}}}, 'offset': {'children': {'x': {'storeas': 'float', 'unit': 'offset_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'y': {'storeas': 'float', 'unit': 'offset_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'z': {'storeas': 'float', 'unit': 'offset_unit', 'attributes': {'unit': {'storeas': 'content'}}}}}, 'orientation': {'children': {'roll': {'storeas': 'float', 'unit': 'orientation_unit', 'attributes': {}}, 'pitch': {'storeas': 'float', 'unit': 'orientation_unit', 'attributes': {}}, 'yaw': {'storeas': 'float', 'unit': 'orientation_unit', 'attributes': {}}}}, 'beam_center': {'children': {'x': {'storeas': 'float', 'unit': 'beam_center_unit', 'attributes': {'storeas': 'content'}}, 'y': {'storeas': 'float', 'unit': 'beam_center_unit', 'attributes': {'storeas': 'content'}}, 'z': {'storeas': 'float', 'unit': 'beam_center_unit', 'attributes': {'storeas': 'content'}}}}, 'pixel_size': {'children': {'x': {'storeas': 'float', 'unit': 'pixel_size_unit', 'attributes': {'storeas': 'content'}}, 'y': {'storeas': 'float', 'unit': 'pixel_size_unit', 'attributes': {'storeas': 'content'}}, 'z': {'storeas': 'float', 'unit': 'pixel_size_unit', 'attributes': {'storeas': 'content'}}}}, 'slit_length': {'storeas': 'float', 'unit': 'slit_length_unit', 'attributes': {'unit': {}}}}}}}
SASINSTR_COLL = {'attributes': {'name': {}}, 'children': {'length': {'unit': 'length_unit', 'storeas': 'float', 'attributes': {'storeas': 'content', 'unit': {}}}, 'aperture': {'attributes': {'name': {}, 'type': {}}, 'children': {'size': {'attributes': {'unit': {}}, 'children': {'storeas': 'float', 'x': {'unit': 'size_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'y': {'unit': 'size_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'z': {'unit': 'size_unit', 'storeas': 'float', 'attributes': {'unit': {}}}}}, 'distance': {'storeas': 'float', 'attributes': {'unit': {}}, 'unit': 'distance_unit'}}}}}
SASINSTR_COLL_APER = {'attributes': {'name': {}, 'type': {}}, 'children': {'size': {'attributes': {'unit': {}}, 'children': {'storeas': 'float', 'x': {'unit': 'size_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'y': {'unit': 'size_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'z': {'unit': 'size_unit', 'storeas': 'float', 'attributes': {'unit': {}}}}}, 'distance': {'storeas': 'float', 'attributes': {'unit': {}}, 'unit': 'distance_unit'}}}
SASINSTR_COLL_APER_ATTR = {'unit': {}}
SASINSTR_COLL_APER_DIST = {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'distance_unit'}
SASINSTR_COLL_APER_SIZE = {'attributes': {'unit': {}}, 'children': {'storeas': 'float', 'x': {'unit': 'size_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'y': {'unit': 'size_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'z': {'unit': 'size_unit', 'storeas': 'float', 'attributes': {'unit': {}}}}}
SASINSTR_COLL_APER_X = {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'size_unit'}
SASINSTR_COLL_APER_Y = {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'size_unit'}
SASINSTR_COLL_APER_Z = {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'size_unit'}
SASINSTR_DET = {'attributes': {'name': {'storeas': 'content'}}, 'children': {'name': {'storeas': 'content'}, 'SDD': {'storeas': 'float', 'unit': 'distance_unit', 'attributes': {'unit': {}}}, 'offset': {'children': {'x': {'storeas': 'float', 'unit': 'offset_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'y': {'storeas': 'float', 'unit': 'offset_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'z': {'storeas': 'float', 'unit': 'offset_unit', 'attributes': {'unit': {'storeas': 'content'}}}}}, 'orientation': {'children': {'roll': {'storeas': 'float', 'unit': 'orientation_unit', 'attributes': {}}, 'pitch': {'storeas': 'float', 'unit': 'orientation_unit', 'attributes': {}}, 'yaw': {'storeas': 'float', 'unit': 'orientation_unit', 'attributes': {}}}}, 'beam_center': {'children': {'x': {'storeas': 'float', 'unit': 'beam_center_unit', 'attributes': {'storeas': 'content'}}, 'y': {'storeas': 'float', 'unit': 'beam_center_unit', 'attributes': {'storeas': 'content'}}, 'z': {'storeas': 'float', 'unit': 'beam_center_unit', 'attributes': {'storeas': 'content'}}}}, 'pixel_size': {'children': {'x': {'storeas': 'float', 'unit': 'pixel_size_unit', 'attributes': {'storeas': 'content'}}, 'y': {'storeas': 'float', 'unit': 'pixel_size_unit', 'attributes': {'storeas': 'content'}}, 'z': {'storeas': 'float', 'unit': 'pixel_size_unit', 'attributes': {'storeas': 'content'}}}}, 'slit_length': {'storeas': 'float', 'unit': 'slit_length_unit', 'attributes': {'unit': {}}}}}
SASINSTR_DET_BC = {'children': {'x': {'storeas': 'float', 'unit': 'beam_center_unit', 'attributes': {'storeas': 'content'}}, 'y': {'storeas': 'float', 'unit': 'beam_center_unit', 'attributes': {'storeas': 'content'}}, 'z': {'storeas': 'float', 'unit': 'beam_center_unit', 'attributes': {'storeas': 'content'}}}}
SASINSTR_DET_BC_X = {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'beam_center_unit'}
SASINSTR_DET_BC_Y = {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'beam_center_unit'}
SASINSTR_DET_BC_Z = {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'beam_center_unit'}
SASINSTR_DET_OFF = {'children': {'x': {'storeas': 'float', 'unit': 'offset_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'y': {'storeas': 'float', 'unit': 'offset_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'z': {'storeas': 'float', 'unit': 'offset_unit', 'attributes': {'unit': {'storeas': 'content'}}}}}
SASINSTR_DET_OFF_ATTR = {'unit': {'storeas': 'content'}}
SASINSTR_DET_OFF_X = {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'offset_unit'}
SASINSTR_DET_OFF_Y = {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'offset_unit'}
SASINSTR_DET_OFF_Z = {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'offset_unit'}
SASINSTR_DET_OR = {'children': {'roll': {'storeas': 'float', 'unit': 'orientation_unit', 'attributes': {}}, 'pitch': {'storeas': 'float', 'unit': 'orientation_unit', 'attributes': {}}, 'yaw': {'storeas': 'float', 'unit': 'orientation_unit', 'attributes': {}}}}
SASINSTR_DET_OR_ATTR = {}
SASINSTR_DET_OR_PITCH = {'attributes': {}, 'storeas': 'float', 'unit': 'orientation_unit'}
SASINSTR_DET_OR_ROLL = {'attributes': {}, 'storeas': 'float', 'unit': 'orientation_unit'}
SASINSTR_DET_OR_YAW = {'attributes': {}, 'storeas': 'float', 'unit': 'orientation_unit'}
SASINSTR_DET_PIXEL = {'children': {'x': {'storeas': 'float', 'unit': 'pixel_size_unit', 'attributes': {'storeas': 'content'}}, 'y': {'storeas': 'float', 'unit': 'pixel_size_unit', 'attributes': {'storeas': 'content'}}, 'z': {'storeas': 'float', 'unit': 'pixel_size_unit', 'attributes': {'storeas': 'content'}}}}
SASINSTR_DET_PIXEL_X = {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'pixel_size_unit'}
SASINSTR_DET_PIXEL_Y = {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'pixel_size_unit'}
SASINSTR_DET_PIXEL_Z = {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'pixel_size_unit'}
SASINSTR_DET_SDD = {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'distance_unit'}
SASINSTR_DET_SLIT = {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'slit_length_unit'}
SASINSTR_SRC = {'attributes': {'name': {}}, 'children': {'radiation': {}, 'beam_size': {'attributes': {'name': {}}, 'children': {'x': {'unit': 'beam_size_unit', 'storeas': 'float', 'attributes': {'unit': ''}}, 'y': {'unit': 'beam_size_unit', 'storeas': 'float', 'attributes': {'unit': ''}}, 'z': {'unit': 'beam_size_unit', 'storeas': 'float', 'attributes': {'unit': ''}}}}, 'beam_shape': {}, 'wavelength': {'unit': 'wavelength_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'wavelength_min': {'unit': 'wavelength_min_unit', 'storeas': 'float', 'attributes': {'unit': {'storeas': 'content'}}}, 'wavelength_max': {'unit': 'wavelength_max_unit', 'storeas': 'float', 'attributes': {'unit': {'storeas': 'content'}}}, 'wavelength_spread': {'unit': 'wavelength_spread_unit', 'storeas': 'float', 'attributes': {'unit': {'storeas': 'content'}}}}}
SASINSTR_SRC_BEAMSIZE = {'attributes': {'name': {}}, 'children': {'x': {'unit': 'beam_size_unit', 'storeas': 'float', 'attributes': {'unit': ''}}, 'y': {'unit': 'beam_size_unit', 'storeas': 'float', 'attributes': {'unit': ''}}, 'z': {'unit': 'beam_size_unit', 'storeas': 'float', 'attributes': {'unit': ''}}}}
SASINSTR_SRC_BEAMSIZE_ATTR = {'unit': ''}
SASINSTR_SRC_BEAMSIZE_X = {'attributes': {'unit': ''}, 'storeas': 'float', 'unit': 'beam_size_unit'}
SASINSTR_SRC_BEAMSIZE_Y = {'attributes': {'unit': ''}, 'storeas': 'float', 'unit': 'beam_size_unit'}
SASINSTR_SRC_BEAMSIZE_Z = {'attributes': {'unit': ''}, 'storeas': 'float', 'unit': 'beam_size_unit'}
SASINSTR_SRC_WL = {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'wavelength_unit'}
SASINSTR_SRC_WL_MAX = {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'wavelength_max_unit'}
SASINSTR_SRC_WL_MIN = {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'wavelength_min_unit'}
SASINSTR_SRC_WL_SPR = {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'wavelength_spread_unit'}
SASNOTE = {}
SASPROCESS = {'children': {'name': {}, 'date': {}, 'description': {}, 'term': {'attributes': {'unit': {}, 'name': {}}}, 'SASprocessnote': {'children': {'<any>': {'storeas': 'content'}}}, '<any>': {'storeas': 'content'}}}
SASPROCESS_SASPROCESSNOTE = {'children': {'<any>': {'storeas': 'content'}}}
SASPROCESS_TERM = {'attributes': {'unit': {}, 'name': {}}}
SASSAMPLE = {'attributes': {'name': {}}, 'children': {'ID': {}, 'thickness': {'unit': 'thickness_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'transmission': {'storeas': 'float'}, 'temperature': {'unit': 'temperature_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'position': {'children': {'x': {'unit': 'position_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'y': {'unit': 'position_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'z': {'unit': 'position_unit', 'storeas': 'float', 'attributes': {'unit': {}}}}}, 'orientation': {'children': {'roll': {'unit': 'orientation_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'pitch': {'unit': 'orientation_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'yaw': {'unit': 'orientation_unit', 'storeas': 'float', 'attributes': {'unit': {}}}}}, 'details': {}, '<any>': {'storeas': 'content'}}}
SASSAMPLE_ORIENT = {'children': {'roll': {'unit': 'orientation_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'pitch': {'unit': 'orientation_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'yaw': {'unit': 'orientation_unit', 'storeas': 'float', 'attributes': {'unit': {}}}}}
SASSAMPLE_ORIENT_ATTR = {'unit': {}}
SASSAMPLE_ORIENT_PITCH = {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'orientation_unit'}
SASSAMPLE_ORIENT_ROLL = {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'orientation_unit'}
SASSAMPLE_ORIENT_YAW = {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'orientation_unit'}
SASSAMPLE_POS = {'children': {'x': {'unit': 'position_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'y': {'unit': 'position_unit', 'storeas': 'float', 'attributes': {'unit': {}}}, 'z': {'unit': 'position_unit', 'storeas': 'float', 'attributes': {'unit': {}}}}}
SASSAMPLE_POS_ATTR = {'unit': {}}
SASSAMPLE_POS_X = {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'position_unit'}
SASSAMPLE_POS_Y = {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'position_unit'}
SASSAMPLE_POS_Z = {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'position_unit'}
SASSAMPLE_TEMP = {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'temperature_unit'}
SASSAMPLE_THICK = {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'thickness_unit'}
SASSAMPLE_TRANS = {'storeas': 'float'}
SASTRANSSPEC = {'attributes': {'name': {}, 'timestamp': {}}, 'children': {'Tdata': {'children': {'Lambda': {'storeas': 'float', 'unit': 'wavelength_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'T': {'storeas': 'float', 'unit': 'transmission_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'Tdev': {'storeas': 'float', 'unit': 'transmission_deviation_unit', 'attributes': {'unit': {'storeas': 'content'}}}, '<any>': {'storeas': 'content'}}}, '<any>': {'storeas': 'content'}}}
SASTRANSSPEC_TDATA = {'children': {'Lambda': {'storeas': 'float', 'unit': 'wavelength_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'T': {'storeas': 'float', 'unit': 'transmission_unit', 'attributes': {'unit': {'storeas': 'content'}}}, 'Tdev': {'storeas': 'float', 'unit': 'transmission_deviation_unit', 'attributes': {'unit': {'storeas': 'content'}}}, '<any>': {'storeas': 'content'}}}
SASTRANSSPEC_TDATA_LAMDBA = {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'wavelength_unit'}
SASTRANSSPEC_TDATA_T = {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'transmission_unit'}
SASTRANSSPEC_TDATA_TDEV = {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'transmission_deviation_unit'}
TITLE = {}
format = ''
get_namespace_map()[source]

Helper method to get the names namespace list

iterate_namespace(namespace)[source]

Method to iterate through a cansas constants tree based on a list of names

Parameters:namespace – A list of names that match the tree structure of cansas_constants
names = ''
class sas.sascalc.dataloader.readers.cansas_constants.CurrentLevel[source]

Bases: object

A helper class to hold information on where you are in the constants tree

current_level = ''
get_current_level()[source]

Helper method to get the current_level map

get_data_type()[source]

Helper method to get the ns_datatype label

get_variable()[source]

Helper method to get the ns_variable label

ns_datatype = ''
ns_optional = True

sas.sascalc.dataloader.readers.cansas_reader module

class sas.sascalc.dataloader.readers.cansas_reader.Reader(xml=None, schema=None)[source]

Bases: sas.sascalc.dataloader.readers.xml_reader.XMLreader

allow_all = True
base_ns = '{cansas1d/1.1}'
cansas_defaults = None
cansas_version = '1.1'
current_data1d = None
data = None
errors = set()
ext = ['.xml', '.svs']
frm = ''
get_file_contents()[source]

Reader specific class to access the contents of the file All reader classes that inherit from FileReader must implement

invalid = True
is_cansas(ext='xml')[source]

Checks to see if the XML file is a CanSAS file

Parameters:ext – The file extension of the data file
Raises:FileContentsException – Raised if XML file isn’t valid CanSAS
load_file_and_schema(xml_file, schema_path='')[source]
logging = None
names = None
ns_list = None
reset_state()[source]

Resets the class state to a base case when loading a new data file so previous data files do not appear a second time

type = ['XML files (*.xml)|*.xml', 'SasView Save Files (*.svs)|*.svs']
type_name = 'canSAS'
write(filename, datainfo)[source]

Write the content of a Data1D as a CanSAS XML file

Parameters:
  • filename – name of the file to write
  • datainfo – Data1D object
write_node(parent, name, value, attr=None)[source]
Parameters:
  • doc – document DOM
  • parent – parent node
  • name – tag of the element
  • value – value of the child text node
  • attr – attribute dictionary
Returns:

True if something was appended, otherwise False

sas.sascalc.dataloader.readers.cansas_reader.get_content(location, node)[source]

Get the first instance of the content of a xpath location.

Parameters:
  • location – xpath location
  • node – node to start at
Returns:

Element, or None

sas.sascalc.dataloader.readers.cansas_reader.getattrchain(obj, chain, default=None)[source]

Like getattr, but the attr may contain multiple parts separated by ‘.’

sas.sascalc.dataloader.readers.cansas_reader.setattrchain(obj, chain, value)[source]

Like setattr, but the attr may contain multiple parts separated by ‘.’

sas.sascalc.dataloader.readers.cansas_reader.write_node(doc, parent, name, value, attr=None)[source]
Parameters:
  • doc – document DOM
  • parent – parent node
  • name – tag of the element
  • value – value of the child text node
  • attr – attribute dictionary
Returns:

True if something was appended, otherwise False

sas.sascalc.dataloader.readers.cansas_reader_HDF5 module

NXcanSAS data reader for reading HDF5 formatted CanSAS files.

class sas.sascalc.dataloader.readers.cansas_reader_HDF5.Reader[source]

Bases: sas.sascalc.dataloader.file_reader_base_class.FileReader

A class for reading in NXcanSAS data files. The current implementation has been tested to load data generated by multiple facilities, all of which are known to produce NXcanSAS standards compliant data. Any number of data sets may be present within the file and any dimensionality of data may be used. Currently 1D and 2D SAS data sets are supported, but should be immediately extensible to SESANS data.

Any number of SASdata groups may be present in a SASentry and the data within each SASdata group can be a single 1D I(Q), multi-framed 1D I(Q), 2D I(Qx, Qy) or multi-framed 2D I(Qx, Qy).

Dependencies:The NXcanSAS HDF5 reader requires h5py => v2.5.0 or later.
add_data_set(key='')[source]

Adds the current_dataset to the list of outputs after preforming final processing on the data and then calls a private method to generate a new data set.

Parameters:key – NeXus group name for current tree level
add_intermediate()[source]

This method stores any intermediate objects within the final data set after fully reading the set.

Parameters:parent – The NXclass name for the h5py Group object that just finished being processed
allow_all = True
static as_list_or_array(iterable)[source]

Return value as a list if not already a list or array. :param iterable: :return:

cansas_version = 2.0
ext = ['.h5', '.H5']
final_data_cleanup()[source]

Does some final cleanup and formatting on self.current_datainfo and all data1D and data2D objects and then combines the data and info into Data1D and Data2D objects

get_file_contents()[source]

This is the general read method that all SasView data_loaders must have.

Parameters:filename – A path for an HDF5 formatted CanSAS 2D data file.
Returns:List of Data1D/2D objects and/or a list of errors.
process_1d_data_object(data_set, key, unit)[source]

SASdata processor method for 1d data items :param data_set: data from HDF5 file :param key: canSAS_class attribute :param unit: unit attribute

process_2d_data_object(data_set, key, unit)[source]
process_aperture(data_point, key)[source]

SASaperture processor :param data_point: Single point from an HDF5 data file :param key: class name data_point was taken from

process_collimation(data_point, key, unit)[source]

SAScollimation processor :param data_point: Single point from an HDF5 data file :param key: class name data_point was taken from :param unit: unit attribute from data set

process_detector(data_point, key, unit)[source]

SASdetector processor :param data_point: Single point from an HDF5 data file :param key: class name data_point was taken from :param unit: unit attribute from data set

process_process(data_point, key)[source]

SASprocess processor :param data_point: Single point from an HDF5 data file :param key: class name data_point was taken from

process_sample(data_point, key)[source]

SASsample processor :param data_point: Single point from an HDF5 data file :param key: class name data_point was taken from

process_source(data_point, key, unit)[source]

SASsource processor :param data_point: Single point from an HDF5 data file :param key: class name data_point was taken from :param unit: unit attribute from data set

process_trans_spectrum(data_set, key)[source]

SAStransmission_spectrum processor :param data_set: data from HDF5 file :param key: canSAS_class attribute

read_children(data, parent_list)[source]

A recursive method for stepping through the hierarchical data file.

Parameters:
  • data – h5py Group object of any kind
  • parent – h5py Group parent name
reset_state()[source]

Create the reader object and define initial states for class variables

type = ['NXcanSAS HDF5 Files (*.h5)|*.h5|']
type_name = 'NXcanSAS'
sas.sascalc.dataloader.readers.cansas_reader_HDF5.h5attr(node, key, default=None)[source]

sas.sascalc.dataloader.readers.danse_reader module

DANSE/SANS file reader

class sas.sascalc.dataloader.readers.danse_reader.Reader[source]

Bases: sas.sascalc.dataloader.file_reader_base_class.FileReader

Example data manipulation

ext = ['.sans', '.SANS']
get_file_contents()[source]

Reader specific class to access the contents of the file All reader classes that inherit from FileReader must implement

type = ['DANSE files (*.sans)|*.sans']
type_name = 'DANSE'

sas.sascalc.dataloader.readers.red2d_reader module

TXT/IGOR 2D Q Map file reader

class sas.sascalc.dataloader.readers.red2d_reader.Reader[source]

Bases: sas.sascalc.dataloader.file_reader_base_class.FileReader

Simple data reader for Igor data files

ext = ['.DAT', '.dat']
get_file_contents()[source]

Reader specific class to access the contents of the file All reader classes that inherit from FileReader must implement

type = ['IGOR/DAT 2D file in Q_map (*.dat)|*.DAT']
type_name = 'IGOR/DAT 2D Q_map'
write(filename, data)[source]

Write to .dat

Parameters:
  • filename – file name to write
  • data – data2D
sas.sascalc.dataloader.readers.red2d_reader.check_point(x_point)[source]

check point validity

sas.sascalc.dataloader.readers.sesans_reader module

SESANS reader (based on ASCII reader)

Reader for .ses or .sesans file format

Jurrian Bakker

class sas.sascalc.dataloader.readers.sesans_reader.Reader[source]

Bases: sas.sascalc.dataloader.file_reader_base_class.FileReader

Class to load sesans files (6 columns).

allow_all = True
ext = ['.ses', '.SES', '.sesans', '.SESANS']
get_file_contents()[source]

Reader specific class to access the contents of the file All reader classes that inherit from FileReader must implement

type = ['SESANS files (*.ses)|*.ses', 'SESANS files (*..sesans)|*.sesans']
type_name = 'SESANS'

sas.sascalc.dataloader.readers.tiff_reader module

Image reader. Untested.

class sas.sascalc.dataloader.readers.tiff_reader.Reader[source]

Bases: object

Example data manipulation

ext = ['.tif', '.tiff']
read(filename=None)[source]

Open and read the data in a file

Parameters:file – path of the file
type = ['TIF files (*.tif)|*.tif', 'TIFF files (*.tiff)|*.tiff']
type_name = 'TIF'

sas.sascalc.dataloader.readers.xml_reader module

Generic XML read and write utility

Usage: Either extend xml_reader or add as a class variable.

class sas.sascalc.dataloader.readers.xml_reader.XMLreader(xml=None, schema=None)[source]

Bases: sas.sascalc.dataloader.file_reader_base_class.FileReader

Generic XML read and write class. Mostly helper functions. Makes reading/writing XML a bit easier than calling lxml libraries directly.

Dependencies:This class requires lxml 2.3 or higher.
append(element, tree)[source]

Append an etree Element to an ElementTree.

Parameters:
  • element – etree Element to append
  • tree – ElementTree object to append to
break_processing_instructions(string, dic)[source]

Method to break a processing instruction string apart and add to a dict

Parameters:
  • string – A processing instruction as a string
  • dic – The dictionary to save the PIs to
create_element(name, attrib=None, nsmap=None)[source]

Create an XML element for writing to file

Parameters:name – The name of the element to be created
create_element_from_string(xml_string)[source]

Create an element from an XML string

Parameters:xml_string – A string of xml
create_tree(root)[source]

Create an element tree for processing from an etree element

Parameters:root – etree Element(s)
ebuilder(parent, elementname, text=None, attrib=None)[source]

Use lxml E builder class with arbitrary inputs.

Parameters:
  • parnet – The parent element to append a child to
  • elementname – The name of the child in string form
  • text – The element text
  • attrib – A dictionary of attribute names to attribute values
encoding = None
find_invalid_xml()[source]

Finds the first offending element that should not be present in XML file

parse_schema_and_doc()[source]

Creates a dictionary of the parsed schema and xml files.

processing_instructions = None
reader()[source]

Read in an XML file into memory and return an lxml dictionary

return_processing_instructions()[source]

Get all processing instructions saved when loading the document

Parameters:tree – etree.ElementTree object to write PIs to
schema = None
schemadoc = None
set_encoding(attr_str)[source]

Find the encoding in the xml declaration and save it as a string

Parameters:attr_str – All attributes as a string e.g. “foo1=”bar1” foo2=”bar2” foo3=”bar3” … foo_n=”bar_n”“
set_processing_instructions()[source]

Take out all processing instructions and create a dictionary from them If there is a default encoding, the value is also saved

set_schema(schema)[source]

Set the schema file and parse

set_xml_file(xml)[source]

Set the XML file and parse

set_xml_string(tag_soup)[source]

Set an XML string as the working XML.

Parameters:tag_soup – XML formatted string
to_string(elem, pretty_print=False, encoding=None)[source]

Converts an etree element into a string

validate_xml()[source]

Checks to see if the XML file meets the schema

write_attribute(elem, attr_name, attr_value)[source]

Write attributes to an Element

Parameters:
  • elem – etree.Element object
  • attr_name – attribute name to write
  • attr_value – attribute value to set
write_text(elem, text)[source]

Write text to an etree Element

Parameters:
  • elem – etree.Element object
  • text – text to write to the element
xml = None
xmldoc = None
xmlroot = None

Module contents