{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Openoil\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, location='Norway')\n\nprint(o.oiltypes) # Print available oil types" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Arome atmospheric model\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reader_arome = reader_netCDF_CF_generic.Reader(o.test_data_folder() +\n '16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc')\n# Norkyst ocean model\nreader_norkyst = reader_netCDF_CF_generic.Reader(o.test_data_folder() +\n '16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc')\no.add_reader([reader_norkyst, reader_arome])" ] }, { "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:evaporation', True)\no.set_config('processes:emulsification', True)\no.set_config('drift:vertical_mixing', True)\no.set_config('vertical_mixing:timestep', 5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Seeding some particles\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "time = reader_arome.start_time\noil_type = 'HEIDRUN AARE 2023'\no.seed_elements(lon=4.9, lat=60.1, radius=3000, number=2000,\n time=time, z=0, oil_type=oil_type)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Running model\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.run(steps=4*40, 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.plot(fast=True)\no.plot_oil_budget()\n#o.plot(filename='openoil_drift')\no.plot_vertical_distribution(maxnum=100,bins=50)\no.plot_property('water_fraction', mean=True)\no.plot_property('z')\n#o.plot_property('mass_evaporated')\n#o.plot_property('water_fraction')\n#o.plot_property('interfacial_area')\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 }