{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Vertical advection correction\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In OpenDrift, element depth (z) is relative to actual surface, and not mean sea level.\nVertical velocity from ocean models contain a contribution which is due to\nchange in sea surface elevation, however, this should in OpenDrift be subtracted\ndue to the choice of defining z relative to actual surface elevation\nThis correction is activated with config setting 'drift:vertical_advection_correction'\nThe effect is illustrated with the simulations below.\n\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\nfrom opendrift.readers import reader_oscillating\nfrom opendrift.models.oceandrift import OceanDrift\n\ntime = datetime.now()\nreader_tidal = reader_oscillating.Reader('sea_surface_height', amplitude=-1,\n period=timedelta(hours=6), zero_time=time)\nlat=59.8113; lon=10.5517 # Oslo fjord\nz = np.arange(0, -60, -5) # Seeding one particle every 5 meter from surface to 60m depth\n\n# Without stetching\no = OceanDrift(loglevel=0)\no.add_reader(reader_tidal)\no.add_readers_from_list(['https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be'])\no.set_config('drift:water_column_stretching', False)\no.set_config('drift:vertical_advection', True)\no.seed_elements(lon=lon, lat=lat, time=time, z=z, number=len(z))\no.run(duration=timedelta(hours=24), time_step=1800)\n\n# With stetching\no2 = OceanDrift(loglevel=0)\no2.add_reader(reader_tidal)\no2.add_readers_from_list(['https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be'])\no2.set_config('drift:water_column_stretching', True)\no2.set_config('drift:vertical_advection', True)\no2.seed_elements(lon=lon, lat=lat, time=time, z=z, number=len(z))\no2.run(duration=timedelta(hours=24), time_step=1800)\n\n# With w correction\no3 = OceanDrift(loglevel=0)\no3.add_reader(reader_tidal)\no3.add_readers_from_list(['https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be'])\no3.set_config('drift:water_column_stretching', False)\no3.set_config('drift:vertical_advection', True)\no3.set_config('drift:vertical_advection_correction', True)\no3.seed_elements(lon=lon, lat=lat, time=time, z=z, number=len(z))\no3.run(duration=timedelta(hours=24), time_step=1800)\n\n\nfig = plt.figure(figsize=(10, 10))\ngs = fig.add_gridspec(5, 1)\nax1 = fig.add_subplot(gs[0:3, 0])\no.result.z.plot.line(ax=ax1, x='time', add_legend=False, color='k')\no2.result.z.plot.line(ax=ax1, x='time', add_legend=False, color='r')\no3.result.z.plot.line(ax=ax1, x='time', add_legend=False, color='g')\nplt.plot([], [], color='k', label='No stretching or correction')\nplt.plot([], [], color='r', label='Column stretching')\nplt.plot([], [], color='g', label='Vertical velocity correction')\nplt.legend()\nax2 = fig.add_subplot(gs[3, 0])\no.result.sea_floor_depth_below_sea_level.plot.line(ax=ax2, x='time', add_legend=False, color='k')\nax3 = fig.add_subplot(gs[4, 0])\no.result.upward_sea_water_velocity.plot.line(ax=ax3, x='time', add_legend=False, color='k')\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 }