|
5 | 5 | [](https://badge.fury.io/py/trajan) |
6 | 6 | [](https://anaconda.org/conda-forge/trajan) |
7 | 7 |
|
8 | | -TrajAn is a Python package with functionality to handle trajectory datasets following the CF-conventions on trajectories: |
9 | | -http://cfconventions.org/Data/cf-conventions/cf-conventions-1.10/cf-conventions.html#trajectory-data |
| 8 | +TrajAn is a Python package for working with trajectory datasets that follow the [CF-conventions for trajectories](http://cfconventions.org/Data/cf-conventions/cf-conventions-1.10/cf-conventions.html#trajectory-data). Trajectory datasets contain position time series from e.g. drifting buoys or output from Lagrangian models. |
10 | 9 |
|
11 | | -Trajectory datasets contain position time series from e.g. drifting buoys, or output from lagrangian models. |
| 10 | + |
12 | 11 |
|
13 | | -[Documentation and demonstration can be found here](https://opendrift.github.io/trajan/gallery) |
| 12 | +## Installation |
| 13 | + |
| 14 | +**conda / mamba** (recommended): |
| 15 | +```bash |
| 16 | +mamba install -c conda-forge trajan |
| 17 | +``` |
| 18 | + |
| 19 | +**pip**: |
| 20 | +```bash |
| 21 | +pip install trajan |
| 22 | +``` |
| 23 | + |
| 24 | +## Quick start |
| 25 | + |
| 26 | +TrajAn exposes a `.traj` accessor on xarray Datasets: |
| 27 | + |
| 28 | +```python |
| 29 | +import lzma |
| 30 | +import xarray as xr |
| 31 | +import trajan as ta |
| 32 | + |
| 33 | +# Open a CF-trajectory dataset (e.g. from drifting buoys) |
| 34 | +with lzma.open("barents.nc.xz") as f: |
| 35 | + ds = xr.open_dataset(f) |
| 36 | + ds.load() |
| 37 | + |
| 38 | +# Basic map plot — geographic projection is chosen automatically |
| 39 | +ds.traj.plot() |
| 40 | + |
| 41 | +# Calculate drifter speed, drop unreliable fixes, and plot coloured by speed |
| 42 | +ds = ds.traj.drop_where(ds.traj.time_to_next() < np.timedelta64(5, "m")) |
| 43 | +speed = ds.traj.speed() |
| 44 | +ds.traj.plot(color=speed) |
| 45 | + |
| 46 | +# Interpolate to a regular 1-hour time grid |
| 47 | +dh = ds.traj.gridtime("1h") |
| 48 | + |
| 49 | +# Animate the trajectories |
| 50 | +ds.traj.animate().show() |
| 51 | +``` |
| 52 | + |
| 53 | +For more examples and the full API reference see the **[documentation](https://opendrift.github.io/trajan/gallery)**. |
14 | 54 |
|
0 commit comments