# sasdata.dataloader.readers.cansas_reader_HDF5 module

NXcanSAS data reader for reading HDF5 formatted CanSAS files.

class sasdata.dataloader.readers.cansas_reader_HDF5.Reader

  Bases: `FileReader`

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

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

  Dependencies:

    The NXcanSAS HDF5 reader requires h5py => v2.5.0 or later.

  add_data_set()

    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.

  add_intermediate()

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

    Parameters:

      parent – The NXclass name for the h5py Group object that just finished being processed

  allow_all = True
  static as_list_or_array(data: Any) → list | ndarray

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

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

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

  get_file_contents()

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

    Parameters:

      filename – A path for an HDF5 formatted CanSAS 2D data file.

    Returns:

      List of Data1D/2D objects and/or a list of errors.

  process_1d_data_object(data_set: array, key: str, unit: str)

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

  process_2d_data_object(data_set: array, key: str, unit: str)
  process_aperture(data_point: Any, key: str)

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

  process_collimation(data_point: Any, key: str, unit: str)

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

  process_detector(data_point: Any, key: str, unit: str)

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

  process_process(data_point: Any, key: str)

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

  process_sample(data_point: Any, key: str)

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

  process_source(data_point: Any, key: str, unit: str)

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

  process_trans_spectrum(data_set: array, key: str)

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

  read_children(data: dict, parent_list: list)

    A recursive method for stepping through the hierarchical data file.

    Parameters:

      - data – h5py Group object of any kind

      - parent – h5py Group parent name

  reset_state()

    Create the reader object and define initial states for class variables

  type = ['NXcanSAS HDF5 Files (*.h5)|*.h5|']
  type_name = 'NXcanSAS'
  write(filename: str, dataset: Data1D | Data2D)

    Export data in NXcanSAS format

    Parameters:

      - filename – File path where the data will be saved

      - dataset – DataInfo object that will be converted to NXcanSAS

    Returns:

      None

sasdata.dataloader.readers.cansas_reader_HDF5.h5attr(node, key, default=None)