Skip to content

Commit

Permalink
Merge f4e4003 into d7c1b9a
Browse files Browse the repository at this point in the history
  • Loading branch information
hakonanes committed Apr 7, 2024
2 parents d7c1b9a + f4e4003 commit 4cfe545
Show file tree
Hide file tree
Showing 20 changed files with 130 additions and 66 deletions.
12 changes: 5 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ on:
workflow_dispatch:
workflow: '*'

env:
MPLBACKEND: agg

jobs:
code:
name: code style
Expand Down Expand Up @@ -59,15 +56,16 @@ jobs:
name: ${{ matrix.os }}-py${{ matrix.python-version }}${{ matrix.LABEL }}
runs-on: ${{ matrix.os }}
timeout-minutes: 15
env:
MPLBACKEND: agg
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.10", "3.11"]
python-version: ['3.10', '3.11']
include:
- os: ubuntu-latest
python-version: 3.7
OLDEST_SUPPORTED_VERSION: true
DEPENDENCIES: diffpy.structure==3 matplotlib==3.5
LABEL: -oldest
steps:
Expand All @@ -84,7 +82,7 @@ jobs:
pip install -U -e .'[doc, tests]'
- name: Install oldest supported version
if: ${{ matrix.OLDEST_SUPPORTED_VERSION }}
if: ${{ contains(matrix.LABEL, 'oldest') }}
run: |
pip install ${{ matrix.DEPENDENCIES }}
Expand All @@ -102,7 +100,7 @@ jobs:
- name: Run tests
run: |
pytest -n 2 --cov=orix --pyargs orix
pytest --pyargs orix --reruns 2 -n 2 --cov=orix
- name: Generate line coverage
if: ${{ matrix.os == 'ubuntu-latest' }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ doc/build/
doc/examples/
doc/reference/generated/
doc/source/_autosummary/
doc/sg_execution_times.rst

# PyBuilder
target/
Expand Down
12 changes: 6 additions & 6 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +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
- 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.

Changed
Expand All @@ -50,14 +51,13 @@ Deprecated
and will be removed in v0.13. Use the existing ``from_axes_angles()`` and the new
``from_rodrigues()`` and ``from_homochoric()`` instead.

Removed
-------

Fixed
-----
- Transparency of polar stereographic grid lines can now be controlled by Matplotlib's
``grid.alpha``, just like the azimuth grid lines.
- Previously ``Phase`` was failing to adjust atom position to accomodate for the change of basis. This is now fixed.
- Previously, ``Phase`` did not adjust atom positions when forcing
``Phase.structure.lattice.base`` to use the crystal axes alignment ``e1 || a``,
``e3 || c*``. This is now fixed.

2023-03-14 - version 0.11.1
===========================
Expand Down
5 changes: 1 addition & 4 deletions doc/dev/building_writing_documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ New documents should fit into one of these categories.
We use :doc:`Sphinx <sphinx:index>` for documenting functionality.
Install necessary dependencies to build the documentation::

pip install --editable .[doc]
pip install --editable ".[doc]"

.. note::

Expand All @@ -19,9 +19,6 @@ Install necessary dependencies to build the documentation::
See the section on the :ref:`data module <adding-data-to-data-module>` for more
details.

If you get an error message running the above in a ``zsh`` shell, try wrapping the last
part in a string, like ``'.[doc]'``.

Then, build the documentation from the ``doc`` directory::

cd doc
Expand Down
7 changes: 2 additions & 5 deletions doc/dev/running_writing_tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ The tests reside in a ``tests`` module.
Tests are short methods that call functions in ``orix`` and compare resulting output
values with known answers. Install necessary dependencies to run the tests::

pip install --editable .[tests]

If you get an error message running the above in a ``zsh`` shell, try wrapping the last
part in a string, like ``'.[tests]'``.
pip install --editable ".[tests]"

Some useful :doc:`fixtures <pytest:explanation/fixtures>` are available in the
``conftest.py`` file.
Expand Down Expand Up @@ -39,7 +36,7 @@ Docstring examples are tested :doc:`with pytest <pytest:how-to/doctest>` as well
already available in the namespace as ``np`` and ``plt``, respectively.
The docstring tests can be run from the top directory::

pytest --doctest-modules --ignore-glob=orix/tests orix/*.py
pytest orix --doctest-modules --ignore-glob=orix/tests

Tips for writing tests of Numba decorated functions:

Expand Down
2 changes: 1 addition & 1 deletion doc/dev/setting_up_development_installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ with the `Miniconda distribution <https://docs.conda.io/en/latest/miniconda.html
Then, install the required dependencies while making the development version available
globally (in the ``conda`` environment)::

pip install --editable .[dev]
pip install --editable ".[dev]"

This installs all necessary development dependencies, including those for running tests
and building documentation.
6 changes: 3 additions & 3 deletions doc/tutorials/crystal_reference_frame.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
"source": [
"## Alignment of symmetry operations\n",
"\n",
"To see where the crystallographic axes about which the point group symmetry operations rotate, we can add symmetry operations to the figure, like is done in the [Visualizing point groups](point_groups.ipynb) tutorial for all point groups supported in orix"
"To see which crystallographic axes the point group symmetry operations rotate about, we can add symmetry operations to the figure, like is done in the [Visualizing point groups](point_groups.ipynb) tutorial for all point groups supported in orix"
]
},
{
Expand All @@ -238,7 +238,7 @@
"outputs": [],
"source": [
"R = Rotation.from_axes_angles([0, 1, 0], -65, degrees=True)\n",
"phase.point_group.plot(figure=fig, orientation=R, fc=\"none\", ec=\"C0\", s=150)\n",
"phase.point_group.plot(figure=fig, orientation=R)\n",
"fig"
]
},
Expand Down Expand Up @@ -299,7 +299,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions doc/tutorials/point_groups.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@
" # respectively, for Symmetry.plot()\n",
"\n",
" # vectors on the upper hemisphere are shown as open circles\n",
" ax[i].scatter(v, marker=\"o\", fc=\"None\", ec=\"k\", s=150)\n",
" ax[i].scatter(v, marker=\"o\", c=\"None\", ec=\"C0\", s=150)\n",
" # vectors on the lower hemisphere are reprojected onto the upper\n",
" # hemisphere and shown as crosses\n",
" ax[i].scatter(v_reproject, marker=\"+\", ec=\"C0\", s=150)\n",
" ax[i].scatter(v_reproject, marker=\"+\", c=\"C0\", s=150)\n",
"\n",
" ax[i].set_title(f\"${S}$ $({Si.name})$\")\n",
" ax[i].set_labels(\"$e_1$\", \"$e_2$\", None)"
Expand All @@ -156,7 +156,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.11.8"
}
},
"nbformat": 4,
Expand Down
8 changes: 8 additions & 0 deletions doc/user/applications.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ If you think your work should be listed here, please raise an issue `on GitHub
<https://github.com/pyxem/orix>`__ or `contact the developers
<pyxem.team@gmail.com>`__.

2024
====
- I. MacLaren, E. Frutos-Myro, S. Zeltmann, C. Ophus, "A method for crystallographic
mapping of an alpha-beta titanium alloy with nanometre resolution using scanning
precession electron diffraction and open-source software libraries," *Journal of
Microscopy*, 1-9 (2024).
https://doi/10.1111/jmi.13275.

2022
====

Expand Down
8 changes: 5 additions & 3 deletions doc/user/related_projects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ find useful:
orix depends on numpy-quaternion for quaternion multiplication.
- `texture <https://github.com/usnistgov/texture>`_: Python scripts for analysis of
crystallographic texture.
- pymicro: Python package to work with material microstructures and 3D data sets.
- Dream3D: C++ library to reconstruct, instatiate, quantify, mesh, handle and visualize
multidimensional (3D), multimodal data (mainly EBSD orientation data).
- `pymicro <https://pymicro.readthedocs.io>`_`: Python package to work with material
microstructures and 3D data sets.
- `DREAM.3D <https://dream3d.io/>`_`: C++ library to reconstruct, instatiate, quantify,
mesh, handle and visualize multidimensional (3D), multimodal data (mainly EBSD
orientation data).
14 changes: 14 additions & 0 deletions examples/crystal_maps/create_empty_map.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
========================
Create empty crystal map
========================
This example shows how to create an empty crystal map, which can be useful for testing.
"""

from orix.crystal_map import CrystalMap

xmap = CrystalMap.empty((5, 10))
xmap

xmap.plot("x")
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
# Plot the two directions in the (unrotated) first crystal's reference
# frame as open circles
fig = t_cubic.scatter(
c="none",
ec=["r", "b"],
fc="none",
grid=True,
axes_labels=["e1", "e2"],
return_figure=True,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# %%
r"""
====================================
Orientation from aligning directions
Expand Down Expand Up @@ -39,8 +40,8 @@

# Plot the reference orientation sample directions as empty circles
fig = v.scatter(
c="none",
ec=["r", "b"],
fc="none",
grid=True,
axes_labels=["X", "Y"],
return_figure=True,
Expand Down
58 changes: 58 additions & 0 deletions examples/rotations/rotations_mapping_fundamental_sector.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""
================================================
Rotations mapping the fundamental sector on *S2*
================================================
This example shows how to sample rotations :math:`\mathbf{R}` that when
rotating the vector :math:`\mathbf{v_z} = (0, 0, 1)`, the resulting
vectors cover the fundamental sector of a given Laue class.
We show this by comparing the vectors we get by:
1. sampling rotations for *4/mmm* and then rotating :math:`\mathbf{v_z}`
2. sampling all of *S2* but only keeping those within the corresponding
fundamental sector.
Apart from the first rotation, all rotations have a Euler angle
:math:`\phi = 0^{\circ}`.
These "reduced" rotations are useful in template matching of spot
patterns from the transmission electron microscope.
"""

import matplotlib.pyplot as plt
import numpy as np

from orix import plot, sampling
from orix.quaternion import symmetry
from orix.vector import Vector3d


# Sample rotations with an average misorientation
res = 2
pg = symmetry.D4h # 4/mmm

R = sampling.get_sample_reduced_fundamental(res, point_group=pg)
print(np.allclose(R.to_euler()[1:, 0], 0))

########################################################################
# Get vectors within the fundamental sector following the two routes
v1 = R * Vector3d.zvector()

v2 = sampling.sample_S2(res)
v2 = v2[v2 <= pg.fundamental_sector]

# Only equivalent for the same S2 sampling method
print(np.allclose(v1.data, v2.data))
print(v1)
print(v2)

########################################################################
# Plot the vectors in the fundamental sector of 4/mmm
fig, (ax0, ax1) = plt.subplots(
ncols=2, subplot_kw={"projection": "ipf", "symmetry": pg}, layout="tight"
)
ax0.scatter(v1, s=5)
ax1.scatter(v2, c="C1", s=5)
ax0.set_title("Rotated Z vectors", loc="left")
ax1.set_title("Directly sampled", loc="left")
_ = fig.suptitle("Vectors in the fundamental sector of 4/mmm", y=0.8)
18 changes: 7 additions & 11 deletions examples/stereographic_projection/zoom_inset_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"""

import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import InsetPosition

from orix import plot, projections, sampling
from orix.vector import Vector3d
Expand Down Expand Up @@ -38,22 +37,19 @@
# The zoomed inset rectangle origin (x, y), width and height
rect = [0.15, 0.2, 0.43, 0.43]

# Add a new stereographic projection axis with a grid resolution of 2
# degrees to the figure and plot the vectors here as well
ax_inset = fig.add_axes(rect, projection="stereographic")
ax_inset.stereographic_grid(True, 2, 2)
ax_inset.scatter(v2)
ax_inset.scatter(v_ref, c="r")

# Restrict the inset region to the extent vectors
# Add a new stereographic projection axis and zoom in
ax_inset = ax.inset_axes(rect, projection="stereographic")
ax_inset.set(
xlim=(x_inset.min(), x_inset.max()),
ylim=(y_inset.min(), y_inset.max()),
)

# Add a grid of 2 degrees resolution and re-plot the vectors
ax_inset.stereographic_grid(True, 2, 2)
ax_inset.scatter(v2)
ax_inset.scatter(v_ref, c="r")

# Add lines indicating the inset zoom
ip = InsetPosition(ax, rect)
ax_inset.set_axes_locator(ip)
ax.indicate_inset_zoom(ax_inset, edgecolor="k")

# Add border to the inset region
Expand Down
1 change: 1 addition & 0 deletions orix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"Niels Cautaerts",
"Austin Gerlt",
"Anders Christian Mathisen",
"Carter Francis",
"Simon Høgås",
"Alexander Clausen",
"Viljar Johan Femoen",
Expand Down
11 changes: 0 additions & 11 deletions orix/crystal_map/crystal_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,17 +775,6 @@ def empty(
-------
xmap
Crystal map.
Examples
--------
>>> from orix.crystal_map import CrystalMap
>>> xmap = CrystalMap.empty((5, 10))
>>> xmap
Phase Orientations Name Space group Point group Proper point group Color
0 50 (100.0%) None None None None tab:blue
Properties:
Scan unit: px
>>> xmap.plot("x") # Increasing towards the right
"""
d, n = create_coordinate_arrays(shape, step_sizes)
d["rotations"] = Rotation.identity((n,))
Expand Down

0 comments on commit 4cfe545

Please sign in to comment.