{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Drift at different depths\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from datetime import datetime, timedelta\nimport numpy as np\nfrom opendrift.models.oceandrift import OceanDrift\n\no = OceanDrift(loglevel=20) # Set loglevel to 0 for debug information" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Using live data from Thredds\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.add_readers_from_list([\n 'https://thredds.met.no/thredds/dodsC/sea/norkyst800m/1h/aggregate_be'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Adding some diffusion\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.set_config('drift:horizontal_diffusivity', 10) # m2/s" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Seed 1000 elements at random depths\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "z = -np.random.rand(2000)*50\no.seed_elements(lon=4.8, lat=60.0, z=z, radius=0, number=2000,\n time=datetime.utcnow())\n\nprint(o)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Running model\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.run(duration=timedelta(hours=24), time_step=1800)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plot results with lines and particles colored by depth\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(o)\no.plot(linecolor='z', buffer=.1, show_elements=False, fast=False)\no.animation(color='z', buffer=.1, 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 }