Workflows (pysdic.workflows)#
The submodule pysdic.workflows is a bank of procedures built on the API of pysdic: each workflow chains the
base objects and functions (analyses, terms, cameras, meshes, …) to solve a recurring task of a SDIC analysis. The
workflows are not part of the base API: they are called from their namespace,
from pysdic.workflows import create_grid_integration_points, measure_reference_shape
so that the base API stays small while new workflows can be added freely.
Conventions of a workflow:
it only uses the public API of
pysdic: it can be read as an example of the API;it does not modify its inputs (in particular the analysis), except when it is its purpose and it is documented: the displacements computed by a workflow are returned, and written by the user with
pysdic.SDICAnalysis.set_displacement();its results are returned as a frozen dataclass named
<Name>Resultwhen there are several outputs.
See also
The gallery section of the workflows gives an example of each family of workflows.
Integration points#
Prepare the material points of a correlation: a regular grid of points in each element, sized from the number of pixels per element, and the selection of the points visible in all the views.
create_grid_integration_points: Regular grid of \(n \times n\) integration points (midpoints of the cells) in each element (or in some elements), with the weights of the cells.
compute_grid_size: The size \(n\) of the grid giving a target density of points per pixel, from the projected areas of the elements.
select_visible_integration_points: Keep the points visible in all the views of some frames (projection in the image, not hidden by the mesh).
VisibleIntegrationPointsResult: Result of
select_visible_integration_points()(selected points, mask and visibility per view).
Initialization of the displacements#
Estimate the displacement of a frame before the correlation, which needs an initial guess close to the solution.
compute_optical_flow_displacement: Displacement of the vertices of a frame from the optical flow between the views and the triangulation of the matched points.
OpticalFlowDisplacementResult: Result of
compute_optical_flow_displacement().
Shape at the reference frame#
The mesh of an analysis (e.g. from a CAD model) is never exactly at the position of the specimen: its shape at the reference frame is measured with the stereo pairings of this frame, before any measure of displacement.
measure_reference_shape: Displacement bringing the mesh onto the observed surface, along the normals of the vertices by default (the tangential displacement is not observable with stereo pairings only).
ReferenceShapeResult: Result of
measure_reference_shape().
Tools on the displacements#
Process the displacements of the frames of an analysis. The functions return a dictionary {frame: displacement},
the analysis is not modified.
compute_interpolated_displacements: Temporal interpolation (linear or cubic) of the displacements of frames from known frames, with a constant extrapolation.
compute_median_filtered_displacements: Median filter of the displacements over a neighborhood of the vertices (given, by graph distance or by radius).
from pysdic.workflows import compute_interpolated_displacements
interpolated = compute_interpolated_displacements(analysis, missing_frames, measured_frames)
for frame, displacement in interpolated.items():
analysis.set_displacement(frame, displacement)
Quality control#
Check a measure after its convergence: the residuals per element (reflections, occlusions, damaged speckle) and the uncertainty of the displacements.
compute_elements_residual_rms: RMS of the residuals per element and per pairing, and the badly correlated elements (robust threshold on the median and the MAD).
ElementsResidualRMSResult: Result of
compute_elements_residual_rms().compute_uncertainty: Covariance of the unknowns of a correlation term, \(s^2 H^{-1} (J^T W J) H^{-1}\), from its Jacobian at convergence and the noise of the images.
UncertaintyResult: Result of
compute_uncertainty()(covariances and standard deviations of the vertices and of the transformations).