.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/example_2d.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_2d.py: 2D simulation profile ===================== .. GENERATED FROM PYTHON SOURCE LINES 6-13 .. code-block:: Python from datetime import datetime, timedelta import numpy as np from opendrift.models.oceandrift import OceanDrift o = OceanDrift(loglevel=20) # Set loglevel to 0 for debug information .. rst-class:: sphx-glr-script-out .. code-block:: none 17:04:24 INFO opendrift.models.basemodel:533: OpenDriftSimulation initialised (version 1.11.2 / v1.11.2-17-g1eadfa7) .. GENERATED FROM PYTHON SOURCE LINES 14-15 Disable any 3D motion .. GENERATED FROM PYTHON SOURCE LINES 15-17 .. code-block:: Python o.disable_vertical_motion() .. rst-class:: sphx-glr-script-out .. code-block:: none 17:04:24 INFO opendrift.models.oceandrift:381: Setting config: drift:vertical_advection -> False 17:04:24 INFO opendrift.models.oceandrift:381: Setting config: drift:vertical_mixing -> False .. GENERATED FROM PYTHON SOURCE LINES 18-19 Define some constant current, wind and Stokes drift .. GENERATED FROM PYTHON SOURCE LINES 19-25 .. code-block:: Python o.set_config('environment:fallback:x_wind', 7) o.set_config('environment:fallback:x_sea_water_velocity', .1) o.set_config('environment:fallback:sea_surface_wave_stokes_drift_x_velocity', .2) o.set_config('environment:fallback:sea_surface_wave_significant_height', 2) o.set_config('environment:fallback:sea_surface_wave_period_at_variance_spectral_density_maximum', 8) .. GENERATED FROM PYTHON SOURCE LINES 26-27 Seed elements between surface and 5m depth .. GENERATED FROM PYTHON SOURCE LINES 27-31 .. code-block:: Python time = datetime.utcnow() z = -np.linspace(0, 5, 50) o.seed_elements(lon=4.5, lat=60.0, z=z, radius=0, number=len(z), time=time) .. rst-class:: sphx-glr-script-out .. code-block:: none 17:04:24 INFO opendrift.models.basemodel.environment:218: Adding a dynamical landmask with max. priority based on assumed maximum speed of 1.0 m/s. Adding a customised landmask may be faster... 17:04:30 INFO opendrift.models.basemodel.environment:245: Fallback values will be used for the following variables which have no readers: 17:04:30 INFO opendrift.models.basemodel.environment:248: x_sea_water_velocity: 0.100000 17:04:30 INFO opendrift.models.basemodel.environment:248: y_sea_water_velocity: 0.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: sea_surface_height: 0.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: x_wind: 7.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: y_wind: 0.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: upward_sea_water_velocity: 0.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: ocean_vertical_diffusivity: 0.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: sea_surface_wave_significant_height: 2.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: sea_surface_wave_stokes_drift_x_velocity: 0.200000 17:04:30 INFO opendrift.models.basemodel.environment:248: sea_surface_wave_stokes_drift_y_velocity: 0.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: sea_surface_wave_period_at_variance_spectral_density_maximum: 8.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: sea_surface_swell_wave_to_direction: 0.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: sea_surface_swell_wave_peak_period_from_variance_spectral_density: 0.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: sea_surface_swell_wave_significant_height: 0.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: sea_surface_wind_wave_to_direction: 0.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: sea_surface_wind_wave_mean_period: 0.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: sea_surface_wind_wave_significant_height: 0.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: surface_downward_x_stress: 0.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: surface_downward_y_stress: 0.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: turbulent_kinetic_energy: 0.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: turbulent_generic_length_scale: 0.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: ocean_mixed_layer_thickness: 50.000000 17:04:30 INFO opendrift.models.basemodel.environment:248: sea_floor_depth_below_sea_level: 10000.000000 .. GENERATED FROM PYTHON SOURCE LINES 32-33 Running model for 6 hours .. GENERATED FROM PYTHON SOURCE LINES 33-35 .. code-block:: Python o.run(duration=timedelta(hours=6), time_step=600) .. rst-class:: sphx-glr-script-out .. code-block:: none 17:04:30 INFO opendrift.models.basemodel:909: Using existing reader for land_binary_mask 17:04:30 INFO opendrift.models.basemodel:920: All points are in ocean 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 17:04:24.742649 - step 1 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 17:14:24.742649 - step 2 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 17:24:24.742649 - step 3 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 17:34:24.742649 - step 4 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 17:44:24.742649 - step 5 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 17:54:24.742649 - step 6 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 18:04:24.742649 - step 7 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 18:14:24.742649 - step 8 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 18:24:24.742649 - step 9 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 18:34:24.742649 - step 10 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 18:44:24.742649 - step 11 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 18:54:24.742649 - step 12 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 19:04:24.742649 - step 13 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 19:14:24.742649 - step 14 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 19:24:24.742649 - step 15 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 19:34:24.742649 - step 16 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 19:44:24.742649 - step 17 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 19:54:24.742649 - step 18 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 20:04:24.742649 - step 19 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 20:14:24.742649 - step 20 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 20:24:24.742649 - step 21 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 20:34:24.742649 - step 22 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 20:44:24.742649 - step 23 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 20:54:24.742649 - step 24 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 21:04:24.742649 - step 25 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 21:14:24.742649 - step 26 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 21:24:24.742649 - step 27 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 21:34:24.742649 - step 28 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 21:44:24.742649 - step 29 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 21:54:24.742649 - step 30 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 22:04:24.742649 - step 31 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 22:14:24.742649 - step 32 of 36 - 50 active elements (0 deactivated) 17:04:30 INFO opendrift.models.basemodel:2009: 2024-04-12 22:24:24.742649 - step 33 of 36 - 50 active elements (0 deactivated) 17:04:31 INFO opendrift.models.basemodel:2009: 2024-04-12 22:34:24.742649 - step 34 of 36 - 50 active elements (0 deactivated) 17:04:31 INFO opendrift.models.basemodel:2009: 2024-04-12 22:44:24.742649 - step 35 of 36 - 50 active elements (0 deactivated) 17:04:31 INFO opendrift.models.basemodel:2009: 2024-04-12 22:54:24.742649 - step 36 of 36 - 50 active elements (0 deactivated) .. GENERATED FROM PYTHON SOURCE LINES 36-37 To check that z is really kept constant for all particles .. GENERATED FROM PYTHON SOURCE LINES 37-39 .. code-block:: Python o.plot_property('z') .. image-sg:: /gallery/images/sphx_glr_example_2d_001.png :alt: z :srcset: /gallery/images/sphx_glr_example_2d_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 40-41 Vertical profile of advection. Note the decaying importance of Stokes drift, and the additional windage of the element at surface .. GENERATED FROM PYTHON SOURCE LINES 41-43 .. code-block:: Python o.animation_profile() .. rst-class:: sphx-glr-script-out .. code-block:: none /root/project/opendrift/models/basemodel/__init__.py:3120: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored points = ax.scatter([], [], 17:04:31 INFO opendrift.models.basemodel:4561: Saving animation to /root/project/docs/source/gallery/animations/example_2d_0.gif... 17:04:35 INFO opendrift.models.basemodel:3215: Time to make animation: 0:00:03.889299 .. GENERATED FROM PYTHON SOURCE LINES 44-45 .. image:: /gallery/animations/example_2d_0.gif .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 12.787 seconds) .. _sphx_glr_download_gallery_example_2d.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_2d.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_2d.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_