# magni.afm.io._util module¶

Module providing the public functionality of the magni.afm.io subpackage.

magni.afm.io._util.read_mi_file(path)[source]

Read an .mi file given by a path.

The supported .mi file types are Image and Spectroscopy.

Parameters: path (str) – The path of the .mi file to read. file_ (magni.afm.types.File) – The read .mi file.

magni.afm.io._stream_conversion()
magni.afm.io._object_building()
magni.afm.io._data_attachment()

Notes

Depending on the .mi file type, the returned value will be an instance of a subclass of magni.afm.types.File: magni.afm.types.image.Image or magni.afm.types.spectroscopy.Spectroscopy.

The reading of an .mi file is logically separated into four steps:

1. Converting the file stream to flat, basic variables.
2. Converting the header parameters to a hierarchical object-structure mimicking that of magni.afm.types.
3. Attaching the actual data to the hierarchical object-structure.
4. Instantiating the classes in magni.afm.types from the hierarchical object structure.

The functionality needed for each step is grouped in separate modules with the functionality needed for the fourth step being grouped in the this module.

Examples

An example of how to use this function to read the example .mi file provided with the package:

>>> import os, magni
>>> path = magni.utils.split_path(magni.__path__[0])[0]
>>> path = path + 'examples' + os.sep + 'example.mi'
>>> if os.path.isfile(path):

magni.afm.io._util._instantiate_spectroscopy(obj)[source]

Instantiate a Spectroscopy object from a hierarchical object-structure.

Parameters: obj (object) – The hierarchical object-structure. spectroscopy (magni.afm.types.spectroscopy.Spectroscopy) – The instantiated Spectroscopy object.

read_mi_file()
Function using the present function.

Notes

This function instantiates the sweep buffer and the spectroscopy file.

magni.afm.io._util._instantiate_spectroscopy_buffer(data_buffer, sweep_buffer)[source]

Instantiate a spectroscopy Buffer object from a hierarchical object-structure.

Parameters: obj (object) – The hierarchical object-structure. buffer_ (magni.afm.types.spectroscopy.Buffer) – The instantiated spectroscopy Buffer.

_instantiate_spectroscopy()