.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/example_shipdrift_leeway.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_example_shipdrift_leeway.py: Comparing Leeway and ShipDrift model ==================================== .. GENERATED FROM PYTHON SOURCE LINES 8-12 The Leeway model contain many object categories from persons-in-water to various types of boats and ships. Here we compare the Leeway model with a fishing vessel to the ShipDrift model using the same ship dimensions. .. GENERATED FROM PYTHON SOURCE LINES 12-17 .. code-block:: Python from datetime import datetime, timedelta from opendrift.models.leeway import Leeway from opendrift.models.shipdrift import ShipDrift .. GENERATED FROM PYTHON SOURCE LINES 18-21 We use a simple case with constant wind northwards, and no current. Wave height and period is calculated automatically from wind, and wave direction is the same as wind direction .. GENERATED FROM PYTHON SOURCE LINES 21-28 .. code-block:: Python environment = { 'land_binary_mask': 0, 'x_sea_water_velocity': 0, 'y_sea_water_velocity': 0, 'x_wind': 0, 'y_wind': 18} .. GENERATED FROM PYTHON SOURCE LINES 29-32 For the Leeway model we use "FISHING-VESSEL-3" with a length of 62m For the ShipDrift model we define a ship with the same dimensions, as well as a "large ship" scaled up by a factor of 8 .. GENERATED FROM PYTHON SOURCE LINES 32-59 .. code-block:: Python ship = {'length': 62, 'beam': 8, 'height': 10, 'draft': 5} large_ship = {k: v*8 for k, v in ship.items()} cases = { 'Leeway, FISHING-VESSEL-3': { 'model': Leeway, 'kwargs': {'object_type': 52}}, 'Shipdrift, large ship': { 'model': ShipDrift, 'kwargs': large_ship}, 'Shipdrift, small ship': { 'model': ShipDrift, 'kwargs': ship} } lon=3.5 lat=60 time = datetime.now() duration = timedelta(hours=24) simulations = [] for cname, case in cases.items(): o = case['model'](loglevel=50) for var, value in environment.items(): o.set_config('environment:constant:' + var, value) o.set_config('general:use_auto_landmask', False) o.seed_elements(lon=lon, lat=lat, time=time, number=1000, **case['kwargs']) o.run(duration=duration) simulations.append(o) .. GENERATED FROM PYTHON SOURCE LINES 60-67 We see that the overall drift speed of the ShipDrift model is comparable to the Leeway model. However, the Leeway model yields a much larger directional spread for ships orienters left and right respectively. For the scaled up ship, the drift speed is slightly larger, and the directional spread is slightly larger, but still much smaller than with the Leeway model. .. GENERATED FROM PYTHON SOURCE LINES 67-70 .. code-block:: Python simulations[0].plot(compare=simulations[1:], legend=list(cases), fast=False) simulations[0].animation(compare=simulations[1:], legend=list(cases), fast=False) .. image-sg:: /gallery/images/sphx_glr_example_shipdrift_leeway_001.png :alt: OpenDrift - Leeway (FISHING-VESSEL-3) 2024-04-26 14:41 to 2024-04-27 14:41 UTC (25 steps) :srcset: /gallery/images/sphx_glr_example_shipdrift_leeway_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none /opt/conda/envs/opendrift/lib/python3.11/site-packages/cartopy/mpl/geoaxes.py:1683: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored result = super().scatter(*args, **kwargs) .. GENERATED FROM PYTHON SOURCE LINES 71-72 .. image:: /gallery/animations/example_shipdrift_leeway_0.gif .. rst-class:: sphx-glr-timing **Total running time of the script:** (1 minutes 49.068 seconds) .. _sphx_glr_download_gallery_example_shipdrift_leeway.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_shipdrift_leeway.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_shipdrift_leeway.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_