import numpy as np
import dascore as dc
patch = dc.get_example_patch()
# up-sample time coordinate
time = patch.coords.get_array('time')
time_step = patch.get_coord("time").step
new_time = np.arange(time.min(), time.max(), 0.5 * 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(
*args ,
kind: Any = linear,
**kwargs ,
)-> None
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
Uses scipy.interpolate.interp1d; see its documentation for interpolation details.
Coordinates measured on the interpolated dimension are interpolated with it where they are numbers, and dropped otherwise: a label has nothing between its values, and a time does not survive the trip through floating point.
Interpolation fills across coordinate holes: samples requested inside a gap are interpolated from the samples on either side of it.
See Also
Patch.snap_coords Snap coordinates to evenly sampled values without interpolating data. resample Resample data to a target sampling interval or number of samples.
Examples
Methods
| Name | Description |
|---|---|
| check | Refuse a patch which does not carry what the operation needs. |
| get_metadata | Return the new coordinates, the axis, and both sets of positions. |
| model_copy | Copy the model, dropping cached values the update invalidates. |
| new | Create new instance with some attributed updated. |
| numpy_kernel | Return the data interpolated by scipy at the new positions. |
| interpolate | Set coordinates of patch along a dimension using interpolation. |
| reconcile | Return metadata or a patch holding the final data; default as is. |
| run | Run the operation: check, get_metadata, kernel, reconcile, record. |