hyperspy.io_plugins.tvips module


Find the start and stop index in a rotator index array


Guess whether the dataset contains images (1) or diffraction patterns (2). If no decent guess can be made, None is returned.


Check if the provided first tvips file path is valid

hyperspy.io_plugins.tvips.file_reader(filename, scan_shape=None, scan_start_frame=0, winding_scan_axis=None, hysteresis=0, lazy=True, rechunking='auto', **kwds)

TVIPS stream file reader for in-situ and 4D STEM data

  • scan_shape (str or tuple of int) – By default the data is loaded as an image stack (1 navigation axis). If it concerns a 4D-STEM dataset, the (…, scan_y, scan_x) dimension can be provided. “auto” can also be selected, in which case the rotidx information in the frame headers will be used to try to reconstruct the scan. Additional navigation axes must be prepended.

  • scan_start_frame (int) – First frame where the scan starts. If scan_shape = “auto” this is ignored.

  • winding_scan_axis (str) – “x” or “y” if the scan was performed with winding scan along an axis as opposed to flyback scan. By default (None), flyback scan is assumed with “x” the fast and “y” the slow scan directions.

  • hysteresis (int) – Only applicable if winding_scan_axis is not None. This parameter allows every second column or row to be shifted to correct for hysteresis that occurs during a winding scan.

  • rechunking (bool, str, or Dict) – If set to False each tvips file is a single chunk. For a better experience working with the dataset, an automatic rechunking is recommended (default). If set to anything else, e.g. a Dictionary, the value will be passed to the chunks argument in dask.array.rechunk.

hyperspy.io_plugins.tvips.file_writer(filename, signal, **kwds)

Write signal to TVIPS file.

  • file (str) – Filename of the file to write to. If not supplied, a _000 suffix will automatically be appended before the extension.

  • signal (instance of hyperspy Signal2D) – The signal to save.

  • max_file_size (int, optional) – Maximum size of individual files in bytes. By default there is no maximum and everything is stored in a single file. Otherwise, files are split into sequential parts denoted by a suffix _xxx starting from _000.

  • version (int, optional) – TVIPS file format version (1 or 2), defaults to 2

  • frame_header_extra_bytes (int, optional) – Number of bytes to pad the frame headers with, defaults to 0

  • mode (int, optional) – Imaging mode. 1 is imaging, 2 is diffraction. By default the mode is guessed from signal type and signal units.