Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't read some point group HDF5 datasets from EMsoft's dot product files #159

Closed
hakonanes opened this issue Feb 19, 2021 · 4 comments · Fixed by #180
Closed

Can't read some point group HDF5 datasets from EMsoft's dot product files #159

hakonanes opened this issue Feb 19, 2021 · 4 comments · Fixed by #180
Assignees
Labels
bug Something isn't working
Milestone

Comments

@hakonanes
Copy link
Member

hakonanes commented Feb 19, 2021

The EMsoft dot product file reader is not flexible enough to pick out the point group from this point group string "b'Monoclinic b (C2h) [2/m]'", and throws this error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-12-8df9dedf1234> in <module>
      1 phase = "fe4al13"
----> 2 xmap_fe4al13 = io.load(
      3     os.path.join(emdir, phase, f"{phase}_dp.h5"), refined=False
      4 )
      5 #xmap_fe4al13.phases[phase].space_group = 12

~/miniconda3/envs/kp/lib/python3.8/site-packages/orix/io/__init__.py in load(filename, **kwargs)
    121         reader = readers[0]
    122 
--> 123     return reader.file_reader(filename, **kwargs)
    124 
    125 

~/miniconda3/envs/kp/lib/python3.8/site-packages/orix/io/plugins/emsoft_h5ebsd.py in file_reader(filename, refined, **kwargs)
     67 
     68     # Some of the data needed to create a CrystalMap object
---> 69     phase_name, point_group, structure = _get_phase(phase_group)
     70     data_dict = {
     71         # Get map coordinates ("Y Position" data set is not correct in EMsoft as of

~/miniconda3/envs/kp/lib/python3.8/site-packages/orix/io/plugins/emsoft_h5ebsd.py in _get_phase(data_group)
    174     """
    175     name = re.search(r"([A-z0-9]+)", data_group["MaterialName"][:][0].decode()).group(1)
--> 176     point_group = re.search(
    177         r"\[([A-z0-9]+)\]", data_group["Point Group"][:][0].decode()
    178     ).group(1)

AttributeError: 'NoneType' object has no attribute 'group'
@hakonanes hakonanes added the bug Something isn't working label Feb 19, 2021
@hakonanes hakonanes added this to the v0.6.0 milestone Feb 19, 2021
@hakonanes hakonanes self-assigned this Feb 19, 2021
@pc494
Copy link
Member

pc494 commented Feb 19, 2021

That looks like it'll be some fun string regrexing...

Might be worth a minor refactor too given that we know what this edge case (re.search line returns None) is likely to be:

point_group = re.search(r"\[([A-z0-9]+)\]", data_group["Point Group"][:][0].decode())
if point_group is not None:
     point_group = point_group.group(1)
else:
    raise ValueError('some useful error message that shows the difficult string')

@hakonanes
Copy link
Member Author

Definitely, thanks for the tip, @pc494! Will do that.

hakonanes added a commit to hakonanes/orix that referenced this issue Apr 19, 2021
Signed-off-by: Håkon Wiik Ånes <[email protected]>
@hakonanes hakonanes mentioned this issue Apr 21, 2021
9 tasks
@hakonanes
Copy link
Member Author

EMsoft dot product file string: b'Cubic (Td) [-43m]'

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-474bb6bffba0> in <module>
      1 xmap_au = io.load(os.path.join(dir_em, "austenite", "res_austenite.h5"))
      2 xmap_fe = io.load(os.path.join(dir_em, "ferrite", "res_ferrite.h5"))
----> 3 xmap_chi = io.load(os.path.join(dir_em, "chi", "res_chi.h5"))

~/miniconda3/envs/kp-dev/lib/python3.8/site-packages/orix/io/__init__.py in load(filename, **kwargs)
    121         reader = readers[0]
    122 
--> 123     return reader.file_reader(filename, **kwargs)
    124 
    125 

~/miniconda3/envs/kp-dev/lib/python3.8/site-packages/orix/io/plugins/emsoft_h5ebsd.py in file_reader(filename, refined, **kwargs)
     67 
     68     # Some of the data needed to create a CrystalMap object
---> 69     phase_name, point_group, structure = _get_phase(phase_group)
     70     data_dict = {
     71         # Get map coordinates ("Y Position" data set is not correct in EMsoft as of

~/miniconda3/envs/kp-dev/lib/python3.8/site-packages/orix/io/plugins/emsoft_h5ebsd.py in _get_phase(data_group)
    173     """
    174     name = re.search(r"([A-z0-9]+)", data_group["MaterialName"][:][0].decode()).group(1)
--> 175     point_group = re.search(
    176         r"\[([A-z0-9/]+)\]", data_group["Point Group"][:][0].decode()
    177     ).group(1)

AttributeError: 'NoneType' object has no attribute 'group'

@hakonanes hakonanes reopened this Jun 1, 2021
@hakonanes hakonanes modified the milestones: v0.6.0, v0.6.1 Jun 1, 2021
@hakonanes hakonanes removed this from the v0.6.1 milestone Sep 7, 2021
@hakonanes hakonanes added this to the v0.8.0 milestone Dec 1, 2021
@hakonanes
Copy link
Member Author

This is the last issue I'd like to fix before I'm happy for the v0.8 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants