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
16:18:26 INFO opendrift:569: OpenDriftSimulation initialised (version 1.14.10 / v1.14.10-37-gd24556f)
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)]
16:18:26 INFO opendrift.models.basemodel.environment:203: Adding a global landmask from GSHHG
16:18:33 INFO opendrift.models.basemodel.environment:227: Fallback values will be used for the following variables which have no readers:
16:18:33 INFO opendrift.models.basemodel.environment:230: sea_surface_height: 0.000000
16:18:33 INFO opendrift.models.basemodel.environment:230: upward_sea_water_velocity: 0.000000
16:18:33 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_significant_height: 0.000000
16:18:33 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_stokes_drift_x_velocity: 0.000000
16:18:33 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_stokes_drift_y_velocity: 0.000000
16:18:33 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_period_at_variance_spectral_density_maximum: 0.000000
16:18:33 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000
16:18:33 INFO opendrift.models.basemodel.environment:230: sea_ice_area_fraction: 0.000000
16:18:33 INFO opendrift.models.basemodel.environment:230: sea_ice_x_velocity: 0.000000
16:18:33 INFO opendrift.models.basemodel.environment:230: sea_ice_y_velocity: 0.000000
16:18:33 INFO opendrift.models.basemodel.environment:230: sea_water_temperature: 10.000000
16:18:33 INFO opendrift.models.basemodel.environment:230: sea_water_salinity: 34.000000
16:18:33 INFO opendrift.models.basemodel.environment:230: sea_floor_depth_below_sea_level: 10000.000000
16:18:33 INFO opendrift.models.basemodel.environment:230: horizontal_diffusivity: 0.000000
16:18:33 INFO opendrift.models.basemodel.environment:230: ocean_vertical_diffusivity: 0.020000
16:18:33 INFO opendrift.models.basemodel.environment:230: ocean_mixed_layer_thickness: 50.000000
16:18:33 INFO opendrift.models.openoil.adios.dirjs:86: Querying ADIOS database for oil: EKOFISK
16:18:34 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.
16:18:34 INFO opendrift.models.openoil.openoil:1731: Using density 809.002835 and viscosity 3.3498550728972226e-06 of oiltype EKOFISK
===========================
Model: OpenOil (OpenDrift version 1.14.10)
0 active Oil particles (0 deactivated, 10000 scheduled)
-------------------
Environment variables:
-----
land_binary_mask
1) global_landmask
-----
Readers not added for the following variables:
horizontal_diffusivity
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)
16:18:34 INFO opendrift:1903: Skipping environment variable upward_sea_water_velocity because of condition ['drift:vertical_advection', 'is', False]
16:18:34 INFO opendrift:1914: Storing previous values of element property lon because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous']))
16:18:34 INFO opendrift:1914: Storing previous values of element property lat because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous']))
16:18:34 INFO opendrift:955: Using existing reader for land_binary_mask to move elements to ocean
16:18:34 INFO opendrift:986: All points are in ocean
16:18:34 INFO opendrift.models.openoil.openoil:697: Oil-water surface tension is 0.027884 Nm
16:18:34 INFO opendrift.models.openoil.openoil:710: Max water fraction not available for EKOFISK, using default
16:18:34 INFO opendrift:2213: 2026-08-21 16:18:26.905071 - step 1 of 48 - 417 active elements (0 deactivated)
16:18:34 INFO opendrift.readers:67: Opening file with xr.open_dataset
16:18:35 INFO opendrift.readers.reader_netCDF_CF_generic:340: Detected dimensions: {'x': 'X', 'y': 'Y', 'z': 'depth', 'time': 'time'}
16:18:35 INFO opendrift.readers.basereader:175: Variable x_sea_water_velocity will be rotated from eastward_sea_water_velocity
16:18:35 INFO opendrift.readers.basereader:175: Variable y_sea_water_velocity will be rotated from northward_sea_water_velocity
16:18:35 INFO opendrift.readers.basereader:175: Variable x_wind will be rotated from eastward_wind
16:18:35 INFO opendrift.readers.basereader:175: Variable y_wind will be rotated from northward_wind
16:18:38 INFO opendrift:2213: 2026-08-21 16:48:26.905071 - step 2 of 48 - 834 active elements (0 deactivated)
16:18:38 INFO opendrift:2213: 2026-08-21 17:18:26.905071 - step 3 of 48 - 1250 active elements (0 deactivated)
16:18:40 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`.
16:18:40 INFO opendrift:2213: 2026-08-21 17:48:26.905071 - step 4 of 48 - 1667 active elements (0 deactivated)
16:18:40 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`.
16:18:40 INFO opendrift:2213: 2026-08-21 18:18:26.905071 - step 5 of 48 - 2084 active elements (0 deactivated)
16:18:41 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`.
16:18:42 INFO opendrift:2213: 2026-08-21 18:48:26.905071 - step 6 of 48 - 2500 active elements (0 deactivated)
16:18:42 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`.
16:18:42 INFO opendrift:2213: 2026-08-21 19:18:26.905071 - step 7 of 48 - 2917 active elements (0 deactivated)
16:18:43 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`.
16:18:43 INFO opendrift:2213: 2026-08-21 19:48:26.905071 - step 8 of 48 - 3334 active elements (0 deactivated)
16:18:43 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`.
16:18:44 INFO opendrift:2213: 2026-08-21 20:18:26.905071 - step 9 of 48 - 3750 active elements (0 deactivated)
16:18:45 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`.
16:18:45 INFO opendrift:2213: 2026-08-21 20:48:26.905071 - step 10 of 48 - 4167 active elements (0 deactivated)
16:18:45 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`.
16:18:46 INFO opendrift:2213: 2026-08-21 21:18:26.905071 - step 11 of 48 - 4583 active elements (0 deactivated)
16:18:47 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`.
16:18:47 INFO opendrift:2213: 2026-08-21 21:48:26.905071 - step 12 of 48 - 5000 active elements (0 deactivated)
16:18:47 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`.
16:18:48 INFO opendrift:2213: 2026-08-21 22:18:26.905071 - step 13 of 48 - 5417 active elements (0 deactivated)
16:18:49 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`.
16:18:50 INFO opendrift:2213: 2026-08-21 22:48:26.905071 - step 14 of 48 - 5833 active elements (0 deactivated)
16:18:50 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`.
16:18:50 INFO opendrift:2213: 2026-08-21 23:18:26.905071 - step 15 of 48 - 6250 active elements (0 deactivated)
16:18:51 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`.
16:18:52 INFO opendrift:2213: 2026-08-21 23:48:26.905071 - step 16 of 48 - 6667 active elements (0 deactivated)
16:18: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`.
16:18:52 INFO opendrift:2213: 2026-08-22 00:18:26.905071 - step 17 of 48 - 7083 active elements (0 deactivated)
16:18: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`.
16:18:54 INFO opendrift:2213: 2026-08-22 00:48:26.905071 - step 18 of 48 - 7500 active elements (0 deactivated)
16:18: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`.
16:18:54 INFO opendrift:2213: 2026-08-22 01:18:26.905071 - step 19 of 48 - 7916 active elements (0 deactivated)
16:18: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`.
16:18:57 INFO opendrift:2213: 2026-08-22 01:48:26.905071 - step 20 of 48 - 8333 active elements (0 deactivated)
16:18: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`.
16:18:57 INFO opendrift:2213: 2026-08-22 02:18:26.905071 - step 21 of 48 - 8750 active elements (0 deactivated)
16:18: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`.
16:18:59 INFO opendrift:2213: 2026-08-22 02:48:26.905071 - step 22 of 48 - 9166 active elements (0 deactivated)
16:18: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`.
16:18:59 INFO opendrift:2213: 2026-08-22 03:18:26.905071 - step 23 of 48 - 9583 active elements (0 deactivated)
16:19:01 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`.
16:19:01 INFO opendrift:2213: 2026-08-22 03:48:26.905071 - step 24 of 48 - 9999 active elements (1 deactivated)
16:19:01 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`.
16:19:02 INFO opendrift:2213: 2026-08-22 04:18:26.905071 - step 25 of 48 - 9999 active elements (1 deactivated)
16:19:03 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`.
16:19:04 INFO opendrift:2213: 2026-08-22 04:48:26.905071 - step 26 of 48 - 9994 active elements (6 deactivated)
16:19:04 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`.
16:19:04 INFO opendrift:2213: 2026-08-22 05:18:26.905071 - step 27 of 48 - 9991 active elements (9 deactivated)
16:19:07 INFO opendrift:2213: 2026-08-22 05:48:26.905071 - step 28 of 48 - 9990 active elements (10 deactivated)
16:19:07 INFO opendrift:2213: 2026-08-22 06:18:26.905071 - step 29 of 48 - 9989 active elements (11 deactivated)
16:19:09 INFO opendrift:2213: 2026-08-22 06:48:26.905071 - step 30 of 48 - 9987 active elements (13 deactivated)
16:19:10 INFO opendrift:2213: 2026-08-22 07:18:26.905071 - step 31 of 48 - 9984 active elements (16 deactivated)
16:19:12 INFO opendrift:2213: 2026-08-22 07:48:26.905071 - step 32 of 48 - 9978 active elements (22 deactivated)
16:19:12 INFO opendrift:2213: 2026-08-22 08:18:26.905071 - step 33 of 48 - 9970 active elements (30 deactivated)
16:19:15 INFO opendrift:2213: 2026-08-22 08:48:26.905071 - step 34 of 48 - 9958 active elements (42 deactivated)
16:19:15 INFO opendrift:2213: 2026-08-22 09:18:26.905071 - step 35 of 48 - 9947 active elements (53 deactivated)
16:19:17 INFO opendrift:2213: 2026-08-22 09:48:26.905071 - step 36 of 48 - 9941 active elements (59 deactivated)
16:19:18 INFO opendrift:2213: 2026-08-22 10:18:26.905071 - step 37 of 48 - 9931 active elements (69 deactivated)
16:19:20 INFO opendrift:2213: 2026-08-22 10:48:26.905071 - step 38 of 48 - 9911 active elements (89 deactivated)
16:19:20 INFO opendrift:2213: 2026-08-22 11:18:26.905071 - step 39 of 48 - 9904 active elements (96 deactivated)
16:19:23 INFO opendrift:2213: 2026-08-22 11:48:26.905071 - step 40 of 48 - 9894 active elements (106 deactivated)
16:19:23 INFO opendrift:2213: 2026-08-22 12:18:26.905071 - step 41 of 48 - 9886 active elements (114 deactivated)
16:19:26 INFO opendrift:2213: 2026-08-22 12:48:26.905071 - step 42 of 48 - 9864 active elements (136 deactivated)
16:19:26 INFO opendrift:2213: 2026-08-22 13:18:26.905071 - step 43 of 48 - 9848 active elements (152 deactivated)
16:19:28 INFO opendrift:2213: 2026-08-22 13:48:26.905071 - step 44 of 48 - 9833 active elements (167 deactivated)
16:19:29 INFO opendrift:2213: 2026-08-22 14:18:26.905071 - step 45 of 48 - 9823 active elements (177 deactivated)
16:19:31 INFO opendrift:2213: 2026-08-22 14:48:26.905071 - step 46 of 48 - 9817 active elements (183 deactivated)
16:19:32 INFO opendrift:2213: 2026-08-22 15:18:26.905071 - step 47 of 48 - 9803 active elements (197 deactivated)
16:19:35 INFO opendrift:2213: 2026-08-22 15:48:26.905071 - step 48 of 48 - 9795 active elements (205 deactivated)
Print and plot results
print(o)
===========================
--------------------
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/fou-hi/norkystv3_800m_m00_be
0:00:49.3 total
0:00:00.0 preparing
0:00:48.0 reading
0:00:05.1 interpolation
0:00:00.1 interpolation_time
0:00:01.3 rotating vectors
0:00:00.0 masking
--------------------
Performance:
1:08.9 total time
7.2 configuration
0.1 preparing main loop
0.0 moving elements to ocean
1:01.5 main loop
6.5 updating elements
0.1 oil weathering
0.0 updating viscosities
0.0 updating densities
0.0 emulsification
0.0 dispersion
5.7 vertical mixing
0.0 cleaning up
--------------------
===========================
Model: OpenOil (OpenDrift version 1.14.10)
9776 active Oil particles (224 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:
horizontal_diffusivity
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: 2026-08-21 16:18:26.905071 UTC
Present: 2026-08-22 16:18:26.905071 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)
16:19:52 INFO opendrift:4799: Saving animation to /root/project/docs/source/gallery/animations/example_cone_0.gif...
16:20:07 INFO opendrift:3217: Time to make animation: 0:00:31.205261
o.plot(fast=True, ocean_color='skyblue', land_color='dimgray', text=text)

16:20:07 WARNING opendrift:2589: Plotting fast. This will make your plots less accurate.
(<GeoAxes: title={'center': 'OpenDrift - OpenOil (EKOFISK)\n2026-08-21 16:18 to 2026-08-22 16:18 UTC (25 steps)'}>, <Figure size 700.471x1100 with 1 Axes>)
Total running time of the script: (2 minutes 21.760 seconds)