import pandas as pd
import dascore as dc
# Add a coordinate specifying the distance to a theoretical shot.
= pd.Series({"x": 10, "y": 10, "z": 0})
shot = dc.get_example_patch("random_patch_with_xyz")
patch = patch.add_distance_to(shot)
patch_with_origin_dist # Now the new coordinates of distance and shot origin exist.
= patch_with_origin_dist.get_array("origin_distance")
dist = patch_with_origin_dist.get_array("origin_x")
origin_x
# Of course, the new coordinate can be used for sorting.
= patch_with_origin_dist.sort_coords("origin_distance") sorted_patch
add_distance_to
add_distance_to(
patch: Patch ,
origin: Series ,
ord = None,
prefix: str = origin,
)-> ‘PatchType’
Calculate the distance to “origin” and create new coordinate.
A new coordinate called origin_distance
(or another name controlled by the pre-fix argument) is added to the output patch to specify the exact distance. Coordinates representing the origin location (eg origin_x, origin_y, origin_z) are also added as non-associated coordinates.
Parameters
Parameter | Description |
---|---|
patch |
The patch object which contains some overlap in coordiantes as index names in origin. |
origin |
A series which contains index names that overlap with patch coordinates. All the referenced coordinates must be associated with the same dimension. |
ord |
Controls the norm type. Default is Frobenius norm, see the norm function of numpy.linalg for supported options. |
prefix | The prefix name for the added coordinates and attributes. |