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.
conda / mamba (recommended):
mamba install -c conda-forge trajanpip:
pip install trajanTrajAn 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.
