Skip to content

Commit 54b5c7d

Browse files
committed
traj: add gridobs abstract method
1 parent 9ee375e commit 54b5c7d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

docs/source/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ Methods
121121
Dataset.traj.convex_hull_contains_point
122122
Dataset.traj.get_area_convex_hull
123123
Dataset.traj.gridtime
124+
Dataset.traj.gridobs
124125
Dataset.traj.seltime
125126
Dataset.traj.iseltime
126127
Dataset.traj.is_1d

trajan/traj.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,21 @@ def gridtime(self, times, timedim=None) -> xr.Dataset:
666666
A new dataset interpolated to the target times. The dataset will be 1D (i.e. gridded) and the time dimension will be named `time`.
667667
"""
668668

669+
@abstractmethod
670+
def gridobs(self, times) -> xr.Dataset:
671+
"""Interpolate dataset to observation times.
672+
673+
Parameters
674+
----------
675+
times : DataArray (trajectory, obs)
676+
A time variable with the target times for each trajectory.
677+
678+
Returns
679+
-------
680+
Dataset
681+
A new dataset interpolated to the target times. The dataset will be 2D (i.e. observational).
682+
"""
683+
669684
@abstractmethod
670685
def seltime(self, t0=None, t1=None) -> xr.Dataset:
671686
"""Select observations in time window between `t0` and `t1` (inclusive). For 1D datasets prefer to use `xarray.Dataset.sel`.

0 commit comments

Comments
 (0)