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'
    ])

Out:

13:44:52 INFO    opendrift.models.basemodel: OpenDriftSimulation initialised (version 1.7.1 / v1.7.1-87-g074c1d2)

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)

Out:

13:44:52 WARNING opendrift.models.shipdrift: 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)

Out:

13:44:53 INFO    opendrift.models.basemodel: Fallback values will be used for the following variables which have no readers:
13:44:53 INFO    opendrift.models.basemodel:    sea_surface_wave_stokes_drift_x_velocity: 0.000000
13:44:53 INFO    opendrift.models.basemodel:    sea_surface_wave_stokes_drift_y_velocity: 0.000000
13:44:53 INFO    opendrift.models.basemodel:    sea_surface_wave_significant_height: 0.000000
13:44:53 INFO    opendrift.models.basemodel:    sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000
13:44:53 INFO    opendrift.models.basemodel: Adding a dynamical landmask with max. priority based on assumed maximum speed of 2 m/s. Adding a customised landmask may be faster...
13:44:55 INFO    opendrift.models.basemodel: Using existing reader for land_binary_mask
13:44:55 INFO    opendrift.models.basemodel: All points are in ocean
13:44:55 INFO    opendrift.models.basemodel: 2021-09-24 13:44:52.977539 - step 1 of 24 - 1000 active elements (0 deactivated)
13:44:55 INFO    opendrift.readers.reader_netCDF_CF_generic: Opening dataset: https://thredds.met.no/thredds/dodsC/cmems/topaz6/dataset-topaz6-arc-15min-3km-be.ncml
13:45:01 INFO    opendrift.readers.reader_netCDF_CF_generic: Opening dataset: https://thredds.met.no/thredds/dodsC/mepslatest/meps_lagged_6_h_latest_2_5km_latest.nc
13:45:02 INFO    opendrift.readers.reader_netCDF_CF_generic: Opening dataset: https://thredds.met.no/thredds/dodsC/cmems/mywavewam3km/dataset-wam-arctic-1hr3km-be.ncml
13:45:10 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:10 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:10 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:10 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:14 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:45:14 INFO    opendrift.models.basemodel: 2021-09-24 14:44:52.977539 - step 2 of 24 - 1000 active elements (0 deactivated)
13:45:15 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:15 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:16 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:45:16 INFO    opendrift.models.basemodel: 2021-09-24 15:44:52.977539 - step 3 of 24 - 1000 active elements (0 deactivated)
13:45:17 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:17 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:18 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:45:18 INFO    opendrift.models.basemodel: 2021-09-24 16:44:52.977539 - step 4 of 24 - 1000 active elements (0 deactivated)
13:45:21 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:21 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:22 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:45:22 INFO    opendrift.models.basemodel: 2021-09-24 17:44:52.977539 - step 5 of 24 - 1000 active elements (0 deactivated)
13:45:23 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:23 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:24 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:45:24 INFO    opendrift.models.basemodel: 2021-09-24 18:44:52.977539 - step 6 of 24 - 1000 active elements (0 deactivated)
13:45:25 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:25 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:26 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:45:26 INFO    opendrift.models.basemodel: 2021-09-24 19:44:52.977539 - step 7 of 24 - 1000 active elements (0 deactivated)
13:45:27 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:27 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:28 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:45:28 INFO    opendrift.models.basemodel: 2021-09-24 20:44:52.977539 - step 8 of 24 - 1000 active elements (0 deactivated)
13:45:29 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:29 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:30 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:45:30 INFO    opendrift.models.basemodel: 2021-09-24 21:44:52.977539 - step 9 of 24 - 1000 active elements (0 deactivated)
13:45:31 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:31 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:32 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:45:32 INFO    opendrift.models.basemodel: 2021-09-24 22:44:52.977539 - step 10 of 24 - 1000 active elements (0 deactivated)
13:45:33 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:33 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:34 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:45:34 INFO    opendrift.models.basemodel: 2021-09-24 23:44:52.977539 - step 11 of 24 - 1000 active elements (0 deactivated)
13:45:36 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:36 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:39 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:45:39 INFO    opendrift.models.basemodel: 2021-09-25 00:44:52.977539 - step 12 of 24 - 1000 active elements (0 deactivated)
13:45:40 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:40 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:41 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:45:41 INFO    opendrift.models.basemodel: 2021-09-25 01:44:52.977539 - step 13 of 24 - 1000 active elements (0 deactivated)
13:45:42 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:42 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:43 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:45:43 INFO    opendrift.models.basemodel: 2021-09-25 02:44:52.977539 - step 14 of 24 - 1000 active elements (0 deactivated)
13:45:45 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:45 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:46 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:45:46 INFO    opendrift.models.basemodel: 2021-09-25 03:44:52.977539 - step 15 of 24 - 1000 active elements (0 deactivated)
13:45:47 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:47 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:48 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:45:48 INFO    opendrift.models.basemodel: 2021-09-25 04:44:52.977539 - step 16 of 24 - 1000 active elements (0 deactivated)
13:45:50 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:50 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:52 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:45:52 INFO    opendrift.models.basemodel: 2021-09-25 05:44:52.977539 - step 17 of 24 - 1000 active elements (0 deactivated)
13:45:54 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:54 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:56 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:45:56 INFO    opendrift.models.basemodel: 2021-09-25 06:44:52.977539 - step 18 of 24 - 1000 active elements (0 deactivated)
13:45:58 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:58 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:59 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:45:59 INFO    opendrift.models.basemodel: 2021-09-25 07:44:52.977539 - step 19 of 24 - 1000 active elements (0 deactivated)
13:46:01 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:46:01 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:46:02 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:46:02 INFO    opendrift.models.basemodel: 2021-09-25 08:44:52.977539 - step 20 of 24 - 1000 active elements (0 deactivated)
13:46:06 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:46:06 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:46:07 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:46:07 INFO    opendrift.models.basemodel: 2021-09-25 09:44:52.977539 - step 21 of 24 - 1000 active elements (0 deactivated)
13:46:08 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:46:08 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:46:09 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:46:09 INFO    opendrift.models.basemodel: 2021-09-25 10:44:52.977539 - step 22 of 24 - 1000 active elements (0 deactivated)
13:46:11 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:46:11 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:46:12 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:46:12 INFO    opendrift.models.basemodel: 2021-09-25 11:44:52.977539 - step 23 of 24 - 1000 active elements (0 deactivated)
13:46:14 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:46:14 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:46:15 INFO    opendrift.models.shipdrift: Using Stokes drift direction as wave direction
13:46:15 INFO    opendrift.models.basemodel: 2021-09-25 12:44:52.977539 - step 24 of 24 - 1000 active elements (0 deactivated)
13:46:17 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:46:17 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:46:18 INFO    opendrift.models.shipdrift: 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 2021-09-24 13:44 to 2021-09-25 13:44 UTC (25 steps)

Out:

===========================
--------------------
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.4  total
 0:00:00.0  preparing
 0:00:18.1  reading
 0:00:00.0  interpolation
 0:00:00.0  interpolation_time
 0:00:00.3  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:25.9  total
 0:00:00.0  preparing
 0:00:25.6  reading
 0:00:00.2  interpolation
 0:00:00.0  interpolation_time
 0:00:00.3  rotating vectors
 0:00:00.0  masking
--------------------
https://thredds.met.no/thredds/dodsC/cmems/mywavewam3km/dataset-wam-arctic-1hr3km-be.ncml
 0:00:25.3  total
 0:00:00.0  preparing
 0:00:25.0  reading
 0:00:00.0  interpolation
 0:00:00.0  interpolation_time
 0:00:00.3  rotating vectors
 0:00:00.0  masking
--------------------
Performance:
 1:25.5 total time
    0.3 configuration
    2.4 preparing main loop
      2.4 making dynamical landmask
      0.0 moving elements to ocean
   1:21.9 readers
        0.0 global_landmask
        0.0 postprocessing
 1:22.6 main loop
       18.4 https://thredds.met.no/thredds/dodsC/cmems/topaz6/dataset-topaz6-arc-15min-3km-be.ncml
       25.9 https://thredds.met.no/thredds/dodsC/mepslatest/meps_lagged_6_h_latest_2_5km_latest.nc
       25.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.7.1)
        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
  -----
  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: 2021-09-24 13:44:52.977539
        Present: 2021-09-25 13:44:52.977539
        Calculation steps: 24 * 1:00:00 - total time: 1 day, 0:00:00
        Output steps: 25 * 1:00:00
===========================

13:46:31 INFO    opendrift.models.basemodel: Saving animation to /root/project/docs/source/gallery/animations/example_shipdrift_0.gif...
13:46:31 INFO    opendrift.models.basemodel: Making animated gif...
MovieWriter imagemagick unavailable; using Pillow instead.
../_images/example_shipdrift_0.gif

Total running time of the script: ( 1 minutes 43.366 seconds)

Gallery generated by Sphinx-Gallery