dxchange.writer

Module for data exporting data files.

Functions:

write_dxf(data[, fname, axes, dtype, overwrite])

Write data to a data exchange hdf5 file.

write_hdf5(data[, fname, gname, dname, ...])

Write data to hdf5 file in a specific group.

write_npy(data[, fname, dtype, overwrite])

Write data to a binary file in NumPy .npy format.

write_tiff(data[, fname, dtype, overwrite])

Write image data to a tiff file.

write_tiff_stack(data[, fname, dtype, axis, ...])

Write data to stack of tiff file.

write_netcdf4(data[, fname, dname, dtype, ...])

Write data to netCDF file.

dxchange.writer.write_aps_1id_report(df_scanmeta, reportfn)[source]

Generate report of beam conditions based on given DataFrame of the metadata

Parameters:
  • df_scanmeta (pd.DataFrame) –

    DataFrame of the parsed metadata

    dxreader.read_aps_1id_metafile(log_file)

  • reportfn (str) – Output report file name (include path)

Returns:

pd.DataFrame – Updated Dataframe with added beam conditions

dxchange.writer.write_dxf(data, fname='tmp/data.h5', axes='theta:y:x', dtype=None, overwrite=False)[source]

Write data to a data exchange hdf5 file.

Parameters:
  • data (ndarray) – Array data to be saved.

  • fname (str) – File name to which the data is saved. .h5 extension will be appended if it does not already have one.

  • axes (str) – Attribute labels for the data array axes.

  • dtype (data-type, optional) – By default, the data-type is inferred from the input data.

  • overwrite (bool, optional) – if True, overwrites the existing file if the file exists.

dxchange.writer.write_hdf5(data, fname='tmp/data.h5', gname='exchange', dname='data', dtype=None, overwrite=False, appendaxis=None, maxsize=None)[source]

Write data to hdf5 file in a specific group.

Parameters:
  • data (ndarray) – Array data to be saved.

  • fname (str) – File name to which the data is saved. .h5 extension will be appended if it does not already have one.

  • gname (str, optional) – Path to the group inside hdf5 file where data will be written.

  • dname (str, optional) – Name for dataset where data will be written.

  • dtype (data-type, optional) – By default, the data-type is inferred from the input data.

  • overwrite (bool, optional) – if True, overwrites the existing file if the file exists.

  • appendaxis (int, optional) – Axis where data is to be appended to. Must be given when creating a resizable dataset.

  • maxsizee (int, optional) – Maximum size that the dataset can be resized to along the given axis.

dxchange.writer.write_netcdf4(data, fname='tmp/data.nc', dname='VOLUME', dtype=None, overwrite=False, appendaxis=None, maxsize=None)[source]

Write data to netCDF file.

Parameters:
  • data (ndarray) – Array data to be saved.

  • fname (str) – File name to which the data is saved.

dxchange.writer.write_npy(data, fname='tmp/data.npy', dtype=None, overwrite=False)[source]

Write data to a binary file in NumPy .npy format.

Parameters:
  • data (ndarray) – Array data to be saved.

  • fname (str) – File name to which the data is saved. .npy extension will be appended if it does not already have one.

dxchange.writer.write_tiff(data, fname='tmp/data.tiff', dtype=None, overwrite=False)[source]

Write image data to a tiff file.

Parameters:
  • data (ndarray) – Array data to be saved.

  • fname (str) – File name to which the data is saved. .tiff extension will be appended if it does not already have one.

  • dtype (data-type, optional) – By default, the data-type is inferred from the input data.

  • overwrite (bool, optional) – if True, overwrites the existing file if the file exists.

dxchange.writer.write_tiff_stack(data, fname='tmp/data.tiff', dtype=None, axis=0, digit=5, start=0, overwrite=False)[source]

Write data to stack of tiff file.

Parameters:
  • data (ndarray) – Array data to be saved.

  • fname (str) – Base file name to which the data is saved. .tiff extension will be appended if it does not already have one.

  • dtype (data-type, optional) – By default, the data-type is inferred from the input data.

  • axis (int, optional) – Axis along which stacking is performed.

  • start (int, optional) – First index of file in stack for saving.

  • digit (int, optional) – Number of digits in indexing stacked files.

  • overwrite (bool, optional) – if True, overwrites the existing file if the file exists.

dxchange.writer.write_vtr(data, fname='tmp/data.vtr', down_sampling=(5, 5, 5))[source]

Write the reconstructed data (img stackes) to vtr file (retangular grid)

Parameters:
  • data (np.3darray) – reconstructed 3D image stacks with axis=0 as the omega

  • fname (str) – file name of the output vtr file

  • down_sampling (tuple) – down sampling steps along three axes

Returns:

None