# Buggy code
def get_data_reader(self, enc_dtype):
    # _data_type dictionary.
    # The first element of the InfoArray in the TagType
    # will always be one of _data_type keys.
    # the tuple reads: ('read bytes function', 'number of bytes', 'type')

    dtype_dict = {
        2: (iou.read_short, 2, "h"),
        3: (iou.read_long, 4, "l"),
        4: (iou.read_ushort, 2, "H"),  # dm3 uses ushorts for unicode chars
        5: (iou.read_ulong, 4, "L"),
        6: (iou.read_float, 4, "f"),
        7: (iou.read_double, 8, "d"),
        8: (iou.read_boolean, 1, "B"),
        # dm3 uses chars for 1-Byte signed integers
        9: (iou.read_char, 1, "b"),
        10: (iou.read_byte, 1, "b"),  # 0x0a
        11: (iou.read_double, 8, "l"),  # Unknown, new in DM4
        12: (iou.read_double, 8, "l"),  # Unknown, new in DM4
        15: (
            self.read_struct,
            None,
            "struct",
        ),  # 0x0f
        18: (self.read_string, None, "c"),  # 0x12
        20: (self.read_array, None, "array"),  # 0x14
    }
    return dtype_dict[enc_dtype]


# Traceback (DM3TagIDError)
ss = hs.load('D:\\Vadim\\2018-08-02_STEM-d_C_fiber_Fengshan\\bin2\\02_0V.dm4')

---------------------------------------------------------------------------
DM3TagIDError                             Traceback (most recent call last)
<ipython-input-20-bfa902970b32> in <module>()
----> 1 ss = hs.load('D:\\Vadim\\2018-08-02_STEM-d_C_fiber_Fengshan\\bin2\\02_0V.dm4')

C:\Users\migunov\AppData\Local\conda\conda\envs\hs\lib\site-packages\hyperspy\io.py in load(filenames, signal_type, stack, stack_axis, new_axis_name, lazy, **kwds)
241             objects = [load_single_file(filename, lazy=lazy,
242                                         **kwds)
--> 243                        for filename in filenames]
244
245         if len(objects) == 1:

C:\Users\migunov\AppData\Local\conda\conda\envs\hs\lib\site-packages\hyperspy\io.py in <listcomp>(.0)
241             objects = [load_single_file(filename, lazy=lazy,
242                                         **kwds)
--> 243                        for filename in filenames]
244
245         if len(objects) == 1:

C:\Users\migunov\AppData\Local\conda\conda\envs\hs\lib\site-packages\hyperspy\io.py in load_single_file(filename, signal_type, **kwds)
284                                 reader=reader,
285                                 signal_type=signal_type,
--> 286                                 **kwds)
287
288

C:\Users\migunov\AppData\Local\conda\conda\envs\hs\lib\site-packages\hyperspy\io.py in load_with_reader(filename, reader, signal_type, **kwds)
293     lazy = kwds.get('lazy', False)
294     file_data_list = reader.file_reader(filename,
--> 295                                         **kwds)
296     objects = []
297

C:\Users\migunov\AppData\Local\conda\conda\envs\hs\lib\site-packages\hyperspy\io_plugins\digital_micrograph.py in file_reader(filename, record_by, order, lazy)
986     with open(filename, "rb") as f:
987         dm = DigitalMicrographReader(f)
--> 988         dm.parse_file()
989         images = [ImageObject(imdict, f, order=order, record_by=record_by)
990                   for imdict in dm.get_image_dictionaries()]

C:\Users\migunov\AppData\Local\conda\conda\envs\hs\lib\site-packages\hyperspy\io_plugins\digital_micrograph.py in parse_file(self)
85             number_of_root_tags,
86             group_name="root",
---> 87             group_dict=self.tags_dict)
88
89     def parse_header(self):

C:\Users\migunov\AppData\Local\conda\conda\envs\hs\lib\site-packages\hyperspy\io_plugins\digital_micrograph.py in parse_tags(self, ntags, group_name, group_dict)
219                     ntags=ntags,
220                     group_name=tag_name,
--> 221                     group_dict=group_dict[tag_name])
222             else:
223                 _logger.debug('File address:', self.f.tell())

C:\Users\migunov\AppData\Local\conda\conda\envs\hs\lib\site-packages\hyperspy\io_plugins\digital_micrograph.py in parse_tags(self, ntags, group_name, group_dict)
219                     ntags=ntags,
220                     group_name=tag_name,
--> 221                     group_dict=group_dict[tag_name])
222             else:
223                 _logger.debug('File address:', self.f.tell())

C:\Users\migunov\AppData\Local\conda\conda\envs\hs\lib\site-packages\hyperspy\io_plugins\digital_micrograph.py in parse_tags(self, ntags, group_name, group_dict)
219                     ntags=ntags,
220                     group_name=tag_name,
--> 221                     group_dict=group_dict[tag_name])
222             else:
223                 _logger.debug('File address:', self.f.tell())

C:\Users\migunov\AppData\Local\conda\conda\envs\hs\lib\site-packages\hyperspy\io_plugins\digital_micrograph.py in parse_tags(self, ntags, group_name, group_dict)
222             else:
223                 _logger.debug('File address:', self.f.tell())
--> 224                 raise DM3TagIDError(tag_header['tag_id'])
225
226     def get_data_reader(self, enc_dtype):

DM3TagIDError: 66

# Fixed code
def get_data_reader(self, enc_dtype):
    # _data_type dictionary.
    # The first element of the InfoArray in the TagType
    # will always be one of _data_type keys.
    # the tuple reads: ('read bytes function', 'number of bytes', 'type')

    dtype_dict = {
        2: (iou.read_short, 2, "h"),
        3: (iou.read_long, 4, "l"),
        4: (iou.read_ushort, 2, "H"),  # dm3 uses ushorts for unicode chars
        5: (iou.read_ulong, 4, "L"),
        6: (iou.read_float, 4, "f"),
        7: (iou.read_double, 8, "d"),
        8: (iou.read_boolean, 1, "B"),
        # dm3 uses chars for 1-Byte signed integers
        9: (iou.read_char, 1, "b"),
        10: (iou.read_byte, 1, "b"),  # 0x0a
        11: (iou.read_long_long, 8, "q"),  # long long, new in DM4
        # unsigned long long, new in DM4
        12: (iou.read_ulong_long, 8, "Q"),
        15: (
            self.read_struct,
            None,
            "struct",
        ),  # 0x0f
        18: (self.read_string, None, "c"),  # 0x12
        20: (self.read_array, None, "array"),  # 0x14
    }
    return dtype_dict[enc_dtype]