.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/example_shipdrift.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.py: Ship drift ================================== .. GENERATED FROM PYTHON SOURCE LINES 6-18 .. code-block:: Python from datetime import datetime from opendrift.models.shipdrift import ShipDrift o = ShipDrift(loglevel=20) o.add_readers_from_list([ 'https://thredds.met.no/thredds/dodsC/cmems/topaz6/dataset-topaz6-arc-15min-3km-be.ncml', 'https://thredds.met.no/thredds/dodsC/mepslatest/meps_lagged_6_h_latest_2_5km_latest.nc', 'https://thredds.met.no/thredds/dodsC/cmems/mywavewam3km/dataset-wam-arctic-1hr3km-be.ncml' ]) .. rst-class:: sphx-glr-script-out .. code-block:: none 13:50:30 INFO opendrift:569: OpenDriftSimulation initialised (version 1.14.4 / v1.14.4-9-g23fa4d2) .. GENERATED FROM PYTHON SOURCE LINES 19-21 Seed ship elements at defined position and time Note: beam/length ratio is larger than allowed, but is then clipped internally .. GENERATED FROM PYTHON SOURCE LINES 21-25 .. code-block:: Python o.seed_elements(lon=5.0, lat=63.0, radius=1000, number=1000, time=datetime.now(), length=80.0, beam=20.0, height=9.0, draft=4.0) .. rst-class:: sphx-glr-script-out .. code-block:: none 13:50:30 WARNING opendrift.models.shipdrift:181: Ratio of beam to length should be in range 0.12 to 0.18, given range is 0.25-0.25. Using border value. 13:50:30 INFO opendrift.models.basemodel.environment:203: Adding a global landmask from GSHHG 13:50:34 INFO opendrift.models.basemodel.environment:227: Fallback values will be used for the following variables which have no readers: 13:50:34 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_stokes_drift_x_velocity: 0.000000 13:50:34 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_stokes_drift_y_velocity: 0.000000 13:50:34 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_significant_height: 0.000000 13:50:34 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000 .. GENERATED FROM PYTHON SOURCE LINES 26-27 Running model .. GENERATED FROM PYTHON SOURCE LINES 27-29 .. code-block:: Python o.run(steps=24, stop_on_error=True) .. rst-class:: sphx-glr-script-out .. code-block:: none 13:50:34 INFO opendrift:1798: Storing previous values of element property lon because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous'])) 13:50:34 INFO opendrift:1798: Storing previous values of element property lat because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous'])) 13:50:34 INFO opendrift:945: Using existing reader for land_binary_mask to move elements to ocean 13:50:34 INFO opendrift:975: All points are in ocean 13:50:34 INFO opendrift:2094: 2025-10-23 13:50:30.077128 - step 1 of 24 - 1000 active elements (0 deactivated) 13:50:34 INFO opendrift.readers:63: Opening file with xr.open_dataset 13:50:37 INFO opendrift.readers.reader_netCDF_CF_generic:332: Detected dimensions: {'x': 'x', 'y': 'y', 'time': 'time'} 13:50:37 INFO opendrift.readers:63: Opening file with xr.open_dataset 13:50:39 INFO opendrift.readers.reader_netCDF_CF_generic:332: Detected dimensions: {'time': 'time', 'x': 'x', 'y': 'y'} 13:50:39 INFO opendrift.readers:63: Opening file with xr.open_dataset 13:50:41 INFO opendrift.readers.reader_netCDF_CF_generic:332: Detected dimensions: {'y': 'rlat', 'x': 'rlon', 'time': 'time'} 13:50:44 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:50:44 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:50:46 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:50:46 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:50:47 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:50:47 INFO opendrift:2094: 2025-10-23 14:50:30.077128 - step 2 of 24 - 1000 active elements (0 deactivated) 13:50:50 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:50:50 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:50:51 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:50:51 INFO opendrift:2094: 2025-10-23 15:50:30.077128 - step 3 of 24 - 1000 active elements (0 deactivated) 13:50:53 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:50:53 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:50:54 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:50:54 INFO opendrift:2094: 2025-10-23 16:50:30.077128 - step 4 of 24 - 1000 active elements (0 deactivated) 13:50:56 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:50:56 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:50:57 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:50:57 INFO opendrift:2094: 2025-10-23 17:50:30.077128 - step 5 of 24 - 1000 active elements (0 deactivated) 13:50:59 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:50:59 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:00 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:51:00 INFO opendrift:2094: 2025-10-23 18:50:30.077128 - step 6 of 24 - 1000 active elements (0 deactivated) 13:51:02 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:02 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:02 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:51:02 INFO opendrift:2094: 2025-10-23 19:50:30.077128 - step 7 of 24 - 1000 active elements (0 deactivated) 13:51:04 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:04 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:05 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:51:05 INFO opendrift:2094: 2025-10-23 20:50:30.077128 - step 8 of 24 - 1000 active elements (0 deactivated) 13:51:08 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:08 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:08 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:51:08 INFO opendrift:2094: 2025-10-23 21:50:30.077128 - step 9 of 24 - 1000 active elements (0 deactivated) 13:51:11 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:11 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:11 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:51:11 INFO opendrift:2094: 2025-10-23 22:50:30.077128 - step 10 of 24 - 1000 active elements (0 deactivated) 13:51:13 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:13 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:14 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:51:14 INFO opendrift:2094: 2025-10-23 23:50:30.077128 - step 11 of 24 - 1000 active elements (0 deactivated) 13:51:16 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:16 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:18 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:51:18 INFO opendrift:2094: 2025-10-24 00:50:30.077128 - step 12 of 24 - 1000 active elements (0 deactivated) 13:51:20 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:20 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:21 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:51:21 INFO opendrift:2094: 2025-10-24 01:50:30.077128 - step 13 of 24 - 1000 active elements (0 deactivated) 13:51:22 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:22 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:23 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:51:23 INFO opendrift:2094: 2025-10-24 02:50:30.077128 - step 14 of 24 - 1000 active elements (0 deactivated) 13:51:26 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:26 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:26 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:51:26 INFO opendrift:2094: 2025-10-24 03:50:30.077128 - step 15 of 24 - 1000 active elements (0 deactivated) 13:51:30 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:30 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:31 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:51:31 INFO opendrift:2094: 2025-10-24 04:50:30.077128 - step 16 of 24 - 1000 active elements (0 deactivated) 13:51:33 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:33 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:33 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:51:33 INFO opendrift:2094: 2025-10-24 05:50:30.077128 - step 17 of 24 - 1000 active elements (0 deactivated) 13:51:36 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:36 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:36 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:51:36 INFO opendrift:2094: 2025-10-24 06:50:30.077128 - step 18 of 24 - 1000 active elements (0 deactivated) 13:51:38 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:38 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:39 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:51:39 INFO opendrift:2094: 2025-10-24 07:50:30.077128 - step 19 of 24 - 1000 active elements (0 deactivated) 13:51:41 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:41 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:41 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:51:41 INFO opendrift:2094: 2025-10-24 08:50:30.077128 - step 20 of 24 - 1000 active elements (0 deactivated) 13:51:43 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:43 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:44 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:51:44 INFO opendrift:2094: 2025-10-24 09:50:30.077128 - step 21 of 24 - 1000 active elements (0 deactivated) 13:51:46 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:46 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:49 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:51:49 INFO opendrift:2094: 2025-10-24 10:50:30.077128 - step 22 of 24 - 1000 active elements (0 deactivated) 13:51:52 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:52 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:53 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:51:53 INFO opendrift:2094: 2025-10-24 11:50:30.077128 - step 23 of 24 - 1000 active elements (0 deactivated) 13:51:55 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:55 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:51:57 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction 13:51:57 INFO opendrift:2094: 2025-10-24 12:50:30.077128 - step 24 of 24 - 1000 active elements (0 deactivated) 13:52:00 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:52:00 WARNING opendrift.readers.interpolation.structured:63: Ensemble data currently not extrapolated towards seafloor 13:52:01 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction .. raw:: html
<xarray.Dataset> Size: 2MB
    Dimensions:                                                                              (
                                                                                              trajectory: 1000,
                                                                                              time: 25)
    Coordinates:
      * trajectory                                                                           (trajectory) int64 8kB ...
      * time                                                                                 (time) datetime64[ns] 200B ...
    Data variables: (12/24)
        status                                                                               (trajectory, time) float32 100kB ...
        moving                                                                               (trajectory, time) float32 100kB ...
        age_seconds                                                                          (trajectory, time) float32 100kB ...
        origin_marker                                                                        (trajectory, time) float32 100kB ...
        lon                                                                                  (trajectory, time) float32 100kB ...
        lat                                                                                  (trajectory, time) float32 100kB ...
        ...                                                                                   ...
        x_sea_water_velocity                                                                 (trajectory, time) float32 100kB ...
        y_sea_water_velocity                                                                 (trajectory, time) float32 100kB ...
        sea_surface_wave_stokes_drift_x_velocity                                             (trajectory, time) float32 100kB ...
        sea_surface_wave_stokes_drift_y_velocity                                             (trajectory, time) float32 100kB ...
        sea_surface_wave_significant_height                                                  (trajectory, time) float32 100kB ...
        sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment  (trajectory, time) float32 100kB ...
    Attributes: (12/96)
        Conventions:                                                             ...
        standard_name_vocabulary:                                                ...
        featureType:                                                             ...
        title:                                                                   ...
        summary:                                                                 ...
        keywords:                                                                ...
        ...                                                                                                               ...
        geospatial_lon_units:                                                    ...
        geospatial_lon_resolution:                                               ...
        runtime:                                                                 ...
        geospatial_vertical_min:                                                 ...
        geospatial_vertical_max:                                                 ...
        geospatial_vertical_positive:                                            ...


.. GENERATED FROM PYTHON SOURCE LINES 30-31 Print and plot results .. GENERATED FROM PYTHON SOURCE LINES 31-36 .. code-block:: Python print(o) o.plot(linecolor='orientation') #o.animation(color='orientation', markersize=20, filename="orientation.gif", legend=['left','right'],colorbar=False,cmap='bwr') o.animation(color='orientation', legend=['left','right'], markersize=20, colorbar=False, cmap='bwr') .. image-sg:: /gallery/images/sphx_glr_example_shipdrift_001.png :alt: OpenDrift - ShipDrift 2025-10-23 13:50 to 2025-10-24 13:50 UTC (25 steps) :srcset: /gallery/images/sphx_glr_example_shipdrift_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none =========================== -------------------- Reader performance: -------------------- global_landmask 0:00:00.0 total 0:00:00.0 preparing 0:00:00.0 reading 0:00:00.0 masking -------------------- https://thredds.met.no/thredds/dodsC/cmems/topaz6/dataset-topaz6-arc-15min-3km-be.ncml 0:00:21.5 total 0:00:00.0 preparing 0:00:21.5 reading 0:00:00.0 interpolation 0:00:00.0 interpolation_time 0:00:00.0 rotating vectors 0:00:00.0 masking -------------------- https://thredds.met.no/thredds/dodsC/mepslatest/meps_lagged_6_h_latest_2_5km_latest.nc 0:00:35.4 total 0:00:00.0 preparing 0:00:35.4 reading 0:00:00.2 interpolation 0:00:00.0 interpolation_time 0:00:00.0 rotating vectors 0:00:00.0 masking -------------------- https://thredds.met.no/thredds/dodsC/cmems/mywavewam3km/dataset-wam-arctic-1hr3km-be.ncml 0:00:21.0 total 0:00:00.0 preparing 0:00:21.0 reading 0:00:00.0 interpolation 0:00:00.0 interpolation_time 0:00:00.0 rotating vectors 0:00:00.0 masking -------------------- Performance: 1:31.2 total time 4.1 configuration 0.0 preparing main loop 0.0 moving elements to ocean 1:27.1 main loop 0.4 updating elements 0.0 cleaning up -------------------- =========================== Model: ShipDrift (OpenDrift version 1.14.4) 1000 active ShipObject particles (0 deactivated, 0 scheduled) ------------------- Environment variables: ----- land_binary_mask 1) global_landmask ----- x_sea_water_velocity y_sea_water_velocity 1) https://thredds.met.no/thredds/dodsC/cmems/topaz6/dataset-topaz6-arc-15min-3km-be.ncml 2) https://thredds.met.no/thredds/dodsC/cmems/mywavewam3km/dataset-wam-arctic-1hr3km-be.ncml ----- x_wind y_wind 1) https://thredds.met.no/thredds/dodsC/mepslatest/meps_lagged_6_h_latest_2_5km_latest.nc ----- sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment sea_surface_wave_significant_height sea_surface_wave_stokes_drift_x_velocity sea_surface_wave_stokes_drift_y_velocity 1) https://thredds.met.no/thredds/dodsC/cmems/mywavewam3km/dataset-wam-arctic-1hr3km-be.ncml Discarded readers: Time: Start: 2025-10-23 13:50:30.077128 UTC Present: 2025-10-24 13:50:30.077128 UTC Calculation steps: 24 * 1:00:00 - total time: 1 day, 0:00:00 Output steps: 25 * 1:00:00 =========================== 13:52:14 INFO opendrift:4623: Saving animation to /root/project/docs/source/gallery/animations/example_shipdrift_0.gif... 13:52:29 INFO opendrift:3064: Time to make animation: 0:00:15.893288 .. GENERATED FROM PYTHON SOURCE LINES 37-38 .. image:: /gallery/animations/example_shipdrift_0.gif .. rst-class:: sphx-glr-timing **Total running time of the script:** (2 minutes 6.400 seconds) .. _sphx_glr_download_gallery_example_shipdrift.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.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_shipdrift.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: example_shipdrift.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_