-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #306 from harripj/add_Symmetry_scatter
Add Symmetry plot method
- Loading branch information
Showing
7 changed files
with
233 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"nbsphinx": "hidden" | ||
}, | ||
"source": [ | ||
"This notebook is part of the orix documentation https://orix.rtfd.io. Links to the documentation won’t work from the notebook." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Visualizing point groups\n", | ||
"\n", | ||
"Point group symmetry operations are shown here under the stereographic projection.\n", | ||
"\n", | ||
"Vectors located on the upper (`z >= 0`) hemisphere are displayed as points (`o`), whereas vectors on the lower hemisphere are reprojected onto the upper hemisphere and shown as crosses (`+`) by default. For more information about plot formatting and visualization, see [Vector3d.scatter()](reference.rst#orix.vector.Vector3d.scatter).\n", | ||
"\n", | ||
"More explanation of these figures is provided at http://xrayweb.chem.ou.edu/notes/symmetry.html#point." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"For example, the `O (432)` point group:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"tags": [ | ||
"nbsphinx-thumbnail" | ||
] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"%matplotlib inline\n", | ||
"\n", | ||
"from orix.quaternion import symmetry\n", | ||
"\n", | ||
"symmetry.O.plot()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"The stereographic projection of all point groups is shown below:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from matplotlib import pyplot as plt\n", | ||
"import numpy as np\n", | ||
"\n", | ||
"from orix import plot\n", | ||
"from orix.quaternion import Rotation\n", | ||
"from orix.vector import Vector3d\n", | ||
"\n", | ||
"schoenflies = ['C1', 'Ci', 'C2x', 'C2y', 'C2z', 'Csx', 'Csy', 'Csz', 'C2h', 'D2', 'C2v', 'D2h', 'C4', 'S4', 'C4h', 'D4', 'C4v', 'D2d', 'D4h', 'C3', 'S6', 'D3x', 'D3y', 'D3', 'C3v', 'D3d', 'C6', 'C3h', 'C6h', 'D6', 'C6v', 'D3h', 'D6h', 'T', 'Th', 'O', 'Td', 'Oh']\n", | ||
"\n", | ||
"assert len(symmetry._groups) == len(schoenflies)\n", | ||
"\n", | ||
"schoenflies = [s for s in schoenflies if not (s.endswith('x') or s.endswith('y'))]\n", | ||
"\n", | ||
"assert len(schoenflies) == 32\n", | ||
"\n", | ||
"orientation = Rotation.from_axes_angles((-1, 8, 1), np.deg2rad(65))\n", | ||
"\n", | ||
"fig, ax = plt.subplots(nrows=8, ncols=4, figsize=(10, 20), subplot_kw=dict(projection='stereographic'))\n", | ||
"ax = ax.ravel()\n", | ||
"\n", | ||
"for i, s in enumerate(schoenflies):\n", | ||
" sym = getattr(symmetry, s)\n", | ||
"\n", | ||
" ori_sym = sym.outer(orientation)\n", | ||
" v = (ori_sym * Vector3d.zvector())\n", | ||
" \n", | ||
" # reflection in the projection plane (x-y) is performed internally in\n", | ||
" # Symmetry.plot() or when using the `reproject=True` argument for\n", | ||
" # Vector3d.scatter()\n", | ||
" v_reproject = Vector3d(v.data.copy())\n", | ||
" v_reproject.z *= -1\n", | ||
" \n", | ||
" # the Symmetry marker formatting for vectors on the upper and lower hemisphere\n", | ||
" # can be set using `kwargs` and `reproject_scatter_kwargs`, respectively, for\n", | ||
" # 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", | ||
" # vectors on the lower hemisphere are reprojected onto the upper hemisphere and\n", | ||
" # shown as crosses\n", | ||
" ax[i].scatter(v_reproject, marker='+', ec='C0', s=150)\n", | ||
"\n", | ||
" ax[i].set_title(f'${s}$ $({sym.name})$')\n", | ||
" ax[i].set_labels('a', 'b', None)\n", | ||
"\n", | ||
"fig.tight_layout()" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters