import dascore as dc
# get an example patch which has unevenly sampled coords time, distance
= dc.get_example_patch("wacky_dim_coords_patch")
patch # sort time coordinate (dimension) in ascending order
= patch.sort_coords("time")
time_snap assert time_snap.coords.coord_map['time'].sorted
# sort distance coordinate (dimension) in descending order
= patch.sort_coords("distance", reverse=True)
dist_snap assert dist_snap.coords.coord_map['distance'].reverse_sorted
sort_coords
sort_coords(
patch: Patch ,
*coords ,
reverse = False,
)
Sort one or more coordinates.
Sorts the specified coordinates in the patch. An error will be raised if the coordinates have overlapping dimensions since it may not be possible to sort each. An error is also raised in any of the coordinates are multidimensional.
Parameters
Parameter | Description |
---|---|
*coords | Used to specify the coordinates to sort. |
reverse | If True, sort in descending order, else ascending. |