pyxem / kikuchipy

Toolbox for analysis of electron backscatter diffraction (EBSD) patterns
https://kikuchipy.org
GNU General Public License v3.0
79 stars 30 forks source link

Add calib. pat. coords. and area/ROI shapes to NORDIF calib. pat. original metadata #586

Closed hakonanes closed 1 year ago

hakonanes commented 1 year ago

Description of the change

This PR adds the following information to the original_metadata of a returned EBSD signal with NORDIF calibration patterns (reading of a Setting.txt file):

The coordinates and shapes are given both in terms of pixels in the area image and in terms of the actual navigation shape of the ROI.

This information is required to fit a plane of projection centers (PCs) to selected PCs determined from the calibration patterns.

Other change(s):

Progress of the PR

Minimal example of the bug fix or new feature

>>> import kikuchipy as kp
>>> s = kp.data.ni_gain0_calibration(allow_download=True)  # or kp.load("Setting.txt")
>>> s
<EBSD, title: Calibration patterns, dimensions: (9|480, 480)>
>>> s.original_metadata.as_dictionary()  # "nordif_header" entry is omitted
{'calibration_patterns': {'indices': array([[447, 425],
         [532, 294],
         [543, 573],
         [378, 596],
         [369, 308],
         [632, 171],
         [668, 704],
         [269, 696],
         [247, 152]]),
  'indices_scaled': array([[119, 113],
         [142,  78],
         [145, 153],
         [101, 159],
         [ 98,  82],
         [169,  46],
         [178, 188],
         [ 72, 186],
         [ 66,  41]])},
 'area': {'shape': (1000, 1000), 'shape_scaled': (267, 267)},
 'roi': {'origin': (185, 73),
  'shape': (558, 750),
  'origin_scaled': (49, 19),
  'shape_scaled': (149, 200)},
 'area_image': array([[144, 120, 165, ..., 255, 255, 252],
        [250, 222, 203, ..., 255, 255, 255],
        [255, 219, 186, ..., 249, 252, 255],
        ...,
        [120, 110, 116, ..., 121, 119, 118],
        [122,  99, 112, ..., 117, 127, 132],
        [122, 108, 121, ..., 112, 118, 122]], dtype=uint8)}

For reviewers