sas.sascalc.dataloader package

Subpackages

Submodules

sas.sascalc.dataloader.data_info module

Module that contains classes to hold information read from reduced data files.

A good description of the data members can be found in the CanSAS 1D XML data format:

http://www.smallangles.net/wgwiki/index.php/cansas1d_documentation

class sas.sascalc.dataloader.data_info.Aperture[source]

Bases: object

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.data_info', 'name': None, 'type': None, 'size_name': None, 'size': None, 'size_unit': 'mm', 'distance': None, 'distance_unit': 'mm', '__init__': <function Aperture.__init__>, '__dict__': <attribute '__dict__' of 'Aperture' objects>, '__weakref__': <attribute '__weakref__' of 'Aperture' objects>, '__doc__': None, '__annotations__': {}})
__doc__ = None
__init__()[source]
__module__ = 'sas.sascalc.dataloader.data_info'
__weakref__

list of weak references to the object (if defined)

distance = None
distance_unit = 'mm'
name = None
size = None
size_name = None
size_unit = 'mm'
type = None
class sas.sascalc.dataloader.data_info.Collimation[source]

Bases: object

Class to hold collimation information

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.data_info', '__doc__': '\n    Class to hold collimation information\n    ', 'name': None, 'length': None, 'length_unit': 'mm', 'aperture': None, '__init__': <function Collimation.__init__>, '__str__': <function Collimation.__str__>, '__dict__': <attribute '__dict__' of 'Collimation' objects>, '__weakref__': <attribute '__weakref__' of 'Collimation' objects>, '__annotations__': {}})
__doc__ = '\n    Class to hold collimation information\n    '
__init__()[source]
__module__ = 'sas.sascalc.dataloader.data_info'
__str__()[source]

Return str(self).

__weakref__

list of weak references to the object (if defined)

aperture = None
length = None
length_unit = 'mm'
name = None
class sas.sascalc.dataloader.data_info.Data1D(x=None, y=None, dx=None, dy=None, lam=None, dlam=None, isSesans=False)[source]

Bases: plottable_1D, DataInfo

1D data class

__doc__ = '\n    1D data class\n    '
__init__(x=None, y=None, dx=None, dy=None, lam=None, dlam=None, isSesans=False)[source]

Initialization

__module__ = 'sas.sascalc.dataloader.data_info'
__str__()[source]

Nice printout

_perform_operation(other, operation)[source]
_perform_union(other)[source]
_validity_check(other)[source]

Checks that the data lengths are compatible. Checks that the x vectors are compatible. Returns errors vectors equal to original errors vectors if they were present or vectors of zeros when none was found.

Parameters:

other – other data set for operation

Returns:

dy for self, dy for other [numpy arrays]

Raises:

ValueError – when lengths are not compatible

_validity_check_union(other)[source]

Checks that the data lengths are compatible. Checks that the x vectors are compatible. Returns errors vectors equal to original errors vectors if they were present or vectors of zeros when none was found.

Parameters:

other – other data set for operation

Returns:

bool

Raises:

ValueError – when data types are not compatible

clone_without_data(length=0, clone=None)[source]

Clone the current object, without copying the data (which will be filled out by a subsequent operation). The data arrays will be initialized to zero.

Parameters:
  • length – length of the data array to be initialized

  • clone – if provided, the data will be copied to clone

copy_from_datainfo(data1d)[source]

copy values of Data1D of type DataLaoder.Data_info

is_slit_smeared()[source]

Check whether the data has slit smearing information :return: True is slit smearing info is present, False otherwise

class sas.sascalc.dataloader.data_info.Data2D(data=None, err_data=None, qx_data=None, qy_data=None, q_data=None, mask=None, dqx_data=None, dqy_data=None, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None)[source]

Bases: plottable_2D, DataInfo

2D data class

I_unit = '1/cm'
Q_unit = '1/A'
__doc__ = '\n    2D data class\n    '
__init__(data=None, err_data=None, qx_data=None, qy_data=None, q_data=None, mask=None, dqx_data=None, dqy_data=None, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None)[source]

Initialization

__module__ = 'sas.sascalc.dataloader.data_info'
__str__()[source]

Return str(self).

_perform_operation(other, operation)[source]

Perform 2D operations between data sets

Parameters:
  • other – other data set

  • operation – function defining the operation

_perform_union(other)[source]

Perform 2D operations between data sets

Parameters:
  • other – other data set

  • operation – function defining the operation

_validity_check(other)[source]

Checks that the data lengths are compatible. Checks that the x vectors are compatible. Returns errors vectors equal to original errors vectors if they were present or vectors of zeros when none was found.

Parameters:

other – other data set for operation

Returns:

dy for self, dy for other [numpy arrays]

Raises:

ValueError – when lengths are not compatible

static _validity_check_union(self, other)[source]

Checks that the data lengths are compatible. Checks that the x vectors are compatible. Returns errors vectors equal to original errors vectors if they were present or vectors of zeros when none was found.

Parameters:

other – other data set for operation

Returns:

bool

Raises:

ValueError – when data types are not compatible

clone_without_data(length=0, clone=None)[source]

Clone the current object, without copying the data (which will be filled out by a subsequent operation). The data arrays will be initialized to zero.

Parameters:
  • length – length of the data array to be initialized

  • clone – if provided, the data will be copied to clone

copy_from_datainfo(data2d)[source]

copy value of Data2D of type DataLoader.data_info

isSesans = False
class sas.sascalc.dataloader.data_info.DataInfo[source]

Bases: object

Class to hold the data read from a file. It includes four blocks of data for the instrument description, the sample description, the data itself and any other meta data.

__add__(other)[source]

Add two data sets

Parameters:

other – data set to add to the current one

Returns:

new data set

Raises:

ValueError – raised when two data sets are incompatible

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.data_info', '__doc__': '\n    Class to hold the data read from a file.\n    It includes four blocks of data for the\n    instrument description, the sample description,\n    the data itself and any other meta data.\n    ', 'title': '', 'run': None, 'run_name': None, 'filename': '', 'notes': None, 'process': None, 'instrument': '', 'detector': None, 'sample': None, 'source': None, 'collimation': None, 'trans_spectrum': None, 'meta_data': None, 'errors': None, 'isSesans': None, '__init__': <function DataInfo.__init__>, 'append_empty_process': <function DataInfo.append_empty_process>, 'add_notes': <function DataInfo.add_notes>, '__str__': <function DataInfo.__str__>, '_perform_operation': <function DataInfo._perform_operation>, '_perform_union': <function DataInfo._perform_union>, '__add__': <function DataInfo.__add__>, '__radd__': <function DataInfo.__radd__>, '__sub__': <function DataInfo.__sub__>, '__rsub__': <function DataInfo.__rsub__>, '__mul__': <function DataInfo.__mul__>, '__rmul__': <function DataInfo.__rmul__>, '__truediv__': <function DataInfo.__truediv__>, '__div__': <function DataInfo.__truediv__>, '__rtruediv__': <function DataInfo.__rtruediv__>, '__rdiv__': <function DataInfo.__rtruediv__>, '__or__': <function DataInfo.__or__>, '__ror__': <function DataInfo.__ror__>, '__dict__': <attribute '__dict__' of 'DataInfo' objects>, '__weakref__': <attribute '__weakref__' of 'DataInfo' objects>, '__annotations__': {}})
__div__(other)

Divided a data set by another

Parameters:

other – data set that the current one is divided by

Returns:

new data set

Raises:

ValueError – raised when two data sets are incompatible

__doc__ = '\n    Class to hold the data read from a file.\n    It includes four blocks of data for the\n    instrument description, the sample description,\n    the data itself and any other meta data.\n    '
__init__()[source]

Initialization

__module__ = 'sas.sascalc.dataloader.data_info'
__mul__(other)[source]

Multiply two data sets

Parameters:

other – data set to subtract from the current one

Returns:

new data set

Raises:

ValueError – raised when two data sets are incompatible

__or__(other)[source]

Union a data set with another

Parameters:

other – data set to be unified

Returns:

new data set

Raises:

ValueError – raised when two data sets are incompatible

__radd__(other)[source]

Add two data sets

Parameters:

other – data set to add to the current one

Returns:

new data set

Raises:

ValueError – raised when two data sets are incompatible

__rdiv__(other)

Divided a data set by another

Parameters:

other – data set that the current one is divided by

Returns:

new data set

Raises:

ValueError – raised when two data sets are incompatible

__rmul__(other)[source]

Multiply two data sets

Parameters:

other – data set to subtract from the current one

Returns:

new data set

Raises:

ValueError – raised when two data sets are incompatible

__ror__(other)[source]

Union a data set with another

Parameters:

other – data set to be unified

Returns:

new data set

Raises:

ValueError – raised when two data sets are incompatible

__rsub__(other)[source]

Subtract two data sets

Parameters:

other – data set to subtract from the current one

Returns:

new data set

Raises:

ValueError – raised when two data sets are incompatible

__rtruediv__(other)[source]

Divided a data set by another

Parameters:

other – data set that the current one is divided by

Returns:

new data set

Raises:

ValueError – raised when two data sets are incompatible

__str__()[source]

Nice printout

__sub__(other)[source]

Subtract two data sets

Parameters:

other – data set to subtract from the current one

Returns:

new data set

Raises:

ValueError – raised when two data sets are incompatible

__truediv__(other)[source]

Divided a data set by another

Parameters:

other – data set that the current one is divided by

Returns:

new data set

Raises:

ValueError – raised when two data sets are incompatible

__weakref__

list of weak references to the object (if defined)

_perform_operation(other, operation)[source]

Private method to perform operation. Not implemented for DataInfo, but should be implemented for each data class inherited from DataInfo that holds actual data (ex.: Data1D)

_perform_union(other)[source]

Private method to perform union operation. Not implemented for DataInfo, but should be implemented for each data class inherited from DataInfo that holds actual data (ex.: Data1D)

add_notes(message='')[source]

Add notes to datainfo

append_empty_process()[source]
collimation = None
detector = None
errors = None
filename = ''
instrument = ''
isSesans = None
meta_data = None
notes = None
process = None
run = None
run_name = None
sample = None
source = None
title = ''
trans_spectrum = None
class sas.sascalc.dataloader.data_info.Detector[source]

Bases: object

Class to hold detector information

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.data_info', '__doc__': '\n    Class to hold detector information\n    ', 'name': None, 'distance': None, 'distance_unit': 'mm', 'offset': None, 'offset_unit': 'm', 'orientation': None, 'orientation_unit': 'degree', 'beam_center': None, 'beam_center_unit': 'mm', 'pixel_size': None, 'pixel_size_unit': 'mm', 'slit_length': None, 'slit_length_unit': 'mm', '__init__': <function Detector.__init__>, '__str__': <function Detector.__str__>, '__dict__': <attribute '__dict__' of 'Detector' objects>, '__weakref__': <attribute '__weakref__' of 'Detector' objects>, '__annotations__': {}})
__doc__ = '\n    Class to hold detector information\n    '
__init__()[source]

Initialize class attribute that are objects…

__module__ = 'sas.sascalc.dataloader.data_info'
__str__()[source]

Return str(self).

__weakref__

list of weak references to the object (if defined)

beam_center = None
beam_center_unit = 'mm'
distance = None
distance_unit = 'mm'
name = None
offset = None
offset_unit = 'm'
orientation = None
orientation_unit = 'degree'
pixel_size = None
pixel_size_unit = 'mm'
slit_length = None
slit_length_unit = 'mm'
class sas.sascalc.dataloader.data_info.Process[source]

Bases: object

Class that holds information about the processes performed on the data.

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.data_info', '__doc__': '\n    Class that holds information about the processes\n    performed on the data.\n    ', 'name': '', 'date': '', 'description': '', 'term': None, 'notes': None, '__init__': <function Process.__init__>, 'is_empty': <function Process.is_empty>, 'single_line_desc': <function Process.single_line_desc>, '__str__': <function Process.__str__>, '__dict__': <attribute '__dict__' of 'Process' objects>, '__weakref__': <attribute '__weakref__' of 'Process' objects>, '__annotations__': {}})
__doc__ = '\n    Class that holds information about the processes\n    performed on the data.\n    '
__init__()[source]
__module__ = 'sas.sascalc.dataloader.data_info'
__str__()[source]

Return str(self).

__weakref__

list of weak references to the object (if defined)

date = ''
description = ''
is_empty()[source]

Return True if the object is empty

name = ''
notes = None
single_line_desc()[source]

Return a single line string representing the process

term = None
class sas.sascalc.dataloader.data_info.Sample[source]

Bases: object

Class to hold the sample description

ID = ''
__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.data_info', '__doc__': '\n    Class to hold the sample description\n    ', 'name': '', 'ID': '', 'thickness': None, 'thickness_unit': 'mm', 'transmission': None, 'temperature': None, 'temperature_unit': None, 'position': None, 'position_unit': 'mm', 'orientation': None, 'orientation_unit': 'degree', 'details': None, 'zacceptance': (0, ''), 'yacceptance': (0, ''), '__init__': <function Sample.__init__>, '__str__': <function Sample.__str__>, '__dict__': <attribute '__dict__' of 'Sample' objects>, '__weakref__': <attribute '__weakref__' of 'Sample' objects>, '__annotations__': {}})
__doc__ = '\n    Class to hold the sample description\n    '
__init__()[source]
__module__ = 'sas.sascalc.dataloader.data_info'
__str__()[source]

Return str(self).

__weakref__

list of weak references to the object (if defined)

details = None
name = ''
orientation = None
orientation_unit = 'degree'
position = None
position_unit = 'mm'
temperature = None
temperature_unit = None
thickness = None
thickness_unit = 'mm'
transmission = None
yacceptance = (0, '')
zacceptance = (0, '')
class sas.sascalc.dataloader.data_info.Source[source]

Bases: object

Class to hold source information

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.data_info', '__doc__': '\n    Class to hold source information\n    ', 'name': None, 'radiation': None, 'type': None, 'probe': None, 'beam_size_name': None, 'beam_size': None, 'beam_size_unit': 'mm', 'beam_shape': None, 'wavelength': None, 'wavelength_unit': 'A', 'wavelength_min': None, 'wavelength_min_unit': 'nm', 'wavelength_max': None, 'wavelength_max_unit': 'nm', 'wavelength_spread': None, 'wavelength_spread_unit': 'percent', '__init__': <function Source.__init__>, '__str__': <function Source.__str__>, '__dict__': <attribute '__dict__' of 'Source' objects>, '__weakref__': <attribute '__weakref__' of 'Source' objects>, '__annotations__': {}})
__doc__ = '\n    Class to hold source information\n    '
__init__()[source]
__module__ = 'sas.sascalc.dataloader.data_info'
__str__()[source]

Return str(self).

__weakref__

list of weak references to the object (if defined)

beam_shape = None
beam_size = None
beam_size_name = None
beam_size_unit = 'mm'
name = None
probe = None
radiation = None
type = None
wavelength = None
wavelength_max = None
wavelength_max_unit = 'nm'
wavelength_min = None
wavelength_min_unit = 'nm'
wavelength_spread = None
wavelength_spread_unit = 'percent'
wavelength_unit = 'A'
class sas.sascalc.dataloader.data_info.TransmissionSpectrum[source]

Bases: object

Class that holds information about transmission spectrum for white beams and spallation sources.

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.data_info', '__doc__': '\n    Class that holds information about transmission spectrum\n    for white beams and spallation sources.\n    ', 'name': '', 'timestamp': '', 'wavelength': None, 'wavelength_unit': 'A', 'transmission': None, 'transmission_unit': '', 'transmission_deviation': None, 'transmission_deviation_unit': '', '__init__': <function TransmissionSpectrum.__init__>, '__str__': <function TransmissionSpectrum.__str__>, '__dict__': <attribute '__dict__' of 'TransmissionSpectrum' objects>, '__weakref__': <attribute '__weakref__' of 'TransmissionSpectrum' objects>, '__annotations__': {}})
__doc__ = '\n    Class that holds information about transmission spectrum\n    for white beams and spallation sources.\n    '
__init__()[source]
__module__ = 'sas.sascalc.dataloader.data_info'
__str__()[source]

Return str(self).

__weakref__

list of weak references to the object (if defined)

name = ''
timestamp = ''
transmission = None
transmission_deviation = None
transmission_deviation_unit = ''
transmission_unit = ''
wavelength = None
wavelength_unit = 'A'
class sas.sascalc.dataloader.data_info.Vector(x=None, y=None, z=None)[source]

Bases: object

Vector class to hold multi-dimensional objects

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.data_info', '__doc__': '\n    Vector class to hold multi-dimensional objects\n    ', 'x': None, 'y': None, 'z': None, '__init__': <function Vector.__init__>, '__str__': <function Vector.__str__>, '__dict__': <attribute '__dict__' of 'Vector' objects>, '__weakref__': <attribute '__weakref__' of 'Vector' objects>, '__annotations__': {}})
__doc__ = '\n    Vector class to hold multi-dimensional objects\n    '
__init__(x=None, y=None, z=None)[source]

Initialization. Components that are not set a set to None by default.

Parameters:
  • x – x component

  • y – y component

  • z – z component

__module__ = 'sas.sascalc.dataloader.data_info'
__str__()[source]

Return str(self).

__weakref__

list of weak references to the object (if defined)

x = None
y = None
z = None
sas.sascalc.dataloader.data_info.combine_data_info_with_plottable(data, datainfo)[source]

A function that combines the DataInfo data in self.current_datainto with a plottable_1D or 2D data object.

Parameters:
  • data – A plottable_1D or plottable_2D data object

  • datainfo – A DataInfo object to be combined with the plottable

Returns:

A fully specified Data1D or Data2D object

class sas.sascalc.dataloader.data_info.plottable_1D(x, y, dx=None, dy=None, dxl=None, dxw=None, lam=None, dlam=None)[source]

Bases: object

Data1D is a place holder for 1D plottables.

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.data_info', '__doc__': '\n    Data1D is a place holder for 1D plottables.\n    ', 'x': None, 'y': None, 'dx': None, 'dy': None, 'dxl': None, 'dxw': None, 'lam': None, 'dlam': None, '_xaxis': '', '_xunit': '', '_yaxis': '', '_yunit': '', '__init__': <function plottable_1D.__init__>, 'xaxis': <function plottable_1D.xaxis>, 'yaxis': <function plottable_1D.yaxis>, '__dict__': <attribute '__dict__' of 'plottable_1D' objects>, '__weakref__': <attribute '__weakref__' of 'plottable_1D' objects>, '__annotations__': {}})
__doc__ = '\n    Data1D is a place holder for 1D plottables.\n    '
__init__(x, y, dx=None, dy=None, dxl=None, dxw=None, lam=None, dlam=None)[source]
__module__ = 'sas.sascalc.dataloader.data_info'
__weakref__

list of weak references to the object (if defined)

_xaxis = ''
_xunit = ''
_yaxis = ''
_yunit = ''
dlam = None
dx = None
dxl = None
dxw = None
dy = None
lam = None
x = None
xaxis(label, unit)[source]

set the x axis label and unit

y = None
yaxis(label, unit)[source]

set the y axis label and unit

class sas.sascalc.dataloader.data_info.plottable_2D(data=None, err_data=None, qx_data=None, qy_data=None, q_data=None, mask=None, dqx_data=None, dqy_data=None, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, x_bins=None, y_bins=None)[source]

Bases: object

Data2D is a place holder for 2D plottables.

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.data_info', '__doc__': '\n    Data2D is a place holder for 2D plottables.\n    ', 'xmin': None, 'xmax': None, 'ymin': None, 'ymax': None, 'data': None, 'qx_data': None, 'qy_data': None, 'q_data': None, 'err_data': None, 'dqx_data': None, 'dqy_data': None, 'mask': None, 'x_bins': None, 'y_bins': None, '_xaxis': '', '_xunit': '', '_yaxis': '', '_yunit': '', '_zaxis': '', '_zunit': '', '__init__': <function plottable_2D.__init__>, 'xaxis': <function plottable_2D.xaxis>, 'yaxis': <function plottable_2D.yaxis>, 'zaxis': <function plottable_2D.zaxis>, '__dict__': <attribute '__dict__' of 'plottable_2D' objects>, '__weakref__': <attribute '__weakref__' of 'plottable_2D' objects>, '__annotations__': {}})
__doc__ = '\n    Data2D is a place holder for 2D plottables.\n    '
__init__(data=None, err_data=None, qx_data=None, qy_data=None, q_data=None, mask=None, dqx_data=None, dqy_data=None, xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, x_bins=None, y_bins=None)[source]
__module__ = 'sas.sascalc.dataloader.data_info'
__weakref__

list of weak references to the object (if defined)

_xaxis = ''
_xunit = ''
_yaxis = ''
_yunit = ''
_zaxis = ''
_zunit = ''
data = None
dqx_data = None
dqy_data = None
err_data = None
mask = None
q_data = None
qx_data = None
qy_data = None
x_bins = None
xaxis(label, unit)[source]

set the x axis label and unit

xmax = None
xmin = None
y_bins = None
yaxis(label, unit)[source]

set the y axis label and unit

ymax = None
ymin = None
zaxis(label, unit)[source]

set the z axis label and unit

sas.sascalc.dataloader.file_reader_base_class module

This is the base file reader class most file readers should inherit from. All generic functionality required for a file loader/reader is built into this class

class sas.sascalc.dataloader.file_reader_base_class.FileReader[source]

Bases: object

_ZERO = 1e-16
__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.file_reader_base_class', 'type_name': 'ASCII', 'type': ['Text files (*.txt|*.TXT)'], 'ext': ['.txt'], 'deprecated_extensions': ['.asc'], 'allow_all': False, 'has_converter': True, '_ZERO': 1e-16, '__init__': <function FileReader.__init__>, 'read': <function FileReader.read>, 'reset_state': <function FileReader.reset_state>, 'nextline': <function FileReader.nextline>, 'nextlines': <function FileReader.nextlines>, 'readall': <function FileReader.readall>, 'handle_error_message': <function FileReader.handle_error_message>, 'send_to_output': <function FileReader.send_to_output>, 'sort_data': <function FileReader.sort_data>, '_reorder_1d_array': <staticmethod object>, '_remove_nans_in_data': <staticmethod object>, 'set_default_1d_units': <staticmethod object>, 'set_default_2d_units': <staticmethod object>, 'convert_data_units': <function FileReader.convert_data_units>, 'format_unit': <function FileReader.format_unit>, 'set_all_to_none': <function FileReader.set_all_to_none>, 'data_cleanup': <function FileReader.data_cleanup>, 'remove_empty_q_values': <function FileReader.remove_empty_q_values>, 'reset_data_list': <function FileReader.reset_data_list>, 'splitline': <staticmethod object>, 'get_file_contents': <function FileReader.get_file_contents>, '__dict__': <attribute '__dict__' of 'FileReader' objects>, '__weakref__': <attribute '__weakref__' of 'FileReader' objects>, '__doc__': None, '__annotations__': {}})
__doc__ = None
__init__()[source]
__module__ = 'sas.sascalc.dataloader.file_reader_base_class'
__weakref__

list of weak references to the object (if defined)

static _remove_nans_in_data(data)[source]

Remove data points where nan is loaded :param data: 1D or 2D data object :return: data with nan points removed

static _reorder_1d_array(array, ind)[source]

Reorders a 1D array based on the indices passed as ind :param array: Array to be reordered :param ind: Indices used to reorder array :return: reordered array

allow_all = False
convert_data_units(default_q_unit='1/A')[source]

Converts al; data to the sasview default of units of A^{-1} for Q and cm^{-1} for I. :param default_q_unit: The default Q unit used by Sasview

data_cleanup()[source]

Clean up the data sets and refresh everything :return: None

deprecated_extensions = ['.asc']
ext = ['.txt']
format_unit(unit=None)[source]

Format units a common way :param unit: :return:

abstract get_file_contents()[source]

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

handle_error_message(msg)[source]

Generic error handler to add an error to the current datainfo to propagate the error up the error chain. :param msg: Error message

has_converter = True
nextline()[source]

Returns the next line in the file as a string.

nextlines()[source]

Returns the next line in the file as a string.

read(filepath)[source]

Basic file reader

Parameters:

filepath – The full or relative path to a file to be loaded

readall()[source]

Returns the entire file as a string.

remove_empty_q_values()[source]

Remove any point where Q == 0

reset_data_list(no_lines=0)[source]

Reset the plottable_1D object

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

send_to_output()[source]

Helper that automatically combines the info and set and then appends it to output

set_all_to_none()[source]

Set all mutable values to None for error handling purposes

static set_default_1d_units(data)[source]

Set the x and y axes to the default 1D units :param data: 1D data set :return:

static set_default_2d_units(data)[source]

Set the x and y axes to the default 2D units :param data: 2D data set :return:

sort_data()[source]

Sort 1D data along the X axis for consistency

static splitline(line)[source]

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

type = ['Text files (*.txt|*.TXT)']
type_name = 'ASCII'
sas.sascalc.dataloader.file_reader_base_class.decode(s)[source]

sas.sascalc.dataloader.loader module

File handler to support different file extensions. Uses reflectometer registry utility. The default readers are found in the ‘readers’ sub-module and registered by default at initialization time. To add a new default reader, one must register it in the register_readers method found in readers/__init__.py. A utility method (find_plugins) is available to inspect a directory (for instance, a user plug-in directory) and look for new readers/writers.

class sas.sascalc.dataloader.loader.Loader[source]

Bases: object

Utility class to use the Registry as a singleton.

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.loader', '__doc__': '\n    Utility class to use the Registry as a singleton.\n    ', '_Loader__registry': <sas.sascalc.dataloader.loader.Registry object>, 'associate_file_type': <function Loader.associate_file_type>, 'associate_file_reader': <function Loader.associate_file_reader>, 'load': <function Loader.load>, 'save': <function Loader.save>, '_get_registry_creation_time': <function Loader._get_registry_creation_time>, 'find_plugins': <function Loader.find_plugins>, 'get_wildcards': <function Loader.get_wildcards>, '__dict__': <attribute '__dict__' of 'Loader' objects>, '__weakref__': <attribute '__weakref__' of 'Loader' objects>, '__annotations__': {}})
__doc__ = '\n    Utility class to use the Registry as a singleton.\n    '
__module__ = 'sas.sascalc.dataloader.loader'
__registry = <sas.sascalc.dataloader.loader.Registry object>
__weakref__

list of weak references to the object (if defined)

_get_registry_creation_time()[source]

Internal method used to test the uniqueness of the registry object

associate_file_reader(ext, loader)[source]

Append a reader object to readers :param ext: file extension [string] :param module: reader object

associate_file_type(ext, module)[source]

Look into a module to find whether it contains a Reader class. If so, append it to readers and (potentially) to the list of writers for the given extension :param ext: file extension [string] :param module: module object

find_plugins(directory)[source]

Find plugins in a given directory :param dir: directory to look into to find new readers/writers

get_wildcards()[source]

Return the list of wildcards

load(file, format=None)[source]

Load a file :param file: file name (path) :param format: specified format to use (optional) :return: DataInfo object

save(file, data, format)[source]

Save a DataInfo object to file :param file: file name (path) :param data: DataInfo object :param format: format to write the data in

class sas.sascalc.dataloader.loader.Registry[source]

Bases: ExtensionRegistry

Registry class for file format extensions. Readers and writers are supported.

__doc__ = '\n    Registry class for file format extensions.\n    Readers and writers are supported.\n    '
__init__()[source]
__module__ = 'sas.sascalc.dataloader.loader'
_identify_plugin(module)[source]

Look into a module to find whether it contains a Reader class. If so, add it to readers and (potentially) to the list of writers. :param module: module object

associate_file_reader(ext, loader)[source]

Append a reader object to readers :param ext: file extension [string] :param module: reader object

associate_file_type(ext, module)[source]

Look into a module to find whether it contains a Reader class. If so, APPEND it to readers and (potentially) to the list of writers for the given extension :param ext: file extension [string] :param module: module object

find_plugins(dir)[source]

Find readers in a given directory. This method can be used to inspect user plug-in directories to find new readers/writers. :param dir: directory to search into :return: number of readers found

load(path, format=None, debug=False, use_defaults=True)[source]

Call the loader for the file type of path.

Parameters:
  • path – file path

  • format – explicit extension, to force the use of a particular reader

  • debug – when True, print the traceback for each loader that fails

  • use_defaults – Flag to use the default readers as a backup if the main reader fails or no reader exists

Defaults to the ascii (multi-column), cansas XML, and cansas NeXuS readers if no reader was registered for the file’s extension.

load_using_generic_loaders(path)[source]

If the expected reader cannot load the file or no known loader exists, attempt to load the file using a few defaults readers :param path: file path :return: List of Data1D and Data2D objects

lookup_writers(path)[source]
Returns:

the loader associated with the file type of path.

Raises ValueError:

if file type is not known.

save(path, data, format=None)[source]

Call the writer for the file type of path. Raises ValueError if no writer is available. Raises KeyError if format is not available. May raise a writer-defined exception if writer fails.

sas.sascalc.dataloader.loader_exceptions module

Exceptions specific to loading data.

exception sas.sascalc.dataloader.loader_exceptions.DataReaderException(e=None)[source]

Bases: Exception

Exception for files that were able to mostly load, but had minor issues along the way. Any exceptions of this type should be put into the datainfo.errors

__doc__ = '\n    Exception for files that were able to mostly load, but had minor issues\n    along the way.\n    Any exceptions of this type should be put into the datainfo.errors\n    '
__init__(e=None)[source]
__module__ = 'sas.sascalc.dataloader.loader_exceptions'
__weakref__

list of weak references to the object (if defined)

exception sas.sascalc.dataloader.loader_exceptions.DefaultReaderException(e=None)[source]

Bases: Exception

Exception for files with no associated reader. This should be thrown by default readers only to tell Loader to try the next reader.

__doc__ = '\n    Exception for files with no associated reader. This should be thrown by\n    default readers only to tell Loader to try the next reader.\n    '
__init__(e=None)[source]
__module__ = 'sas.sascalc.dataloader.loader_exceptions'
__weakref__

list of weak references to the object (if defined)

exception sas.sascalc.dataloader.loader_exceptions.FileContentsException(e=None)[source]

Bases: Exception

Exception for files with an associated reader, but with no loadable data. This is useful for catching loader or file format issues.

__doc__ = '\n    Exception for files with an associated reader, but with no loadable data.\n    This is useful for catching loader or file format issues.\n    '
__init__(e=None)[source]
__module__ = 'sas.sascalc.dataloader.loader_exceptions'
__weakref__

list of weak references to the object (if defined)

exception sas.sascalc.dataloader.loader_exceptions.NoKnownLoaderException(e=None)[source]

Bases: Exception

Exception for files with no associated reader based on the file extension of the loaded file. This exception should only be thrown by loader.py.

__doc__ = '\n    Exception for files with no associated reader based on the file\n    extension of the loaded file. This exception should only be thrown by\n    loader.py.\n    '
__init__(e=None)[source]
__module__ = 'sas.sascalc.dataloader.loader_exceptions'
__weakref__

list of weak references to the object (if defined)

sas.sascalc.dataloader.manipulations module

class sas.sascalc.dataloader.manipulations.Binning(min_value, max_value, n_bins, base=None)[source]

Bases: object

This class just creates a binning object either linear or log

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.manipulations', '__doc__': '\n    This class just creates a binning object\n    either linear or log\n    ', '__init__': <function Binning.__init__>, 'get_bin_index': <function Binning.get_bin_index>, '__dict__': <attribute '__dict__' of 'Binning' objects>, '__weakref__': <attribute '__weakref__' of 'Binning' objects>, '__annotations__': {}})
__doc__ = '\n    This class just creates a binning object\n    either linear or log\n    '
__init__(min_value, max_value, n_bins, base=None)[source]

if base is None: Linear binning

__module__ = 'sas.sascalc.dataloader.manipulations'
__weakref__

list of weak references to the object (if defined)

get_bin_index(value)[source]

The general formula logarithm binning is: bin = floor(N * (log(x) - log(min)) / (log(max) - log(min)))

class sas.sascalc.dataloader.manipulations.Boxavg(x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0)[source]

Bases: Boxsum

Perform the average of counts in a 2D region of interest.

__call__(data2D)[source]

Perform the sum in the region of interest

Parameters:

data2D – Data2D object

Returns:

average counts, error on average counts

__doc__ = '\n    Perform the average of counts in a 2D region of interest.\n    '
__init__(x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0)[source]
__module__ = 'sas.sascalc.dataloader.manipulations'
class sas.sascalc.dataloader.manipulations.Boxcut(x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0)[source]

Bases: object

Find a rectangular 2D region of interest.

__call__(data2D)[source]

Find a rectangular 2D region of interest.

Parameters:

data2D – Data2D object

Returns:

mask, 1d array (len = len(data)) with Trues where the data points are inside ROI, otherwise False

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.manipulations', '__doc__': '\n    Find a rectangular 2D region of interest.\n    ', '__init__': <function Boxcut.__init__>, '__call__': <function Boxcut.__call__>, '_find': <function Boxcut._find>, '__dict__': <attribute '__dict__' of 'Boxcut' objects>, '__weakref__': <attribute '__weakref__' of 'Boxcut' objects>, '__annotations__': {}})
__doc__ = '\n    Find a rectangular 2D region of interest.\n    '
__init__(x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0)[source]
__module__ = 'sas.sascalc.dataloader.manipulations'
__weakref__

list of weak references to the object (if defined)

_find(data2D)[source]

Find a rectangular 2D region of interest.

Parameters:

data2D – Data2D object

Returns:

out, 1d array (length = len(data)) with Trues where the data points are inside ROI, otherwise Falses

class sas.sascalc.dataloader.manipulations.Boxsum(x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0)[source]

Bases: object

Perform the sum of counts in a 2D region of interest.

__call__(data2D)[source]

Perform the sum in the region of interest

Parameters:

data2D – Data2D object

Returns:

number of counts, error on number of counts, number of points summed

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.manipulations', '__doc__': '\n    Perform the sum of counts in a 2D region of interest.\n    ', '__init__': <function Boxsum.__init__>, '__call__': <function Boxsum.__call__>, '_sum': <function Boxsum._sum>, '__dict__': <attribute '__dict__' of 'Boxsum' objects>, '__weakref__': <attribute '__weakref__' of 'Boxsum' objects>, '__annotations__': {}})
__doc__ = '\n    Perform the sum of counts in a 2D region of interest.\n    '
__init__(x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0)[source]
__module__ = 'sas.sascalc.dataloader.manipulations'
__weakref__

list of weak references to the object (if defined)

_sum(data2D)[source]

Perform the sum in the region of interest

Parameters:

data2D – Data2D object

Returns:

number of counts, error on number of counts, number of entries summed

class sas.sascalc.dataloader.manipulations.CircularAverage(r_min=0.0, r_max=0.0, bin_width=0.0005)[source]

Bases: object

Perform circular averaging on 2D data

The data returned is the distribution of counts as a function of Q

__call__(data2D, ismask=False)[source]

Perform circular averaging on the data

Parameters:

data2D – Data2D object

Returns:

Data1D object

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.manipulations', '__doc__': '\n    Perform circular averaging on 2D data\n\n    The data returned is the distribution of counts\n    as a function of Q\n    ', '__init__': <function CircularAverage.__init__>, '__call__': <function CircularAverage.__call__>, '__dict__': <attribute '__dict__' of 'CircularAverage' objects>, '__weakref__': <attribute '__weakref__' of 'CircularAverage' objects>, '__annotations__': {}})
__doc__ = '\n    Perform circular averaging on 2D data\n\n    The data returned is the distribution of counts\n    as a function of Q\n    '
__init__(r_min=0.0, r_max=0.0, bin_width=0.0005)[source]
__module__ = 'sas.sascalc.dataloader.manipulations'
__weakref__

list of weak references to the object (if defined)

class sas.sascalc.dataloader.manipulations.Ring(r_min=0, r_max=0, center_x=0, center_y=0, nbins=36)[source]

Bases: object

Defines a ring on a 2D data set. The ring is defined by r_min, r_max, and the position of the center of the ring.

The data returned is the distribution of counts around the ring as a function of phi.

Phi_min and phi_max should be defined between 0 and 2*pi in anti-clockwise starting from the x- axis on the left-hand side

__call__(data2D)[source]

Apply the ring to the data set. Returns the angular distribution for a given q range

Parameters:

data2D – Data2D object

Returns:

Data1D object

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.manipulations', '__doc__': '\n    Defines a ring on a 2D data set.\n    The ring is defined by r_min, r_max, and\n    the position of the center of the ring.\n\n    The data returned is the distribution of counts\n    around the ring as a function of phi.\n\n    Phi_min and phi_max should be defined between 0 and 2*pi\n    in anti-clockwise starting from the x- axis on the left-hand side\n    ', '__init__': <function Ring.__init__>, '__call__': <function Ring.__call__>, '__dict__': <attribute '__dict__' of 'Ring' objects>, '__weakref__': <attribute '__weakref__' of 'Ring' objects>, '__annotations__': {}})
__doc__ = '\n    Defines a ring on a 2D data set.\n    The ring is defined by r_min, r_max, and\n    the position of the center of the ring.\n\n    The data returned is the distribution of counts\n    around the ring as a function of phi.\n\n    Phi_min and phi_max should be defined between 0 and 2*pi\n    in anti-clockwise starting from the x- axis on the left-hand side\n    '
__init__(r_min=0, r_max=0, center_x=0, center_y=0, nbins=36)[source]
__module__ = 'sas.sascalc.dataloader.manipulations'
__weakref__

list of weak references to the object (if defined)

class sas.sascalc.dataloader.manipulations.Ringcut(r_min=0, r_max=0, center_x=0, center_y=0)[source]

Bases: object

Defines a ring on a 2D data set. The ring is defined by r_min, r_max, and the position of the center of the ring.

The data returned is the region inside the ring

Phi_min and phi_max should be defined between 0 and 2*pi in anti-clockwise starting from the x- axis on the left-hand side

__call__(data2D)[source]

Apply the ring to the data set. Returns the angular distribution for a given q range

Parameters:

data2D – Data2D object

Returns:

index array in the range

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.manipulations', '__doc__': '\n    Defines a ring on a 2D data set.\n    The ring is defined by r_min, r_max, and\n    the position of the center of the ring.\n\n    The data returned is the region inside the ring\n\n    Phi_min and phi_max should be defined between 0 and 2*pi\n    in anti-clockwise starting from the x- axis on the left-hand side\n    ', '__init__': <function Ringcut.__init__>, '__call__': <function Ringcut.__call__>, '__dict__': <attribute '__dict__' of 'Ringcut' objects>, '__weakref__': <attribute '__weakref__' of 'Ringcut' objects>, '__annotations__': {}})
__doc__ = '\n    Defines a ring on a 2D data set.\n    The ring is defined by r_min, r_max, and\n    the position of the center of the ring.\n\n    The data returned is the region inside the ring\n\n    Phi_min and phi_max should be defined between 0 and 2*pi\n    in anti-clockwise starting from the x- axis on the left-hand side\n    '
__init__(r_min=0, r_max=0, center_x=0, center_y=0)[source]
__module__ = 'sas.sascalc.dataloader.manipulations'
__weakref__

list of weak references to the object (if defined)

class sas.sascalc.dataloader.manipulations.SectorPhi(r_min, r_max, phi_min=0, phi_max=6.283185307179586, nbins=20, base=None)[source]

Bases: _Sector

Sector average as a function of phi. I(phi) is return and the data is averaged over Q.

A sector is defined by r_min, r_max, phi_min, phi_max. The number of bin in phi also has to be defined.

__call__(data2D)[source]

Perform sector average and return I(phi).

Parameters:

data2D – Data2D object

Returns:

Data1D object

__doc__ = '\n    Sector average as a function of phi.\n    I(phi) is return and the data is averaged over Q.\n\n    A sector is defined by r_min, r_max, phi_min, phi_max.\n    The number of bin in phi also has to be defined.\n    '
__module__ = 'sas.sascalc.dataloader.manipulations'
class sas.sascalc.dataloader.manipulations.SectorQ(r_min, r_max, phi_min=0, phi_max=6.283185307179586, nbins=20, base=None)[source]

Bases: _Sector

Sector average as a function of Q for both symatric wings. I(Q) is return and the data is averaged over phi.

A sector is defined by r_min, r_max, phi_min, phi_max. r_min, r_max, phi_min, phi_max >0. The number of bin in Q also has to be defined.

__call__(data2D)[source]

Perform sector average and return I(Q).

Parameters:

data2D – Data2D object

Returns:

Data1D object

__doc__ = '\n    Sector average as a function of Q for both symatric wings.\n    I(Q) is return and the data is averaged over phi.\n\n    A sector is defined by r_min, r_max, phi_min, phi_max.\n    r_min, r_max, phi_min, phi_max >0.\n    The number of bin in Q also has to be defined.\n    '
__module__ = 'sas.sascalc.dataloader.manipulations'
class sas.sascalc.dataloader.manipulations.Sectorcut(phi_min=0, phi_max=3.141592653589793)[source]

Bases: object

Defines a sector (major + minor) region on a 2D data set. The sector is defined by phi_min, phi_max, where phi_min and phi_max are defined by the right and left lines wrt central line.

Phi_min and phi_max are given in units of radian and (phi_max-phi_min) should not be larger than pi

__call__(data2D)[source]

Find a rectangular 2D region of interest.

Parameters:

data2D – Data2D object

Returns:

mask, 1d array (len = len(data))

with Trues where the data points are inside ROI, otherwise False

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.manipulations', '__doc__': '\n    Defines a sector (major + minor) region on a 2D data set.\n    The sector is defined by phi_min, phi_max,\n    where phi_min and phi_max are defined by the right\n    and left lines wrt central line.\n\n    Phi_min and phi_max are given in units of radian\n    and (phi_max-phi_min) should not be larger than pi\n    ', '__init__': <function Sectorcut.__init__>, '__call__': <function Sectorcut.__call__>, '_find': <function Sectorcut._find>, '__dict__': <attribute '__dict__' of 'Sectorcut' objects>, '__weakref__': <attribute '__weakref__' of 'Sectorcut' objects>, '__annotations__': {}})
__doc__ = '\n    Defines a sector (major + minor) region on a 2D data set.\n    The sector is defined by phi_min, phi_max,\n    where phi_min and phi_max are defined by the right\n    and left lines wrt central line.\n\n    Phi_min and phi_max are given in units of radian\n    and (phi_max-phi_min) should not be larger than pi\n    '
__init__(phi_min=0, phi_max=3.141592653589793)[source]
__module__ = 'sas.sascalc.dataloader.manipulations'
__weakref__

list of weak references to the object (if defined)

_find(data2D)[source]

Find a rectangular 2D region of interest.

Parameters:

data2D – Data2D object

Returns:

out, 1d array (length = len(data))

with Trues where the data points are inside ROI, otherwise Falses

class sas.sascalc.dataloader.manipulations.SlabX(x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0, bin_width=0.001, fold=False)[source]

Bases: _Slab

Compute average I(Qx) for a region of interest

__call__(data2D)[source]

Compute average I(Qx) for a region of interest :param data2D: Data2D object :return: Data1D object

__doc__ = '\n    Compute average I(Qx) for a region of interest\n    '
__module__ = 'sas.sascalc.dataloader.manipulations'
class sas.sascalc.dataloader.manipulations.SlabY(x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0, bin_width=0.001, fold=False)[source]

Bases: _Slab

Compute average I(Qy) for a region of interest

__call__(data2D)[source]

Compute average I(Qy) for a region of interest

Parameters:

data2D – Data2D object

Returns:

Data1D object

__doc__ = '\n    Compute average I(Qy) for a region of interest\n    '
__module__ = 'sas.sascalc.dataloader.manipulations'
class sas.sascalc.dataloader.manipulations._Sector(r_min, r_max, phi_min=0, phi_max=6.283185307179586, nbins=20, base=None)[source]

Bases: object

Defines a sector region on a 2D data set. The sector is defined by r_min, r_max, phi_min, phi_max, and the position of the center of the ring where phi_min and phi_max are defined by the right and left lines wrt central line and phi_max could be less than phi_min.

Phi is defined between 0 and 2*pi in anti-clockwise starting from the x- axis on the left-hand side

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.manipulations', '__doc__': '\n    Defines a sector region on a 2D data set.\n    The sector is defined by r_min, r_max, phi_min, phi_max,\n    and the position of the center of the ring\n    where phi_min and phi_max are defined by the right\n    and left lines wrt central line\n    and phi_max could be less than phi_min.\n\n    Phi is defined between 0 and 2*pi in anti-clockwise\n    starting from the x- axis on the left-hand side\n    ', '__init__': <function _Sector.__init__>, '_agv': <function _Sector._agv>, '__dict__': <attribute '__dict__' of '_Sector' objects>, '__weakref__': <attribute '__weakref__' of '_Sector' objects>, '__annotations__': {}})
__doc__ = '\n    Defines a sector region on a 2D data set.\n    The sector is defined by r_min, r_max, phi_min, phi_max,\n    and the position of the center of the ring\n    where phi_min and phi_max are defined by the right\n    and left lines wrt central line\n    and phi_max could be less than phi_min.\n\n    Phi is defined between 0 and 2*pi in anti-clockwise\n    starting from the x- axis on the left-hand side\n    '
__init__(r_min, r_max, phi_min=0, phi_max=6.283185307179586, nbins=20, base=None)[source]
Parameters:

base – must be a valid base for an algorithm, i.e.,

a positive number

__module__ = 'sas.sascalc.dataloader.manipulations'
__weakref__

list of weak references to the object (if defined)

_agv(data2D, run='phi')[source]

Perform sector averaging.

Parameters:
  • data2D – Data2D object

  • run – define the varying parameter (‘phi’ , ‘q’ , or ‘q2’)

Returns:

Data1D object

class sas.sascalc.dataloader.manipulations._Slab(x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0, bin_width=0.001, fold=False)[source]

Bases: object

Compute average I(Q) for a region of interest

__call__(data2D)[source]

Call self as a function.

__dict__ = mappingproxy({'__module__': 'sas.sascalc.dataloader.manipulations', '__doc__': '\n    Compute average I(Q) for a region of interest\n    ', '__init__': <function _Slab.__init__>, '__call__': <function _Slab.__call__>, '_avg': <function _Slab._avg>, '__dict__': <attribute '__dict__' of '_Slab' objects>, '__weakref__': <attribute '__weakref__' of '_Slab' objects>, '__annotations__': {}})
__doc__ = '\n    Compute average I(Q) for a region of interest\n    '
__init__(x_min=0.0, x_max=0.0, y_min=0.0, y_max=0.0, bin_width=0.001, fold=False)[source]
__module__ = 'sas.sascalc.dataloader.manipulations'
__weakref__

list of weak references to the object (if defined)

_avg(data2D, maj)[source]

Compute average I(Q_maj) for a region of interest. The major axis is defined as the axis of Q_maj. The minor axis is the axis that we average over.

Parameters:
  • data2D – Data2D object

  • maj_min – min value on the major axis

Returns:

Data1D object

sas.sascalc.dataloader.manipulations.flip_phi(phi)[source]

Correct phi to within the 0 <= to <= 2pi range

Returns:

phi in >=0 and <=2Pi

sas.sascalc.dataloader.manipulations.get_dq_data(data2D)[source]

Get the dq for resolution averaging The pinholes and det. pix contribution present in both direction of the 2D which must be subtracted when converting to 1D: dq_overlap should calculated ideally at q = 0. Note This method works on only pinhole geometry. Extrapolate dqx(r) and dqy(phi) at q = 0, and take an average.

sas.sascalc.dataloader.manipulations.get_intercept(q, q_0, q_1)[source]

Returns the fraction of the side at which the q-value intercept the pixel, None otherwise. The values returned is the fraction ON THE SIDE OF THE LOWEST Q.

    A           B
+-----------+--------+    <--- pixel size
0                    1
Q_0 -------- Q ----- Q_1   <--- equivalent Q range
if Q_1 > Q_0, A is returned
if Q_1 < Q_0, B is returned
if Q is outside the range of [Q_0, Q_1], None is returned
sas.sascalc.dataloader.manipulations.get_pixel_fraction(qmax, q_00, q_01, q_10, q_11)[source]

Returns the fraction of the pixel defined by the four corners (q_00, q_01, q_10, q_11) that has q < qmax.:

        q_01                q_11
y=1         +--------------+
            |              |
            |              |
            |              |
y=0         +--------------+
        q_00                q_10

            x=0            x=1
sas.sascalc.dataloader.manipulations.get_pixel_fraction_square(x, xmin, xmax)[source]

Return the fraction of the length from xmin to x.:

    A            B
+-----------+---------+
xmin        x         xmax
Parameters:
  • x – x-value

  • xmin – minimum x for the length considered

  • xmax – minimum x for the length considered

Returns:

(x-xmin)/(xmax-xmin) when xmin < x < xmax

sas.sascalc.dataloader.manipulations.get_q(dx, dy, det_dist, wavelength)[source]
Parameters:
  • dx – x-distance from beam center [mm]

  • dy – y-distance from beam center [mm]

Returns:

q-value at the given position

sas.sascalc.dataloader.manipulations.get_q_compo(dx, dy, det_dist, wavelength, compo=None)[source]

This reduces tiny error at very large q. Implementation of this func is not started yet.<–ToDo

sas.sascalc.dataloader.manipulations.reader2D_converter(data2d=None)[source]

convert old 2d format opened by IhorReader or danse_reader to new Data2D format This is mainly used by the Readers

Parameters:

data2d – 2d array of Data2D object

Returns:

1d arrays of Data2D object

Module contents