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. Returns: file_ (magni.afm.types.File) – The read .mi file. See also
magni.afm.io._stream_conversion()
- First step of the reading.
magni.afm.io._object_building()
- Second step of the reading.
magni.afm.io._data_attachment()
- Third step of the reading.
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
ormagni.afm.types.spectroscopy.Spectroscopy
.The reading of an .mi file is logically separated into four steps:
- Converting the file stream to flat, basic variables.
- Converting the header parameters to a hierarchical object-structure
mimicking that of
magni.afm.types
. - Attaching the actual data to the hierarchical object-structure.
- 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 >>> from magni.afm.io 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)
-
magni.afm.io._util.
_instantiate_spectroscopy
(obj)[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
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. Returns: buffer_ (magni.afm.types.spectroscopy.Buffer) – The instantiated spectroscopy Buffer. See also
_instantiate_spectroscopy()
- Function using the present function.