{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Icebergs (openberg)\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from datetime import datetime, timedelta\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport opendrift\nfrom opendrift.models.openberg import OpenBerg" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Currents and wind forcing\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "forcing = ['https://thredds.met.no/thredds/dodsC/fou-hi/barents_eps_zdepth_be']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A permutation of iceberg sizes/dimensions\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "n = 10\nlengths = np.linspace(50, 500, n)\nwidths = np.linspace(20, 200, n)\nsails = np.linspace(5, 50, n)\ndrafts = np.linspace(2, 120, n)\nlengths, widths, sails, drafts = np.meshgrid(lengths, widths, sails, drafts)\n\nicebergs = {'lon': 18.127, 'lat': 74.776, 'time': datetime.now(),\n 'number': lengths.size, 'radius': 500,\n 'sail': sails, 'draft': drafts, 'length': lengths, 'width': widths}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Simulating drift for 48 hours\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o = OpenBerg()\no.set_config('drift:vertical_profile', False)\no.set_config('environment:constant:horizontal_diffusivity', 100)\no.add_readers_from_list(forcing)\no.seed_elements(**icebergs)\no.run(duration=timedelta(hours=48))\n\no.animation(color='draft', contourlines=np.arange(0, 500, 25))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.plot(contourlines=np.arange(0, 500, 25))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Plotting the speed of icebergs\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "iceberg_speed = np.sqrt(o.result.iceb_x_velocity**2 + o.result.iceb_y_velocity**2)\niceberg_speed.plot.line(x='time', add_legend=False, color='gray')\nplt.ylabel('Iceberg speed [m/s]')\nplt.show()" ] } ], "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.14.3" } }, "nbformat": 4, "nbformat_minor": 0 }