Skip to content

Commit

Permalink
Merge pull request #608 from hakonanes/vbse-module
Browse files Browse the repository at this point in the history
Deprecate generators.VirtualBSEGenerator in favor of imaging.VirtualBSEImager
  • Loading branch information
hakonanes committed Feb 10, 2023
2 parents c296cc2 + 571291a commit 88945e2
Show file tree
Hide file tree
Showing 31 changed files with 1,147 additions and 434 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Expand Up @@ -62,7 +62,7 @@ jobs:
- os: ubuntu-latest
python-version: 3.7
OLDEST_SUPPORTED_VERSION: true
DEPENDENCIES: dask==2021.8.1 diffsims==0.5.0 hyperspy==1.7.3 matplotlib==3.3 numba==0.52 numpy==1.19 orix==0.9.0 scikit-image==0.16.2
DEPENDENCIES: dask==2021.8.1 diffsims==0.5.0 hyperspy==1.7.3 matplotlib==3.3 numba==0.55 numpy==1.19 orix==0.11.0 scikit-image==0.16.2
LABEL: -oldest
steps:
- uses: actions/checkout@v3
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -18,6 +18,9 @@ Unreleased

Added
-----
- ``kikuchipy.imaging.VirtualBSEImager`` replaces the
``kikuchipy.generators.VirtualBSEGenerator`` class.
(`#608 <https://github.com/pyxem/kikuchipy/pull/608>`_)
- Adaptive histogram equalization is available to all signals.
(`#606 <https://github.com/pyxem/kikuchipy/pull/606>`_)
- Option to return a new signal (lazy or not) instead of operating inplace is added to
Expand Down Expand Up @@ -106,6 +109,8 @@ Added

Changed
-------
- Minimal version of orix set to >= 0.11 and of numba set to >= 0.55.
(`#608 <https://github.com/pyxem/kikuchipy/pull/608>`_)
- Added warnings when trying to perform adaptive histogram equalization on a signal with
data in floating type or when some of the data is NaN.
(`#606 <https://github.com/pyxem/kikuchipy/pull/606>`_)
Expand Down Expand Up @@ -143,6 +148,9 @@ Changed

Deprecated
----------
- ``kikuchipy.generators.VirtualBSEGenerator`` class is deprecated and will be removed
in version 0.9. Use ``kikuchipy.imaging.VirtualBSEImager`` instead.
(`#608 <https://github.com/pyxem/kikuchipy/pull/608>`_)
- The data module functions ``silicon_ebsd_moving_screen_x()``, where "x" is "in",
"out5mm" or "out10mm", are deprecated and will be removed in v0.9. Use
``si_ebsd_moving_screen(distance)`` instead, where ``distance`` is ``0`` (in), ``5``
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/indexing/test_refinement.py
Expand Up @@ -82,7 +82,7 @@ def test_refine_orientation(benchmark):

# Relaxed check of results, just to make sure results are not way
# off
assert np.all(xmap_ref.rotations.angle_with(rot) < np.deg2rad(0.8))
assert np.all(xmap_ref.rotations.angle_with(rot, degrees=True) < 0.8)


def test_refine_pc(benchmark):
Expand Down
1 change: 1 addition & 0 deletions doc/reference/index.rst
Expand Up @@ -50,6 +50,7 @@ this:
draw
filters
generators
imaging
indexing
io
pattern
Expand Down
136 changes: 68 additions & 68 deletions doc/tutorials/esteem2022_diffraction_workshop.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions doc/tutorials/hough_indexing.ipynb
Expand Up @@ -99,8 +99,8 @@
"metadata": {},
"outputs": [],
"source": [
"vbse_gen = kp.generators.VirtualBSEGenerator(s)\n",
"print(vbse_gen.grid_shape)"
"vbse_imager = kp.imaging.VirtualBSEImager(s)\n",
"print(vbse_imager.grid_shape)"
]
},
{
Expand All @@ -118,7 +118,7 @@
"metadata": {},
"outputs": [],
"source": [
"maps_vbse_rgb = vbse_gen.get_rgb_image(r=(2, 1), g=(2, 2), b=(2, 3))\n",
"maps_vbse_rgb = vbse_imager.get_rgb_image(r=(2, 1), g=(2, 2), b=(2, 3))\n",
"maps_vbse_rgb"
]
},
Expand Down
126 changes: 64 additions & 62 deletions doc/tutorials/hybrid_indexing.ipynb

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions doc/tutorials/load_save_data.ipynb
Expand Up @@ -1152,12 +1152,12 @@
"metadata": {},
"outputs": [],
"source": [
"# Get virtual image from generator\n",
"vbse_gen = kp.generators.VirtualBSEGenerator(s)\n",
"print(vbse_gen)\n",
"# Get virtual image from image generator\n",
"vbse_imager = kp.imaging.VirtualBSEImager(s)\n",
"print(vbse_imager)\n",
"\n",
"print(vbse_gen.grid_shape)\n",
"vbse = vbse_gen.get_images_from_grid()\n",
"print(vbse_imager.grid_shape)\n",
"vbse = vbse_imager.get_images_from_grid()\n",
"print(vbse)"
]
},
Expand Down
96 changes: 44 additions & 52 deletions doc/tutorials/mandm2021_sunday_short_course.ipynb

Large diffs are not rendered by default.

79 changes: 40 additions & 39 deletions doc/tutorials/pattern_matching.ipynb

Large diffs are not rendered by default.

60 changes: 31 additions & 29 deletions doc/tutorials/pc_extrapolate_plane.ipynb
Expand Up @@ -282,8 +282,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[########################################] | 100% Completed | 101.45 ms\n",
"[########################################] | 100% Completed | 202.57 ms\n"
"[########################################] | 100% Completed | 101.33 ms\n",
"[########################################] | 100% Completed | 101.19 ms\n"
]
}
],
Expand Down Expand Up @@ -456,11 +456,11 @@
" GPU: True\n",
" Projection center: (0.4208, 0.2182, 0.4999)\n",
" Indexing 9 pattern(s) in 1 chunk(s)\n",
"Radon Time: 0.05065198699958273\n",
"Convolution Time: 0.004807140001503285\n",
"Peak ID Time: 0.001738914997986285\n",
"Band Label Time: 0.05457071899945731\n",
"Total Band Find Time: 0.11179470299975947\n"
"Radon Time: 0.03806788400106598\n",
"Convolution Time: 0.0031347900003311224\n",
"Peak ID Time: 0.0016060470006777905\n",
"Band Label Time: 0.040003152997087454\n",
"Total Band Find Time: 0.0828367710018938\n"
]
},
{
Expand All @@ -477,8 +477,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Band Vote Time: 0.025686940000014147\n",
" Indexing speed: 30.92640 patterns/s\n"
"Band Vote Time: 0.01957559899892658\n",
" Indexing speed: 31.14729 patterns/s\n"
]
}
],
Expand Down Expand Up @@ -511,8 +511,8 @@
" Trust region (+/-): [5. 5. 5. 0.05 0.05 0.05]\n",
" Relative tolerance: 1e-07\n",
"Refining 9 orientation(s) and projection center(s):\n",
"[########################################] | 100% Completed | 85.72 ss\n",
"Refinement speed: 0.10499 patterns/s\n"
"[########################################] | 100% Completed | 78.42 ss\n",
"Refinement speed: 0.11476 patterns/s\n"
]
}
],
Expand Down Expand Up @@ -562,8 +562,10 @@
"print(\"PC std: \", det_ref.pc.std(0))\n",
"print(\"PC max. diff:\", abs(det_cal.pc - det_ref.pc).max(0))\n",
"\n",
"ori_diff = xmap_hi.orientations.angle_with(xmap_ref.orientations).max()\n",
"print(\"Ori. max. diff [deg]:\", np.rad2deg(ori_diff))"
"ori_diff = xmap_hi.orientations.angle_with(\n",
" xmap_ref.orientations, degrees=True\n",
").max()\n",
"print(\"Ori. max. diff [deg]:\", ori_diff)"
]
},
{
Expand Down Expand Up @@ -964,8 +966,8 @@
" Trust region (+/-): [5 5 5]\n",
" Relative tolerance: 1e-07\n",
"Refining 9 orientation(s):\n",
"[########################################] | 100% Completed | 16.27 ss\n",
"Refinement speed: 0.55309 patterns/s\n"
"[########################################] | 100% Completed | 14.60 ss\n",
"Refinement speed: 0.61588 patterns/s\n"
]
}
],
Expand Down Expand Up @@ -994,11 +996,11 @@
"output_type": "stream",
"text": [
"Finding bands that are in some pattern:\n",
"[########################################] | 100% Completed | 101.58 ms\n",
"[########################################] | 100% Completed | 101.56 ms\n",
"Finding zone axes that are in some pattern:\n",
"[########################################] | 100% Completed | 102.69 ms\n",
"[########################################] | 100% Completed | 102.22 ms\n",
"Calculating detector coordinates for bands and zone axes:\n",
"[########################################] | 100% Completed | 103.87 ms\n"
"[########################################] | 100% Completed | 104.01 ms\n"
]
}
],
Expand Down Expand Up @@ -1037,8 +1039,8 @@
" Trust region (+/-): [5 5 5]\n",
" Relative tolerance: 1e-07\n",
"Refining 9 orientation(s):\n",
"[########################################] | 100% Completed | 15.86 ss\n",
"Refinement speed: 0.56707 patterns/s\n"
"[########################################] | 100% Completed | 14.23 ss\n",
"Refinement speed: 0.63225 patterns/s\n"
]
}
],
Expand Down Expand Up @@ -1067,11 +1069,11 @@
"output_type": "stream",
"text": [
"Finding bands that are in some pattern:\n",
"[########################################] | 100% Completed | 101.37 ms\n",
"[########################################] | 100% Completed | 101.42 ms\n",
"Finding zone axes that are in some pattern:\n",
"[########################################] | 100% Completed | 102.19 ms\n",
"[########################################] | 100% Completed | 102.23 ms\n",
"Calculating detector coordinates for bands and zone axes:\n",
"[########################################] | 100% Completed | 105.06 ms\n"
"[########################################] | 100% Completed | 101.58 ms\n"
]
}
],
Expand Down Expand Up @@ -1110,8 +1112,8 @@
" Trust region (+/-): [5 5 5]\n",
" Relative tolerance: 1e-07\n",
"Refining 9 orientation(s):\n",
"[########################################] | 100% Completed | 14.95 ss\n",
"Refinement speed: 0.60200 patterns/s\n"
"[########################################] | 100% Completed | 13.71 ss\n",
"Refinement speed: 0.65594 patterns/s\n"
]
}
],
Expand Down Expand Up @@ -1140,11 +1142,11 @@
"output_type": "stream",
"text": [
"Finding bands that are in some pattern:\n",
"[########################################] | 100% Completed | 102.23 ms\n",
"[########################################] | 100% Completed | 101.96 ms\n",
"Finding zone axes that are in some pattern:\n",
"[########################################] | 100% Completed | 101.86 ms\n",
"[########################################] | 100% Completed | 102.18 ms\n",
"Calculating detector coordinates for bands and zone axes:\n",
"[########################################] | 100% Completed | 101.72 ms\n"
"[########################################] | 100% Completed | 103.92 ms\n"
]
}
],
Expand Down Expand Up @@ -1271,7 +1273,7 @@
}
],
"source": [
"np.rad2deg(xmap_proj.orientations.angle_with(xmap_ext.orientations))"
"xmap_proj.orientations.angle_with(xmap_ext.orientations, degrees=True)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorials/reference_frames.ipynb
Expand Up @@ -716,7 +716,7 @@
" rot_hi = Rotation(data[-1][\"quat\"]) * post_rot[vendor]\n",
" ori_hi = Orientation(rot_hi, mp.phase.point_group)\n",
"\n",
" print(\"Mori. angle to ground truth:\", np.rad2deg(ori_hi.angle_with(ori)))\n",
" print(\"Mori. angle to ground truth:\", ori_hi.angle_with(ori, degrees=True))\n",
" fig = ori.scatter(\n",
" \"ipf\",\n",
" direction=v_sample,\n",
Expand Down
28 changes: 14 additions & 14 deletions doc/tutorials/virtual_backscatter_electron_imaging.ipynb
Expand Up @@ -143,7 +143,7 @@
"channels to obtain RGB images.\n",
"\n",
"First, we initialize a virtual BSE image generator,\n",
"[kikuchipy.generators.VirtualBSEGenerator](../reference/generated/kikuchipy.generators.VirtualBSEGenerator.rst),\n",
"[kikuchipy.imaging.VirtualBSEImager](../reference/generated/kikuchipy.imaging.VirtualBSEImager.rst),\n",
"with an [EBSD](../reference/generated/kikuchipy.signals.EBSD.rst) signal, in\n",
"case the raw EBSD patterns without any background correction or other processing"
]
Expand All @@ -154,8 +154,8 @@
"metadata": {},
"outputs": [],
"source": [
"vbse_gen = kp.generators.VirtualBSEGenerator(s)\n",
"vbse_gen"
"vbse_imager = kp.imaging.VirtualBSEImager(s)\n",
"vbse_imager"
]
},
{
Expand All @@ -165,7 +165,7 @@
"We can set and plot the detector grid on one of the EBSD patterns, also coloring\n",
"one or more of the grid tiles red, green and blue, as is done in\n",
"<cite data-cite=\"nolze2017electron\">Nolze et al. (2017)</cite>, by calling\n",
"[VirtualBSEGenerator.plot_grid()](../reference/generated/kikuchipy.generators.VirtualBSEGenerator.plot_grid.rst)"
"[VirtualBSEImager.plot_grid()](../reference/generated/kikuchipy.imaging.VirtualBSEImager.plot_grid.rst)"
]
},
{
Expand All @@ -174,7 +174,7 @@
"metadata": {},
"outputs": [],
"source": [
"vbse_gen.grid_shape"
"vbse_imager.grid_shape"
]
},
{
Expand All @@ -183,11 +183,11 @@
"metadata": {},
"outputs": [],
"source": [
"vbse_gen.grid_shape = (10, 10)\n",
"vbse_imager.grid_shape = (10, 10)\n",
"red = [(7, 1), (8, 1), (8, 2), (9, 1), (9, 2)]\n",
"green = [(8, 4), (8, 5), (9, 4), (9, 5)]\n",
"blue = [(7, 8), (8, 7), (8, 8), (9, 7), (9, 8)]\n",
"p = vbse_gen.plot_grid(\n",
"p = vbse_imager.plot_grid(\n",
" rgb_channels=[red, green, blue],\n",
" visible_indices=True, # Default\n",
" pattern_idx=(10, 20), # Default is (0, 0)\n",
Expand All @@ -209,7 +209,7 @@
"metadata": {},
"source": [
"To obtain an RGB image from the detector grid tiles shown above, we use\n",
"[get_rgb_image()](../reference/generated/kikuchipy.generators.VirtualBSEGenerator.get_rgb_image.rst)\n",
"[get_rgb_image()](../reference/generated/kikuchipy.imaging.VirtualBSEImager.get_rgb_image.rst)\n",
"(see the docstring for all available parameters)"
]
},
Expand All @@ -219,7 +219,7 @@
"metadata": {},
"outputs": [],
"source": [
"vbse_rgb_img = vbse_gen.get_rgb_image(r=red, g=green, b=blue)\n",
"vbse_rgb_img = vbse_imager.get_rgb_image(r=red, g=green, b=blue)\n",
"vbse_rgb_img"
]
},
Expand Down Expand Up @@ -252,7 +252,7 @@
"metadata": {},
"source": [
"To obtain one grey scale virtual BSE image from each grid tile, we use\n",
"[get_images_from_grid()](../reference/generated/kikuchipy.generators.VirtualBSEGenerator.get_images_from_grid.rst)"
"[get_images_from_grid()](../reference/generated/kikuchipy.imaging.VirtualBSEImager.get_images_from_grid.rst)"
]
},
{
Expand All @@ -261,8 +261,8 @@
"metadata": {},
"outputs": [],
"source": [
"vbse_gen.grid_shape = (3, 3)\n",
"vbse_imgs = vbse_gen.get_images_from_grid()\n",
"vbse_imager.grid_shape = (3, 3)\n",
"vbse_imgs = vbse_imager.get_images_from_grid()\n",
"vbse_imgs"
]
},
Expand Down Expand Up @@ -353,7 +353,7 @@
"metadata": {},
"source": [
"To obtain a rectangular ROI from the grid, we can use\n",
"[VirtualBSEGenerator.roi_from_grid()](../reference/generated/kikuchipy.generators.VirtualBSEGenerator.roi_from_grid.rst)"
"[VirtualBSEGenerator.roi_from_grid()](../reference/generated/kikuchipy.imaging.VirtualBSEImager.roi_from_grid.rst)"
]
},
{
Expand All @@ -362,7 +362,7 @@
"metadata": {},
"outputs": [],
"source": [
"roi2 = vbse_gen.roi_from_grid((3, 3)) # (Row, column)\n",
"roi2 = vbse_imager.roi_from_grid((3, 3)) # (Row, column)\n",
"roi2"
]
},
Expand Down
10 changes: 5 additions & 5 deletions doc/tutorials/visualizing_patterns.ipynb
Expand Up @@ -96,7 +96,7 @@
"## Virtual image\n",
"\n",
"A virtual backscatter electron (VBSE) image created from any detector region of interest with the [get_virtual_bse_intensity()](../reference/generated/kikuchipy.signals.EBSD.get_virtual_bse_intensity.rst) method or\n",
"[get_rgb_image()](../reference/generated/kikuchipy.generators.VirtualBSEGenerator.get_rgb_image.rst) explained in the [virtual backscatter electron imaging](virtual_backscatter_electron_imaging.ipynb) tutorial, can be used as a navigator for a scan `s`"
"[get_rgb_image()](../reference/generated/kikuchipy.imaging.VirtualBSEImager.get_rgb_image.rst) explained in the [virtual backscatter electron imaging](virtual_backscatter_electron_imaging.ipynb) tutorial, can be used as a navigator for a scan `s`"
]
},
{
Expand All @@ -105,9 +105,9 @@
"metadata": {},
"outputs": [],
"source": [
"vbse_gen = kp.generators.VirtualBSEGenerator(s)\n",
"print(vbse_gen)\n",
"print(vbse_gen.grid_shape)"
"vbse_imager = kp.imaging.VirtualBSEImager(s)\n",
"print(vbse_imager)\n",
"print(vbse_imager.grid_shape)"
]
},
{
Expand All @@ -116,7 +116,7 @@
"metadata": {},
"outputs": [],
"source": [
"vbse_rgb = vbse_gen.get_rgb_image(r=(3, 1), b=(3, 2), g=(3, 3))\n",
"vbse_rgb = vbse_imager.get_rgb_image(r=(3, 1), b=(3, 2), g=(3, 3))\n",
"vbse_rgb"
]
},
Expand Down

0 comments on commit 88945e2

Please sign in to comment.