This example runs an OceanDrift simulation with current data from CMEMS To run this example, you need a CMEMS account created at with username and password stored in a .netrc file with contents:

machine login <your username> password <your password>

This file must be stored in your home folder and made unreadable by others with chmod 700 .netrc Additionally, a file .dodsrc must also be stored in your home folder, containing the following line:

HTTP.NETRC=<path to your .netrc file>
from datetime import datetime, timedelta
from opendrift.models.oceandrift import OceanDrift

lon = 4.8; lat = 60  # Bergen, Norway
lon = -89; lat = 29.8  # New Orleans
lon = 107; lat = 10  # Ho Chi Minh
lon = 123; lat = -16.3  # Australia

o = OceanDrift()


o.seed_elements(lon=lon, lat=lat, number=5000, radius=1000, time=datetime.utcnow())

o.animation(fast=True, clabel='Ocean current [m/s]',
            background=['x_sea_water_velocity', 'y_sea_water_velocity'])

Total running time of the script: (0 minutes 0.000 seconds)

Gallery generated by Sphinx-Gallery