Note
Go to the end to download the full example code.
Cone seeding
from datetime import datetime, timedelta
from opendrift.readers import reader_netCDF_CF_generic
from opendrift.models.openoil import OpenOil
o = OpenOil(loglevel=20) # Set loglevel to 0 for debug information
09:00:40 INFO opendrift:513: OpenDriftSimulation initialised (version 1.14.2 / v1.14.2-108-gbbc988b)
Using live data from Thredds
o.add_readers_from_list([
'https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be'])
Adjusting some configuration
o.set_config('processes:dispersion', True)
o.set_config('processes:evaporation', False)
o.set_config('processes:emulsification', True)
Seed elements along cone, e.g. ship track with increasing uncertainty in position
latstart = 68.988911
lonstart = 16.040701
latend = 69.991446
lonend = 17.760061
time = [datetime.utcnow(), datetime.utcnow() + timedelta(hours=12)]
o.seed_cone(lon=[lonstart, lonend], lat=[latstart, latend],
oil_type='EKOFISK', radius=[100, 800], number=10000, time=[time])
print(o)
/root/project/examples/example_cone.py:31: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
time = [datetime.utcnow(), datetime.utcnow() + timedelta(hours=12)]
09:00:40 INFO opendrift.models.basemodel.environment:206: Adding a global landmask from GSHHG
09:00:45 INFO opendrift.models.basemodel.environment:229: Fallback values will be used for the following variables which have no readers:
09:00:45 INFO opendrift.models.basemodel.environment:232: sea_surface_height: 0.000000
09:00:45 INFO opendrift.models.basemodel.environment:232: upward_sea_water_velocity: 0.000000
09:00:45 INFO opendrift.models.basemodel.environment:232: sea_surface_wave_significant_height: 0.000000
09:00:45 INFO opendrift.models.basemodel.environment:232: sea_surface_wave_stokes_drift_x_velocity: 0.000000
09:00:45 INFO opendrift.models.basemodel.environment:232: sea_surface_wave_stokes_drift_y_velocity: 0.000000
09:00:45 INFO opendrift.models.basemodel.environment:232: sea_surface_wave_period_at_variance_spectral_density_maximum: 0.000000
09:00:45 INFO opendrift.models.basemodel.environment:232: sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000
09:00:45 INFO opendrift.models.basemodel.environment:232: sea_ice_area_fraction: 0.000000
09:00:45 INFO opendrift.models.basemodel.environment:232: sea_ice_x_velocity: 0.000000
09:00:45 INFO opendrift.models.basemodel.environment:232: sea_ice_y_velocity: 0.000000
09:00:45 INFO opendrift.models.basemodel.environment:232: sea_water_temperature: 10.000000
09:00:45 INFO opendrift.models.basemodel.environment:232: sea_water_salinity: 34.000000
09:00:45 INFO opendrift.models.basemodel.environment:232: sea_floor_depth_below_sea_level: 10000.000000
09:00:45 INFO opendrift.models.basemodel.environment:232: ocean_vertical_diffusivity: 0.020000
09:00:45 INFO opendrift.models.basemodel.environment:232: ocean_mixed_layer_thickness: 50.000000
09:00:45 INFO opendrift.models.openoil.adios.dirjs:86: Querying ADIOS database for oil: EKOFISK
09:00:45 WARNING opendrift.models.openoil.adios.dirjs:90: Several oils found with name: EKOFISK: ['AD00328', 'AD00329', 'AD00332', 'AD00333', 'AD01944', 'AD02094', 'AD02463', 'AD02558', 'NO00013', 'NO00014', 'NO00015', 'NO00016'], using first.
09:00:45 INFO opendrift.models.openoil.openoil:1717: Using density 809.002835 and viscosity 3.3498550728972226e-06 of oiltype EKOFISK
===========================
Model: OpenOil (OpenDrift version 1.14.2)
0 active Oil particles (0 deactivated, 10000 scheduled)
-------------------
Environment variables:
-----
land_binary_mask
1) global_landmask
-----
Readers not added for the following variables:
ocean_mixed_layer_thickness
ocean_vertical_diffusivity
sea_floor_depth_below_sea_level
sea_ice_area_fraction
sea_ice_x_velocity
sea_ice_y_velocity
sea_surface_height
sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment
sea_surface_wave_period_at_variance_spectral_density_maximum
sea_surface_wave_significant_height
sea_surface_wave_stokes_drift_x_velocity
sea_surface_wave_stokes_drift_y_velocity
sea_water_salinity
sea_water_temperature
upward_sea_water_velocity
x_sea_water_velocity
x_wind
y_sea_water_velocity
y_wind
---
Lazy readers:
LazyReader: https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be
Discarded readers:
===========================
Running model for 24 hours
o.run(steps=24*2, time_step=1800, time_step_output=3600)
09:00:45 INFO opendrift:1733: Skipping environment variable upward_sea_water_velocity because of condition ['drift:vertical_advection', 'is', False]
09:00:45 INFO opendrift:1744: Storing previous values of element property lon because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous']))
09:00:45 INFO opendrift:1744: Storing previous values of element property lat because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous']))
09:00:46 INFO opendrift:899: Using existing reader for land_binary_mask to move elements to ocean
09:00:46 INFO opendrift:929: All points are in ocean
09:00:46 INFO opendrift.models.openoil.openoil:692: Oil-water surface tension is 0.027884 Nm
09:00:46 INFO opendrift.models.openoil.openoil:705: Max water fraction not available for EKOFISK, using default
09:00:46 INFO opendrift:2036: 2025-08-13 09:00:40.785392 - step 1 of 48 - 417 active elements (0 deactivated)
09:00:46 INFO opendrift.readers:61: Opening file with xr.open_dataset
09:00:47 INFO opendrift.readers.reader_netCDF_CF_generic:332: Detected dimensions: {'x': 'X', 'y': 'Y', 'z': 'depth', 'time': 'time'}
09:00:47 INFO opendrift.readers.basereader:176: Variable x_sea_water_velocity will be rotated from eastward_sea_water_velocity
09:00:47 INFO opendrift.readers.basereader:176: Variable y_sea_water_velocity will be rotated from northward_sea_water_velocity
09:00:47 INFO opendrift.readers.basereader:176: Variable x_wind will be rotated from eastward_wind
09:00:47 INFO opendrift.readers.basereader:176: Variable y_wind will be rotated from northward_wind
09:00:50 INFO opendrift:2036: 2025-08-13 09:30:40.785392 - step 2 of 48 - 834 active elements (0 deactivated)
09:00:50 INFO opendrift:2036: 2025-08-13 10:00:40.785392 - step 3 of 48 - 1250 active elements (0 deactivated)
09:00:52 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:00:52 INFO opendrift:2036: 2025-08-13 10:30:40.785392 - step 4 of 48 - 1667 active elements (0 deactivated)
09:00:52 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:00:52 INFO opendrift:2036: 2025-08-13 11:00:40.785392 - step 5 of 48 - 2084 active elements (0 deactivated)
09:00:53 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:00:54 INFO opendrift:2036: 2025-08-13 11:30:40.785392 - step 6 of 48 - 2500 active elements (0 deactivated)
09:00:54 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:00:54 INFO opendrift:2036: 2025-08-13 12:00:40.785392 - step 7 of 48 - 2917 active elements (0 deactivated)
09:00:55 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:00:56 INFO opendrift:2036: 2025-08-13 12:30:40.785392 - step 8 of 48 - 3334 active elements (0 deactivated)
09:00:56 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:00:56 INFO opendrift:2036: 2025-08-13 13:00:40.785392 - step 9 of 48 - 3750 active elements (0 deactivated)
09:00:57 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:00:58 INFO opendrift:2036: 2025-08-13 13:30:40.785392 - step 10 of 48 - 4167 active elements (0 deactivated)
09:00:58 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:00:58 INFO opendrift:2036: 2025-08-13 14:00:40.785392 - step 11 of 48 - 4583 active elements (0 deactivated)
09:00:59 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:01:00 INFO opendrift:2036: 2025-08-13 14:30:40.785392 - step 12 of 48 - 5000 active elements (0 deactivated)
09:01:00 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:01:00 INFO opendrift:2036: 2025-08-13 15:00:40.785392 - step 13 of 48 - 5417 active elements (0 deactivated)
09:01:02 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:01:02 INFO opendrift:2036: 2025-08-13 15:30:40.785392 - step 14 of 48 - 5833 active elements (0 deactivated)
09:01:02 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:01:02 INFO opendrift:2036: 2025-08-13 16:00:40.785392 - step 15 of 48 - 6250 active elements (0 deactivated)
09:01:05 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:01:07 INFO opendrift:2036: 2025-08-13 16:30:40.785392 - step 16 of 48 - 6666 active elements (1 deactivated)
09:01:07 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:01:08 INFO opendrift:2036: 2025-08-13 17:00:40.785392 - step 17 of 48 - 7081 active elements (2 deactivated)
09:01:10 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:01:10 INFO opendrift:2036: 2025-08-13 17:30:40.785392 - step 18 of 48 - 7493 active elements (7 deactivated)
09:01:10 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:01:10 INFO opendrift:2036: 2025-08-13 18:00:40.785392 - step 19 of 48 - 7898 active elements (18 deactivated)
09:01:12 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:01:13 INFO opendrift:2036: 2025-08-13 18:30:40.785392 - step 20 of 48 - 8306 active elements (27 deactivated)
09:01:13 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:01:13 INFO opendrift:2036: 2025-08-13 19:00:40.785392 - step 21 of 48 - 8713 active elements (37 deactivated)
09:01:15 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:01:15 INFO opendrift:2036: 2025-08-13 19:30:40.785392 - step 22 of 48 - 9122 active elements (44 deactivated)
09:01:15 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:01:16 INFO opendrift:2036: 2025-08-13 20:00:40.785392 - step 23 of 48 - 9529 active elements (54 deactivated)
09:01:18 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:01:18 INFO opendrift:2036: 2025-08-13 20:30:40.785392 - step 24 of 48 - 9937 active elements (63 deactivated)
09:01:18 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:01:19 INFO opendrift:2036: 2025-08-13 21:00:40.785392 - step 25 of 48 - 9930 active elements (70 deactivated)
09:01:21 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:01:21 INFO opendrift:2036: 2025-08-13 21:30:40.785392 - step 26 of 48 - 9926 active elements (74 deactivated)
09:01:21 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:01:22 INFO opendrift:2036: 2025-08-13 22:00:40.785392 - step 27 of 48 - 9919 active elements (81 deactivated)
09:01:24 INFO opendrift:2036: 2025-08-13 22:30:40.785392 - step 28 of 48 - 9904 active elements (96 deactivated)
09:01:25 INFO opendrift:2036: 2025-08-13 23:00:40.785392 - step 29 of 48 - 9887 active elements (113 deactivated)
09:01:27 INFO opendrift:2036: 2025-08-13 23:30:40.785392 - step 30 of 48 - 9884 active elements (116 deactivated)
09:01:27 INFO opendrift:2036: 2025-08-14 00:00:40.785392 - step 31 of 48 - 9880 active elements (120 deactivated)
09:01:30 INFO opendrift:2036: 2025-08-14 00:30:40.785392 - step 32 of 48 - 9876 active elements (124 deactivated)
09:01:30 INFO opendrift:2036: 2025-08-14 01:00:40.785392 - step 33 of 48 - 9871 active elements (129 deactivated)
09:01:33 INFO opendrift:2036: 2025-08-14 01:30:40.785392 - step 34 of 48 - 9862 active elements (138 deactivated)
09:01:33 INFO opendrift:2036: 2025-08-14 02:00:40.785392 - step 35 of 48 - 9845 active elements (155 deactivated)
09:01:36 INFO opendrift:2036: 2025-08-14 02:30:40.785392 - step 36 of 48 - 9826 active elements (174 deactivated)
09:01:36 INFO opendrift:2036: 2025-08-14 03:00:40.785392 - step 37 of 48 - 9808 active elements (192 deactivated)
09:01:39 INFO opendrift:2036: 2025-08-14 03:30:40.785392 - step 38 of 48 - 9792 active elements (208 deactivated)
09:01:39 INFO opendrift:2036: 2025-08-14 04:00:40.785392 - step 39 of 48 - 9770 active elements (230 deactivated)
09:01:42 INFO opendrift:2036: 2025-08-14 04:30:40.785392 - step 40 of 48 - 9747 active elements (253 deactivated)
09:01:42 INFO opendrift:2036: 2025-08-14 05:00:40.785392 - step 41 of 48 - 9731 active elements (269 deactivated)
09:01:45 INFO opendrift:2036: 2025-08-14 05:30:40.785392 - step 42 of 48 - 9714 active elements (286 deactivated)
09:01:45 INFO opendrift:2036: 2025-08-14 06:00:40.785392 - step 43 of 48 - 9693 active elements (307 deactivated)
09:01:48 INFO opendrift:2036: 2025-08-14 06:30:40.785392 - step 44 of 48 - 9671 active elements (329 deactivated)
09:01:48 INFO opendrift:2036: 2025-08-14 07:00:40.785392 - step 45 of 48 - 9661 active elements (339 deactivated)
09:01:50 INFO opendrift:2036: 2025-08-14 07:30:40.785392 - step 46 of 48 - 9653 active elements (347 deactivated)
09:01:51 INFO opendrift:2036: 2025-08-14 08:00:40.785392 - step 47 of 48 - 9644 active elements (356 deactivated)
09:01:53 INFO opendrift:2036: 2025-08-14 08:30:40.785392 - step 48 of 48 - 9634 active elements (366 deactivated)
Print and plot results
print(o)
===========================
--------------------
Reader performance:
--------------------
global_landmask
0:00:01.5 total
0:00:00.0 preparing
0:00:01.5 reading
0:00:00.0 masking
--------------------
https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be
0:00:52.6 total
0:00:00.0 preparing
0:00:51.3 reading
0:00:04.1 interpolation
0:00:00.1 interpolation_time
0:00:01.2 rotating vectors
0:00:00.0 masking
--------------------
Performance:
1:13.0 total time
5.0 configuration
0.2 preparing main loop
0.0 moving elements to ocean
1:07.7 main loop
6.7 updating elements
0.0 oil weathering
0.0 updating viscosities
0.0 updating densities
0.0 emulsification
0.0 dispersion
6.0 vertical mixing
0.0 cleaning up
--------------------
===========================
Model: OpenOil (OpenDrift version 1.14.2)
9612 active Oil particles (388 deactivated, 0 scheduled)
-------------------
Environment variables:
-----
land_binary_mask
1) global_landmask
-----
ocean_vertical_diffusivity
sea_floor_depth_below_sea_level
sea_surface_height
sea_water_salinity
sea_water_temperature
x_sea_water_velocity
x_wind
y_sea_water_velocity
y_wind
1) https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be
-----
Readers not added for the following variables:
ocean_mixed_layer_thickness
sea_ice_area_fraction
sea_ice_x_velocity
sea_ice_y_velocity
sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment
sea_surface_wave_period_at_variance_spectral_density_maximum
sea_surface_wave_significant_height
sea_surface_wave_stokes_drift_x_velocity
sea_surface_wave_stokes_drift_y_velocity
Discarded readers:
Time:
Start: 2025-08-13 09:00:40.785392 UTC
Present: 2025-08-14 09:00:40.785392 UTC
Calculation steps: 48 * 0:30:00 - total time: 1 day, 0:00:00
Output steps: 25 * 1:00:00
===========================
Add text label on the map
text = [{'s': 'Senja', 'x': 17.3, 'y': 69.3, 'fontsize': 20, 'color': 'g',
'backgroundcolor': 'white', 'bbox': dict(facecolor='white', alpha=0.8), 'zorder': 1000}]
o.animation(fast=False, ocean_color='skyblue', land_color='burlywood', text=text)
09:02:07 INFO opendrift:4560: Saving animation to /root/project/docs/source/gallery/animations/example_cone_0.gif...
09:02:25 INFO opendrift:3001: Time to make animation: 0:00:30.973262

o.plot(fast=True, ocean_color='skyblue', land_color='dimgray', text=text)

09:02:25 WARNING opendrift:2392: Plotting fast. This will make your plots less accurate.
(<GeoAxes: title={'center': 'OpenDrift - OpenOil (EKOFISK)\n2025-08-13 09:00 to 2025-08-14 09:00 UTC (25 steps)'}>, <Figure size 799.385x1100 with 1 Axes>)
Total running time of the script: (2 minutes 11.611 seconds)