pysdic.workflows.compute_interpolated_displacements#

compute_interpolated_displacements(analysis, frames, known_frames, *, method='linear')[source]#

Interpolate in time the displacements of frames from the displacements of known frames.

The known displacements \(U(t_k)\) are interpolated at the times \(t_f\) of the frames (see pysdic.SDICAnalysis.times), vertex by vertex and component by component:

  • "linear": piecewise linear interpolation between the two closest known frames;

  • "cubic": cubic spline through the known frames (scipy.interpolate.CubicSpline, not-a-knot conditions), smoother for a regular motion.

Before the first known time and after the last one, the displacement is constant (the displacement of the first or last known frame): a spline is never extrapolated.

Typical use: the frames without views (no image, broken calibration) between measured frames. Do not put a reference frame outside the time series in known_frames (e.g. a frame 0 placed at \(t = 0\) by convention).

Parameters:
  • analysis (pysdic.SDICAnalysis) – The analysis, with times and the displacements of known_frames set.

  • frames (Sequence[Integral]) – The frames to interpolate (not in known_frames).

  • known_frames (Sequence[Integral]) – The frames giving the displacements, with distinct times (any order).

  • method (str, optional (default: "linear")) – "linear" or "cubic".

Returns:

For each frame of frames, its interpolated displacement \((N_v, E)\).

Return type:

Dict[int, numpy.ndarray]

Raises:

ValueError – If the analysis has no times, a known displacement is not set, two known frames have the same time, or a frame is in both inputs.

Examples

from pysdic.workflows import compute_interpolated_displacements

measured = [frame for frame in range(1, analysis.n_frames) if analysis.n_views(frame) > 0]
missing = [frame for frame in range(1, analysis.n_frames) if analysis.n_views(frame) == 0]

for frame, displacement in compute_interpolated_displacements(analysis, missing, measured).items():
    analysis.set_displacement(frame, displacement)