Skip to content

Commit

Permalink
Remove master pattern metadata, add projection, hemisphere and phase …
Browse files Browse the repository at this point in the history
…attributes (#246)

* Set up necessary (empty) tests, add desired changes to changelog

Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>

* Remove simulation metadata node, add master pattern properties, update docs/tests

Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>

* Specify .hspy extension when saving master pattern in test

Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
  • Loading branch information
hakonanes committed Nov 13, 2020
1 parent 6617120 commit 8dc22a1
Show file tree
Hide file tree
Showing 15 changed files with 161 additions and 747 deletions.
9 changes: 9 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ Added

Changed
-------
- The EBSDMasterPattern gets unsettable phase, hemisphere and projection
properties. (`#246 <https://github.com/pyxem/kikuchipy/pull/246>`_)
- EMsoft EBSD master pattern plugin can read a single energy pattern. Parameter
`energy_range` changed to `energy`.
(`240 <https://github.com/pyxem/kikuchipy/pull/240>`_)
Expand All @@ -70,6 +72,13 @@ Changed
- Remove language_version in pre-commit config file.
(`#195 <https://github.com/pyxem/kikuchipy/pull/195>`_)

Removed
-------
- The EBSDMasterPattern and EBSD metadata node Sample.Phases, to be replaced
by class attributes. The set_phase_parameters() method is removed from both
classes, and the set_simulation_parameters() is removed from the former class.
(`#246 <https://github.com/pyxem/kikuchipy/pull/246>`_)

Fixed
-----
- NumPy array creation when calculating window pixel's distance to the origin is
Expand Down
26 changes: 6 additions & 20 deletions doc/load_save_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,7 @@
"[set_experimental_parameters()](reference.rst#kikuchipy.signals.EBSD.set_experimental_parameters),\n",
"[set_phase_parameters()](reference.rst#kikuchipy.signals.EBSD.set_phase_parameters),\n",
"[set_scan_calibration()](reference.rst#kikuchipy.signals.EBSD.set_scan_calibration) and\n",
"[set_detector_calibration()](reference.rst#kikuchipy.signals.EBSD.set_detector_calibration),\n",
"or the [EBSDMasterPattern](reference.rst#kikuchipy.signals.EBSDMasterPattern)\n",
"class methods [set_simulation_parameters()](reference.rst#kikuchipy.signals.EBSDMasterPattern.set_simulation_parameters) or\n",
"[set_phase_parameters()](reference.rst#kikuchipy.signals.EBSDMasterPattern.set_phase_parameters).\n",
"[set_detector_calibration()](reference.rst#kikuchipy.signals.EBSD.set_detector_calibration).\n",
"For example, to set or change the accelerating voltage, horizontal pattern\n",
"centre coordinate and static background pattern (stored as a `numpy.ndarray`):"
]
Expand Down Expand Up @@ -768,14 +765,9 @@
"s_mp = kp.load(filename=datadir + emsoft_master_pattern)\n",
"\n",
"print(s_mp)\n",
"print(\n",
" s_mp.metadata.get_item(\n",
" \"Simulation.EBSD_master_pattern.Master_pattern.projection\"\n",
" ),\n",
" s_mp.metadata.get_item(\n",
" \"Simulation.EBSD_master_pattern.Master_pattern.hemisphere\"\n",
" )\n",
")"
"print(s_mp.projection)\n",
"print(s_mp.hemisphere)\n",
"print(s_mp.phase)"
]
},
{
Expand Down Expand Up @@ -808,14 +800,8 @@
")\n",
"\n",
"print(s_mp)\n",
"print(\n",
" s_mp.metadata.get_item(\n",
" \"Simulation.EBSD_master_pattern.Master_pattern.projection\"\n",
" ),\n",
" s_mp.metadata.get_item(\n",
" \"Simulation.EBSD_master_pattern.Master_pattern.hemisphere\"\n",
" )\n",
")"
"print(s_mp.projection)\n",
"print(s_mp.hemisphere)"
]
},
{
Expand Down
95 changes: 30 additions & 65 deletions doc/metadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@
Metadata structure
==================

The :class:`~kikuchipy.signals.EBSD` and
:class:`~kikuchipy.signals.EBSDMasterPattern` classes store metadata in the
The :class:`~kikuchipy.signals.EBSD` class stores metadata in the
``metadata`` attribute provided by HyperSpy. While kikuchipy's EBSD
(:func:`~kikuchipy.signals.util.ebsd_metadata`) and EBSDMasterPattern
(:func:`~kikuchipy.signals.util.ebsd_master_pattern_metadata`) metadata
structures are based on `HyperSpy's metadata structure
(:func:`~kikuchipy.signals.util.ebsd_metadata`) metadata structure is based on
`HyperSpy's metadata structure
<http://hyperspy.org/hyperspy-doc/current/user_guide/metadata_structure.html>`_,
they each include a node ``Acquisition_instrument.Sample.Phases`` to store
phase information, and ``Acquisition_instrument.SEM.Detector.EBSD`` or
``Simulation.EBSD_master_pattern``, respectively. The information in these nodes
are written, along with the patterns, to file when saving an EBSD object in the
`kikuchipy h5ebsd format <load_save_data.ipynb#h5ebsd>`_
or an EBSDMasterPattern object in `the HyperSpy HDF5 format
<http://hyperspy.org/hyperspy-doc/current/user_guide/io.html#hspy-hyperspy-s-hdf5-specification>`_.
it includes the nodes ``Acquisition_instrument.Sample.Phases`` to store
phase information and ``Acquisition_instrument.SEM.Detector.EBSD`` for
acquisition information. The information in these nodes are written, along with
the patterns, to file when saving an EBSD signal in the
`kikuchipy h5ebsd format <load_save_data.ipynb#h5ebsd>`_.

::

Expand Down Expand Up @@ -44,49 +40,28 @@ or an EBSDMasterPattern object in `the HyperSpy HDF5 format
│ ├── magnification
│ ├── microscope
│ └── working_distance [mm]
├── Sample
│ └── Phases
│ └── 1
│ ├── atom_coordinates
│ │ └── 1
│ │ ├── atom
│ │ ├── coordinates (x0, y0, z0)
│ │ ├── debye_waller_factor [nm^2]
│ │ └── site_occupation
│ ├── formula
│ ├── info
│ ├── lattice_constants (a, b, c and alfa, beta, gamma) [nm and º]
│ ├── laue_group
│ ├── material_name
│ ├── point_group
│ ├── setting
│ ├── source
│ ├── space_group
│ └── symmetry
└── Simulation
└── EBSD_master_pattern
├── BSE_simulation
│ ├── depth_step [nm]
│ ├── energy_step [keV]
│ ├── incident_beam_energy [keV]
│ ├── max_depth [nm]
│ ├── min_beam_energy [keV]
│ ├── mode
│ ├── number_of_electrons
│ ├── pixels_along_x
│ └── sample_tilt [º]
└── Master_pattern
├── Bethe_parameters
│ ├── complete_cutoff
│ ├── strong_beam_cutoff
│ └── weak_beam_cutoff
├── projection
├── hemisphere
└── smallest_interplanar_spacing [nm]
└── Sample
└── Phases
└── 1
├── atom_coordinates
│ └── 1
│ ├── atom
│ ├── coordinates (x0, y0, z0)
│ ├── debye_waller_factor [nm^2]
│ └── site_occupation
├── formula
├── info
├── lattice_constants (a, b, c and alfa, beta, gamma) [nm and º]
├── laue_group
├── material_name
├── point_group
├── setting
├── source
├── space_group
└── symmetry

The utility function :func:`~kikuchipy.signals.util.metadata_nodes` returns the
node strings for the ``SEM``, ``EBSD`` and ``EBSD_master_pattern`` nodes for
convenience.
node strings for the ``SEM`` and ``EBSD`` nodes for convenience.

.. note::

Expand All @@ -101,20 +76,10 @@ This node contains information relevant for EBSD data. All parameters can be
set with the method :meth:`~kikuchipy.signals.EBSD.set_experimental_parameters`.
An explanation of each parameter is given in the method's docstring.

EBSD master pattern
===================

This node contains information relevant for simulated EBSD master patterns. All
parameters can be set with the method
:meth:`~kikuchipy.signals.EBSDMasterPattern.set_simulation_parameters`. An
explanation of each parameter is given in the method's docstring.

Phases
======

This node contains information relevant for EBSD scans or simulated patterns'
phases. All parameters can be set with the :class:`~kikuchipy.signals.EBSD`
method :meth:`~kikuchipy.signals.EBSD.set_phase_parameters` or the
:class:`~kikuchipy.signals.EBSDMasterPattern` method
:meth:`~kikuchipy.signals.EBSDMasterPattern.set_phase_parameters`.
An explanation of each parameter is given in the methods' docstring.
method :meth:`~kikuchipy.signals.EBSD.set_phase_parameters`. An explanation of
each parameter is given in the methods' docstring.
4 changes: 0 additions & 4 deletions doc/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -503,12 +503,9 @@ All methods listed here are also available to
.. autosummary::
normalize_intensity
rescale_intensity
set_simulation_parameters
set_phase_parameters

.. autoclass:: kikuchipy.signals.EBSDMasterPattern
:members:
:undoc-members:
:inherited-members: Signal2D
:show-inheritance:

Expand Down Expand Up @@ -539,7 +536,6 @@ util
.. currentmodule:: kikuchipy.signals.util

.. autosummary::
ebsd_master_pattern_metadata
ebsd_metadata
metadata_nodes

Expand Down
14 changes: 2 additions & 12 deletions kikuchipy/data/tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,8 @@ def test_load_nickel_ebsd_master_pattern_small_kwargs(
assert isinstance(mp, EBSDMasterPattern)
assert mp.data.shape == desired_shape
assert np.issubdtype(mp.data.dtype, np.uint8)
assert (
mp.metadata.get_item(
"Simulation.EBSD_master_pattern.Master_pattern.projection"
)
== projection
)
assert (
mp.metadata.get_item(
"Simulation.EBSD_master_pattern.Master_pattern.hemisphere"
)
== hemisphere
)
assert mp.projection == projection
assert mp.hemisphere == hemisphere

mp_lazy = data.nickel_ebsd_master_pattern_small(lazy=True)

Expand Down
10 changes: 0 additions & 10 deletions kikuchipy/io/plugins/emsoft_ebsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
from orix.quaternion import Rotation

from kikuchipy.io.plugins.h5ebsd import hdf5group2dict
from kikuchipy.io.plugins.emsoft_ebsd_master_pattern import (
_crystal_data_2_metadata,
)
from kikuchipy.signals.util._metadata import (
ebsd_metadata,
metadata_nodes,
Expand Down Expand Up @@ -104,13 +101,6 @@ def file_reader(
"title": f.filename.split("/")[-1].split(".")[0],
"original_filename": f.filename.split("/")[-1],
},
"Sample": {
"Phases": {
"1": _crystal_data_2_metadata(
hdf5group2dict(f["CrystalData"])
)
}
},
}
)
scan = {"metadata": md, "original_metadata": omd}
Expand Down
Loading

0 comments on commit 8dc22a1

Please sign in to comment.