fit_pc#
- EBSDDetector.fit_pc(pc_indices: list | tuple | ndarray, map_indices: list | tuple | ndarray, transformation: Literal['projective', 'affine'] = 'projective', is_outlier: ndarray | None = None, plot: bool = True, return_figure: Literal[False] = False, figure_kwargs: dict[str, Any] | None = None) Self[source]#
- EBSDDetector.fit_pc(pc_indices: list | tuple | ndarray, map_indices: list | tuple | ndarray, transformation: Literal['projective', 'affine'] = 'projective', is_outlier: ndarray | None = None, plot: bool = True, return_figure: Literal[True] = True, figure_kwargs: dict[str, Any] | None = None) tuple[Self, mfigure.Figure]
Return a new detector with interpolated projection centers (PCs) for all points in a map by fitting a plane to
pc.See [Winkelmann et al., 2020] for further details.
- Parameters:
- pc_indices
2D coordinates (row, column) of each
pcin map_indices. Must be a flattened array of shape (2,) +navigation_shape.- map_indices
2D coordinates (row, column) of all map points in a regular grid to interpolate PCs for. Must be a flattened array of shape (2,) +
navigation_shape.- transformation
Which transformation function to use when fitting PCs, either “projective” (default) or “affine”. Both transformations preserve co-planarity of map points. The projective transformation allows parallel lines in the map point grid to become non-parallel within the sample plane.
- is_outlier
Boolean array with True for PCs to not include in the fit. If not given, all PCs are used. Must be of
navigation_shape.- plot
Whether to plot the experimental and estimated PCs (default is True).
- return_figure
Whether to return the figure if plot is True (default is False).
- figure_kwargs
Keyword arguments passed to
matplotlib.pyplot.Figure()if plot is True.
- Returns:
new_detectorNew detector with as many interpolated PCs as indices given in map_indices and an estimated sample tilt. The detector tilt is assumed to be constant.
figFigure of experimental and estimated PCs, returned if plot is True and return_figure is True.
- Raises:
ValueErrorIf
navigation_sizeis 1 or if the pc_indices or map_indices arrays have the incorrect shape.
Notes
This method is adapted from Aimo Winkelmann’s functions
fit_affine()andfit_projective()in the xcdskd Python package. Their uses are described in [Winkelmann et al., 2020]. Winkelmann et al. refers to a code example from StackOverflow (https://stackoverflow.com/a/20555267/3228100) for the affine transformation.