Note
Go to the end to download the full example code.
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'
])
17:21:53 INFO opendrift.models.basemodel:512: OpenDriftSimulation initialised (version 1.12.0 / v1.12.0-55-g4faa301)
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)
17:21:53 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.
17:21:53 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...
17:21:57 INFO opendrift.models.basemodel.environment:245: Fallback values will be used for the following variables which have no readers:
17:21:57 INFO opendrift.models.basemodel.environment:248: sea_surface_wave_stokes_drift_x_velocity: 0.000000
17:21:57 INFO opendrift.models.basemodel.environment:248: sea_surface_wave_stokes_drift_y_velocity: 0.000000
17:21:57 INFO opendrift.models.basemodel.environment:248: sea_surface_wave_significant_height: 0.000000
17:21:57 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)
17:21:58 INFO opendrift.models.basemodel:932: Using existing reader for land_binary_mask
17:21:58 INFO opendrift.models.basemodel:943: All points are in ocean
17:21:58 INFO opendrift.models.basemodel:2032: 2025-01-14 17:21:53.911106 - step 1 of 24 - 1000 active elements (0 deactivated)
17:21:58 INFO opendrift.readers:58: Opening file with xr.open_dataset
17:22:00 INFO opendrift.readers.reader_netCDF_CF_generic:338: Detected dimensions: {'x': 'x', 'y': 'y', 'time': 'time'}
17:22:00 INFO opendrift.readers:58: Opening file with xr.open_dataset
17:22:03 INFO opendrift.readers.reader_netCDF_CF_generic:338: Detected dimensions: {'time': 'time', 'x': 'x', 'y': 'y'}
17:22:03 INFO opendrift.readers:58: Opening file with xr.open_dataset
17:22:07 INFO opendrift.readers.reader_netCDF_CF_generic:338: Detected dimensions: {'y': 'rlat', 'x': 'rlon', 'time': 'time'}
17:22:08 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:08 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:09 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:09 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:11 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:22:11 INFO opendrift.models.basemodel:2032: 2025-01-14 18:21:53.911106 - step 2 of 24 - 1000 active elements (0 deactivated)
17:22:13 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:13 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:14 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:22:14 INFO opendrift.models.basemodel:2032: 2025-01-14 19:21:53.911106 - step 3 of 24 - 1000 active elements (0 deactivated)
17:22:15 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:15 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:16 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:22:16 INFO opendrift.models.basemodel:2032: 2025-01-14 20:21:53.911106 - step 4 of 24 - 1000 active elements (0 deactivated)
17:22:18 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:18 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:19 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:22:19 INFO opendrift.models.basemodel:2032: 2025-01-14 21:21:53.911106 - step 5 of 24 - 1000 active elements (0 deactivated)
17:22:20 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:20 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:21 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:22:21 INFO opendrift.models.basemodel:2032: 2025-01-14 22:21:53.911106 - step 6 of 24 - 1000 active elements (0 deactivated)
17:22:23 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:23 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:24 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:22:24 INFO opendrift.models.basemodel:2032: 2025-01-14 23:21:53.911106 - step 7 of 24 - 1000 active elements (0 deactivated)
17:22:25 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:25 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:26 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:22:26 INFO opendrift.models.basemodel:2032: 2025-01-15 00:21:53.911106 - step 8 of 24 - 1000 active elements (0 deactivated)
17:22:27 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:27 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:28 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:22:28 INFO opendrift.models.basemodel:2032: 2025-01-15 01:21:53.911106 - step 9 of 24 - 1000 active elements (0 deactivated)
17:22:30 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:30 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:30 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:22:30 INFO opendrift.models.basemodel:2032: 2025-01-15 02:21:53.911106 - step 10 of 24 - 1000 active elements (0 deactivated)
17:22:32 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:32 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:33 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:22:33 INFO opendrift.models.basemodel:2032: 2025-01-15 03:21:53.911106 - step 11 of 24 - 1000 active elements (0 deactivated)
17:22:35 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:35 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:36 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:22:36 INFO opendrift.models.basemodel:2032: 2025-01-15 04:21:53.911106 - step 12 of 24 - 1000 active elements (0 deactivated)
17:22:38 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:38 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:39 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:22:39 INFO opendrift.models.basemodel:2032: 2025-01-15 05:21:53.911106 - step 13 of 24 - 1000 active elements (0 deactivated)
17:22:40 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:40 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:41 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:22:41 INFO opendrift.models.basemodel:2032: 2025-01-15 06:21:53.911106 - step 14 of 24 - 1000 active elements (0 deactivated)
17:22:42 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:42 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:43 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:22:43 INFO opendrift.models.basemodel:2032: 2025-01-15 07:21:53.911106 - step 15 of 24 - 1000 active elements (0 deactivated)
17:22:45 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:45 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:46 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:22:46 INFO opendrift.models.basemodel:2032: 2025-01-15 08:21:53.911106 - step 16 of 24 - 1000 active elements (0 deactivated)
17:22:47 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:47 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:48 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:22:48 INFO opendrift.models.basemodel:2032: 2025-01-15 09:21:53.911106 - step 17 of 24 - 1000 active elements (0 deactivated)
17:22:49 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:49 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:50 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:22:50 INFO opendrift.models.basemodel:2032: 2025-01-15 10:21:53.911106 - step 18 of 24 - 1000 active elements (0 deactivated)
17:22:52 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:52 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:53 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:22:53 INFO opendrift.models.basemodel:2032: 2025-01-15 11:21:53.911106 - step 19 of 24 - 1000 active elements (0 deactivated)
17:22:54 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:54 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:55 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:22:55 INFO opendrift.models.basemodel:2032: 2025-01-15 12:21:53.911106 - step 20 of 24 - 1000 active elements (0 deactivated)
17:22:59 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:22:59 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:23:00 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:23:00 INFO opendrift.models.basemodel:2032: 2025-01-15 13:21:53.911106 - step 21 of 24 - 1000 active elements (0 deactivated)
17:23:01 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:23:01 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:23:02 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:23:02 INFO opendrift.models.basemodel:2032: 2025-01-15 14:21:53.911106 - step 22 of 24 - 1000 active elements (0 deactivated)
17:23:04 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:23:04 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:23:04 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:23:04 INFO opendrift.models.basemodel:2032: 2025-01-15 15:21:53.911106 - step 23 of 24 - 1000 active elements (0 deactivated)
17:23:06 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:23:06 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:23:07 INFO opendrift.models.shipdrift:311: Using Stokes drift direction as wave direction
17:23:07 INFO opendrift.models.basemodel:2032: 2025-01-15 16:21:53.911106 - step 24 of 24 - 1000 active elements (0 deactivated)
17:23:09 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:23:09 WARNING opendrift.readers.interpolation.structured:55: Ensemble data currently not extrapolated towards seafloor
17:23:09 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')
===========================
--------------------
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:17.1 total
0:00:00.0 preparing
0:00:16.9 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:25.4 total
0:00:00.0 preparing
0:00:25.1 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:18.8 total
0:00:00.0 preparing
0:00:18.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:16.0 total time
4.4 configuration
0.0 preparing main loop
0.0 moving elements to ocean
1:11.5 main loop
0.6 updating elements
0.0 cleaning up
--------------------
===========================
Model: ShipDrift (OpenDrift version 1.12.0)
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-01-14 17:21:53.911106 UTC
Present: 2025-01-15 17:21:53.911106 UTC
Calculation steps: 24 * 1:00:00 - total time: 1 day, 0:00:00
Output steps: 25 * 1:00:00
===========================
17:23:35 INFO opendrift.models.basemodel:4606: Saving animation to /root/project/docs/source/gallery/animations/example_shipdrift_0.gif...
17:23:47 INFO opendrift.models.basemodel:3034: Time to make animation: 0:00:12.119514
Total running time of the script: (2 minutes 0.406 seconds)