sas.sascalc.dataloader.readers package

Submodules

sas.sascalc.dataloader.readers.IgorReader module

IGOR 2D reduced file reader

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

Simple data reader for Igor data files

ext = ['.ASC', '.asc']
read(filename=None)[source]

Read file

type = ['IGOR 2D files (*.ASC)|*.ASC']
type_name = 'IGOR 2D'

sas.sascalc.dataloader.readers.abs_reader module

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

Class to load IGOR reduced .ABS files

ext = ['.abs', '.ABS']
read(path)[source]

Load data file.

Parameters:

path – file path

Returns:

Data1D object, or None

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']
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 CanSAS v2.0 data files. The existing iteration opens Mantid generated HDF5 formatted files with file extension .h5/.H5. 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 future implementations will include 1D and 2D SESANS data. This class assumes a single data set for each sasentry.

Dependencies:The CanSAS HDF5 reader requires h5py v2.5.0 or later.
allow_all = False
current_dataset = None
errors = None
ext = ['.pdh', '.PDH']
logging = None
output = None
parent_list = None
raw_data = None
read(filename)[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.
read_data()[source]
reset_state()[source]
type = ['Anton Paar SAXSess Files (*.pdh)|*.pdh']
type_name = 'Anton Paar SAXSess'

sas.sascalc.dataloader.readers.ascii_reader module

ASCII reader

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

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

allow_all = True
ext = ['.txt', '.TXT', '.dat', '.DAT', '.abs', '.ABS', 'csv', 'CSV']
read(path)[source]

Load data file

Parameters:

path – file path

Returns:

Data1D object, or None

Raises:
  • RuntimeError – when the file can’t be opened
  • ValueError – when the length of the data vectors are inconsistent
splitline(line)[source]

Splits a line into pieces based on common delimeters :param line: A single line of text :return: list of values

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.read_associations(loader, settings='defaults.json')[source]

Read the specified settings file to associate default readers to file extension.

Parameters:
  • loader – Loader object
  • settings – path to the json settings file [string]
sas.sascalc.dataloader.readers.associations.register_readers(registry_function)[source]

Function called by the registry/loader object to register all default readers using a call back function.

WARNING:this method is now obsolete
Parameters:registry_function – function to be called to register each reader

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': {'attributes': {'name': {}}, 'units_optional': True, 'storeas': 'content', 'children': {'SASsample': {'attributes': {'name': {}}, 'children': {'<any>': {'storeas': 'content'}, 'orientation': {'children': {'yaw': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'orientation_unit'}, 'roll': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'orientation_unit'}, 'pitch': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'orientation_unit'}}}, 'temperature': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'temperature_unit'}, 'transmission': {'storeas': 'float'}, 'position': {'children': {'y': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'position_unit'}, 'x': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'position_unit'}, 'z': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'position_unit'}}}, 'details': {}, 'ID': {}, 'thickness': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'thickness_unit'}}}, 'SASinstrument': {'children': {'SAScollimation': {'attributes': {'name': {}}, 'children': {'aperture': {'attributes': {'type': {}, 'name': {}}, 'children': {'distance': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'distance_unit'}, 'size': {'attributes': {'unit': {}}, 'children': {'y': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'size_unit'}, 'x': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'size_unit'}, 'z': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'size_unit'}, 'storeas': 'float'}}}}, 'length': {'attributes': {'storeas': 'content', 'unit': {}}, 'storeas': 'float', 'unit': 'length_unit'}}}, 'SASdetector': {'attributes': {'name': {'storeas': 'content'}}, 'children': {'orientation': {'children': {'yaw': {'attributes': {}, 'storeas': 'float', 'unit': 'orientation_unit'}, 'roll': {'attributes': {}, 'storeas': 'float', 'unit': 'orientation_unit'}, 'pitch': {'attributes': {}, 'storeas': 'float', 'unit': 'orientation_unit'}}}, 'beam_center': {'children': {'y': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'beam_center_unit'}, 'x': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'beam_center_unit'}, 'z': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'beam_center_unit'}}}, 'SDD': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'distance_unit'}, 'slit_length': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'slit_length_unit'}, 'offset': {'children': {'y': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'offset_unit'}, 'x': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'offset_unit'}, 'z': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'offset_unit'}}}, 'pixel_size': {'children': {'y': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'pixel_size_unit'}, 'x': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'pixel_size_unit'}, 'z': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'pixel_size_unit'}}}, 'name': {'storeas': 'content'}}}, 'name': {}, 'SASsource': {'attributes': {'name': {}}, 'children': {'wavelength_max': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'wavelength_max_unit'}, 'radiation': {}, 'wavelength_spread': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'wavelength_spread_unit'}, 'beam_size': {'attributes': {'name': {}}, 'children': {'y': {'attributes': {'unit': ''}, 'storeas': 'float', 'unit': 'beam_size_unit'}, 'x': {'attributes': {'unit': ''}, 'storeas': 'float', 'unit': 'beam_size_unit'}, 'z': {'attributes': {'unit': ''}, 'storeas': 'float', 'unit': 'beam_size_unit'}}}, 'wavelength': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'wavelength_unit'}, 'wavelength_min': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'wavelength_min_unit'}, 'beam_shape': {}}}}}, 'Run': {'attributes': {'name': {}}}, '<any>': {'storeas': 'content'}, 'Title': {}, 'SASnote': {}, 'SAStransmission_spectrum': {'attributes': {'timestamp': {}, 'name': {}}, 'children': {'Tdata': {'children': {'Tdev': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'transmission_deviation_unit'}, '<any>': {'storeas': 'content'}, 'T': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'transmission_unit'}, 'Lambda': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'wavelength_unit'}}}, '<any>': {'storeas': 'content'}}}, 'SASdata': {'variable': None, 'attributes': {'name': {}}, 'children': {'zacceptance': {'storeas': 'float'}, 'Sesans': {'storeas': 'content'}, 'Idata': {'attributes': {'timestamp': {'storeas': 'timestamp'}, 'name': {}}, 'children': {'Q': {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'x_unit'}, 'dQl': {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'x_unit'}, 'Qdev': {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'x_unit'}, 'dQw': {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'x_unit'}, '<any>': {'storeas': 'content'}, 'I': {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'y_unit'}, 'Shadowfactor': {}, 'Idev': {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'y_unit'}, 'Qmean': {'attributes': {'unit': {}}, 'unit': 'x_unit'}}}, '<any>': {'storeas': 'content'}}}, 'SASprocess': {'children': {'term': {'attributes': {'name': {}, 'unit': {}}}, '<any>': {'storeas': 'content'}, 'description': {}, 'SASprocessnote': {'children': {'<any>': {'storeas': 'content'}}}, 'date': {}, 'name': {}}}}}}
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 = {'variable': None, 'attributes': {'name': {}}, 'children': {'zacceptance': {'storeas': 'float'}, 'Sesans': {'storeas': 'content'}, 'Idata': {'attributes': {'timestamp': {'storeas': 'timestamp'}, 'name': {}}, 'children': {'Q': {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'x_unit'}, 'dQl': {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'x_unit'}, 'Qdev': {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'x_unit'}, 'dQw': {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'x_unit'}, '<any>': {'storeas': 'content'}, 'I': {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'y_unit'}, 'Shadowfactor': {}, 'Idev': {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'y_unit'}, 'Qmean': {'attributes': {'unit': {}}, 'unit': 'x_unit'}}}, '<any>': {'storeas': 'content'}}}
SASDATA_IDATA = {'attributes': {'timestamp': {'storeas': 'timestamp'}, 'name': {}}, 'children': {'Q': {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'x_unit'}, 'dQl': {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'x_unit'}, 'Qdev': {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'x_unit'}, 'dQw': {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'x_unit'}, '<any>': {'storeas': 'content'}, 'I': {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'y_unit'}, 'Shadowfactor': {}, 'Idev': {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'y_unit'}, 'Qmean': {'attributes': {'unit': {}}, 'unit': 'x_unit'}}}
SASDATA_IDATA_DQL = {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'x_unit'}
SASDATA_IDATA_DQW = {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'x_unit'}
SASDATA_IDATA_I = {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'y_unit'}
SASDATA_IDATA_IDEV = {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'y_unit'}
SASDATA_IDATA_Q = {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'x_unit'}
SASDATA_IDATA_QDEV = {'attributes': {'unit': {'storeas': 'content'}}, 'units_optional': False, 'storeas': 'float', 'unit': 'x_unit'}
SASDATA_IDATA_QMEAN = {'attributes': {'unit': {}}, 'unit': 'x_unit'}
SASDATA_IDATA_SHADOWFACTOR = {}
SASINSTR = {'children': {'SAScollimation': {'attributes': {'name': {}}, 'children': {'aperture': {'attributes': {'type': {}, 'name': {}}, 'children': {'distance': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'distance_unit'}, 'size': {'attributes': {'unit': {}}, 'children': {'y': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'size_unit'}, 'x': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'size_unit'}, 'z': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'size_unit'}, 'storeas': 'float'}}}}, 'length': {'attributes': {'storeas': 'content', 'unit': {}}, 'storeas': 'float', 'unit': 'length_unit'}}}, 'SASdetector': {'attributes': {'name': {'storeas': 'content'}}, 'children': {'orientation': {'children': {'yaw': {'attributes': {}, 'storeas': 'float', 'unit': 'orientation_unit'}, 'roll': {'attributes': {}, 'storeas': 'float', 'unit': 'orientation_unit'}, 'pitch': {'attributes': {}, 'storeas': 'float', 'unit': 'orientation_unit'}}}, 'beam_center': {'children': {'y': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'beam_center_unit'}, 'x': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'beam_center_unit'}, 'z': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'beam_center_unit'}}}, 'SDD': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'distance_unit'}, 'slit_length': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'slit_length_unit'}, 'offset': {'children': {'y': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'offset_unit'}, 'x': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'offset_unit'}, 'z': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'offset_unit'}}}, 'pixel_size': {'children': {'y': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'pixel_size_unit'}, 'x': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'pixel_size_unit'}, 'z': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'pixel_size_unit'}}}, 'name': {'storeas': 'content'}}}, 'name': {}, 'SASsource': {'attributes': {'name': {}}, 'children': {'wavelength_max': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'wavelength_max_unit'}, 'radiation': {}, 'wavelength_spread': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'wavelength_spread_unit'}, 'beam_size': {'attributes': {'name': {}}, 'children': {'y': {'attributes': {'unit': ''}, 'storeas': 'float', 'unit': 'beam_size_unit'}, 'x': {'attributes': {'unit': ''}, 'storeas': 'float', 'unit': 'beam_size_unit'}, 'z': {'attributes': {'unit': ''}, 'storeas': 'float', 'unit': 'beam_size_unit'}}}, 'wavelength': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'wavelength_unit'}, 'wavelength_min': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'wavelength_min_unit'}, 'beam_shape': {}}}}}
SASINSTR_COLL = {'attributes': {'name': {}}, 'children': {'aperture': {'attributes': {'type': {}, 'name': {}}, 'children': {'distance': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'distance_unit'}, 'size': {'attributes': {'unit': {}}, 'children': {'y': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'size_unit'}, 'x': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'size_unit'}, 'z': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'size_unit'}, 'storeas': 'float'}}}}, 'length': {'attributes': {'storeas': 'content', 'unit': {}}, 'storeas': 'float', 'unit': 'length_unit'}}}
SASINSTR_COLL_APER = {'attributes': {'type': {}, 'name': {}}, 'children': {'distance': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'distance_unit'}, 'size': {'attributes': {'unit': {}}, 'children': {'y': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'size_unit'}, 'x': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'size_unit'}, 'z': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'size_unit'}, 'storeas': 'float'}}}}
SASINSTR_COLL_APER_ATTR = {'unit': {}}
SASINSTR_COLL_APER_DIST = {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'distance_unit'}
SASINSTR_COLL_APER_SIZE = {'attributes': {'unit': {}}, 'children': {'y': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'size_unit'}, 'x': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'size_unit'}, 'z': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'size_unit'}, 'storeas': 'float'}}
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': {'orientation': {'children': {'yaw': {'attributes': {}, 'storeas': 'float', 'unit': 'orientation_unit'}, 'roll': {'attributes': {}, 'storeas': 'float', 'unit': 'orientation_unit'}, 'pitch': {'attributes': {}, 'storeas': 'float', 'unit': 'orientation_unit'}}}, 'beam_center': {'children': {'y': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'beam_center_unit'}, 'x': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'beam_center_unit'}, 'z': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'beam_center_unit'}}}, 'SDD': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'distance_unit'}, 'slit_length': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'slit_length_unit'}, 'offset': {'children': {'y': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'offset_unit'}, 'x': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'offset_unit'}, 'z': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'offset_unit'}}}, 'pixel_size': {'children': {'y': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'pixel_size_unit'}, 'x': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'pixel_size_unit'}, 'z': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'pixel_size_unit'}}}, 'name': {'storeas': 'content'}}}
SASINSTR_DET_BC = {'children': {'y': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'beam_center_unit'}, 'x': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'beam_center_unit'}, 'z': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'beam_center_unit'}}}
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': {'y': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'offset_unit'}, 'x': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'offset_unit'}, 'z': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'offset_unit'}}}
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': {'yaw': {'attributes': {}, 'storeas': 'float', 'unit': 'orientation_unit'}, 'roll': {'attributes': {}, 'storeas': 'float', 'unit': 'orientation_unit'}, 'pitch': {'attributes': {}, 'storeas': 'float', 'unit': 'orientation_unit'}}}
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': {'y': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'pixel_size_unit'}, 'x': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'pixel_size_unit'}, 'z': {'attributes': {'storeas': 'content'}, 'storeas': 'float', 'unit': 'pixel_size_unit'}}}
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': {'wavelength_max': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'wavelength_max_unit'}, 'radiation': {}, 'wavelength_spread': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'wavelength_spread_unit'}, 'beam_size': {'attributes': {'name': {}}, 'children': {'y': {'attributes': {'unit': ''}, 'storeas': 'float', 'unit': 'beam_size_unit'}, 'x': {'attributes': {'unit': ''}, 'storeas': 'float', 'unit': 'beam_size_unit'}, 'z': {'attributes': {'unit': ''}, 'storeas': 'float', 'unit': 'beam_size_unit'}}}, 'wavelength': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'wavelength_unit'}, 'wavelength_min': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'wavelength_min_unit'}, 'beam_shape': {}}}
SASINSTR_SRC_BEAMSIZE = {'attributes': {'name': {}}, 'children': {'y': {'attributes': {'unit': ''}, 'storeas': 'float', 'unit': 'beam_size_unit'}, 'x': {'attributes': {'unit': ''}, 'storeas': 'float', 'unit': 'beam_size_unit'}, 'z': {'attributes': {'unit': ''}, 'storeas': 'float', 'unit': 'beam_size_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': {'term': {'attributes': {'name': {}, 'unit': {}}}, '<any>': {'storeas': 'content'}, 'description': {}, 'SASprocessnote': {'children': {'<any>': {'storeas': 'content'}}}, 'date': {}, 'name': {}}}
SASPROCESS_SASPROCESSNOTE = {'children': {'<any>': {'storeas': 'content'}}}
SASPROCESS_TERM = {'attributes': {'name': {}, 'unit': {}}}
SASSAMPLE = {'attributes': {'name': {}}, 'children': {'<any>': {'storeas': 'content'}, 'orientation': {'children': {'yaw': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'orientation_unit'}, 'roll': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'orientation_unit'}, 'pitch': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'orientation_unit'}}}, 'temperature': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'temperature_unit'}, 'transmission': {'storeas': 'float'}, 'position': {'children': {'y': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'position_unit'}, 'x': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'position_unit'}, 'z': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'position_unit'}}}, 'details': {}, 'ID': {}, 'thickness': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'thickness_unit'}}}
SASSAMPLE_ORIENT = {'children': {'yaw': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'orientation_unit'}, 'roll': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'orientation_unit'}, 'pitch': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'orientation_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': {'y': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'position_unit'}, 'x': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'position_unit'}, 'z': {'attributes': {'unit': {}}, 'storeas': 'float', 'unit': 'position_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': {'timestamp': {}, 'name': {}}, 'children': {'Tdata': {'children': {'Tdev': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'transmission_deviation_unit'}, '<any>': {'storeas': 'content'}, 'T': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'transmission_unit'}, 'Lambda': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'wavelength_unit'}}}, '<any>': {'storeas': 'content'}}}
SASTRANSSPEC_TDATA = {'children': {'Tdev': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'transmission_deviation_unit'}, '<any>': {'storeas': 'content'}, 'T': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'transmission_unit'}, 'Lambda': {'attributes': {'unit': {'storeas': 'content'}}, 'storeas': 'float', 'unit': 'wavelength_unit'}}}
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

CanSAS data reader - new recursive cansas_version.

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

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

Class to load cansas 1D XML files

Dependencies:The CanSAS reader requires PyXML 0.8.4 or later.
add_data_set()[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
base_ns = '{cansas1d/1.0}'
cansas_defaults = None
cansas_version = '1.0'
current_data1d = None
current_datainfo = None
current_dataset = None
data = None
errors = set([])
ext = ['.xml', '.XML', '.svs', '.SVS']
frm = ''
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
load_file_and_schema(xml_file, schema_path='')[source]

Loads the file and associates a schema, if a schema is passed in or if one already exists

Parameters:
  • xml_file – The xml file path sent to Reader.read
  • schema_path – The path to a schema associated with the xml_file, or find one based on the file
logging = None
names = None
ns_list = None
output = None
read(xml_file, schema_path='', invalid=True)[source]

Validate and read in an xml_file file in the canSAS format.

Parameters:
  • xml_file – A canSAS file path in proper XML format
  • schema_path – A file path to an XML schema to validate the xml_file against
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.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

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

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

A class for reading in CanSAS v2.0 data files. The existing iteration opens Mantid generated HDF5 formatted files with file extension .h5/.H5. 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 future implementations will include 1D and 2D SESANS data.

Any number of SASdata sets may be present in a SASentry and the data within can be either 1D I(Q) or 2D I(Qx, Qy).

Also supports reading NXcanSAS formatted HDF5 files

Dependencies:The CanSAS 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
cansas_version = 2.0
current_datainfo = None
current_dataset = None
data1d = None
data2d = None
errors = None
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

logging = None
output = None
raw_data = None
read(filename)[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.
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_class_variables()[source]

Create the reader object and define initial states for class variables

type = ['CanSAS 2.0 HDF5 Files (*.h5)|*.h5']
type_name = 'CanSAS 2.0'

sas.sascalc.dataloader.readers.danse_reader module

DANSE/SANS file reader

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

Example data manipulation

ext = ['.sans', '.SANS']
read(filename=None)[source]

Open and read the data in a file @param file: path of the file

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

sas.sascalc.dataloader.readers.hfir1d_reader module

HFIR 1D 4-column data reader

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

Bases: object

Class to load HFIR 1D 4-column files

ext = ['.d1d']
read(path)[source]

Load data file

Parameters:

path – file path

Returns:

Data1D object, or None

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

sas.sascalc.dataloader.readers.nexus_reader module

Nexus reader for 2D data reduced by Mantid

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

Nexus reader for 2D data reduced by Mantid

ext = ['.nxs']
read(filename=None)[source]

Open and read the data in a file

Parameters:filename – path of the file
type = ['Nexus files (*.nxs)|*.nxs']
type_name = 'NXS'

sas.sascalc.dataloader.readers.red2d_reader module

TXT/IGOR 2D Q Map file reader

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

Simple data reader for Igor data files

ext = ['.DAT', '.dat']
read(filename=None)[source]

Read file

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]

Class to load sesans files (6 columns).

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

Load data file

Parameters:

path – file path

Returns:

SESANSData1D object, or None

Raises:
  • RuntimeError – when the file can’t be opened
  • ValueError – when the length of the data vectors are inconsistent
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]

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]

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

sas.sascalc.dataloader.readers.get_data_path()[source]

Return the location of the settings file for the data readers.