Skip to content

Commit 1dfb49c

Browse files
gautehCopilot
andcommitted
README: add figure, quick-start example, and install instructions
- Add Barents Sea drifter figure from published docs - Add mamba and pip install instructions - Add quick-start code snippet covering plot, speed filter, gridtime, and animate - Link to documentation gallery for further examples Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ca40965 commit 1dfb49c

1 file changed

Lines changed: 44 additions & 4 deletions

File tree

README.md

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,50 @@
55
[![PyPI version](https://badge.fury.io/py/trajan.svg)](https://badge.fury.io/py/trajan)
66
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/trajan/badges/version.svg)](https://anaconda.org/conda-forge/trajan)
77

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.
109

11-
Trajectory datasets contain position time series from e.g. drifting buoys, or output from lagrangian models.
10+
![Barents Sea drifter trajectories coloured by speed](https://opendrift.github.io/trajan/_images/sphx_glr_example_drifters_004.png)
1211

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)**.
1454

0 commit comments

Comments
 (0)