A robot travel report may ask for a position just beyond the last recorded timestamp. A natural cubic spline can return a plausible-looking number there. That number is a continuation of the fitted curve. Decide explicitly how a report handles those queries before resampling motion data or joining it to a second event log.
Distinguish the endpoint condition from the query policy
SciPy uses the boundary condition to build the spline. The natural condition sets the second derivative to zero at the first and last sample times. This constrains curvature at those two points. It does not turn the entire first or last polynomial segment into a straight line. When extrapolation is enabled, the corresponding end segment is evaluated outside the captured interval.
The extrapolation setting controls evaluation independently of how the spline is constructed. Setting it to false leaves interpolation inside the measured interval unchanged and returns NaN for queries outside it. The first and last timestamps still belong to the interval.
Test the same fit with two policies
Consider three synthetic readings from a linear axis. The recorded positions are 0, 5, and 20 millimeters at 0, 1, and 2 seconds. A second log asks for positions at minus 0.25, 0.5, and 2.25 seconds.
import numpy as np
from scipy.interpolate import CubicSpline
time = np.array([0., 1., 2.])
position = np.array([0., 5., 20.])
query = np.array([-0.25, 0.5, 2.25])
extended = CubicSpline(time, position, bc_type="natural")
bounded = CubicSpline(time, position, bc_type="natural", extrapolate=False)
assert np.allclose(extended(query), [-0.6640625, 1.5625, 24.3359375])
assert np.isnan(bounded(query)[[0, 2]]).all()
assert np.isclose(bounded(query)[1], extended(query)[1])
With SciPy 1.18.1 and NumPy 2.5.5, the default continuation returns about minus 0.664 millimeters before the first sample and 24.336 millimeters after the last. These are mathematical estimates. The bounded evaluation preserves the 1.5625-millimeter result at 0.5 seconds and marks the two outside requests as missing.
Preserve which samples support each report value
Check that the input timestamps are finite and strictly increasing. Record the captured interval and flag out-of-range requests separately from estimates within it. When joining reports from two devices, inspect timestamp alignment and keep the original times alongside any derived values. A query can fall inside the interval and still cross a long gap between recorded samples. A separate gap check can flag those estimates for review.
If the report needs a value beyond the measured interval, document the assumption that supplies it. Holding the final position, continuing a velocity estimate, and acquiring a new measurement represent different evidence. Keeping explicit range and gap flags lets the next reviewer distinguish the cases without reverse-engineering the spline configuration.
Sources
SciPy CubicSpline reference for boundary conditions and evaluation options
https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.CubicSpline.html
SciPy extrapolation guide for the behavior of natural cubic end segments
https://docs.scipy.org/doc/scipy/tutorial/interpolate/extrapolation_examples.html