import dascore as dc
# get an example patch which has unevenly sampled coords time, distance
= dc.get_example_patch("wacky_dim_coords_patch")
patch # snap time dimension
= patch.snap_coords("time")
time_snap # snap the distance dimension
= patch.snap_coords("distance") dist_snap
snap_coords
snap_coords(
patch: Patch ,
*coords ,
reverse = False,
)
Snap coordinates to evenly spaced samples.
This ensures all of the specified coordinates are evenly spaced and monotonic. First, the patch is sorted along specified coordinates, then coordinates are assumed evenly-sampled from their min to max value. Doing this can introduce some error since the coordinate labels are moved and the data (apart from the sorting) are left unchanged. Consider using interpolate for a more expensive but more accurate linear interpolation.
Parameters
Parameter | Description |
---|---|
*coords |
Used to specify the dimension names to convert to CoordRanges. If not specified convert all dimensional coordinates. |
reverse | If True, reverse the sorting of the coordinates. |