{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Double gyre - Lagrangian Coherent Structures\n\nCalculating attracting and repelling LCS for an idealised (analytical) eddy current field.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from datetime import datetime, timedelta\nimport matplotlib.pyplot as plt\n\nfrom opendrift.readers import reader_double_gyre\nfrom opendrift.models.oceandrift import OceanDrift\n\no = OceanDrift(loglevel=20) # Set loglevel to 0 for debug information\n\no.set_config('environment:fallback:land_binary_mask', 0)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that Runge-Kutta here makes a difference to Euler scheme\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.set_config('drift:advection_scheme', 'runge-kutta4')\n\ndouble_gyre = reader_double_gyre.Reader(epsilon=.25, omega=0.628, A=0.1)\nprint(double_gyre)\n\no.add_reader(double_gyre)\n\nlcs = o.calculate_ftle(time=double_gyre.initial_time+timedelta(seconds=3),\n time_step=timedelta(seconds=.5),\n duration=timedelta(seconds=15),\n delta=.02)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "These plots should reproduce Mov 12 on this page:\nhttps://shaddenlab.berkeley.edu/uploads/LCS-tutorial/examples.html\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "plt.subplot(2,1,1)\nplt.imshow(lcs['RLCS'][0,:,:], interpolation='nearest', cmap='jet', origin='lower')\nplt.colorbar()\nplt.title('Repelling LCS (forwards)')\nplt.subplot(2,1,2)\nplt.imshow(lcs['ALCS'][0,:,:], interpolation='nearest', cmap='jet', origin='lower')\nplt.colorbar()\nplt.title('Attracting LCS (backwards)')\nplt.show()" ] } ], "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 }