Module providing the public functionality of the subpackage.[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.
Returns:file_ (magni.afm.types.File) – The read .mi file.

See also
First step of the reading.
Second step of the reading.
Third step of the reading.


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.


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

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

Instantiate a Spectroscopy object from a hierarchical object-structure.

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

See also

Function using the present function.


This function instantiates the sweep buffer and the spectroscopy file., sweep_buffer)[source]

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

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

See also

Function using the present function.