Skip to content

Commit

Permalink
doc: condense_obs
Browse files Browse the repository at this point in the history
  • Loading branch information
gauteh committed Oct 12, 2024
1 parent 95fe217 commit 2ad6378
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
26 changes: 26 additions & 0 deletions trajan/traj.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,3 +745,29 @@ def skill(self, other, method='liu-weissberg', **kwargs) -> xr.Dataset:
Attributes:
method: liu-weissberg
"""

@abstractmethod
def condense_obs(self) -> xr.Dataset:
"""
Move all observations to the first index, so that the observation
dimension is reduced to a minimum. When creating ragged arrays the
observations from consecutive trajectories start at the observation
index after the previous, causing a very long observation dimension.
Original:
.............. Observations --->
trajectory 1: | t01 | t02 | t03 | t04 | t05 | nan | nan | nan | nan |
trajectory 2: | nan | nan | nan | nan | nan | t11 | t12 | t13 | t14 |
After condensing:
.............. Observations --->
trajectory 1: | t01 | t02 | t03 | t04 | t05 |
trajectory 2: | t11 | t12 | t13 | t14 | nan |
Returns:
A new Dataset with observations condensed.
"""

24 changes: 1 addition & 23 deletions trajan/traj2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,29 +134,7 @@ def drop_where(self, condition):
return xr.concat(trajs, dim='trajectory')

@__require_obsdim__
def condense_obs(self):
"""
Move all observations to the first index, so that the observation
dimension is reduced to a minimum. When creating ragged arrays the
observations from consecutive trajectories start at the observation
index after the previous, causing a very long observation dimension.
Original:
.............. Observations --->
trajectory 1: | t01 | t02 | t03 | t04 | t05 | nan | nan | nan | nan |
trajectory 2: | nan | nan | nan | nan | nan | t11 | t12 | t13 | t14 |
After condensing:
.............. Observations --->
trajectory 1: | t01 | t02 | t03 | t04 | t05 |
trajectory 2: | t11 | t12 | t13 | t14 | nan |
Returns:
A new Dataset with observations condensed.
"""
def condense_obs(self) -> xr.Dataset:

on = self.ds.sizes[self.obsdim]
logger.debug(f'Condensing {on} observations.')
Expand Down

0 comments on commit 2ad6378

Please sign in to comment.