Skip to content

OpenDrift/trajan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

756 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trajectory analysis ( TrajAn )

Build (python) Docs PyPI version Anaconda-Server Badge

TrajAn is a Python package for working with trajectory datasets that follow the CF-conventions for trajectories. Trajectory datasets contain position time series from e.g. drifting buoys or output from Lagrangian models.

Barents Sea drifter trajectories coloured by speed

Installation

conda / mamba (recommended):

mamba install -c conda-forge trajan

pip:

pip install trajan

Quick start

TrajAn exposes a .traj accessor on xarray Datasets:

import xarray as xr
import trajan as ta

# Open a CF-trajectory dataset (e.g. from drifting buoys)
ds = xr.open_dataset('barents.nc')

# Basic map plot — geographic projection is chosen automatically
ds.traj.plot()

# Calculate drifter speed, drop unreliable fixes, and plot coloured by speed
ds = ds.traj.drop_where(ds.traj.time_to_next() < np.timedelta64(5, "m"))
speed = ds.traj.speed()
ds.traj.plot(color=speed)

# Interpolate to a regular 1-hour time grid
dh = ds.traj.gridtime("1h")

# Animate the trajectories
ds.traj.animate().show()

For more examples and the full API reference see the documentation.

About

Trajectory analysis package for simulated and observed trajectories

Resources

License

Stars

21 stars

Watchers

4 watching

Forks

Packages

 
 
 

Contributors

Languages