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)

Out:

13:46:10 INFO    opendrift.models.basemodel: OpenDriftSimulation initialised (version 1.7.1 / v1.7.1-87-g074c1d2)
13:46:10 INFO    opendrift.models.basemodel: Fallback values will be used for the following variables which have no readers:
13:46:10 INFO    opendrift.models.basemodel:    x_wind: 0.000000
13:46:10 INFO    opendrift.models.basemodel:    y_wind: 0.000000
13:46:10 INFO    opendrift.models.basemodel:    upward_sea_water_velocity: 0.000000
13:46:10 INFO    opendrift.models.basemodel:    ocean_vertical_diffusivity: 0.000000
13:46:10 INFO    opendrift.models.basemodel:    sea_surface_wave_significant_height: 0.000000
13:46:10 INFO    opendrift.models.basemodel:    sea_surface_wave_stokes_drift_x_velocity: 0.000000
13:46:10 INFO    opendrift.models.basemodel:    sea_surface_wave_stokes_drift_y_velocity: 0.000000
13:46:10 INFO    opendrift.models.basemodel:    sea_surface_wave_period_at_variance_spectral_density_maximum: 0.000000
13:46:10 INFO    opendrift.models.basemodel:    sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000
13:46:10 INFO    opendrift.models.basemodel:    surface_downward_x_stress: 0.000000
13:46:10 INFO    opendrift.models.basemodel:    surface_downward_y_stress: 0.000000
13:46:10 INFO    opendrift.models.basemodel:    turbulent_kinetic_energy: 0.000000
13:46:10 INFO    opendrift.models.basemodel:    turbulent_generic_length_scale: 0.000000
13:46:10 INFO    opendrift.models.basemodel:    sea_floor_depth_below_sea_level: 10000.000000
13:46:10 INFO    opendrift.models.basemodel: No land reader added, making a temporary landmask reader
13:46:13 INFO    opendrift.models.basemodel: OpenDriftSimulation initialised (version 1.7.1 / v1.7.1-87-g074c1d2)
13:46:13 INFO    opendrift.models.basemodel: All points are in ocean
13:46:13 INFO    opendrift.models.basemodel: 2021-09-24 13:46:10.055535 - step 1 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-24 14:46:10.055535 - step 2 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-24 15:46:10.055535 - step 3 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-24 16:46:10.055535 - step 4 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-24 17:46:10.055535 - step 5 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-24 18:46:10.055535 - step 6 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-24 19:46:10.055535 - step 7 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-24 20:46:10.055535 - step 8 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-24 21:46:10.055535 - step 9 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-24 22:46:10.055535 - step 10 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-24 23:46:10.055535 - step 11 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 00:46:10.055535 - step 12 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 01:46:10.055535 - step 13 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 02:46:10.055535 - step 14 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 03:46:10.055535 - step 15 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 04:46:10.055535 - step 16 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 05:46:10.055535 - step 17 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 06:46:10.055535 - step 18 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 07:46:10.055535 - step 19 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 08:46:10.055535 - step 20 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 09:46:10.055535 - step 21 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 10:46:10.055535 - step 22 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 11:46:10.055535 - step 23 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 12:46:10.055535 - step 24 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 13:46:10.055535 - step 25 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 14:46:10.055535 - step 26 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 15:46:10.055535 - step 27 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 16:46:10.055535 - step 28 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 17:46:10.055535 - step 29 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 18:46:10.055535 - step 30 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 19:46:10.055535 - step 31 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 20:46:10.055535 - step 32 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 21:46:10.055535 - step 33 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 22:46:10.055535 - step 34 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-25 23:46:10.055535 - step 35 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-26 00:46:10.055535 - step 36 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-26 01:46:10.055535 - step 37 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-26 02:46:10.055535 - step 38 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-26 03:46:10.055535 - step 39 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-26 04:46:10.055535 - step 40 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-26 05:46:10.055535 - step 41 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-26 06:46:10.055535 - step 42 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-26 07:46:10.055535 - step 43 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-26 08:46:10.055535 - step 44 of 72 - 1000 active elements (0 deactivated)
13:46:13 INFO    opendrift.models.basemodel: 2021-09-26 09:46:10.055535 - step 45 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-26 10:46:10.055535 - step 46 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-26 11:46:10.055535 - step 47 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-26 12:46:10.055535 - step 48 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-26 13:46:10.055535 - step 49 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-26 14:46:10.055535 - step 50 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-26 15:46:10.055535 - step 51 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-26 16:46:10.055535 - step 52 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-26 17:46:10.055535 - step 53 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-26 18:46:10.055535 - step 54 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-26 19:46:10.055535 - step 55 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-26 20:46:10.055535 - step 56 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-26 21:46:10.055535 - step 57 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-26 22:46:10.055535 - step 58 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-26 23:46:10.055535 - step 59 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-27 00:46:10.055535 - step 60 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-27 01:46:10.055535 - step 61 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-27 02:46:10.055535 - step 62 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-27 03:46:10.055535 - step 63 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-27 04:46:10.055535 - step 64 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-27 05:46:10.055535 - step 65 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-27 06:46:10.055535 - step 66 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-27 07:46:10.055535 - step 67 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-27 08:46:10.055535 - step 68 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-27 09:46:10.055535 - step 69 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-27 10:46:10.055535 - step 70 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-27 11:46:10.055535 - step 71 of 72 - 1000 active elements (0 deactivated)
13:46:14 INFO    opendrift.models.basemodel: 2021-09-27 12:46:10.055535 - step 72 of 72 - 1000 active elements (0 deactivated)
13:46:14 WARNING opendrift.models.basemodel: Plotting fast. This will make your plots less accurate.
13:46:15 INFO    opendrift.models.basemodel: Saving animation to /root/project/docs/source/gallery/animations/example_static_2d_current_0.gif...
13:46:15 INFO    opendrift.models.basemodel: Making animated gif...
MovieWriter imagemagick unavailable; using Pillow instead.
../_images/example_static_2d_current_0.gif

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

Gallery generated by Sphinx-Gallery