pyxem package

Subpackages

Submodules

pyxem.version module

Module contents

pyxem.assign_signal_subclass(dtype, signal_dimension, signal_type='', lazy=False)[source]

Given record_by and signal_type return the matching Signal subclass.

Parameters
  • dtype (dtype) –

  • signal_dimension (int) –

  • signal_type ({None, "electron_diffraction", "diffraction_profile",) – “diffraction_vectors”, “crystallographic_map”, str}

  • lazy (bool) –

Returns

Return type

Signal or subclass

pyxem.dict2signal(signal_dict, lazy=False)[source]

Create a signal (or subclass) instance defined by a dictionary

Parameters

signal_dict (dictionary) –

Returns

s

Return type

Signal or subclass

pyxem.load(filenames=None, signal_type=None, stack=False, stack_axis=None, new_axis_name='stack_element', lazy=False, **kwds)[source]

Load supported files into a pyxem structure.

Supported formats: hspy (HDF5), Medipix (hdr + mib), blockfile, Gatan dm3, tif, msa, Bruker bcf, FEI ser and emi, SEMPER unf, EMD, EDAX spd/spc, tif, and a number of image formats.

Additional keyword arguments are passed to the corresponding reader. For available options see their individual documentation, which may be found in either pyxem or hyperspy.

Parameters
  • filenames (None, str or list of strings) – The filename to be loaded. If None, a window will open to select a file to load. If a valid filename is passed in that single file is loaded. If multiple file names are passed in a list, a list of objects or a single object containing the data of the individual files stacked are returned. This behaviour is controlled by the stack parameter (see bellow). Multiple files can be loaded by using simple shell-style wildcards, e.g. ‘my_file*.msa’ loads all the files that starts by ‘my_file’ and has the ‘.msa’ extension.

  • signal_type ({None, "electron_diffraction", "diffraction_profile",) – “diffraction_vectors”, “crystallographic_map”, str} The acronym that identifies the signal type. The value provided may determine the Signal subclass assigned to the data. If None the value is read/guessed from the file. Any other value overrides the value stored in the file if any. For electron energy-loss spectroscopy use “EELS”. For energy dispersive x-rays use “EDS_TEM” if acquired from an electron-transparent sample — as it is usually the case in a transmission electron microscope (TEM) —, “EDS_SEM” if acquired from a non electron-transparent sample — as it is usually the case in a scanning electron microscope (SEM) —. If “” (empty string) the value is not read from the file and is considered undefined.

  • stack (bool) – If True and multiple filenames are passed in, stacking all the data into a single object is attempted. All files must match in shape. If each file contains multiple (N) signals, N stacks will be created, with the requirement that each file contains the same number of signals.

  • stack_axis ({None, int, str}) – If None, the signals are stacked over a new axis. The data must have the same dimensions. Otherwise the signals are stacked over the axis given by its integer index or its name. The data must have the same shape, except in the dimension corresponding to axis.

  • new_axis_name (string) – The name of the new axis when axis is None. If an axis with this name already exists it automatically append ‘-i’, where i are integers, until it finds a name that is not yet in use.

  • lazy ({None, bool}) – Open the data lazily - i.e. without actually reading the data from the disk until required. Allows opening arbitrary-sized datasets. default is False.

  • print_info (bool) – For SEMPER unf- and EMD (Berkley)-files, if True (default is False) additional information read during loading is printed for a quick overview.

  • downsample (int (1–4095)) – For Bruker bcf files, if set to integer (>=2) (default 1) bcf is parsed into down-sampled size array by given integer factor, multiple values from original bcf pixels are summed forming downsampled pixel. This allows to improve signal and conserve the memory with the cost of lower resolution.

  • cutoff_at_kV ({None, int, float}) – For Bruker bcf files, if set to numerical (default is None) bcf is parsed into array with depth cutoff at coresponding given energy. This allows to conserve the memory, with cutting-off unused spectra’s tail, or force enlargement of the spectra size.

  • select_type ({'spectrum', 'image', None}) – For Bruker bcf files, if one of ‘spectrum’ or ‘image’ (default is None) the loader returns either only hypermap or only SEM/TEM electron images.

Returns

Return type

Signal instance or list of signal instances

Examples

Loading a single file providing the signal type: >>> d = hs.load(‘file.dm3’, signal_type=”EDS_TEM”)

Loading multiple files:

>>> d = hs.load('file1.dm3','file2.dm3')

Loading multiple files matching the pattern:

>>> d = hs.load('file*.dm3')

Loading (potentially larger than the available memory) files lazily and stacking:

>>> s = hs.load('file*.blo', lazy=True, stack=True)
pyxem.load_mib(filename, scan_size, sum_length=10)[source]

Load a medipix hdr/mib file.

Parameters
  • filename (string) – File path and name to .hdr file.

  • scan_size (int) – Scan size in pixels, allows the function to reshape the array into the right shape.

  • sum_length (int) – Number of lines to sum over to determine scan fly back location.

pyxem.load_single_file(filename, signal_type=None, **kwds)[source]

Load any supported file into an HyperSpy structure Supported formats: netCDF, msa, Gatan dm3, Ripple (rpl+raw), Bruker bcf, FEI ser and emi, EDAX spc and spd, hspy (HDF5), and SEMPER unf.

Parameters

filename (string) – File name (including the extension)

pyxem.load_with_reader(filename, reader, signal_type=None, **kwds)[source]
pyxem.save(filename, signal, overwrite=None, **kwds)[source]