{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Checkerboard\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import numpy as np\nfrom opendrift.readers import reader_global_landmask\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\n#reader_norkyst = reader_netCDF_CF_generic.Reader('https://thredds.met.no/thredds/dodsC/sea/norkyst800m/1h/aggregate_be')\nreader_norkyst = reader_netCDF_CF_generic.Reader(o.test_data_folder() + '16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc')\n\no.add_reader([reader_norkyst])\n\no.set_config('drift:vertical_mixing', False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Seeding particles in a checkerboard pattern\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "di = 5 # Horizontal number of particles per square\ndj = 5 # Vertical number of particles per square\nlons = np.linspace(3.5, 5.0, 100)\nlats = np.linspace(60, 61, 100)\n\nii = np.arange(len(lons))//di\njj = np.arange(len(lats))//dj\nii, jj = np.meshgrid(ii, jj)\nboard = (ii+jj)%2 > 0\n\nlons, lats = np.meshgrid(lons, lats)\nlons = lons[board].ravel()\nlats = lats[board].ravel()\n\no.seed_elements(lons, lats, radius=0, number=5000,\n time=reader_norkyst.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=66*2, time_step=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()" ] } ], "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 }