hyperspy.io_plugins.digital_micrograph module
- class hyperspy.io_plugins.digital_micrograph.DigitalMicrographReader(f)
Bases:
object
Class to read Gatan Digital Micrograph (TM) files.
Currently it supports versions 3 and 4.
- dm_version, endian, tags_dict
- parse_file, parse_header, get_image_dictionaries
- get_image_dictionaries()
Returns the image dictionaries of all images in the file except the thumbnails.
- Return type:
dict, None
- parse_array_definition()
Reads and returns the element type and length of the array.
The position in the file must be just after the array encoded dtype.
- parse_string_definition()
Reads and returns the length of the string.
The position in the file must be just after the string encoded dtype.
- parse_struct_definition()
Reads and returns the struct definition tuple.
The position in the file must be just after the struct encoded dtype.
- parse_tag_group(size=False)
Parse the root TagGroup of the given DM3 file f. Returns the tuple (is_sorted, is_open, n_tags). endian can be either ‘big’ or ‘little’.
- parse_tags(ntags, group_name='root', group_dict=None)
Parse the DM file into a dictionary.
- read_array(size, enc_eltype, extra=None, skip=False)
Read an array, defined by iarray, from file f with a given endianness (byte order). endian can be either ‘big’ or ‘little’.
- read_simple_data(etype)
Parse the data of the given DM3 file f with the given endianness (byte order). The infoArray iarray specifies how to read the data. Returns the tuple (file address, data). The tag data is stored in the platform’s byte order: ‘little’ endian for Intel, PC; ‘big’ endian for Mac, Motorola. If skip != 0 the data is actually skipped.
- read_string(length, skip=False)
Read a string defined by the infoArray iarray from file f with a given endianness (byte order). endian can be either ‘big’ or ‘little’.
If it’s a tag name, each char is 1-Byte; if it’s a tag data, each char is 2-Bytes Unicode,
- read_struct(definition, skip=False)
Read a struct, defined by iarray, from file f with a given endianness (byte order). Returns a list of 2-tuples in the form (fieldAddress, fieldValue). endian can be either ‘big’ or ‘little’.
- hyperspy.io_plugins.digital_micrograph.file_reader(filename, record_by=None, order=None, lazy=False, optimize=True)
Reads a DM3/4 file and loads the data into the appropriate class. data_id can be specified to load a given image within a DM3/4 file that contains more than one dataset.
- Parameters:
record_by (Str) – One of: SI, Signal2D
order (Str) – One of ‘C’ or ‘F’
lazy (bool, default False) – Load the signal lazily.
%s –