Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made method to crop dataset to a given region. Added tests and demons… #147

Merged
merged 2 commits into from
Nov 15, 2024

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