dxchange.reader

Module for importing data files.

Functions:

read_hdf_meta(fname[, add_shape])

Get meta data and tree view of a generic hdf file.

read_edf(fname[, slc])

Read data from edf file.

read_hdf5(fname, dataset[, slc, dtype, shared])

Read data from hdf5 file from a specific group.

read_netcdf4(fname, group[, slc])

Read data from netcdf4 file from a specific group.

read_npy(fname[, slc])

Read binary data from a .npy file.

read_spe(fname[, slc])

Read data from spe file.

read_fits(fname[, fixdtype])

Read data from fits file.

read_tiff(fname[, slc, angle, mblur])

Read data from tiff file.

read_tiff_stack(fname, ind[, digit, slc, ...])

Read data from stack of tiff files in a folder.

read_hdf5_stack(h5group, dname, ind[, ...])

Read data from stacked datasets in a hdf5 file

read_xrm(fname[, slice_range])

Read data from xrm file.

read_xrm_stack(fname, ind[, slc])

Read data from stack of xrm files in a folder.

read_txrm(file_name[, slice_range])

Read data from a .txrm file, a compilation of .xrm files.

dxchange.reader.read_aps_1id_metafile(metafn)[source]

Parse log file generated at APS 1-ID

Parameters:

metafn (str) – Path to metafile of the experiment

Returns:

dataframe – Metadata stored as Pandas DataFrame.

dxchange.reader.read_edf(fname, slc=None)[source]

Read data from edf file.

Parameters:
  • fname (str) – String defining the path of file or file name.

  • slc (sequence of tuples, optional) – Range of values for slicing data in each axis. ((start_1, end_1, step_1), … , (start_N, end_N, step_N)) defines slicing parameters for each axis of the data matrix.

Returns:

ndarray – Data.

dxchange.reader.read_file_list(file_list)[source]

Read data from stack of image files in a folder.

Parameters:

file_list (list of str) – List of file names to read, in order

dxchange.reader.read_fits(fname, fixdtype=True)[source]

Read data from fits file.

Parameters:

fname (str) – String defining the path of file or file name.

Returns:

ndarray – Data.

dxchange.reader.read_hdf5(fname, dataset, slc=None, dtype=None, shared=False)[source]

Read data from hdf5 file from a specific group.

Parameters:
  • fname (str) – String defining the path of file or file name.

  • dataset (str) – Path to the dataset inside hdf5 file where data is located.

  • slc (sequence of tuples, optional) – Range of values for slicing data in each axis. ((start_1, end_1, step_1), … , (start_N, end_N, step_N)) defines slicing parameters for each axis of the data matrix.

  • dtype (numpy datatype (optional)) – Convert data to this datatype on read if specified.

  • shared (bool (optional)) – If True, read data into shared memory location. Defaults to True.

Returns:

ndarray – Data.

dxchange.reader.read_hdf5_stack(h5group, dname, ind, digit=4, slc=None, out_ind=None)[source]

Read data from stacked datasets in a hdf5 file

Parameters:
  • fname (str) – One of the dataset names in the dataset stack

  • ind (list of int) – Indices of the datasets to be read

  • digit (int) – (Deprecated) Number of digits indexing the stacked datasets

  • slc ({sequence, int}) – Range of values for slicing data. ((start_1, end_1, step_1), … , (start_N, end_N, step_N)) defines slicing parameters for each axis of the data matrix

  • out_ind (list of int, optional) – Outer level indices for files with two levels of indexing. i.e. [name_000_000.tif, name_000_001.tif, …, name_000_lmn.tif, name_001_lmn.tif, …, …, name_fgh_lmn.tif]

dxchange.reader.read_hdf_meta(fname, add_shape=True)[source]

Get meta data and tree view of a generic hdf file.

Parameters:
  • file_path (str) – Path to the file.

  • add_shape (bool) – Including the shape of a dataset to the tree if True.

Returns:

  • tree (str) – Graphic rapresentation of the hdf file structure

  • meta (dict) – Dictionary containing all the hdf file stored dict[key] = list. list[0] contains the meta data value; list[1] its attribute (e.g. units).

dxchange.reader.read_netcdf4(fname, group, slc=None)[source]

Read data from netcdf4 file from a specific group.

Parameters:
  • fname (str) – String defining the path of file or file name.

  • group (str) – Variable name where data is stored.

  • slc (sequence of tuples, optional) – Range of values for slicing data in each axis. ((start_1, end_1, step_1), … , (start_N, end_N, step_N)) defines slicing parameters for each axis of the data matrix.

Returns:

ndarray – Data.

dxchange.reader.read_npy(fname, slc=None)[source]

Read binary data from a .npy file.

Parameters:
  • fname (str) – String defining the path of file or file name.

  • slc (sequence of tuples, optional) – Range of values for slicing data in each axis. ((start_1, end_1, step_1), … , (start_N, end_N, step_N)) defines slicing parameters for each axis of the data matrix.

Returns:

ndarray – Data.

dxchange.reader.read_spe(fname, slc=None)[source]

Read data from spe file.

Parameters:
  • fname (str) – String defining the path of file or file name.

  • slc (sequence of tuples, optional) – Range of values for slicing data in each axis. ((start_1, end_1, step_1), … , (start_N, end_N, step_N)) defines slicing parameters for each axis of the data matrix.

Returns:

ndarray – Data.

dxchange.reader.read_tiff(fname, slc=None, angle=None, mblur=None)[source]

Read data from tiff file.

Parameters:
  • fname (str) – String defining the path of file or file name.

  • slc (sequence of tuples, optional) – Range of values for slicing data in each axis. ((start_1, end_1, step_1), … , (start_N, end_N, step_N)) defines slicing parameters for each axis of the data matrix.

  • angle (angle in degree(+ ccw), optional) – angle of rotation after open the image.

  • mblur (size of median filter (should be positive integer >= 3))

Returns:

ndarray – Output 2D image.

dxchange.reader.read_tiff_stack(fname, ind, digit=None, slc=None, angle=None, mblur=None)[source]

Read data from stack of tiff files in a folder.

Parameters:
  • fname (str) – One of the file names in the tiff stack.

  • ind (list of int) – Indices of the files to read.

  • digit (int) – (Deprecated) Number of digits used in indexing stacked files.

  • slc (sequence of tuples, optional) – Range of values for slicing data in each axis. ((start_1, end_1, step_1), … , (start_N, end_N, step_N)) defines slicing parameters for each axis of the data matrix.

  • angle (angle to rotate after reading the tiff image)

  • mblue (median filter)

Returns:

ndarray – Output 3D image.

dxchange.reader.read_txrm(file_name, slice_range=None)[source]

Read data from a .txrm file, a compilation of .xrm files.

Parameters:
  • file_name (str) – String defining the path of file or file name.

  • slice_range (sequence of tuples, optional) – Range of values for slicing data in each axis. ((start_1, end_1, step_1), … , (start_N, end_N, step_N)) defines slicing parameters for each axis of the data matrix.

Returns:

  • ndarray – Array of 2D images.

  • dictionary – Dictionary of metadata.

dxchange.reader.read_xrm(fname, slice_range=None)[source]

Read data from xrm file.

Parameters:
  • fname (str) – String defining the path of file or file name.

  • slice_range (sequence of tuples, optional) – Range of values for slicing data in each axis. ((start_1, end_1, step_1), … , (start_N, end_N, step_N)) defines slicing parameters for each axis of the data matrix.

Returns:

ndarray – Output 2D image.

dxchange.reader.read_xrm_stack(fname, ind, slc=None)[source]

Read data from stack of xrm files in a folder.

Parameters:
  • fname (str) – One of the file names in the tiff stack.

  • ind (list of int) – Indices of the files to read.

  • slc (sequence of tuples, optional) – Range of values for slicing data in each axis. ((start_1, end_1, step_1), … , (start_N, end_N, step_N)) defines slicing parameters for each axis of the data matrix.

Returns:

ndarray – Output 3D image.