{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Copernicus marine client\n\nThis example runs an OceanDrift simulation\nwith current data from CMEMS\nTo run this example, you need a CMEMS account created at\nhttps://marine.copernicus.eu\nand the copernicus_marine_client installed from\nhttps://pypi.org/project/copernicusmarine\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from datetime import datetime, timedelta\nimport copernicus_marine_client as copernicusmarine\nfrom opendrift.readers.reader_netCDF_CF_generic import Reader\nfrom opendrift.models.oceandrift import OceanDrift\n\nlon = 4.8; lat = 60 # Bergen, Norway\nlon = -89; lat = 29.8 # New Orleans\nlon = 107; lat = 10 # Ho Chi Minh\nlon = 123; lat = -16.3 # Australia\n\n\no = OceanDrift()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First get a Xarray dataset from copernicus_marine_client\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ds = copernicusmarine.open_dataset(\n dataset_id='cmems_mod_glo_phy_anfc_merged-uv_PT1H-i',\n username='', password='')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Then create an OpenDrift reader from this dataset\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "r = Reader(ds)\no.add_reader(r)\n\no.seed_elements(lon=lon, lat=lat, number=5000, radius=1000, time=datetime.utcnow())\no.run(duration=timedelta(days=3))\n\no.animation(fast=True, clabel='Ocean current [m/s]',\n background=['x_sea_water_velocity', 'y_sea_water_velocity'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.6" } }, "nbformat": 4, "nbformat_minor": 0 }