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
check_data_tag_delimiter()
find_next_data_tag()
find_next_tag()
get_data_reader(enc_dtype)
get_image_dictionaries()

Returns the image dictionaries of all images in the file except the thumbnails.

Returns

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_file()
parse_header()
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_tag_header()
parse_tags(ntags, group_name='root', group_dict={})

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’.

property read_l_or_q
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’.

simple_type = (2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
skipif4(n=1)
class hyperspy.io_plugins.digital_micrograph.ImageObject(imdict, file, order='C', record_by=None)

Bases: object

property dtype
get_axes_dict()
get_data()
get_mapping()
get_metadata(metadata={})
property intensity_calibration
property names
property offsets
property order
property record_by
property scales
property shape
property signal_type
property size
property title
property to_spectrum
property units
unpack_new_packed_complex(data)
unpack_packed_complex(tmpdata)
hyperspy.io_plugins.digital_micrograph.file_reader(filename, record_by=None, order=None, lazy=False, optimize=True)

Reads a DM3 file and loads the data into the appropriate class. data_id can be specified to load a given image within a DM3 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