Static 2D current field

from datetime import datetime, timedelta
import numpy as np

from opendrift.readers.reader_constant_2d import Reader
from opendrift.models.oceandrift import OceanDrift

Constructing a static, rotating ocean current field,

lon, lat = np.meshgrid(np.linspace(2,6,30), np.linspace(59,62,30))
lon0 = 4
lat0 = 60.5
u = -(lat-lat0)/np.sqrt((lon-lon0)**2 + (lat-lat0)**2)
v = (lon-lon0)/np.sqrt((lon-lon0)**2 + (lat-lat0)**2)
lon = np.linspace(0,5,30)
lat = np.linspace(59,62,30)

r = Reader(x=lon, y=lat, proj4='+proj=latlong',
           array_dict = {'x_sea_water_velocity': u, 'y_sea_water_velocity': v})

o = OceanDrift(loglevel=20)
o.set_config('environment:fallback:land_binary_mask', 0)
o.add_reader(r)
o.seed_elements(lon=3, lat=60.5, number=1000, radius=30000, time=datetime.now())
o.run(duration=timedelta(hours=72))
o.animation(fast=True)
20:19:55 INFO    opendrift.models.basemodel:515: OpenDriftSimulation initialised (version 1.12.0 / v1.12.0-26-g390e945)
20:19:55 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...
20:19:58 INFO    opendrift.models.basemodel.environment:245: Fallback values will be used for the following variables which have no readers:
20:19:58 INFO    opendrift.models.basemodel.environment:248:    sea_surface_height: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    x_wind: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    y_wind: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    upward_sea_water_velocity: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    ocean_vertical_diffusivity: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_significant_height: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_stokes_drift_x_velocity: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_stokes_drift_y_velocity: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_period_at_variance_spectral_density_maximum: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    sea_surface_swell_wave_to_direction: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    sea_surface_swell_wave_peak_period_from_variance_spectral_density: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    sea_surface_swell_wave_significant_height: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wind_wave_to_direction: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wind_wave_mean_period: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wind_wave_significant_height: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    surface_downward_x_stress: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    surface_downward_y_stress: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    turbulent_kinetic_energy: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    turbulent_generic_length_scale: 0.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    ocean_mixed_layer_thickness: 50.000000
20:19:58 INFO    opendrift.models.basemodel.environment:248:    sea_floor_depth_below_sea_level: 10000.000000
20:19:58 INFO    opendrift.models.basemodel:935: Using existing reader for land_binary_mask
20:19:58 INFO    opendrift.models.basemodel:946: All points are in ocean
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-12 20:19:55.043568 - step 1 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-12 21:19:55.043568 - step 2 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-12 22:19:55.043568 - step 3 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-12 23:19:55.043568 - step 4 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 00:19:55.043568 - step 5 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 01:19:55.043568 - step 6 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 02:19:55.043568 - step 7 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 03:19:55.043568 - step 8 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 04:19:55.043568 - step 9 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 05:19:55.043568 - step 10 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 06:19:55.043568 - step 11 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 07:19:55.043568 - step 12 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 08:19:55.043568 - step 13 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 09:19:55.043568 - step 14 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 10:19:55.043568 - step 15 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 11:19:55.043568 - step 16 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 12:19:55.043568 - step 17 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 13:19:55.043568 - step 18 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 14:19:55.043568 - step 19 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 15:19:55.043568 - step 20 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 16:19:55.043568 - step 21 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 17:19:55.043568 - step 22 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 18:19:55.043568 - step 23 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 19:19:55.043568 - step 24 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 20:19:55.043568 - step 25 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 21:19:55.043568 - step 26 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 22:19:55.043568 - step 27 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-13 23:19:55.043568 - step 28 of 72 - 1000 active elements (0 deactivated)
20:19:58 INFO    opendrift.models.basemodel:2035: 2024-12-14 00:19:55.043568 - step 29 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 01:19:55.043568 - step 30 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 02:19:55.043568 - step 31 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 03:19:55.043568 - step 32 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 04:19:55.043568 - step 33 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 05:19:55.043568 - step 34 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 06:19:55.043568 - step 35 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 07:19:55.043568 - step 36 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 08:19:55.043568 - step 37 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 09:19:55.043568 - step 38 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 10:19:55.043568 - step 39 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 11:19:55.043568 - step 40 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 12:19:55.043568 - step 41 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 13:19:55.043568 - step 42 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 14:19:55.043568 - step 43 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 15:19:55.043568 - step 44 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 16:19:55.043568 - step 45 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 17:19:55.043568 - step 46 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 18:19:55.043568 - step 47 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 19:19:55.043568 - step 48 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 20:19:55.043568 - step 49 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 21:19:55.043568 - step 50 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 22:19:55.043568 - step 51 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-14 23:19:55.043568 - step 52 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 00:19:55.043568 - step 53 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 01:19:55.043568 - step 54 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 02:19:55.043568 - step 55 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 03:19:55.043568 - step 56 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 04:19:55.043568 - step 57 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 05:19:55.043568 - step 58 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 06:19:55.043568 - step 59 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 07:19:55.043568 - step 60 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 08:19:55.043568 - step 61 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 09:19:55.043568 - step 62 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 10:19:55.043568 - step 63 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 11:19:55.043568 - step 64 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 12:19:55.043568 - step 65 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 13:19:55.043568 - step 66 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 14:19:55.043568 - step 67 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 15:19:55.043568 - step 68 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 16:19:55.043568 - step 69 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 17:19:55.043568 - step 70 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 18:19:55.043568 - step 71 of 72 - 1000 active elements (0 deactivated)
20:19:59 INFO    opendrift.models.basemodel:2035: 2024-12-15 19:19:55.043568 - step 72 of 72 - 1000 active elements (0 deactivated)
20:19:59 WARNING opendrift.models.basemodel:2410: Plotting fast. This will make your plots less accurate.
/opt/conda/envs/opendrift/lib/python3.11/site-packages/cartopy/mpl/geoaxes.py:1692: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  result = super().scatter(*args, **kwargs)
20:20:01 INFO    opendrift.models.basemodel:4613: Saving animation to /root/project/docs/source/gallery/animations/example_static_2d_current_0.gif...
20:20:40 INFO    opendrift.models.basemodel:3037: Time to make animation: 0:00:40.864937
../_images/example_static_2d_current_0.gif

Total running time of the script: (0 minutes 49.468 seconds)

Gallery generated by Sphinx-Gallery