diff --git a/trajan/traj.py b/trajan/traj.py index 6b80b94..b99990c 100644 --- a/trajan/traj.py +++ b/trajan/traj.py @@ -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. + """ + diff --git a/trajan/traj2d.py b/trajan/traj2d.py index 809c2fc..54ed365 100644 --- a/trajan/traj2d.py +++ b/trajan/traj2d.py @@ -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.')