Skip to content

Commit 65c1f11

Browse files
committed
More updated docstrings
1 parent f82e501 commit 65c1f11

File tree

2 files changed

+60
-20
lines changed

2 files changed

+60
-20
lines changed

docs/source/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@
104104
"sequence": ":term:`sequence`",
105105
"iterable": ":term:`iterable`",
106106
"callable": ":py:func:`callable`",
107-
"dict_like": ":term:`dict-like <mapping>`",
108107
"dict-like": ":term:`dict-like <mapping>`",
109108
"path-like": ":term:`path-like <path-like object>`",
110109
"mapping": ":term:`mapping`",

trajan/traj.py

Lines changed: 60 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -280,12 +280,22 @@ def set_crs(self, crs) -> xr.Dataset:
280280
return ds
281281

282282
@abstractmethod
283-
def is_1d(self):
284-
"""Returns True if dataset is 1D, i.e. time is a 1D coordinate variable."""
283+
def is_1d(self) -> bool:
284+
"""Returns True if dataset is 1D, i.e. time is a 1D coordinate variable.
285+
286+
Returns
287+
-------
288+
bool
289+
"""
285290

286291
@abstractmethod
287-
def is_2d(self):
288-
"""Returns True if dataset is 2D, i.e. time is a 2D variable and not a coordinate variable."""
292+
def is_2d(self) -> bool:
293+
"""Returns True if dataset is 2D, i.e. time is a 2D variable and not a coordinate variable.
294+
295+
Returns
296+
-------
297+
bool
298+
"""
289299

290300
def assign_cf_attrs(self,
291301
creator_name=None,
@@ -396,8 +406,8 @@ def time_to_next(self) -> pd.Timedelta:
396406
397407
Returns
398408
-------
399-
xarray.DataArray
400-
Scalar timedelta for 1D objects, and DataArray of same size as input for 2D objects
409+
DataArray
410+
Scalar timedelta for 1D objects (fixed timestep), and DataArray of same size as input for 2D objects
401411
402412
See Also
403413
--------
@@ -418,13 +428,18 @@ def distance_to(self, other) -> xr.Dataset:
418428
419429
Parameters
420430
----------
421-
other : xarray.DataSet
431+
other : Dataset
422432
Other dataset to which distance is calculated
423433
424434
Returns
425435
-------
426-
xarray.Dataset
427-
Same dimensions as original dataset
436+
Dataset
437+
Same dimensions as original dataset, containing three DataArrays from pyproj.geod.inv:
438+
distance : distance [meters]
439+
440+
az_fwd : forward azimuth angle [degrees]
441+
442+
az_bwd : backward azimuth angle [degrees]
428443
429444
See Also
430445
--------
@@ -456,18 +471,18 @@ def distance_to(self, other) -> xr.Dataset:
456471
return ds
457472

458473
def distance_to_next(self):
459-
"""Returns distance in m from one position to the next.
474+
"""Returns distance in meters from one position to the next along trajectories.
460475
461-
Last time is repeated for last position (which has no next position)
476+
Last time is repeated for last position (which has no next position).
462477
463478
Returns
464479
-------
465-
xarray.DataArray
466-
Same dimensions as original dataset, since last value is repeated along time dimension
480+
DataArray
481+
Same dimensions as original Dataset, since last value is repeated along time dimension.
467482
468483
See Also
469484
--------
470-
time_to_next, speed
485+
azimuth_to_next, time_to_next, speed
471486
472487
"""
473488

@@ -490,7 +505,16 @@ def distance_to_next(self):
490505
def azimuth_to_next(self):
491506
"""Returns azimution travel direction in degrees from one position to the next.
492507
493-
Last time is repeated for last position (which has no next position)
508+
Last time is repeated for last position (which has no next position).
509+
510+
Returns
511+
-------
512+
DataArray
513+
Same dimensions as original Dataset, since last value is repeated along time dimension.
514+
515+
See Also
516+
--------
517+
distance_to_next, time_to_next, speed
494518
"""
495519

496520
# TODO: method is almost duplicate of "distance_to_next" above
@@ -516,7 +540,12 @@ def azimuth_to_next(self):
516540
def velocity_components(self):
517541
"""Returns velocity components [m/s] from one position to the next.
518542
519-
Last time is repeated for last position (which has no next position)
543+
Last time is repeated for last position (which has no next position)
544+
545+
Returns
546+
-------
547+
(u, v) : array_like
548+
East and north components of velocities at given position along trajectories.
520549
"""
521550
speed = self.speed()
522551
azimuth = self.azimuth_to_next()
@@ -557,7 +586,7 @@ def convex_hull_contains_point(self, lon, lat):
557586
558587
Parameters
559588
----------
560-
lon, lat scalars
589+
lon, lat : scalar
561590
longitude and latitude [degrees] of a position.
562591
563592
Returns
@@ -575,7 +604,13 @@ def convex_hull_contains_point(self, lon, lat):
575604
return p.contains_points(point)[0]
576605

577606
def get_area_convex_hull(self):
578-
"""Return the area [m2] of the convex hull spanned by all particles."""
607+
"""Return the area [m2] of the convex hull spanned by all positions.
608+
609+
Returns
610+
-------
611+
scalar
612+
Area [m2] of convex hull around all positions.
613+
"""
579614

580615
from scipy.spatial import ConvexHull
581616

@@ -621,7 +656,13 @@ def gridtime(self, times, timedim = None) -> xr.Dataset:
621656

622657
@abstractmethod
623658
def seltime(self, t0=None, t1=None) -> xr.Dataset:
624-
""" Select observations in time window between `t0` and `t1` (inclusive). """
659+
""" Select observations in time window between `t0` and `t1` (inclusive).
660+
661+
Parameters
662+
----------
663+
t0, t1 : numpy.datetime64
664+
Test
665+
"""
625666

626667

627668
@abstractmethod

0 commit comments

Comments
 (0)