import numpy as np
import dascore as dc
patch = dc.get_example_patch()
# up-sample time coordinate
time = patch.coords.get_array('time')
new_time = np.arange(time.min(), time.max(), 0.5*patch.attrs.time_step)
patch_uptime = patch.interpolate(time=new_time)
# interpolate unevenly sampled dim to evenly sampled
patch = dc.get_example_patch("wacky_dim_coords_patch")
patch_time_even = patch.interpolate(time=None)interpolate
interpolate(
patch: Patch ,
kind: str | int[str, int] = linear,
**kwargs ,
)-> ‘PatchType’
Set coordinates of patch along a dimension using interpolation.
Parameters
| Parameter | Description |
|---|---|
| patch | The patch object to which interpolation is applied. |
| kind |
The type of interpolation. See Notes for more details. If a string, the following are supported: linear - linear interpolation between a pair of points. nearest - use the nearest sample for interpolation. If an int, it specifies the order of spline to use. EG 1 is a linear spline, 2 is quadratic, 3 is cubic, etc. |
| **kwargs |
Used to specify dimension and interpolation values. Use a value of None to “snap” coordinate to evenly sampled points along coordinate. |
Note
This function just uses scipy’s interp1d function under the hood. See scipy.interpolate.interp1d for information.
See also snap.