Skip to content

Commit 2f31ca5

Browse files
committed
doc: doc more methods
1 parent 1094cc0 commit 2f31ca5

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

docs/source/api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ Methods
114114
Dataset.traj.distance_to
115115
Dataset.traj.distance_to_next
116116
Dataset.traj.azimuth_to_next
117+
Dataset.traj.skill
117118
Dataset.traj.velocity_components
119+
Dataset.traj.velocity_spectrum
118120
Dataset.traj.convex_hull
119121
Dataset.traj.convex_hull_contains_point
120122
Dataset.traj.get_area_convex_hull

trajan/traj.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,15 +330,21 @@ def index_of_last(self):
330330
return np.ma.notmasked_edges(np.ma.masked_invalid(self.ds.lon.values),
331331
axis=1)[1][1]
332332

333+
@abstractmethod
333334
def speed(self):
334335
"""Returns the speed [m/s] along trajectories"""
335-
pass
336+
distance = self.distance_to_next()
337+
timedelta_seconds = self.time_to_next() / np.timedelta64(1, 's')
336338

337-
def time_to_next(self):
339+
return distance / timedelta_seconds
340+
341+
@abstractmethod
342+
def time_to_next(self) -> pd.Timedelta:
338343
"""Returns the timedelta between time steps"""
339344
pass
340345

341-
def velocity_spectrum(self):
346+
@abstractmethod
347+
def velocity_spectrum(self) -> xr.DataArray:
342348
pass
343349

344350
# def rotary_spectrum(self):
@@ -510,6 +516,7 @@ def seltime(self, t0=None, t1=None) -> xr.Dataset:
510516
""" Select observations in time window between `t0` and `t1` (inclusive). """
511517

512518

519+
@abstractmethod
513520
@__require_obsdim__
514521
def skill(self, other, method='liu-weissberg', **kwargs) -> xr.DataArray:
515522
"""
@@ -590,4 +597,3 @@ def skill(self, other, method='liu-weissberg', **kwargs) -> xr.DataArray:
590597
method: liu-weissberg
591598
592599
"""
593-
pass

trajan/traj1d.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ def time_to_next(self):
3434
time_step = self.ds.time[1] - self.ds.time[0]
3535
return time_step
3636

37-
def speed(self):
38-
distance = self.distance_to_next()
39-
timedelta_seconds = self.time_to_next() / np.timedelta64(1, 's')
40-
41-
return distance / timedelta_seconds
42-
4337
def velocity_spectrum(self):
4438

4539
if self.ds.sizes['trajectory'] > 1:

0 commit comments

Comments
 (0)