Skip to content

Error reading files saved by py4DSTEM #3

@matao1984

Description

@matao1984

Hi,

I was trying to read some files saved by py4DSTEM and got the following error:

s = ncem_reader.read(file)
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File /opt/anaconda3/envs/temcompanion/lib/python3.12/site-packages/emdfile/classes/utils.py:39, in _get_class(grp)
     38 classname = grp.attrs['python_class']
---> [39](https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/temcompanion/lib/python3.12/site-packages/emdfile/classes/utils.py:39) __class__ = lookup[classname]
     40 return __class__

KeyError: 'Calibration'

During handling of the above exception, another exception occurred:

Exception                                 Traceback (most recent call last)
Cell In[5], [line 1](vscode-notebook-cell:?execution_count=5&line=1)
----> [1](vscode-notebook-cell:?execution_count=5&line=1) s = ncem_reader.read(file)

File /opt/anaconda3/envs/temcompanion/lib/python3.12/site-packages/emdfile/read.py:110, in read(filepath, emdpath, tree, **legacy_options)
    108         nodegroup = nodegroup[name]
    109 # Read the root
--> [110](https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/temcompanion/lib/python3.12/site-packages/emdfile/read.py:110) root = Root.from_h5(rootgroup)
    111 # if this is all that was requested, return
    112 if nodegroup is rootgroup and tree is False:

File /opt/anaconda3/envs/temcompanion/lib/python3.12/site-packages/emdfile/classes/node.py:635, in Node.from_h5(cls, group)
    632 if md.attrs['python_class'] != 'Metadata':
    633     # and attempt promotion
    634     try:
--> [635](https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/temcompanion/lib/python3.12/site-packages/emdfile/classes/node.py:635)         cls = _get_class(md)
    636         inst = cls( name=basename(md.name) )
    637         inst._params.update(node.metadata[basename(md.name)]._params)

File /opt/anaconda3/envs/temcompanion/lib/python3.12/site-packages/emdfile/classes/utils.py:42, in _get_class(grp)
     40     return __class__
     41 except KeyError:
---> [42](https://file+.vscode-resource.vscode-cdn.net/opt/anaconda3/envs/temcompanion/lib/python3.12/site-packages/emdfile/classes/utils.py:42)     raise Exception(f"Unknown classname {classname}")

Exception: Unknown classname Calibration

The file was saved by the recent release of py4DSTEM which is described as "NCEM EMD v1.0" format. However, it seems it cannot handle "Calibration" that was saved by py4DSTEM.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions