Ship drift

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'
    ])
13:59:57 INFO    opendrift.models.basemodel:539: OpenDriftSimulation initialised (version 1.10.7 / v1.10.6-119-g1da5bec)

Seed ship elements at defined position and time Note: beam/length ratio is larger than allowed, but is then clipped internally

o.seed_elements(lon=5.0, lat=63.0, radius=1000, number=1000,
                time=datetime.utcnow(),
                length=80.0, beam=20.0, height=9.0, draft=4.0)
13:59:57 WARNING opendrift.models.shipdrift:179: Ratio of beam to length should be in range 0.12 to 0.18, given range is 0.25-0.25. Using border value.

Running model

o.run(steps=24, stop_on_error=True)
13:59:57 INFO    opendrift.models.basemodel:2591: Fallback values will be used for the following variables which have no readers:
13:59:57 INFO    opendrift.models.basemodel:2594:       sea_surface_wave_stokes_drift_x_velocity: 0.000000
13:59:57 INFO    opendrift.models.basemodel:2594:       sea_surface_wave_stokes_drift_y_velocity: 0.000000
13:59:57 INFO    opendrift.models.basemodel:2594:       sea_surface_wave_significant_height: 0.000000
13:59:57 INFO    opendrift.models.basemodel:2594:       sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000
13:59:57 INFO    opendrift.models.basemodel:2753: Adding a dynamical landmask with max. priority based on assumed maximum speed of 2 m/s. Adding a customised landmask may be faster...
14:00:03 INFO    opendrift.models.basemodel:1701: Using existing reader for land_binary_mask
14:00:03 INFO    opendrift.models.basemodel:1713: All points are in ocean
14:00:03 INFO    opendrift.models.basemodel:2882: 2023-09-01 13:59:57.525278 - step 1 of 24 - 1000 active elements (0 deactivated)
14:00:03 INFO    opendrift.readers.reader_netCDF_CF_generic:92: Opening dataset: https://thredds.met.no/thredds/dodsC/cmems/topaz6/dataset-topaz6-arc-15min-3km-be.ncml
/opt/conda/envs/opendrift/lib/python3.11/site-packages/pyproj/crs/crs.py:1286: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems
  proj = self._crs.to_proj4(version=version)
14:00:05 INFO    opendrift.readers.reader_netCDF_CF_generic:92: Opening dataset: https://thredds.met.no/thredds/dodsC/mepslatest/meps_lagged_6_h_latest_2_5km_latest.nc
/opt/conda/envs/opendrift/lib/python3.11/site-packages/pyproj/crs/crs.py:1286: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems
  proj = self._crs.to_proj4(version=version)
14:00:07 INFO    opendrift.readers.reader_netCDF_CF_generic:92: Opening dataset: https://thredds.met.no/thredds/dodsC/cmems/mywavewam3km/dataset-wam-arctic-1hr3km-be.ncml
/opt/conda/envs/opendrift/lib/python3.11/site-packages/pyproj/crs/crs.py:1286: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems
  proj = self._crs.to_proj4(version=version)
14:00:17 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:17 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:18 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:18 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:20 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:00:20 INFO    opendrift.models.basemodel:2882: 2023-09-01 14:59:57.525278 - step 2 of 24 - 1000 active elements (0 deactivated)
14:00:22 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:22 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:23 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:00:23 INFO    opendrift.models.basemodel:2882: 2023-09-01 15:59:57.525278 - step 3 of 24 - 1000 active elements (0 deactivated)
14:00:24 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:24 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:25 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:00:25 INFO    opendrift.models.basemodel:2882: 2023-09-01 16:59:57.525278 - step 4 of 24 - 1000 active elements (0 deactivated)
14:00:27 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:27 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:27 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:00:27 INFO    opendrift.models.basemodel:2882: 2023-09-01 17:59:57.525278 - step 5 of 24 - 1000 active elements (0 deactivated)
14:00:29 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:29 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:30 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:00:30 INFO    opendrift.models.basemodel:2882: 2023-09-01 18:59:57.525278 - step 6 of 24 - 1000 active elements (0 deactivated)
14:00:31 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:31 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:32 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:00:32 INFO    opendrift.models.basemodel:2882: 2023-09-01 19:59:57.525278 - step 7 of 24 - 1000 active elements (0 deactivated)
14:00:33 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:33 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:34 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:00:34 INFO    opendrift.models.basemodel:2882: 2023-09-01 20:59:57.525278 - step 8 of 24 - 1000 active elements (0 deactivated)
14:00:36 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:36 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:36 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:00:36 INFO    opendrift.models.basemodel:2882: 2023-09-01 21:59:57.525278 - step 9 of 24 - 1000 active elements (0 deactivated)
14:00:38 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:38 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:39 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:00:39 INFO    opendrift.models.basemodel:2882: 2023-09-01 22:59:57.525278 - step 10 of 24 - 1000 active elements (0 deactivated)
14:00:40 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:40 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:41 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:00:41 INFO    opendrift.models.basemodel:2882: 2023-09-01 23:59:57.525278 - step 11 of 24 - 1000 active elements (0 deactivated)
14:00:43 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:43 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:44 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:00:44 INFO    opendrift.models.basemodel:2882: 2023-09-02 00:59:57.525278 - step 12 of 24 - 1000 active elements (0 deactivated)
14:00:45 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:45 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:46 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:00:46 INFO    opendrift.models.basemodel:2882: 2023-09-02 01:59:57.525278 - step 13 of 24 - 1000 active elements (0 deactivated)
14:00:48 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:48 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:48 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:00:48 INFO    opendrift.models.basemodel:2882: 2023-09-02 02:59:57.525278 - step 14 of 24 - 1000 active elements (0 deactivated)
14:00:50 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:50 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:51 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:00:51 INFO    opendrift.models.basemodel:2882: 2023-09-02 03:59:57.525278 - step 15 of 24 - 1000 active elements (0 deactivated)
14:00:52 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:52 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:53 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:00:53 INFO    opendrift.models.basemodel:2882: 2023-09-02 04:59:57.525278 - step 16 of 24 - 1000 active elements (0 deactivated)
14:00:55 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:55 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:56 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:00:56 INFO    opendrift.models.basemodel:2882: 2023-09-02 05:59:57.525278 - step 17 of 24 - 1000 active elements (0 deactivated)
14:00:57 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:57 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:00:58 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:00:58 INFO    opendrift.models.basemodel:2882: 2023-09-02 06:59:57.525278 - step 18 of 24 - 1000 active elements (0 deactivated)
14:01:00 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:01:00 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:01:00 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:01:00 INFO    opendrift.models.basemodel:2882: 2023-09-02 07:59:57.525278 - step 19 of 24 - 1000 active elements (0 deactivated)
14:01:02 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:01:02 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:01:03 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:01:03 INFO    opendrift.models.basemodel:2882: 2023-09-02 08:59:57.525278 - step 20 of 24 - 1000 active elements (0 deactivated)
14:01:05 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:01:05 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:01:05 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:01:05 INFO    opendrift.models.basemodel:2882: 2023-09-02 09:59:57.525278 - step 21 of 24 - 1000 active elements (0 deactivated)
14:01:07 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:01:07 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:01:08 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:01:08 INFO    opendrift.models.basemodel:2882: 2023-09-02 10:59:57.525278 - step 22 of 24 - 1000 active elements (0 deactivated)
14:01:09 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:01:09 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:01:10 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:01:10 INFO    opendrift.models.basemodel:2882: 2023-09-02 11:59:57.525278 - step 23 of 24 - 1000 active elements (0 deactivated)
14:01:12 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:01:12 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:01:13 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction
14:01:13 INFO    opendrift.models.basemodel:2882: 2023-09-02 12:59:57.525278 - step 24 of 24 - 1000 active elements (0 deactivated)
14:01:15 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:01:15 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:01:16 INFO    opendrift.models.shipdrift:309: Using Stokes drift direction as wave direction

Print and plot results

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')
OpenDrift - ShipDrift 2023-09-01 13:59 to 2023-09-02 13:59 UTC (25 steps)
===========================
--------------------
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:18.0  total
 0:00:00.0  preparing
 0:00:17.9  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:24.1  total
 0:00:00.0  preparing
 0:00:23.9  reading
 0:00:00.2  interpolation
 0:00:00.0  interpolation_time
 0:00:00.2  rotating vectors
 0:00:00.0  masking
--------------------
https://thredds.met.no/thredds/dodsC/cmems/mywavewam3km/dataset-wam-arctic-1hr3km-be.ncml
 0:00:17.3  total
 0:00:00.0  preparing
 0:00:17.1  reading
 0:00:00.0  interpolation
 0:00:00.0  interpolation_time
 0:00:00.1  rotating vectors
 0:00:00.0  masking
--------------------
Performance:
 1:18.9 total time
    0.1 configuration
    5.5 preparing main loop
      5.5 making dynamical landmask
      0.0 moving elements to ocean
   1:12.4 readers
        0.0 global_landmask
        0.0 postprocessing
 1:13.1 main loop
       18.0 https://thredds.met.no/thredds/dodsC/cmems/topaz6/dataset-topaz6-arc-15min-3km-be.ncml
       24.1 https://thredds.met.no/thredds/dodsC/mepslatest/meps_lagged_6_h_latest_2_5km_latest.nc
       17.3 https://thredds.met.no/thredds/dodsC/cmems/mywavewam3km/dataset-wam-arctic-1hr3km-be.ncml
      0.5 updating elements
    0.0 cleaning up
--------------------
===========================
Model:  ShipDrift     (OpenDrift version 1.10.7)
        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

Time:
        Start: 2023-09-01 13:59:57.525278 UTC
        Present: 2023-09-02 13:59:57.525278 UTC
        Calculation steps: 24 * 1:00:00 - total time: 1 day, 0:00:00
        Output steps: 25 * 1:00:00
===========================

0.3984006735749549 ALPHA
14:01:43 INFO    opendrift.models.basemodel:5350: Saving animation to /root/project/docs/source/gallery/animations/example_shipdrift_0.gif...
14:02:55 INFO    opendrift.models.basemodel:3848: Time to make animation: 0:01:14.614224
../_images/example_shipdrift_0.gif

Total running time of the script: (3 minutes 2.079 seconds)

Gallery generated by Sphinx-Gallery