Diffraction Vectors to Mask#

This example shows how to take a set of vectors and create a mask from a set of circles around each vector. Multiplying by the original signal will remove all the signal except for the circles around the vectors.

import pyxem as pxm
import hyperspy.api as hs

s = pxm.data.tilt_boundary_data()
s.calibration.center = None

s.axes_manager[2].scale = 0.3
temp = s.template_match_disk(disk_r=5, subtract_min=False)  # Just right
vectors = temp.get_diffraction_vectors(threshold_abs=0.4, min_distance=5)

mask = vectors.to_mask(disk_r=7)
masked_s = s * mask
masked_s.plot()
  • masking vectors
  • Signal
  0%|          | 0/33 [00:00<?, ?it/s]
 58%|█████▊    | 19/33 [00:00<00:00, 186.81it/s]
100%|██████████| 33/33 [00:00<00:00, 189.13it/s]

  0%|          | 0/33 [00:00<?, ?it/s]
 64%|██████▎   | 21/33 [00:00<00:00, 175.60it/s]
100%|██████████| 33/33 [00:00<00:00, 189.70it/s]

  0%|          | 0/33 [00:00<?, ?it/s]
100%|██████████| 33/33 [00:00<00:00, 11190.24it/s]

  0%|          | 0/33 [00:00<?, ?it/s]
 33%|███▎      | 11/33 [00:00<00:00, 97.34it/s]
 64%|██████▎   | 21/33 [00:00<00:00, 85.20it/s]
 94%|█████████▍| 31/33 [00:00<00:00, 86.00it/s]
100%|██████████| 33/33 [00:00<00:00, 92.28it/s]

Selecting One Position#

We can also just select one position and create a mask from that.

masked_s = s * mask.inav[0, 0]
masked_s.plot()
  • masking vectors
  • Signal

Removing Vectors#

We can also remove the vectors from the signal by inverting the mask and multiplying by the original signal.

  • masking vectors
  • Signal
  0%|          | 0/33 [00:00<?, ?it/s]
100%|██████████| 33/33 [00:00<00:00, 6498.83it/s]

  0%|          | 0/33 [00:00<?, ?it/s]
100%|██████████| 33/33 [00:00<00:00, 343.85it/s]

sphinx_gallery_thumbnail_number = 6

Total running time of the script: (0 minutes 1.943 seconds)

Gallery generated by Sphinx-Gallery