Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement compute_speed and compute_path_length #280

Merged
merged 18 commits into from
Nov 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change 'any' to 'all'
  • Loading branch information
niksirbi authored and lochhh committed Nov 5, 2024
commit 87df402745d800f8967c4d0d5070b039a58c4eb0
6 changes: 3 additions & 3 deletions movement/kinematics.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def compute_speed(data: xr.DataArray) -> xr.DataArray:
-------
xarray.DataArray
An xarray DataArray containing the computed speed,
with dimensions matching those of the input data,
with dimensions matching those of the input data,
except ``space`` is removed.

"""
Expand Down Expand Up @@ -740,7 +740,7 @@ def compute_path_length(
-------
xarray.DataArray
An xarray DataArray containing the computed path length,
with dimensions matching those of the input data,
with dimensions matching those of the input data,
except ``time`` and ``space`` are removed.

Notes
Expand Down Expand Up @@ -900,7 +900,7 @@ def _compute_scaled_path_length(
# Skip first displacement segment (always 0) to not mess up the scaling
displacement = compute_displacement(data).isel(time=slice(1, None))
# count number of valid displacement segments per point track
valid_segments = (~displacement.isnull()).any(dim="space").sum(dim="time")
valid_segments = (~displacement.isnull()).all(dim="space").sum(dim="time")
# compute proportion of valid segments per point track
valid_proportion = valid_segments / (data.sizes["time"] - 1)
# return scaled path length
Expand Down