Temporal interpolation in NumPy/matplotlib
-
12-11-2019 - |
Question
When creating animations in ParaView there is a function to temporally interpolate input files. When generating an animation via multiple contour plots in NumPy/matplotlib is there a similar function which can help make the animation smoother or do I have to temporal interpolate the data manually?
Solution
VTK's TemporalInterpolator
is for interpolating data on unstructured spacial meshes between time steps. You have your data in two-dimensional NumPy arrays, and the task of interpolating it is far easier. For this reason, there is no dedicated function for this, and you'll have to do it manually.
Let's assume a0
is your two-dimensional data array at the time t0
, and a1
is the data at t1
. For some time t0 <= t <= t1
, the linearly interpolated data a_t
is
delta_t = t1 - t0
a_t = (t1 - t) / delta_t * a_0 + (t - t0) / delta_t * a_1
There are more advanced interpolation schemes than this simple linear interpolation, but VTK's TemporalInterpolator
also uses this simple scheme.