hyperspy.io_plugins.semper_unf module

class hyperspy.io_plugins.semper_unf.SemperFormat(data, title='', offsets=(0.0, 0.0, 0.0), scales=(1.0, 1.0, 1.0), units=(<undefined>, <undefined>, <undefined>), metadata=None)

Bases: object

Class for importing and exporting SEMPER .unf-files.

The SemperFormat class represents a SEMPER binary file format with a header, which holds additional information. .unf-files can be saved and read from files.

data

The phase map or magnetization information in a 3D array (with one slice).

Type

ndarray (N=3)

title

Title of the file (not to be confused with the filename).

Type

string

offsets

Offset shifts (in nm) of the grid origin (does not have to start at 0) in x, y, z.

Type

tuple (N=3) of floats

scales

Grid spacing (nm per pixel) in x, y, z.

Type

tuple (N=3) of floats

units

Units of the grid in x, y, z.

Type

tuple (N=3) of strings

metadata

A dictionary of all flags and metadata present in the .unf-file.

Type

dictionary

classmethod from_signal(signal)

Import a SemperFormat object from a Signal object.

Parameters

signal (Signal) – The signal which should be imported.

Returns

Return type

None

classmethod load_from_unf(filename, lazy=False)

Load a .unf-file into a SemperFormat object.

Parameters

filename (string) – The name of the unf-file from which to load the data. Standard format is ‘*.unf’.

Returns

semper – SEMPER file format object containing the loaded information.

Return type

SemperFormat (N=1)

log_info()

log important flag information of the SemperFormat object.

Parameters

None

Returns

Return type

None

save_to_unf(filename='semper.unf', skip_header=False)

Save a SemperFormat to a file.

Parameters
  • filename (string, optional) – The name of the unf-file to which the data should be written.

  • skip_header (bool, optional) – Determines if the header, title and label should be skipped (useful for some other programs). Default is False.

Returns

Return type

None

to_signal(lazy=False)

Export a SemperFormat object to a Signal object.

Parameters

None

Returns

signal – The exported signal.

Return type

Signal

hyperspy.io_plugins.semper_unf.pack_to_intbytes(fmt, value)

Pack a value into a byte list using format fmt and represent it as int (range 0-255).

hyperspy.io_plugins.semper_unf.unpack_from_intbytes(fmt, byte_list)

Read in a list of bytes (as int with range 0-255) and unpack them with format fmt.