From 3b15ff80296903541b9c472d1b50d5a67c3b97a4 Mon Sep 17 00:00:00 2001 From: Andi Gerken <andi.gerken@gmail.com> Date: Tue, 22 Jun 2021 14:30:06 +0200 Subject: [PATCH] Changed docs for actions_speeds_turns to state cm/frame and rad/frame instead of cm/s and rad/frame --- docs/entity.md | 16 ++++++++-------- docs/index.md | 16 ++++++++-------- src/robofish/io/entity.py | 7 ++----- src/robofish/io/file.py | 9 +++++++++ 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/docs/entity.md b/docs/entity.md index ce37847..8a035d8 100644 --- a/docs/entity.md +++ b/docs/entity.md @@ -63,14 +63,14 @@ As described in `robofish.io`, Files and Entities have useful properties. <small> -| Entity function | Description | -| ------------------------------------------------ | ------------------------------------------------------------------------ | -| `robofish.io.entity.Entity.positions` | Positions as a `(timesteps, 2 (x, y))` array. | -| `robofish.io.entity.Entity.orientations` | Orientations as a `(timesteps, 2 (ori_x, ori_y))` array. | -| `robofish.io.entity.Entity.orientations_rad` | Orientations as a `(timesteps, 1 (ori_rad))` array. | -| `robofish.io.entity.Entity.poses` | Poses as a `(timesteps, 4 (x, y, x_ori, y_ori))` array. | -| `robofish.io.entity.Entity.poses_rad` | Poses as a `(timesteps, 3(x, y, ori_rad))` array. | -| `robofish.io.entity.Entity.actions_speeds_turns` | Speed and turn as a `(timesteps - 1, 2 (speed_cm/s, turn_rad/s))` array. | +| Entity function | Description | +| ------------------------------------------------ | -------------------------------------------------------------------------------------- | +| `robofish.io.entity.Entity.positions` | Positions as a `(timesteps, 2 (x, y))` array. | +| `robofish.io.entity.Entity.orientations` | Orientations as a `(timesteps, 2 (ori_x, ori_y))` array. | +| `robofish.io.entity.Entity.orientations_rad` | Orientations as a `(timesteps, 1 (ori_rad))` array. | +| `robofish.io.entity.Entity.poses` | Poses as a `(timesteps, 4 (x, y, x_ori, y_ori))` array. | +| `robofish.io.entity.Entity.poses_rad` | Poses as a `(timesteps, 3(x, y, ori_rad))` array. | +| `robofish.io.entity.Entity.actions_speeds_turns` | Speed and turn as a `(timesteps - 1, 2 (speed in cm/frame, turn in rad/frame))` array. | </small> diff --git a/docs/index.md b/docs/index.md index b4a967d..a6bcde6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -124,14 +124,14 @@ In the same scheme the following properties are available: <small> -| File/ Entity function | Description | -| ----------------------------- | ------------------------------------------------------------------------------------ | -| *entity_*positions | Positions as a `(*entities*, timesteps, 2 (x, y))` arary. | -| *entity_*orientations | Orientations as a `(*entities*, timesteps, 2 (ori_x, ori_y))` arary. | -| *entity_*orientations_rad | Orientations as a `(*entities*, timesteps, 1 (ori_rad))` arary. | -| *entity_*poses | Poses as a `(*entities*, timesteps, 4 (x, y, x_ori, y_ori))` array. | -| *entity_*poses_rad | Poses as a `(*entities*, timesteps, 3(x, y, ori_rad))` array. | -| *entity_*actions_speeds_turns | Speed and turn as a `(*entities*, timesteps - 1, 2 (speed_cm/s, turn_rad/s))` array. | +| File/ Entity function | Description | +| ----------------------------- | -------------------------------------------------------------------------------------------------- | +| *entity_*positions | Positions as a `(*entities*, timesteps, 2 (x, y))` array. | +| *entity_*orientations | Orientations as a `(*entities*, timesteps, 2 (ori_x, ori_y))` array. | +| *entity_*orientations_rad | Orientations as a `(*entities*, timesteps, 1 (ori_rad))` array. | +| *entity_*poses | Poses as a `(*entities*, timesteps, 4 (x, y, x_ori, y_ori))` array. | +| *entity_*poses_rad | Poses as a `(*entities*, timesteps, 3(x, y, ori_rad))` array. | +| *entity_*actions_speeds_turns | Speed and turn as a `(*entities*, timesteps - 1, 2 (speed in cm/frame, turn in rad/frame))` array. | </small> diff --git a/src/robofish/io/entity.py b/src/robofish/io/entity.py index f1b836a..21d157d 100644 --- a/src/robofish/io/entity.py +++ b/src/robofish/io/entity.py @@ -241,15 +241,12 @@ class Entity(h5py.Group): def actions_speeds_turns(self): """Calculate the speed, turn and from the recorded positions and orientations. - The turn is calculated by the change of orientation. + The turn is calculated by the change of orientation between frames. The speed is calculated by the distance between the points, projected on the new orientation vector. The sideway change of position cannot be represented with this method. Returns: - An array with shape (number_of_positions -1, 3). - The first column is the speed (distance projected on new orientation). - The second column is the turning angle. - + An array with shape (number_of_positions -1, 2 (speed in cm/frame, turn in rad/frame). """ ori = self.orientations diff --git a/src/robofish/io/file.py b/src/robofish/io/file.py index ff211af..822f015 100644 --- a/src/robofish/io/file.py +++ b/src/robofish/io/file.py @@ -463,6 +463,15 @@ class File(h5py.File): @property def entity_actions_speeds_turns(self): + """Calculate the speed, turn and from the recorded positions and orientations. + + The turn is calculated by the change of orientation between frames. + The speed is calculated by the distance between the points, projected on the new orientation vector. + The sideway change of position cannot be represented with this method. + + Returns: + An array with shape (number_of_entities, number_of_positions -1, 2 (speed in cm/frame, turn in rad/frame). + """ return self.select_entity_property( None, entity_property=Entity.actions_speeds_turns ) -- GitLab