{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Reader boundary\n\nSeeding elements around the border of a ocean model domain (NorKyst800)\nto demonstrate autmatic transition back and forth with another model\ncovering a larger domain (Topaz).\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\nfrom opendrift.readers import reader_netCDF_CF_generic\nfrom opendrift.models.oceandrift import OceanDrift\n\no = OceanDrift(loglevel=20) # Set loglevel to 0 for debug information\n\n# Norkyst\nreader_norkyst = reader_netCDF_CF_generic.Reader('https://thredds.met.no/thredds/dodsC/sea/norkyst800m/1h/aggregate_be')\n\n# Topaz\nreader_topaz = reader_netCDF_CF_generic.Reader('https://thredds.met.no/thredds/dodsC/cmems/topaz6/dataset-topaz6-arc-15min-3km-be.ncml')\n\no.add_reader([reader_norkyst, reader_topaz])\no.set_config('environment:fallback:land_binary_mask', 0)\no.set_config('drift:vertical_mixing', False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Seeding some particles\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "lons = np.linspace(10.2, 12.2, 50)\nlats = np.linspace(69.8, 70.8, 50)\nlons, lats = np.meshgrid(lons, lats)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Seed oil elements at defined position and time\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.seed_elements(lons, lats, radius=0, number=2500,\n time=reader_topaz.start_time)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Running model\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.run(steps=16*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(fast=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.plot(fast=True)" ] } ], "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 }