cansas_reader

sans.dataloader.readers.cansas_reader

class sans.dataloader.readers.cansas_reader.Reader

Class to load cansas 1D XML files

Dependencies :The CanSas reader requires PyXML 0.8.4 or later.
__init__()
__module__ = 'sans.dataloader.readers.cansas_reader'
_parse_entry()

Parse a SASentry

Parameters:node – SASentry node
Returns:Data1D object
_store_content()

Get the content of a xpath location and store the result. The value is treated as a string.

The xpath location might or might not exist. If it does not exist, nothing is done

Parameters:
  • location – xpath location to fetch
  • node – node to read the data from
  • variable – name of the data member to store it in [string]
  • storage – data object that has the ‘variable’ data member
Returns:

return a list of errors

_store_float()

Get the content of a xpath location and store the result. Check that the units are compatible with the destination. The value is expected to be a float.

The xpath location might or might not exist. If it does not exist, nothing is done

Parameters:
  • location – xpath location to fetch
  • node – node to read the data from
  • variable – name of the data member to store it in [string]
  • storage – data object that has the ‘variable’ data member
  • optional – if True, no exception will be raised if unit conversion can’t be done
Raises ValueError:
 

raised when the units are not recognized

_to_xml_doc()

Create an XML document to contain the content of a Data1D

Parameters:datainfo – Data1D object
ext = ['.xml', '.XML', '.avex', '.AVEx', '.absx', 'ABSx']
read()

Load data file

Parameters:

path – file path

Returns:

Data1D object if a single SASentry was found, or a list of Data1D objects if multiple entries were found, or None of nothing was found

Raises:
  • RuntimeError – when the file can’t be opened
  • ValueError – when the length of the data vectors are inconsistent
type = ['CanSAS 1D files (*.xml)|*.xml', 'CanSAS 1D AVE files (*.AVEx)|*.AVEx', 'CanSAS 1D AVE files (*.ABSx)|*.ABSx']
type_name = 'CanSAS 1D'
version = '1.0'
write()

Write the content of a Data1D as a CanSAS XML file

Parameters:
  • filename – name of the file to write
  • datainfo – Data1D object
sans.dataloader.readers.cansas_reader.get_content()

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

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

Element, or None

sans.dataloader.readers.cansas_reader.get_float()

Get the content of a node as a float

Parameters:
  • location – xpath location
  • node – node to start at
sans.dataloader.readers.cansas_reader.write_node()
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

Table Of Contents

Previous topic

associations

Next topic

danse_reader

This Page