tidy3d.plugins.autograd.primitives.interpolate_spline#
- class interpolate_spline[source]#
- Bases: - Differentiable spline interpolation of a given order with optional endpoint derivatives. - Parameters:
- x_points (np.ndarray) β X coordinates of the data points (must be strictly monotonic) 
- y_points (np.ndarray) β Y coordinates of the data points 
- num_points (int) β Number of points in the output interpolation 
- order (int) β Order of the spline (1=linear, 2=quadratic, 3=cubic) 
- endpoint_derivatives (tuple[float, float] = (None, None)) β - Derivatives at the endpoints (left, right) Note: For order=1 (linear), all endpoint derivatives are ignored. - For order=2 (quadratic), only the left endpoint derivative is used. For order=3 (cubic), both endpoint derivatives are used if provided. 
 
- Returns:
- Tuple of (x_interpolated, y_interpolated) values 
- Return type:
- tuple[np.ndarray, np.ndarray] 
 - Examples - >>> import numpy as np >>> x = np.array([0, 1, 2]) >>> y = np.array([0, 1, 0]) >>> # Linear interpolation >>> x_interp, y_interp = interpolate_spline(x, y, num_points=5, order=1) >>> print(y_interp) [0. 0.5 1. 0.5 0. ] - >>> # Quadratic interpolation with left endpoint derivative >>> x_interp, y_interp = interpolate_spline(x, y, num_points=5, endpoint_derivatives=(0, None), order=2) >>> print(np.round(y_interp, 3)) [0. 0.25 1. 1.25 0. ] - >>> # Cubic interpolation with both endpoint derivatives >>> x_interp, y_interp = interpolate_spline(x, y, num_points=5, endpoint_derivatives=(0, 0), order=3) >>> print(np.round(y_interp, 3)) [0. 0.5 1. 0.5 0. ] - Inherited Common Usage