{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Oil in ice\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\nimport cmocean\n\no = OpenOil(loglevel=20)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Using live data from Barents 2.5 km ocean model\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.add_readers_from_list(['https://thredds.met.no/thredds/dodsC/fou-hi/barents_eps_zdepth_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', False)\no.set_config('processes:evaporation', False)\no.set_config('processes:emulsification', False)\no.set_config('drift:horizontal_diffusivity', 10)\no.set_config('drift:truncate_ocean_model_below_m', 3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Imaginary oil spill in Hinlopen strait\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.seed_elements(lon=19.1909, lat=79.5986, radius=50,\n number=3000, time=datetime.utcnow() - timedelta(days=7))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Running model\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.run(duration=timedelta(hours=48), 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)\no.animation(background='sea_ice_area_fraction', cmap=cmocean.cm.ice,\n vmin=0, vmax=1, bgalpha=1, fast=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.plot(background='sea_ice_area_fraction', cmap=cmocean.cm.ice,\n vmin=0, vmax=1, bgalpha=1, fast=False)" ] } ], "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 }