Copernicus marine client

This example runs an OceanDrift simulation with current data from CMEMS To run this example, you need a CMEMS account created at and the copernicus_marine_client installed from

from datetime import datetime, timedelta
import copernicus_marine_client as copernicusmarine
from opendrift.readers.reader_netCDF_CF_generic import Reader
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()

First get a Xarray dataset from copernicus_marine_client

ds = copernicusmarine.open_dataset(
    username='<your cmems username>', password='<your cmems password>')

Then create an OpenDrift reader from this dataset

r = Reader(ds)

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'])

Gallery generated by Sphinx-Gallery