{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# No stranding\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.readers import reader_ROMS_native\nfrom opendrift.models.oceandrift import OceanDrift\n\no = OceanDrift(loglevel=20) # Set loglevel to 0 for debug information\no.set_config('drift:max_speed', 3)\n\n# This example works better using hourly input from Thredds than the daily data from test folder\nreader_current = reader_netCDF_CF_generic.Reader('https://thredds.met.no/thredds/dodsC/cmems/topaz6/dataset-topaz6-arc-15min-3km-be.ncml')\n#reader_current = reader_ROMS_native.Reader(o.test_data_folder() +\n# '2Feb2016_Nordic_sigma_3d/Nordic-4km_SLEVELS_avg_00_subset2Feb2016.nc')\n\no.add_reader([reader_current])\no.set_config('general:coastline_action', 'previous')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Seeding elements on a grid\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "lons = np.linspace(12, 14.5, 30)\nlats = np.linspace(67.5, 68.5, 30)\nlons, lats = np.meshgrid(lons, lats)\nlon = lons.ravel()\nlat = lats.ravel()\n\ntime = reader_current.start_time\no.seed_elements(lon, lat, radius=0, number=30*30, time=time)\n\no.run(steps=24*2, time_step=3600)" ] }, { "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.plot()\n#o.plot(background=['x_sea_water_velocity', 'y_sea_water_velocity'])\no.animation()" ] }, { "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 }