Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc for hough indexing with multiple phases #633

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Format with black
  • Loading branch information
Erlendos12 committed Mar 29, 2023
commit bd5878c4d59b0e8c9f7dbb5d1cf90faded8590c4
66 changes: 34 additions & 32 deletions doc/tutorials/hough_indexing_multiple_phases.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"outputs": [],
"source": [
"s = kp.data.sdss_ebsd(allow_download=True)\n",
"s"
"s\n"
]
},
{
Expand All @@ -100,7 +100,7 @@
"outputs": [],
"source": [
"vbse_imager = kp.imaging.VirtualBSEImager(s)\n",
"print(vbse_imager.grid_shape)"
"print(vbse_imager.grid_shape)\n"
]
},
{
Expand All @@ -119,7 +119,7 @@
"outputs": [],
"source": [
"maps_vbse_rgb = vbse_imager.get_rgb_image(r=(2, 1), g=(2, 2), b=(2, 3))\n",
"maps_vbse_rgb"
"maps_vbse_rgb\n"
]
},
{
Expand All @@ -137,7 +137,7 @@
"metadata": {},
"outputs": [],
"source": [
"maps_vbse_rgb.plot()"
"maps_vbse_rgb.plot()\n"
]
},
{
Expand All @@ -157,7 +157,7 @@
"outputs": [],
"source": [
"s.remove_static_background()\n",
"s.remove_dynamic_background()"
"s.remove_dynamic_background()\n"
]
},
{
Expand All @@ -175,7 +175,7 @@
"metadata": {},
"outputs": [],
"source": [
"maps_iq = s.get_image_quality()"
"maps_iq = s.get_image_quality()\n"
]
},
{
Expand All @@ -199,7 +199,7 @@
" colorbar=True,\n",
" colorbar_label=\"Image quality $Q$\",\n",
" remove_padding=True,\n",
")"
")\n"
]
},
{
Expand Down Expand Up @@ -234,7 +234,7 @@
"sig_shape = s.axes_manager.signal_shape[::-1] # (Rows, columns)\n",
"det = kp.detectors.EBSDDetector(sig_shape, sample_tilt=70)\n",
"\n",
"det"
"det\n"
]
},
{
Expand All @@ -254,7 +254,7 @@
"source": [
"grid_shape = (4, 4)\n",
"s_grid, idx = s.extract_grid(grid_shape, return_indices=True)\n",
"s_grid"
"s_grid\n"
]
},
{
Expand All @@ -278,7 +278,7 @@
" rc=idx.reshape(2, -1).T, # Shape (n patterns, 2)\n",
" roi_shape=nav_shape, # Or maps_iq.shape\n",
" roi_image=maps_iq,\n",
")"
")\n"
]
},
{
Expand Down Expand Up @@ -335,7 +335,7 @@
"print(indexer.sampleTilt)\n",
"print(indexer.camElev)\n",
"print(indexer.PC)\n",
"print(indexer.phaselist)"
"print(indexer.phaselist)\n"
]
},
{
Expand All @@ -362,7 +362,7 @@
"\n",
"# Print mean and standard deviation\n",
"print(det.pc_flattened.mean(axis=0))\n",
"print(det.pc_flattened.std(0))"
"print(det.pc_flattened.std(0))\n"
]
},
{
Expand All @@ -380,7 +380,7 @@
"metadata": {},
"outputs": [],
"source": [
"det.plot_pc(\"scatter\", s=50, annotate=True)"
"det.plot_pc(\"scatter\", s=50, annotate=True)\n"
]
},
{
Expand All @@ -401,7 +401,7 @@
"metadata": {},
"outputs": [],
"source": [
"det.pc = det.pc_average"
"det.pc = det.pc_average\n"
]
},
{
Expand All @@ -420,7 +420,7 @@
"metadata": {},
"outputs": [],
"source": [
"det.plot(pattern=s_grid.inav[0, 0].data)"
"det.plot(pattern=s_grid.inav[0, 0].data)\n"
]
},
{
Expand All @@ -443,7 +443,7 @@
"outputs": [],
"source": [
"indexer = det.get_indexer(phase_list)\n",
"indexer.PC"
"indexer.PC\n"
]
},
{
Expand All @@ -466,7 +466,7 @@
"source": [
"xmap, data = s.hough_indexing(\n",
" phase_list=phase_list, indexer=indexer, verbose=2, return_index_data=True\n",
")"
")\n"
]
},
{
Expand All @@ -476,7 +476,7 @@
"metadata": {},
"outputs": [],
"source": [
"xmap"
"xmap\n"
]
},
{
Expand Down Expand Up @@ -510,7 +510,7 @@
" im = a.imshow(xmap.get_map_data(to_plot))\n",
" fig.colorbar(im, ax=a, label=to_plot)\n",
" a.axis(\"off\")\n",
"fig.subplots_adjust(wspace=0, hspace=0.05)"
"fig.subplots_adjust(wspace=0, hspace=0.05)\n"
]
},
{
Expand All @@ -534,7 +534,7 @@
"metadata": {},
"outputs": [],
"source": [
"xmap.plot(remove_padding=True)"
"xmap.plot(remove_padding=True)\n"
]
},
{
Expand All @@ -556,7 +556,7 @@
"sym = xmap.phases[0].point_group\n",
"\n",
"ckey = plot.IPFColorKeyTSL(sym, v_ipf)\n",
"ckey"
"ckey\n"
]
},
{
Expand Down Expand Up @@ -588,7 +588,7 @@
"# Place color key in bottom right corner, coordinates are [left, bottom, width, height]\n",
"ax_ckey = fig.add_axes([0.63, 0.08, 0.2, 0.2], projection=\"ipf\", symmetry=sym)\n",
"ax_ckey.plot_ipf_color_key(show_title=False)\n",
"ax_ckey.patch.set_facecolor(\"None\")"
"ax_ckey.patch.set_facecolor(\"None\")\n"
]
},
{
Expand Down Expand Up @@ -619,7 +619,7 @@
" ax[i].imshow(rgb.reshape(xmap.shape + (3,)))\n",
" ax[i].set_title(f\"IPF-{title}\")\n",
" ax[i].axis(\"off\")\n",
"fig.subplots_adjust(wspace=0.02)"
"fig.subplots_adjust(wspace=0.02)\n"
]
},
{
Expand All @@ -645,7 +645,7 @@
")\n",
"rlv = rlv.symmetrise()\n",
"simulator = kp.simulations.KikuchiPatternSimulator(rlv)\n",
"sim = simulator.on_detector(det, xmap.rotations.reshape(*xmap.shape))"
"sim = simulator.on_detector(det, xmap.rotations.reshape(*xmap.shape))\n"
]
},
{
Expand All @@ -667,7 +667,7 @@
"s.add_marker(markers, plot_marker=False, permanent=True)\n",
"\n",
"# To remove existing markers\n",
"# del s.metadata.Markers"
"# del s.metadata.Markers\n"
]
},
{
Expand All @@ -685,7 +685,7 @@
"metadata": {},
"outputs": [],
"source": [
"maps_nav_rgb = kp.draw.get_rgb_navigator(rgb_x.reshape(xmap.shape + (3,)))"
"maps_nav_rgb = kp.draw.get_rgb_navigator(rgb_x.reshape(xmap.shape + (3,)))\n"
]
},
{
Expand All @@ -695,7 +695,7 @@
"metadata": {},
"outputs": [],
"source": [
"s.plot(maps_nav_rgb)"
"s.plot(maps_nav_rgb)\n"
]
},
{
Expand Down Expand Up @@ -733,7 +733,7 @@
" scan_unit=\"um\",\n",
")\n",
"print(xmap_austenite, \"\\n\")\n",
"print(xmap_ferrite)"
"print(xmap_ferrite)\n"
]
},
{
Expand All @@ -756,7 +756,7 @@
"nav_mask_austenite = nav_mask_austenite.reshape(xmap.shape)\n",
"\n",
"nav_mask_ferrite = ~(xmap_ferrite.phase_id == xmap.phases.id_from_name(\"ferrite\"))\n",
"nav_mask_ferrite = nav_mask_ferrite.reshape(xmap.shape)"
"nav_mask_ferrite = nav_mask_ferrite.reshape(xmap.shape)\n"
]
},
{
Expand Down Expand Up @@ -801,7 +801,7 @@
" method=\"minimize\",\n",
" method_kwargs=dict(method=\"Nelder-Mead\", tol=1e-4),\n",
" compute=True,\n",
")"
")\n"
]
},
{
Expand All @@ -810,7 +810,9 @@
"metadata": {},
"outputs": [],
"source": [
"refined_xmap = kp.indexing.merge_crystal_maps([refined_xmap_austenite, refined_xmap_ferrite])"
"refined_xmap = kp.indexing.merge_crystal_maps(\n",
" [refined_xmap_austenite, refined_xmap_ferrite]\n",
")"
]
},
{
Expand Down Expand Up @@ -846,7 +848,7 @@
" rgb = ckey.orientation2color(map.rotations)\n",
" cell.imshow(rgb.reshape(map.shape + (3,)))\n",
" else:\n",
" cell.plot_map(map)"
" cell.plot_map(map)\n"
]
},
{
Expand Down