pysdic.PairingResiduals#

The pysdic.PairingResiduals stores the gray levels and the residuals of the material points (integration points of the mesh) in the two views of a pysdic.Pairing, as compared by a pysdic.SDICCorrelationTerm (gray level correction included, without the weights of the points):

\[r_p = g'_2(\vec{X}_p) - g'_1(\vec{X}_p)\]

with \(g'_k\) the gray levels of the view \(k\) after the gray level correction (the raw gray levels without correction).

PairingResiduals class#

class PairingResiduals(pairing, gray_levels_1, gray_levels_2, residuals, image_points_1, image_points_2, displacement_1, displacement_2, gl_correction=None)[source]#

Bases: object

The gray levels and the residuals of the material points (integration points of the mesh) in the two views of a pairing, as compared by pysdic.SDICCorrelationTerm (gray level correction included, without the weights of the points).

\[r_p = g'_2(\vec{X}_p) - g'_1(\vec{X}_p)\]

with \(g'_k\) the gray levels of the view \(k\) after the gray level correction (the raw gray levels without correction).

Returned by pysdic.compute_residuals() (current state of the analysis) and pysdic.SDICCorrelationTerm.compute_residuals() (state given by a vector of unknowns). Used by pysdic.compute_pixel_residual_maps() and pysdic.display_residual_maps().

Parameters:
pairing#

The two views.

Type:

pysdic.Pairing

gray_levels_1, gray_levels_2

The (corrected) gray levels in the two views, shape \((N_p, C)\). NaN for the points projected out of the ROI of an image.

Type:

numpy.ndarray

residuals#

gray_levels_2 - gray_levels_1, shape \((N_p, C)\).

Type:

numpy.ndarray

image_points_1, image_points_2

The projections \((x, y)\) of the points in the two views (pixels), shape \((N_p, 2)\).

Type:

numpy.ndarray

displacement_1, displacement_2

The displacements \((N_v, E)\) of the frames of the two views used for the evaluation.

Type:

numpy.ndarray

gl_correction#

The gray level correction (complete options), or None for the raw gray levels.

Type:

Optional[Dict[str, Any]]

Instantiation#

A PairingResiduals is a frozen dataclass returned by the functions below, not created by the user:

  • pysdic.compute_residuals(): the residuals of a pairing for the current state of the analysis, with or without gray level correction;

  • pysdic.SDICCorrelationTerm.compute_residuals(): the residuals of the pairings of a term for the state given by a complete vector of unknowns \(\vec{p}\) (by default the current state of the analysis), with the gray level correction of the term.

from pysdic import Pairing, compute_residuals, display_residual_maps

raw = compute_residuals(analysis, Pairing.stereo(1, 0, 1), integration_points)       # Raw gray levels
corrected = correlation.compute_residuals()                                         # One per pairing of the term

print(raw.label, raw.n_points, raw.n_channels)    # "raw", N_p, C
rms = numpy.sqrt(numpy.nanmean(raw.residuals**2))
display_residual_maps(analysis, corrected[0], fill_radius=2.0)

Note

The points projected out of the ROI of an image have NaN gray levels and NaN residuals: use the nan* functions of numpy for the statistics. The RMS per element is computed by pysdic.workflows.compute_elements_residual_rms().

Attributes#

The fields of the dataclass:

Field

Content

pairing

The pysdic.Pairing (the two views).

gray_levels_1, gray_levels_2

The (corrected) gray levels in the two views, shape \((N_p, C)\), NaN out of the ROI.

residuals

gray_levels_2 - gray_levels_1, shape \((N_p, C)\).

image_points_1, image_points_2

The projections \((x, y)\) of the points in the two views (pixels), shape \((N_p, 2)\).

displacement_1, displacement_2

The (total) displacements \((N_v, E)\) of the frames of the two views used for the evaluation.

gl_correction

The gray level correction (complete options), or None for the raw gray levels.

And the derived properties:

PairingResiduals.n_points

The number of points \(N_p\).

PairingResiduals.n_channels

The number of channels \(C\).

PairingResiduals.label

"raw", "ZNSSD" or "matching".

Residual maps#

The residuals of the points are drawn as images in the two views of the pairing: