{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Grid time\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from datetime import timedelta\nimport 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\n# Seeding at a grid at regular interval\no = OceanDrift(loglevel=20) # Set loglevel to 0 for debug information\n\nreader_norkyst = reader_netCDF_CF_generic.Reader(o.test_data_folder() +\n '16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Landmask\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reader_landmask = reader_global_landmask.Reader()\n\no.add_reader([reader_landmask, reader_norkyst])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Seeding some particles\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "lons = np.linspace(4.4, 4.6, 10)\nlats = np.linspace(60.0, 60.1, 10)\nlons, lats = np.meshgrid(lons, lats)\nlons = lons.ravel()\nlats = lats.ravel()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Seed oil elements on a grid at regular time interval\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "start_time = reader_norkyst.start_time\ntime_step = timedelta(hours=6)\nnum_steps = 10\nfor i in range(num_steps+1):\n o.seed_elements(lons, lats, radius=0, number=100,\n time=start_time + i*time_step)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Running model for 60 hours\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.run(steps=60*4, time_step=900, time_step_output=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.animation(fast=True)" ] }, { "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 }