{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Coastline interaction\n\nExample to illustrate stranding options using an artificial\neast-west oscillating current field\nKnut-Frode Dagestad, Feb 2017\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from datetime import datetime\nfrom opendrift.readers import reader_oscillating\nfrom opendrift.models.oceandrift import OceanDrift\n\no = OceanDrift(loglevel=50) # Set loglevel to 0 for debug information\n\nreader_osc = reader_oscillating.Reader('x_sea_water_velocity', amplitude=1,\n zero_time=datetime.utcnow())\no.add_reader([reader_osc]) # Oscillating east-west current component\n\no.set_config('environment:fallback:y_sea_water_velocity', .2) # Adding northwards drift" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Try different options: 'previous', 'stranding', 'none'\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.set_config('general:coastline_action', 'previous')\n\no.seed_elements(lon=12.2, lat=67.7, radius=5000, number=25, time=reader_osc.zero_time)\n\no.run(steps=36*4, time_step=900, time_step_output=1800)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Print and plot results\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "print(o)\no.animation()\no.plot()" ] }, { "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 }