import dascore as dc
# get an example patch which has unevenly sampled coords time, distance
patch = dc.get_example_patch("wacky_dim_coords_patch")
# snap time dimension
time_snap = patch.snap_coords("time")
# snap the distance dimension
dist_snap = patch.snap_coords("distance")SnapCoords
SnapCoords(
*args ,
coords: tuple[str, …] = (),
reverse: bool = False,
)-> None
Snap coordinates to evenly spaced samples.
Sorts each specified coordinate, then replaces its labels with evenly spaced values between its endpoints in the selected sort direction. Data remain unchanged after sorting, so snapping can shift labels. Use interpolate when linear interpolation is preferable.
Parameters
| Parameter | Description |
|---|---|
| *coords | Dimensions to snap. By default, snap every dimensional coordinate. |
| reverse | If True, reverse the sorting of the coordinates. |
Examples
Methods
| Name | Description |
|---|---|
| check | Refuse a patch which does not carry what the operation needs. |
| get_metadata | Return the sorted coordinates and the indexing they imply. |
| kernel | Return the data reordered the way the coordinates were. |
| new | Create new instance with some attributed updated. |
| snap_coords | Snap coordinates to evenly spaced samples. |
| reconcile | Return the result’s metadata once the data are known; default as is. |
| run | Run the operation: check, get_metadata, kernel, reconcile, record. |