Note
Go to the end to download the full example code.
Caspian / lake
from datetime import datetime, timedelta
from opendrift.models.oceandrift import OceanDrift
from opendrift.readers import reader_shape
import cartopy
The default GSHHG landmask reader classifies lakes (e.g. Caspian Sea) as land and not water. For simulations in lakes, we can use a custom reader for lakes only.
level = 'h' # using high resolution coastline
reader_lakes = reader_shape.Reader.from_shpfiles(
f'{cartopy.config['data_dir']}/shapefiles/gshhs/{level}/GSHHS_{level}_L2.shp',
invert=True) # Inverting since inside of polygons is water (lake) and not land.
Disabling the default landmask reader, and using the above reader instead
o = OceanDrift(loglevel=20)
o.add_reader(reader_lakes)
o.set_config('general:use_auto_landmask', False) # To use custom landmask instead
o.set_config('environment:constant:x_sea_water_velocity', 1)
o.set_config('environment:constant:horizontal_diffusivity', 100)
o.seed_elements(lon=48.819, lat=44.959, radius=5000, number=100, time=datetime.now())
o.run(steps=10)
o.plot(fast=False, buffer=2)

14:11:17 INFO opendrift:568: OpenDriftSimulation initialised (version 1.14.9 / v1.14.9-43-g22dbf7d)
14:11:17 INFO opendrift.models.basemodel.environment:227: Fallback values will be used for the following variables which have no readers:
14:11:17 INFO opendrift.models.basemodel.environment:230: y_sea_water_velocity: 0.000000
14:11:17 INFO opendrift.models.basemodel.environment:230: sea_surface_height: 0.000000
14:11:17 INFO opendrift.models.basemodel.environment:230: x_wind: 0.000000
14:11:17 INFO opendrift.models.basemodel.environment:230: y_wind: 0.000000
14:11:17 INFO opendrift.models.basemodel.environment:230: upward_sea_water_velocity: 0.000000
14:11:17 INFO opendrift.models.basemodel.environment:230: ocean_vertical_diffusivity: 0.000000
14:11:17 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_significant_height: 0.000000
14:11:17 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_stokes_drift_x_velocity: 0.000000
14:11:17 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_stokes_drift_y_velocity: 0.000000
14:11:17 INFO opendrift.models.basemodel.environment:230: ocean_mixed_layer_thickness: 50.000000
14:11:17 INFO opendrift.models.basemodel.environment:230: sea_floor_depth_below_sea_level: 10000.000000
14:11:17 INFO opendrift:1894: Skipping environment variable ocean_vertical_diffusivity because of condition ['drift:vertical_mixing', 'is', False]
14:11:17 INFO opendrift:1894: Skipping environment variable ocean_mixed_layer_thickness because of condition ['drift:vertical_mixing', 'is', False]
14:11:17 INFO opendrift:1905: Storing previous values of element property lon because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous']))
14:11:17 INFO opendrift:1905: Storing previous values of element property lat because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous']))
14:11:17 INFO opendrift:1913: Storing previous values of environment variable sea_surface_height because of condition ['drift:vertical_advection', 'is', True]
14:11:17 INFO opendrift:947: Using existing reader for land_binary_mask to move elements to ocean
14:11:17 INFO opendrift.readers.reader_shape:149: Building KDTree from 6601 geometries with buffer distance 0.000000e+00
14:11:21 INFO opendrift:2202: 2026-04-21 14:11:17.551540 - step 1 of 10 - 100 active elements (0 deactivated)
14:11:22 INFO opendrift:2202: 2026-04-21 15:11:17.551540 - step 2 of 10 - 100 active elements (0 deactivated)
14:11:22 INFO opendrift:2202: 2026-04-21 16:11:17.551540 - step 3 of 10 - 100 active elements (0 deactivated)
14:11:22 INFO opendrift:2202: 2026-04-21 17:11:17.551540 - step 4 of 10 - 100 active elements (0 deactivated)
14:11:22 INFO opendrift:2202: 2026-04-21 18:11:17.551540 - step 5 of 10 - 100 active elements (0 deactivated)
14:11:22 INFO opendrift:2202: 2026-04-21 19:11:17.551540 - step 6 of 10 - 100 active elements (0 deactivated)
14:11:22 INFO opendrift:2202: 2026-04-21 20:11:17.551540 - step 7 of 10 - 100 active elements (0 deactivated)
14:11:22 INFO opendrift:2202: 2026-04-21 21:11:17.551540 - step 8 of 10 - 100 active elements (0 deactivated)
14:11:22 INFO opendrift:2202: 2026-04-21 22:11:17.551540 - step 9 of 10 - 100 active elements (0 deactivated)
14:11:22 INFO opendrift:2202: 2026-04-21 23:11:17.551540 - step 10 of 10 - 100 active elements (0 deactivated)
(<GeoAxes: title={'center': 'OpenDrift - OceanDrift\n2026-04-21 14:11 to 2026-04-22 00:11 UTC (11 steps)'}>, <Figure size 1100x755.105 with 1 Axes>)
Total running time of the script: (0 minutes 27.533 seconds)