.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/example_static_2d_current.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_example_static_2d_current.py: Static 2D current field ======================= .. GENERATED FROM PYTHON SOURCE LINES 6-13 .. code-block:: Python from datetime import datetime, timedelta import numpy as np from opendrift.readers.reader_constant_2d import Reader from opendrift.models.oceandrift import OceanDrift .. GENERATED FROM PYTHON SOURCE LINES 14-15 Constructing a static, rotating ocean current field, .. GENERATED FROM PYTHON SOURCE LINES 15-33 .. code-block:: Python 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) .. rst-class:: sphx-glr-script-out .. code-block:: none 13:15:55 INFO opendrift:576: OpenDriftSimulation initialised (version 1.14.8 / v1.14.8-4-g48afd36) 13:15:55 INFO opendrift.models.basemodel.environment:203: Adding a global landmask from GSHHG 13:15:59 INFO opendrift.models.basemodel.environment:227: Fallback values will be used for the following variables which have no readers: 13:15:59 INFO opendrift.models.basemodel.environment:230: sea_surface_height: 0.000000 13:15:59 INFO opendrift.models.basemodel.environment:230: x_wind: 0.000000 13:15:59 INFO opendrift.models.basemodel.environment:230: y_wind: 0.000000 13:15:59 INFO opendrift.models.basemodel.environment:230: upward_sea_water_velocity: 0.000000 13:15:59 INFO opendrift.models.basemodel.environment:230: ocean_vertical_diffusivity: 0.000000 13:15:59 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_significant_height: 0.000000 13:15:59 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_stokes_drift_x_velocity: 0.000000 13:15:59 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_stokes_drift_y_velocity: 0.000000 13:15:59 INFO opendrift.models.basemodel.environment:230: ocean_mixed_layer_thickness: 50.000000 13:15:59 INFO opendrift.models.basemodel.environment:230: sea_floor_depth_below_sea_level: 10000.000000 13:15:59 INFO opendrift:1810: Skipping environment variable ocean_vertical_diffusivity because of condition ['drift:vertical_mixing', 'is', False] 13:15:59 INFO opendrift:1810: Skipping environment variable ocean_mixed_layer_thickness because of condition ['drift:vertical_mixing', 'is', False] 13:15:59 INFO opendrift:1821: Storing previous values of element property lon because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous'])) 13:15:59 INFO opendrift:1821: Storing previous values of element property lat because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous'])) 13:15:59 INFO opendrift:1829: Storing previous values of environment variable sea_surface_height because of condition ['drift:vertical_advection', 'is', True] 13:15:59 INFO opendrift:952: Using existing reader for land_binary_mask to move elements to ocean 13:15:59 INFO opendrift:982: All points are in ocean 13:15:59 INFO opendrift:2118: 2026-01-28 13:15:55.431143 - step 1 of 72 - 1000 active elements (0 deactivated) 13:15:59 INFO opendrift:2118: 2026-01-28 14:15:55.431143 - step 2 of 72 - 1000 active elements (0 deactivated) 13:15:59 INFO opendrift:2118: 2026-01-28 15:15:55.431143 - step 3 of 72 - 1000 active elements (0 deactivated) 13:15:59 INFO opendrift:2118: 2026-01-28 16:15:55.431143 - step 4 of 72 - 1000 active elements (0 deactivated) 13:15:59 INFO opendrift:2118: 2026-01-28 17:15:55.431143 - step 5 of 72 - 1000 active elements (0 deactivated) 13:15:59 INFO opendrift:2118: 2026-01-28 18:15:55.431143 - step 6 of 72 - 1000 active elements (0 deactivated) 13:15:59 INFO opendrift:2118: 2026-01-28 19:15:55.431143 - step 7 of 72 - 1000 active elements (0 deactivated) 13:15:59 INFO opendrift:2118: 2026-01-28 20:15:55.431143 - step 8 of 72 - 1000 active elements (0 deactivated) 13:15:59 INFO opendrift:2118: 2026-01-28 21:15:55.431143 - step 9 of 72 - 1000 active elements (0 deactivated) 13:15:59 INFO opendrift:2118: 2026-01-28 22:15:55.431143 - step 10 of 72 - 1000 active elements (0 deactivated) 13:15:59 INFO opendrift:2118: 2026-01-28 23:15:55.431143 - step 11 of 72 - 1000 active elements (0 deactivated) 13:15:59 INFO opendrift:2118: 2026-01-29 00:15:55.431143 - step 12 of 72 - 1000 active elements (0 deactivated) 13:15:59 INFO opendrift:2118: 2026-01-29 01:15:55.431143 - step 13 of 72 - 1000 active elements (0 deactivated) 13:15:59 INFO opendrift:2118: 2026-01-29 02:15:55.431143 - step 14 of 72 - 1000 active elements (0 deactivated) 13:15:59 INFO opendrift:2118: 2026-01-29 03:15:55.431143 - step 15 of 72 - 1000 active elements (0 deactivated) 13:15:59 INFO opendrift:2118: 2026-01-29 04:15:55.431143 - step 16 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-29 05:15:55.431143 - step 17 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-29 06:15:55.431143 - step 18 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-29 07:15:55.431143 - step 19 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-29 08:15:55.431143 - step 20 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-29 09:15:55.431143 - step 21 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-29 10:15:55.431143 - step 22 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-29 11:15:55.431143 - step 23 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-29 12:15:55.431143 - step 24 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-29 13:15:55.431143 - step 25 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-29 14:15:55.431143 - step 26 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-29 15:15:55.431143 - step 27 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-29 16:15:55.431143 - step 28 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-29 17:15:55.431143 - step 29 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-29 18:15:55.431143 - step 30 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-29 19:15:55.431143 - step 31 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-29 20:15:55.431143 - step 32 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-29 21:15:55.431143 - step 33 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-29 22:15:55.431143 - step 34 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-29 23:15:55.431143 - step 35 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 00:15:55.431143 - step 36 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 01:15:55.431143 - step 37 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 02:15:55.431143 - step 38 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 03:15:55.431143 - step 39 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 04:15:55.431143 - step 40 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 05:15:55.431143 - step 41 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 06:15:55.431143 - step 42 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 07:15:55.431143 - step 43 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 08:15:55.431143 - step 44 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 09:15:55.431143 - step 45 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 10:15:55.431143 - step 46 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 11:15:55.431143 - step 47 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 12:15:55.431143 - step 48 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 13:15:55.431143 - step 49 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 14:15:55.431143 - step 50 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 15:15:55.431143 - step 51 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 16:15:55.431143 - step 52 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 17:15:55.431143 - step 53 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 18:15:55.431143 - step 54 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 19:15:55.431143 - step 55 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 20:15:55.431143 - step 56 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 21:15:55.431143 - step 57 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 22:15:55.431143 - step 58 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-30 23:15:55.431143 - step 59 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-31 00:15:55.431143 - step 60 of 72 - 1000 active elements (0 deactivated) 13:16:00 INFO opendrift:2118: 2026-01-31 01:15:55.431143 - step 61 of 72 - 1000 active elements (0 deactivated) 13:16:01 INFO opendrift:2118: 2026-01-31 02:15:55.431143 - step 62 of 72 - 1000 active elements (0 deactivated) 13:16:01 INFO opendrift:2118: 2026-01-31 03:15:55.431143 - step 63 of 72 - 1000 active elements (0 deactivated) 13:16:01 INFO opendrift:2118: 2026-01-31 04:15:55.431143 - step 64 of 72 - 1000 active elements (0 deactivated) 13:16:01 INFO opendrift:2118: 2026-01-31 05:15:55.431143 - step 65 of 72 - 1000 active elements (0 deactivated) 13:16:01 INFO opendrift:2118: 2026-01-31 06:15:55.431143 - step 66 of 72 - 1000 active elements (0 deactivated) 13:16:01 INFO opendrift:2118: 2026-01-31 07:15:55.431143 - step 67 of 72 - 1000 active elements (0 deactivated) 13:16:01 INFO opendrift:2118: 2026-01-31 08:15:55.431143 - step 68 of 72 - 1000 active elements (0 deactivated) 13:16:01 INFO opendrift:2118: 2026-01-31 09:15:55.431143 - step 69 of 72 - 1000 active elements (0 deactivated) 13:16:01 INFO opendrift:2118: 2026-01-31 10:15:55.431143 - step 70 of 72 - 1000 active elements (0 deactivated) 13:16:01 INFO opendrift:2118: 2026-01-31 11:15:55.431143 - step 71 of 72 - 1000 active elements (0 deactivated) 13:16:01 INFO opendrift:2118: 2026-01-31 12:15:55.431143 - step 72 of 72 - 1000 active elements (0 deactivated) 13:16:01 WARNING opendrift:2480: Plotting fast. This will make your plots less accurate. 13:16:02 INFO opendrift:4675: Saving animation to /root/project/docs/source/gallery/animations/example_static_2d_current_0.gif... 13:16:50 INFO opendrift:3101: Time to make animation: 0:00:48.694806 .. GENERATED FROM PYTHON SOURCE LINES 34-35 .. image:: /gallery/animations/example_static_2d_current_0.gif .. rst-class:: sphx-glr-timing **Total running time of the script:** (1 minutes 0.133 seconds) .. _sphx_glr_download_gallery_example_static_2d_current.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_static_2d_current.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_static_2d_current.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: example_static_2d_current.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_