pyxem / orix

Analysing crystal orientations and symmetry in Python
https://orix.readthedocs.io
GNU General Public License v3.0
79 stars 45 forks source link

Allow reading of EDAX TSL .ang files with ten columns #416

Closed hakonanes closed 1 year ago

hakonanes commented 1 year ago

Description of the change

EDAX TSL .ang files with ten data columns should be read correctly with this patch.

Fixes #413, where it was identified that two openly available .ang files, shown in https://github.com/pyxem/orix/issues/411#issuecomment-1336408578, were read incorrectly. With this patch, there is a correct correspondence between phase ID and phase list, and the scan unit is "um". Big thanks to @argerlt who pointed me to these datasets.

I've made another small change to IO scan units. Previously, ASTAR/orix/unknown .ang files returned maps with "nm" as scan unit. Now, all but ASTAR .ang files return maps with "um" as scan unit. As far as I know there is no scan unit information .ang files. Hence, we have to guess, and I think the new guess is better.

I'd like to release this as part of a 0.10.3 patch soon (see #415).

Progress of the PR

Minimal example of the bug fix or new feature

Previously

>>> from orix import io

>>> xmap = io.load("IN100_Raw/ANG_Series/Slice_001.ang")
/home/hakon/kode/orix/orix/io/plugins/ang.py:268: UserWarning: Number of columns, 10, in the file is not equal to the expected number of columns, 14, for the 
assumed vendor 'tsl'. Will therefore assume the following columns: euler1, euler2, euler3, x, y, unknown1, unknown2, phase_id, unknown3, unknown4, etc.
  warnings.warn(
>>> xmap
Phase    Orientations    Name  Space group  Point group  Proper point group     Color
    0  37989 (100.0%)  Nickel         None          432                 432  tab:blue
Properties: unknown1, unknown2, unknown3, unknown4
Scan unit: nm

>>> xmap2 = io.load("Field of view 1_EBSD data_Raw.ang")
/home/hakon/kode/orix/orix/io/plugins/ang.py:268: UserWarning: Number of columns, 10, in the file is not equal to the expected number of columns, 14, for the 
assumed vendor 'tsl'. Will therefore assume the following columns: euler1, euler2, euler3, x, y, unknown1, unknown2, phase_id, unknown3, unknown4, etc.
  warnings.warn(
>>> xmap2
Phase      Orientations       Name  Space group  Point group  Proper point group       Color
    0         29 (0.0%)  Austenite         None          432                 432  tab:orange
    1      14900 (0.7%)    Ferrite         None          432                 432    tab:blue
    2   2202639 (99.3%)       None         None         None                None   tab:green
Properties: unknown1, unknown2, unknown3, unknown4
Scan unit: nm

Now

>>> from orix import io

>>> xmap = io.load("IN100_Raw/ANG_Series/Slice_001.ang")
>>> xmap
Phase    Orientations         Name  Space group  Point group  Proper point group     Color
   -1    7912 (20.8%)  not_indexed         None         None                None         w
    0   30077 (79.2%)       Nickel         None          432                 432  tab:blue
Properties: iq, ci, unknown1, fit
Scan unit: um

>>> xmap2 = io.load("Field of view 1_EBSD data_Raw.ang")
>>> xmap2
Phase      Orientations         Name  Space group  Point group  Proper point group       Color
   -1         29 (0.0%)  not_indexed         None         None                None           w
    1      14900 (0.7%)    Austenite         None          432                 432  tab:orange
    2   2202639 (99.3%)      Ferrite         None          432                 432    tab:blue
Properties: iq, ci, unknown1, fit
Scan unit: um

For reviewers

hakonanes commented 1 year ago

The two failing tests on Windows Py 3.9/10 are fixed on develop in #410:

I've also bumped the minimum version of diffpy.structure to 3.0.2 in setup.py. This ensures that Phase.from_cif() works on Windows with Python 3.10. I've added a changelog entry for this change.

I think this fix should be included in a potential patch release.

hakonanes commented 1 year ago

The failing tests are test_symmetry_plot() in which the number of Matplotlib collections are checked in the axis returned from Symmetry.plot() (via the figure). The expected number does not match the actual in these tests.

I can reproduce these errors locally after updating to Matplotlib 3.6.3. When running the code in the tests outside of tests, I get the expected number of collections, though. So I do not know what causes the extra collections when running with pytest.

The errors happen when running on both one or more cores (via pytest-xdist).

I think easing the test criteria is the way to go. Will try to find a fix for this in this PR.

hakonanes commented 1 year ago

Thank you, @pc494!