hyperspy.io_plugins.hspy module

class hyperspy.io_plugins.hspy.HyperspyReader(file)

Bases: HierarchicalReader

Initializes a general reader for hierarchical signals.

Parameters

file (str) – A file to be read.

class hyperspy.io_plugins.hspy.HyperspyWriter(file, signal, expg, **kwds)

Bases: HierarchicalWriter

An object used to simplify and organize the process for writing a hyperspy signal. (.hspy format)

Initialize a generic file writer for hierachical data storage types.

Parameters
  • file (str) – The file where the signal is to be saved

  • signal (BaseSignal) – A BaseSignal to be saved

  • group (Group) – A group to where the experimental data will be saved.

  • kwds – Any additional keywords used for saving the data.

static _get_object_dset(group, data, key, chunks, **kwds)

Creates a h5py dataset object for saving ragged data

hyperspy.io_plugins.hspy.file_reader(filename, lazy=False, **kwds)

Read data from hdf5 files saved with the hyperspy hdf5 format specification

Parameters
  • filename (str) –

  • lazy (bool) – Load image lazily using dask

  • **kwds

  • optional

hyperspy.io_plugins.hspy.file_writer(filename, signal, close_file=True, **kwds)

Writes data to hyperspy’s hdf5 format

Parameters
  • filename (str) – The name of the file used to save the signal.

  • signal (a BaseSignal instance) – The signal to save.

  • chunks (tuple of integer or None, default: None) – Define the chunking used for saving the dataset. If None, calculates chunks for the signal, with preferably at least one chunk per signal space.

  • close_file (bool, default: True) – Close the file after writing.

  • write_dataset (bool, default: True) – If True, write the data, otherwise, don’t write it. Useful to save attributes without having to write the whole dataset.

  • **kwds – The keyword argument are passed to the h5py.Group.require_dataset() function.