import numpy as np
import dascore as dc
= dc.get_example_patch()
patch # up-sample time coordinate
= patch.coords.get_array('time')
time = np.arange(time.min(), time.max(), 0.5*patch.attrs.time_step)
new_time = patch.interpolate(time=new_time)
patch_uptime # interpolate unevenly sampled dim to evenly sampled
= dc.get_example_patch("wacky_dim_coords_patch")
patch = patch.interpolate(time=None) patch_time_even
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.