Skip to content

Conversation

knutfrode
Copy link
Contributor

…tration in example_drifter.py

@knutfrode
Copy link
Contributor Author

Demonstration of contained_in:

from datetime import datetime
import xarray as xr
import trajan as _
import matplotlib.pyplot as plt

ds = xr.open_dataset('dataset_trajectories_to_use.nc')
# A subset of trajectories contained in a box
dc = ds.traj.contained_in(lonmin=-55, lonmax=0, latmin=40, latmax=60)
# Combining the above with a temporal selection (2022 only)
dct = ds.traj.seltime(t0=datetime(2022,1,1), t1=datetime(2023,1,1)
        ).traj.contained_in(lonmin=-55, lonmax=0, latmin=40, latmax=60)

ds.traj.plot(color='k', label='Full dataset')
dc.traj.plot(color='r', label='Subset')
dct.traj.plot(color='g', label='Subset for 2022 only')

plt.show()

darpa

@knutfrode knutfrode merged commit 9d2fe64 into OpenDrift:main Nov 15, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant