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'
    ])
14:55:15 INFO    opendrift.models.basemodel:519: OpenDriftSimulation initialised (version 1.11.10 / v1.11.10-15-g65004d9)

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)
14:55:15 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.
14:55:15 INFO    opendrift.models.basemodel.environment:218: Adding a dynamical landmask with max. priority based on assumed maximum speed of 2.0 m/s. Adding a customised landmask may be faster...
14:55:22 INFO    opendrift.models.basemodel.environment:245: Fallback values will be used for the following variables which have no readers:
14:55:22 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_stokes_drift_x_velocity: 0.000000
14:55:22 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_stokes_drift_y_velocity: 0.000000
14:55:22 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_significant_height: 0.000000
14:55:22 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000

Running model

o.run(steps=24, stop_on_error=True)
14:55:23 INFO    opendrift.models.basemodel:940: Using existing reader for land_binary_mask
14:55:23 INFO    opendrift.models.basemodel:951: All points are in ocean
14:55:23 INFO    opendrift.models.basemodel:2042: 2024-07-01 14:55:15.565149 - step 1 of 24 - 1000 active elements (0 deactivated)
14:55:23 INFO    opendrift.readers.reader_netCDF_CF_generic:102: 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:55:26 INFO    opendrift.readers.reader_netCDF_CF_generic:314: Detected dimensions: {'x': 'x', 'y': 'y', 'time': 'time'}
14:55:26 INFO    opendrift.readers.reader_netCDF_CF_generic:102: 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:55:29 INFO    opendrift.readers.reader_netCDF_CF_generic:314: Detected dimensions: {'time': 'time', 'x': 'x', 'y': 'y'}
14:55:29 INFO    opendrift.readers.reader_netCDF_CF_generic:102: 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:55:35 INFO    opendrift.readers.reader_netCDF_CF_generic:314: Detected dimensions: {'y': 'rlat', 'x': 'rlon', 'time': 'time'}
14:55:36 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:36 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:36 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:36 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:38 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:55:38 INFO    opendrift.models.basemodel:2042: 2024-07-01 15:55:15.565149 - step 2 of 24 - 1000 active elements (0 deactivated)
14:55:39 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:39 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:40 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:55:40 INFO    opendrift.models.basemodel:2042: 2024-07-01 16:55:15.565149 - step 3 of 24 - 1000 active elements (0 deactivated)
14:55:41 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:41 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:41 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:55:41 INFO    opendrift.models.basemodel:2042: 2024-07-01 17:55:15.565149 - step 4 of 24 - 1000 active elements (0 deactivated)
14:55:42 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:42 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:43 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:55:43 INFO    opendrift.models.basemodel:2042: 2024-07-01 18:55:15.565149 - step 5 of 24 - 1000 active elements (0 deactivated)
14:55:44 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:44 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:44 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:55:44 INFO    opendrift.models.basemodel:2042: 2024-07-01 19:55:15.565149 - step 6 of 24 - 1000 active elements (0 deactivated)
14:55:45 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:45 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:46 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:55:46 INFO    opendrift.models.basemodel:2042: 2024-07-01 20:55:15.565149 - step 7 of 24 - 1000 active elements (0 deactivated)
14:55:47 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:47 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:48 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:55:48 INFO    opendrift.models.basemodel:2042: 2024-07-01 21:55:15.565149 - step 8 of 24 - 1000 active elements (0 deactivated)
14:55:49 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:49 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:49 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:55:49 INFO    opendrift.models.basemodel:2042: 2024-07-01 22:55:15.565149 - step 9 of 24 - 1000 active elements (0 deactivated)
14:55:50 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:50 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:52 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:55:52 INFO    opendrift.models.basemodel:2042: 2024-07-01 23:55:15.565149 - step 10 of 24 - 1000 active elements (0 deactivated)
14:55:53 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:53 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:54 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:55:54 INFO    opendrift.models.basemodel:2042: 2024-07-02 00:55:15.565149 - step 11 of 24 - 1000 active elements (0 deactivated)
14:55:55 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:55 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:56 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:55:56 INFO    opendrift.models.basemodel:2042: 2024-07-02 01:55:15.565149 - step 12 of 24 - 1000 active elements (0 deactivated)
14:55:57 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:57 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:57 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:55:57 INFO    opendrift.models.basemodel:2042: 2024-07-02 02:55:15.565149 - step 13 of 24 - 1000 active elements (0 deactivated)
14:55:58 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:58 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:55:59 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:55:59 INFO    opendrift.models.basemodel:2042: 2024-07-02 03:55:15.565149 - step 14 of 24 - 1000 active elements (0 deactivated)
14:56:00 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:00 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:01 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:56:01 INFO    opendrift.models.basemodel:2042: 2024-07-02 04:55:15.565149 - step 15 of 24 - 1000 active elements (0 deactivated)
14:56:02 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:02 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:02 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:56:02 INFO    opendrift.models.basemodel:2042: 2024-07-02 05:55:15.565149 - step 16 of 24 - 1000 active elements (0 deactivated)
14:56:03 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:03 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:08 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:56:08 INFO    opendrift.models.basemodel:2042: 2024-07-02 06:55:15.565149 - step 17 of 24 - 1000 active elements (0 deactivated)
14:56:12 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:12 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:12 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:56:12 INFO    opendrift.models.basemodel:2042: 2024-07-02 07:55:15.565149 - step 18 of 24 - 1000 active elements (0 deactivated)
14:56:13 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:13 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:14 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:56:14 INFO    opendrift.models.basemodel:2042: 2024-07-02 08:55:15.565149 - step 19 of 24 - 1000 active elements (0 deactivated)
14:56:15 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:15 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:16 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:56:16 INFO    opendrift.models.basemodel:2042: 2024-07-02 09:55:15.565149 - step 20 of 24 - 1000 active elements (0 deactivated)
14:56:17 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:17 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:17 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:56:17 INFO    opendrift.models.basemodel:2042: 2024-07-02 10:55:15.565149 - step 21 of 24 - 1000 active elements (0 deactivated)
14:56:18 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:18 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:19 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:56:19 INFO    opendrift.models.basemodel:2042: 2024-07-02 11:55:15.565149 - step 22 of 24 - 1000 active elements (0 deactivated)
14:56:20 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:20 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:21 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:56:21 INFO    opendrift.models.basemodel:2042: 2024-07-02 12:55:15.565149 - step 23 of 24 - 1000 active elements (0 deactivated)
14:56:23 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:23 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:25 INFO    opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
14:56:25 INFO    opendrift.models.basemodel:2042: 2024-07-02 13:55:15.565149 - step 24 of 24 - 1000 active elements (0 deactivated)
14:56:28 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:28 WARNING opendrift.readers.interpolation.structured:46: Ensemble data currently not extrapolated towards seafloor
14:56:28 INFO    opendrift.models.shipdrift:311: 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 2024-07-01 14:55 to 2024-07-02 14:55 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:14.7  total
 0:00:00.0  preparing
 0:00:14.4  reading
 0:00:00.0  interpolation
 0:00:00.0  interpolation_time
 0:00:00.2  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:17.3  total
 0:00:00.0  preparing
 0:00:17.0  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:19.8  total
 0:00:00.0  preparing
 0:00:19.6  reading
 0:00:00.0  interpolation
 0:00:00.0  interpolation_time
 0:00:00.2  rotating vectors
 0:00:00.0  masking
--------------------
Performance:
 1:13.3 total time
    7.7 configuration
    0.0 preparing main loop
      0.0 moving elements to ocean
 1:05.5 main loop
      0.8 updating elements
    0.0 cleaning up
--------------------
===========================
Model:  ShipDrift     (OpenDrift version 1.11.10)
        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: 2024-07-01 14:55:15.565149 UTC
        Present: 2024-07-02 14:55:15.565149 UTC
        Calculation steps: 24 * 1:00:00 - total time: 1 day, 0:00:00
        Output steps: 25 * 1:00:00
===========================

14:56:55 INFO    opendrift.models.basemodel:4612: Saving animation to /root/project/docs/source/gallery/animations/example_shipdrift_0.gif...
14:58:08 INFO    opendrift.models.basemodel:3041: Time to make animation: 0:01:15.940042
../_images/example_shipdrift_0.gif

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

Gallery generated by Sphinx-Gallery