Skip to content

Commit

Permalink
Rephrase addition of new sampling function in changelog, remove non-u…
Browse files Browse the repository at this point in the history
…ser facing change

Signed-off-by: Håkon Wiik Ånes <[email protected]>
  • Loading branch information
hakonanes-xn committed Apr 10, 2024
1 parent 4a978df commit 5d00993
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 38 deletions.
8 changes: 3 additions & 5 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ Added
- The ``random()`` methods of ``Orientation`` and ``Misorientation`` now accept
``symmetry``. A ``random()`` method is also added to ``Vector3d`` and ``Miller``, the
latter accepting a ``phase``.
- Added ``orix.sampling.get_sample_zone_axis()`` for getting zone axes for some point
group.
- Added ``orix.sampling.get_sample_reduced_fundamental()`` for getting reduced
fundamental zone for some point group.
- Function ``orix.sampling.get_sample_reduced_fundamental()`` for sampling rotations
that rotate the Z-vector (0, 0, 1) onto the fundamental sector of the Laue group of a
given ``Symmetry``.

Changed
-------
Expand All @@ -43,7 +42,6 @@ Changed
- Allow passing a tuple of integers to ``reshape()`` methods of 3D objects.
- ``random()`` methods no longer accept a list as a valid shape: pass a tuple instead.
- Increase minimal version of Matplotlib to >= 3.5.
- Updated copyright year to 2024.

Deprecated
----------
Expand Down
71 changes: 38 additions & 33 deletions orix/sampling/sample_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

import numpy as np

from orix.quaternion import OrientationRegion, Rotation, Symmetry, symmetry
from orix.quaternion.symmetry import get_point_group
from orix.quaternion import OrientationRegion, Rotation, Symmetry
from orix.quaternion.symmetry import C1, get_point_group
from orix.sampling import sample_S2
from orix.sampling.SO3_sampling import _three_uniform_samples_method, uniform_SO3_sample
from orix.sampling._cubochoric_sampling import cubochoric_sampling
Expand All @@ -40,7 +40,7 @@ def get_sample_fundamental(
----------
resolution
The characteristic distance between a rotation and its neighbour
in degrees.
in degrees. Default is 2 degrees.
point_group
One of the 11 proper point groups. If not given, ``space_group``
must be.
Expand Down Expand Up @@ -104,13 +104,13 @@ def get_sample_local(
----------
resolution
The characteristic distance between a rotation and its neighbour
in degrees.
in degrees. Default is 2 degrees.
center
The rotation at which the grid is centered. The identity is used
if not given.
grid_width
The largest angle of rotation in degrees away from center that
is acceptable.
is acceptable. Default is 10 degrees.
method
``"cubochoric"`` (default), ``"haar_euler"`` or
``"quaternion"``. See :func:`~orix.sampling.uniform_SO3_sample`
Expand Down Expand Up @@ -169,37 +169,42 @@ def _remove_larger_than_angle(rot: Rotation, max_angle: Union[int, float]) -> Ro


def get_sample_reduced_fundamental(
resolution: float,
mesh: str = None,
point_group: Symmetry = None,
resolution: float = 2,
method: Optional[str] = None,
point_group: Optional[Symmetry] = None,
) -> Rotation:
"""Produces rotations to align various crystallographic directions with
the z-axis, with the constraint that the first Euler angle phi_1=0.
The crystallographic directions sample the fundamental zone, representing
the smallest region of symmetrically unique directions of the relevant
crystal system or point group.
r"""Return a grid of rotations that rotate the Z-vector (0, 0, 1)
into the fundamental sector of a point group's Laue group.
The rotations are constrained in that the first Euler angle is
:math:`\phi_1 = 0^{\circ}`.
Parameters
----------
resolution
An angle in degrees representing the maximum angular distance to a
first nearest neighbor grid point.
mesh
Type of meshing of the sphere that defines how the grid is created. See
orix.sampling.sample_S2 for all the options. A suitable default is
chosen depending on the crystal system.
The characteristic distance between a rotation and its neighbour
in degrees. Default is 2 degrees.
method
Name of method to mesh the unit sphere. See
:func:`orix.sampling.sample_S2` for options. If not given, a
suitable default is chosen given by the crystal system of the
given point group.
point_group
Symmetry operations that determines the unique directions. Defaults to
no symmetry, which means sampling all 3D unit vectors.
Point group with symmetry operations that define the
:attr:`~orix.quaternion.symmetry.Symmetry.fundamental_sector`
on the unit sphere. If not given, rotations that rotate the
Z-vector onto the whole sphere are returned.
Returns
-------
Rotation
(N, 3) array representing Euler angles for the different orientations
R
Rotations of shape ``(n, 3)``.
"""
if point_group is None:
point_group = symmetry.C1
point_group = C1

if mesh is None:
s2_auto_sampling_map = {
if method is None:
sampling_method = {
"triclinic": "icosahedral",
"monoclinic": "icosahedral",
"orthorhombic": "spherified_cube_edge",
Expand All @@ -208,14 +213,14 @@ def get_sample_reduced_fundamental(
"trigonal": "hexagonal",
"hexagonal": "hexagonal",
}
mesh = s2_auto_sampling_map[point_group.system]
method = sampling_method[point_group.system]

s2_sample = sample_S2(resolution, method=mesh)
fundamental = s2_sample[s2_sample <= point_group.fundamental_sector]
v = sample_S2(resolution, method=method)
v_fs = v[v <= point_group.fundamental_sector]

phi = fundamental.polar
phi2 = (np.pi / 2 - fundamental.azimuth) % (2 * np.pi)
phi = v_fs.polar
phi2 = (np.pi / 2 - v_fs.azimuth) % (2 * np.pi)
phi1 = np.zeros(phi2.shape[0])
euler_angles = np.vstack([phi1, phi, phi2]).T
euler = np.vstack([phi1, phi, phi2]).T

return Rotation.from_euler(euler_angles, degrees=False)
return Rotation.from_euler(euler, degrees=False)

0 comments on commit 5d00993

Please sign in to comment.