bcdi.postprocessing: Post-processing of data after phase retrieval

facet_recognition

This module provides tools for facet segmentation on nanocrystals, and for plotting the stereographic projection of a diffraction peak or an object. For more details, see: Carnis et al. Small 17, 2007702 (2021) https://doi.org/10.1002/smll.202007702

API Reference

analysis

This module provides the classes used in postprocessing strain analysis. It is mainly an abstration layer making analysis steps more understandable.

API Reference

facet_analysis

This module provides tools to import and stores the output of the facet analyzer plugin from Paraview for further analysis. See Ultramicroscopy 122, 65-75 (2012) https://doi.org/10.1016/j.ultramic.2012.07.024

One can extract the strain component and the displacement on the facets, and retrieve the correct facet normals based on a user input (geometric transformation into the crystal frame). Only cubic lattices are supported.

API Reference

Postprocessing of the output from the facet analyzer plugin for Paraview.

class bcdi.postprocessing.facet_analysis.Facets(filename: str, pathdir: str = './', savedir: Optional[str] = None, lattice: float = 3.912, **kwargs)

Import and stores data output of facet analyzer plugin for further analysis.

Extract the mean and standard deviation of the strain and displacement distribution on the facets. Retrieves the correct facet normals based on a user input (geometric transformation into the crystal frame). It requires as input a VTK file extracted from the FacetAnalyser plugin from ParaView. See: https://doi.org/10.1016/j.ultramic.2012.07.024

Original tutorial on how to open vtk files: http://forrestbao.blogspot.com/2011/12/reading-vtk-files-in-python-via-python.html

Expected directory structure:
  • vtk file should have been saved in in Sxxxx/postprocessing

  • the analysis output will be saved in Sxxxx/postprocessing/facet_analysis

Several plotting options are attributes of this class, feel free to change them (cmap, strain_range, disp_range_avg, disp_range, strain_range_avg, comment, title_fontsize, axes_fontsize, legend_fontsize, ticks_fontsize)

Parameters
  • filename – str, name of the VTK file

  • pathdir – str, path to the VTK file

  • savedir – str, path where to save results. If None, they will be saved in pathdir/facets_analysis

  • lattice – float, atomic spacing of the material in angstroms (only cubic lattices are supported).

evolution_curves(ncol: int = 1) None

Plot strain and displacement evolution for each facet.

Parameters

ncol – number of columns in the plot

extract_facet(facet_id: int, plot: bool = False, elev: int = 0, azim: int = 0, output: bool = True, save: bool = True) Optional[Dict]

Extract data from one facet.

It extracts the facet direction [x, y, z], the strain component, the displacement and their means, and also plots it.

Parameters
  • facet_id – id of facet in paraview

  • plot – True to see plots:

  • elev – elevation angle in the z plane (in degrees).

  • azim – azimuth angle in the (x, y) plane (in degrees).

  • output – True to return facet data

  • save – True to save plot

property filename

Path to the VTK file.

fixed_reference(hkl_reference: Tuple[float, float, float] = (1, 1, 1), plot: bool = True) None

Compute the interplanar angles between each normal and a fixed reference vector.

Parameters
  • hkl_reference – tuple of three real numbers, reference crystallographic direction

  • plot – True to see plots

load_vtk() None

Load the VTK file.

In paraview, the facets have an index that starts at 1, the index 0 corresponds to the edges and corners of the facets.

plot_displacement(figsize: Tuple[float, float] = (12, 10), elev: int = 0, azim: int = 0, save: bool = True) None

Plot two views of the surface dispalcement of the nanocrystal.

The first one with the surface coloured by the mean displacement per facet. The second one with the surface coloured by the displacement per voxel.

Parameters
  • figsize – figure size in inches (width, height)

  • elev – elevation angle in the z plane (in degrees).

  • azim – azimuth angle in the (x, y) plane (in degrees).

  • save – True to save the figures

plot_strain(figsize: Tuple[float, float] = (12, 10), elev: int = 0, azim: int = 0, save: bool = True) None

Plot two views of the surface strain of the nanocrystal.

The first one with the surface coloured by the mean strain per facet. The second one with the surface coloured by the strain per voxel.

Parameters
  • figsize – figure size in inches (width, height)

  • elev – elevation angle in the z plane (in degrees).

  • azim – azimuth angle in the (x, y) plane (in degrees).

  • save – True to save the figures

rotate_particle()

Rotate the nanocrystal.

The rotation is so that the base of the normals to the facets is computed with the new rotation matrix.

save_data(path_to_data: str) None

Save the field data as a csv file.

Parameters

path_to_data – path where to save the data

save_edges_corners_data() None

Extract the edges and corners data, i.e. the mean strain and displacement.

set_rotation_matrix(u0: numpy.ndarray, v0: numpy.ndarray, u: numpy.ndarray, v: numpy.ndarray) None

Define the rotation matrix.

u and v should be the vectors perpendicular to two facets. The rotation matrix is then used if the argument rotate_particle is set to True in the method load_vtk.

Parameters
  • u0 – numpy.ndarray, shape (3,)

  • v0 – numpy.ndarray, shape (3,)

  • u – numpy.ndarray, shape (3,)

  • v – numpy.ndarray, shape (3,)

test_rotation_matrix(vec: numpy.ndarray) None

Computes value of a vector passed through the rotation matrix.

Parameters

vec – numpy ndarray of shape (3,). e.g. np.array([-0.833238, -0.418199, -0.300809])

to_hdf5(path_to_data: str) None

Save the facets object as an hdf5 file.

Can be combined with the file saved by the gwaihir gui.

Parameters

path_to_data – path where to save the data

view_particle(facet_id_range: Tuple[int, int], elev_axis: str, show_edges_corners: bool, elev: int = 0, azim: int = 0) None

Visualization of the nanocrystal.

x, y and z correspond to the frame used in paraview before saving the facet analyser plugin data.

Parameters
  • elev – elevation angle in the z plane (in degrees).

  • azim – azimuth angle in the (x, y) plane (in degrees).

  • facet_id_range – tuple of two facets numbers, facets with numbers between these two values will be plotted (higher boundary is excluded)

  • elev_axis – “x”, “y” or “z”

  • show_edges_corners – set it to True to plot also edges and corners

postprocessing_runner

This module provides the function which manage the whole postprocessing.

API Reference

postprocessing_utils

This module provides methods used for post-processing data after phase retrieval. For example (but not limited to): phase offset and ramp removal, centering, cropping, padding, aligning reconstructions, filtering…

API Reference

process_scan

This module provides the function which manage the postprocessing for a single scan.

API Reference