Skip to content

Commit

Permalink
Limit nb to 80 char. to display OK with PyData Sphinx Theme width
Browse files Browse the repository at this point in the history
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
  • Loading branch information
hakonanes committed Oct 26, 2022
1 parent b6c0032 commit a319d76
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ repos:
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black-jupyter
- id: black
13 changes: 10 additions & 3 deletions doc/tutorials/esteem2022_diffraction_workshop.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@
"from pyebsdindex import ebsd_index, pcopt\n",
"\n",
"\n",
"plt.rcParams.update({\"figure.facecolor\": \"w\", \"font.size\": 15, \"figure.dpi\": 75})"
"plt.rcParams.update(\n",
" {\"figure.facecolor\": \"w\", \"font.size\": 15, \"figure.dpi\": 75}\n",
")"
]
},
{
Expand Down Expand Up @@ -2484,7 +2486,9 @@
}
],
"source": [
"xmap_di = s.dictionary_indexing(s_dict, signal_mask=signal_mask, n_per_iteration=2000)"
"xmap_di = s.dictionary_indexing(\n",
" s_dict, signal_mask=signal_mask, n_per_iteration=2000\n",
")"
]
},
{
Expand Down Expand Up @@ -2570,7 +2574,10 @@
],
"source": [
"fig = xmap_di.plot(\n",
" xmap_di.scores[:, 0], colorbar=True, colorbar_label=\"NCC\", return_figure=True\n",
" xmap_di.scores[:, 0],\n",
" colorbar=True,\n",
" colorbar_label=\"NCC\",\n",
" return_figure=True,\n",
")\n",
"# fig.savefig(os.path.join(dir_data, \"maps_di_ncc.png\"))"
]
Expand Down
10 changes: 8 additions & 2 deletions doc/tutorials/geometrical_ebsd_simulations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@
"phase = Phase(\n",
" space_group=225,\n",
" structure=Structure(\n",
" atoms=[Atom(\"Ni\", [0, 0, 0])], lattice=Lattice(3.52, 3.52, 3.52, 90, 90, 90)\n",
" atoms=[Atom(\"Ni\", [0, 0, 0])],\n",
" lattice=Lattice(3.52, 3.52, 3.52, 90, 90, 90),\n",
" ),\n",
")\n",
"\n",
Expand Down Expand Up @@ -209,7 +210,12 @@
"hkl_colors = np.zeros((ref.size, 3))\n",
"for idx, color in zip(\n",
" hkl_sets.values(),\n",
" [[1, 0, 0], [0, 1, 0], [0, 0, 1], [0.75, 0, 0.75]], # Red, green, blue, magenta\n",
" [\n",
" [1, 0, 0],\n",
" [0, 1, 0],\n",
" [0, 0, 1],\n",
" [0.75, 0, 0.75],\n",
" ], # Red, green, blue, magenta\n",
"):\n",
" hkl_colors[idx] = color"
]
Expand Down
19 changes: 15 additions & 4 deletions doc/tutorials/hough_indexing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from orix import plot\n",
"from orix.crystal_map import create_coordinate_arrays, CrystalMap, Phase, PhaseList\n",
"from orix.crystal_map import (\n",
" create_coordinate_arrays,\n",
" CrystalMap,\n",
" Phase,\n",
" PhaseList,\n",
")\n",
"from orix.quaternion import Rotation\n",
"from orix.vector import Vector3d\n",
"from pyebsdindex import ebsd_index, pcopt\n",
Expand Down Expand Up @@ -376,7 +381,9 @@
"metadata": {},
"outputs": [],
"source": [
"detector = kp.detectors.EBSDDetector(shape=sig_shape, pc=pcs.mean(0), sample_tilt=70)\n",
"detector = kp.detectors.EBSDDetector(\n",
" shape=sig_shape, pc=pcs.mean(0), sample_tilt=70\n",
")\n",
"detector"
]
},
Expand Down Expand Up @@ -409,7 +416,9 @@
},
"outputs": [],
"source": [
"data, *_ = indexer.index_pats(s.data.reshape(-1, *sig_shape), PC=detector.pc, verbose=2)"
"data, *_ = indexer.index_pats(\n",
" s.data.reshape(-1, *sig_shape), PC=detector.pc, verbose=2\n",
")"
]
},
{
Expand Down Expand Up @@ -508,7 +517,9 @@
"metadata": {},
"outputs": [],
"source": [
"ckey = plot.IPFColorKeyTSL(xmap.phases[0].point_group, direction=Vector3d.xvector())\n",
"ckey = plot.IPFColorKeyTSL(\n",
" xmap.phases[0].point_group, direction=Vector3d.xvector()\n",
")\n",
"ckey.plot()"
]
},
Expand Down
10 changes: 8 additions & 2 deletions doc/tutorials/kinematical_ebsd_simulations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,11 @@
"grain2 = (115, 27, -95)\n",
"rot = Rotation.from_euler(\n",
" np.deg2rad(\n",
" [[grain1, grain2, grain2], [grain1, grain2, grain2], [grain1, grain2, grain2]]\n",
" [\n",
" [grain1, grain2, grain2],\n",
" [grain1, grain2, grain2],\n",
" [grain1, grain2, grain2],\n",
" ]\n",
" )\n",
")\n",
"\n",
Expand Down Expand Up @@ -802,7 +806,9 @@
"metadata": {},
"outputs": [],
"source": [
"mp_sic = simulator_sic.calculate_master_pattern(hemisphere=\"both\", half_size=200)"
"mp_sic = simulator_sic.calculate_master_pattern(\n",
" hemisphere=\"both\", half_size=200\n",
")"
]
},
{
Expand Down
37 changes: 29 additions & 8 deletions doc/tutorials/load_save_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@
"metadata": {},
"outputs": [],
"source": [
"emsoft_master_pattern = \"emsoft_ebsd_master_pattern/ni_mc_mp_20kv_uint8_gzip_opts9.h5\"\n",
"emsoft_master_pattern = (\n",
" \"emsoft_ebsd_master_pattern/ni_mc_mp_20kv_uint8_gzip_opts9.h5\"\n",
")\n",
"s_mp = kp.load(filename=datadir + emsoft_master_pattern)\n",
"s_mp"
]
Expand Down Expand Up @@ -327,7 +329,9 @@
"metadata": {},
"outputs": [],
"source": [
"s_da = kp.signals.LazyEBSD(da.random.random((20, 10, 60, 60), chunks=(2, 10, 60, 60)))\n",
"s_da = kp.signals.LazyEBSD(\n",
" da.random.random((20, 10, 60, 60), chunks=(2, 10, 60, 60))\n",
")\n",
"print(s_da)\n",
"s_da.data"
]
Expand Down Expand Up @@ -358,7 +362,12 @@
"metadata": {},
"outputs": [],
"source": [
"for signal_type in [\"EBSD\", \"VirtualBSEImage\", \"ECPMasterPattern\", \"EBSDMasterPattern\"]:\n",
"for signal_type in [\n",
" \"EBSD\",\n",
" \"VirtualBSEImage\",\n",
" \"ECPMasterPattern\",\n",
" \"EBSDMasterPattern\",\n",
"]:\n",
" s_hs.set_signal_type(signal_type)\n",
" print(s_hs)"
]
Expand Down Expand Up @@ -446,7 +455,9 @@
"metadata": {},
"outputs": [],
"source": [
"s_mp2 = hs.load(temp_dir + \"master_pattern.hspy\", signal_type=\"EBSDMasterPattern\")\n",
"s_mp2 = hs.load(\n",
" temp_dir + \"master_pattern.hspy\", signal_type=\"EBSDMasterPattern\"\n",
")\n",
"s_mp2"
]
},
Expand Down Expand Up @@ -587,7 +598,10 @@
"outputs": [],
"source": [
"s_mp = kp.load(\n",
" datadir + emsoft_master_pattern, projection=\"lambert\", hemisphere=\"both\", energy=20\n",
" datadir + emsoft_master_pattern,\n",
" projection=\"lambert\",\n",
" hemisphere=\"both\",\n",
" energy=20,\n",
")\n",
"\n",
"print(s_mp)\n",
Expand Down Expand Up @@ -620,7 +634,9 @@
"outputs": [],
"source": [
"# Load a dummy pattern\n",
"s_mp = kp.load(filename=datadir + \"emsoft_ecp_master_pattern/ecp_master_pattern.h5\")\n",
"s_mp = kp.load(\n",
" filename=datadir + \"emsoft_ecp_master_pattern/ecp_master_pattern.h5\"\n",
")\n",
"\n",
"print(s_mp)\n",
"print(s_mp.projection)\n",
Expand Down Expand Up @@ -651,7 +667,9 @@
"outputs": [],
"source": [
"# Load a dummy pattern\n",
"s_mp = kp.load(filename=datadir + \"emsoft_tkd_master_pattern/tkd_master_pattern.h5\")\n",
"s_mp = kp.load(\n",
" filename=datadir + \"emsoft_tkd_master_pattern/tkd_master_pattern.h5\"\n",
")\n",
"\n",
"print(s_mp)\n",
"print(s_mp.projection)\n",
Expand Down Expand Up @@ -1156,7 +1174,10 @@
"outputs": [],
"source": [
"nav_size = vbse.axes_manager.navigation_size\n",
"_ = [plt.imsave(temp_dir + f\"vbse{i}.png\", vbse.inav[i].data) for i in range(nav_size)]"
"_ = [\n",
" plt.imsave(temp_dir + f\"vbse{i}.png\", vbse.inav[i].data)\n",
" for i in range(nav_size)\n",
"]"
]
},
{
Expand Down
14 changes: 11 additions & 3 deletions doc/tutorials/mandm2021_sunday_short_course.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@
"from orix import io, quaternion, sampling, vector\n",
"\n",
"\n",
"plt.rcParams.update({\"figure.facecolor\": \"w\", \"font.size\": 15, \"figure.dpi\": 75})"
"plt.rcParams.update(\n",
" {\"figure.facecolor\": \"w\", \"font.size\": 15, \"figure.dpi\": 75}\n",
")"
]
},
{
Expand Down Expand Up @@ -1175,7 +1177,9 @@
],
"source": [
"detector.plot(\n",
" coordinates=\"gnomonic\", pattern=s.inav[0, 0].data, draw_gnomonic_circles=True\n",
" coordinates=\"gnomonic\",\n",
" pattern=s.inav[0, 0].data,\n",
" draw_gnomonic_circles=True,\n",
")"
]
},
Expand Down Expand Up @@ -1219,7 +1223,11 @@
],
"source": [
"dynsim = mp.get_patterns(\n",
" rotations=rot, detector=detector, energy=20, dtype_out=s.data.dtype, compute=True\n",
" rotations=rot,\n",
" detector=detector,\n",
" energy=20,\n",
" dtype_out=s.data.dtype,\n",
" compute=True,\n",
")\n",
"dynsim"
]
Expand Down
18 changes: 14 additions & 4 deletions doc/tutorials/pattern_matching.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@
],
"source": [
"energy = 20\n",
"mp = kp.data.nickel_ebsd_master_pattern_small(projection=\"lambert\", energy=energy)\n",
"mp = kp.data.nickel_ebsd_master_pattern_small(\n",
" projection=\"lambert\", energy=energy\n",
")\n",
"mp"
]
},
Expand Down Expand Up @@ -472,7 +474,9 @@
"for i in range(3):\n",
" ax[i].imshow(sim.inav[i].data, cmap=\"gray\")\n",
" euler = np.rad2deg(sim.xmap[i].rotations.to_euler())[0]\n",
" ax[i].set_title(f\"($\\phi_1, \\Phi, \\phi_2)$ = {np.array_str(euler, precision=1)}\")\n",
" ax[i].set_title(\n",
" f\"($\\phi_1, \\Phi, \\phi_2)$ = {np.array_str(euler, precision=1)}\"\n",
" )\n",
" ax[i].axis(\"off\")\n",
"fig.tight_layout()"
]
Expand Down Expand Up @@ -975,7 +979,9 @@
" energy=energy,\n",
" signal_mask=signal_mask,\n",
" method=\"minimize\", # Default\n",
" method_kwargs=dict(method=\"Nelder-Mead\", options=dict(fatol=1e-4)), # Default\n",
" method_kwargs=dict(\n",
" method=\"Nelder-Mead\", options=dict(fatol=1e-4)\n",
" ), # Default\n",
" compute=True, # Default\n",
")"
]
Expand Down Expand Up @@ -1607,7 +1613,11 @@
" f\"PC after PC refinement:\\t{detector_refined2.pc_average}\"\n",
")\n",
"\n",
"pc_to_plot = (detector_refined2.pcx, detector_refined2.pcy, detector_refined2.pcz)\n",
"pc_to_plot = (\n",
" detector_refined2.pcx,\n",
" detector_refined2.pcy,\n",
" detector_refined2.pcz,\n",
")\n",
"fig, ax = plt.subplots(ncols=3, figsize=(15, 3))\n",
"for a, to_plot, label in zip(ax, pc_to_plot, (\"x\", \"y\", \"z\")):\n",
" im = a.imshow(to_plot)\n",
Expand Down
4 changes: 3 additions & 1 deletion doc/tutorials/pattern_processing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,9 @@
"outputs": [],
"source": [
"s7 = s3.deepcopy()\n",
"s7.fft_filter(transfer_function=w_low * w_high, function_domain=\"frequency\", shift=True)\n",
"s7.fft_filter(\n",
" transfer_function=w_low * w_high, function_domain=\"frequency\", shift=True\n",
")\n",
"\n",
"_, ax = plt.subplots(figsize=(13, 6), ncols=2)\n",
"ax[0].imshow(s3.inav[0, 0].data, cmap=\"gray\")\n",
Expand Down
9 changes: 7 additions & 2 deletions doc/tutorials/pc_calibration_moving_screen_technique.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@
"metadata": {},
"outputs": [],
"source": [
"fig, (ax0, ax1) = plt.subplots(ncols=2, sharex=True, sharey=True, figsize=(20, 10))\n",
"fig, (ax0, ax1) = plt.subplots(\n",
" ncols=2, sharex=True, sharey=True, figsize=(20, 10)\n",
")\n",
"ax0.imshow(s_in.data, cmap=\"gray\")\n",
"_ = ax1.imshow(s_out5mm.data, cmap=\"gray\")"
]
Expand Down Expand Up @@ -340,7 +342,10 @@
"outputs": [],
"source": [
"sim.plot(\n",
" coordinates=\"gnomonic\", pattern=s_in.data, zone_axes_labels=False, zone_axes=False\n",
" coordinates=\"gnomonic\",\n",
" pattern=s_in.data,\n",
" zone_axes_labels=False,\n",
" zone_axes=False,\n",
")"
]
}
Expand Down
12 changes: 9 additions & 3 deletions doc/tutorials/reference_frames.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,9 @@
"metadata": {},
"outputs": [],
"source": [
"mp = kp.data.nickel_ebsd_master_pattern_small(projection=\"lambert\", hemisphere=\"upper\")"
"mp = kp.data.nickel_ebsd_master_pattern_small(\n",
" projection=\"lambert\", hemisphere=\"upper\"\n",
")"
]
},
{
Expand All @@ -543,7 +545,9 @@
"metadata": {},
"outputs": [],
"source": [
"detector2 = kp.detectors.EBSDDetector((100, 120), pc=(0.4, 0.2, 0.5), sample_tilt=70)\n",
"detector2 = kp.detectors.EBSDDetector(\n",
" (100, 120), pc=(0.4, 0.2, 0.5), sample_tilt=70\n",
")\n",
"detector2"
]
},
Expand Down Expand Up @@ -651,7 +655,9 @@
"\n",
"# Some wrangling to display a nice table\n",
"for software, pc_i in pcs.items():\n",
" print(f\"{software:<9} {pc_i[0, 0]:>6.3f} {pc_i[0, 1]:>6.3f} {pc_i[0, 2]:>6.3f}\")"
" print(\n",
" f\"{software:<9} {pc_i[0, 0]:>6.3f} {pc_i[0, 1]:>6.3f} {pc_i[0, 2]:>6.3f}\"\n",
" )"
]
},
{
Expand Down

0 comments on commit a319d76

Please sign in to comment.