{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Cone seeding\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from datetime import datetime, timedelta\nfrom opendrift.readers import reader_netCDF_CF_generic\nfrom opendrift.models.openoil import OpenOil\n\no = OpenOil(loglevel=20) # Set loglevel to 0 for debug information" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Using live data from Thredds\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.add_readers_from_list([\n 'https://thredds.met.no/thredds/dodsC/sea/norkyst800m/1h/aggregate_be'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Adjusting some configuration\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.set_config('processes:dispersion', True)\no.set_config('processes:evaporation', False)\no.set_config('processes:emulsification', True)\no.disable_vertical_motion()\n#o.set_config('drift:vertical_mixing', False)\n#o.set_config('drift:vertical_mixing', False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Seed elements along cone, e.g. ship track with\nincreasing uncertainty in position\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "latstart = 68.988911\nlonstart = 16.040701\nlatend = 69.991446\nlonend = 17.760061\ntime = [datetime.utcnow(), datetime.utcnow() + timedelta(hours=12)]\no.seed_cone(lon=[lonstart, lonend], lat=[latstart, latend],\n oil_type='EKOFISK', radius=[100, 800], number=10000, time=[time])\n\nprint(o)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Running model for 24 hours\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.run(steps=24*2, time_step=1800, 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)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Add text label on the map\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "text = [{'s': 'Senja', 'x': 17.3, 'y': 69.3, 'fontsize': 20, 'color': 'g',\n 'backgroundcolor': 'white', 'bbox': dict(facecolor='white', alpha=0.8), 'zorder': 1000}]\n\no.animation(fast=False, ocean_color='skyblue', land_color='burlywood', text=text)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.plot(fast=True, ocean_color='skyblue', land_color='dimgray', text=text)" ] } ], "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 }