{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Static 2D current field\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from datetime import datetime, timedelta\nimport numpy as np\n\nfrom opendrift.readers.reader_constant_2d import Reader\nfrom opendrift.models.oceandrift import OceanDrift" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Constructing a static, rotating ocean current field, \n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "lon, lat = np.meshgrid(np.linspace(2,6,30), np.linspace(59,62,30))\nlon0 = 4\nlat0 = 60.5\nu = -(lat-lat0)/np.sqrt((lon-lon0)**2 + (lat-lat0)**2)\nv = (lon-lon0)/np.sqrt((lon-lon0)**2 + (lat-lat0)**2)\nlon = np.linspace(0,5,30)\nlat = np.linspace(59,62,30)\n\nr = Reader(x=lon, y=lat, proj4='+proj=latlong',\n array_dict = {'x_sea_water_velocity': u, 'y_sea_water_velocity': v})\n\no = OceanDrift(loglevel=20)\no.set_config('environment:fallback:land_binary_mask', 0)\no.add_reader(r)\no.seed_elements(lon=3, lat=60.5, number=1000, radius=30000, time=datetime.now())\no.run(duration=timedelta(hours=72))\no.animation(fast=True)" ] }, { "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 }