.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/example_depth.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_depth.py: Drift at different depths ========================== .. 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 18:36:10 INFO opendrift:513: OpenDriftSimulation initialised (version 1.14.2 / v1.14.2-74-gdbb4afa) .. GENERATED FROM PYTHON SOURCE LINES 14-15 Using live data from Thredds .. GENERATED FROM PYTHON SOURCE LINES 15-18 .. code-block:: Python o.add_readers_from_list([ 'https://thredds.met.no/thredds/dodsC/sea/norkyst800m/1h/aggregate_be']) .. GENERATED FROM PYTHON SOURCE LINES 19-20 Adding some diffusion .. GENERATED FROM PYTHON SOURCE LINES 20-22 .. code-block:: Python o.set_config('drift:horizontal_diffusivity', 10) # m2/s .. GENERATED FROM PYTHON SOURCE LINES 23-24 Seed 1000 elements at random depths .. GENERATED FROM PYTHON SOURCE LINES 24-30 .. code-block:: Python z = -np.random.rand(2000)*50 o.seed_elements(lon=4.8, lat=60.0, z=z, radius=0, number=2000, time=datetime.now()) print(o) .. rst-class:: sphx-glr-script-out .. code-block:: none 18:36:10 INFO opendrift.models.basemodel.environment:206: Adding a global landmask from GSHHG 18:36:15 INFO opendrift.models.basemodel.environment:229: Fallback values will be used for the following variables which have no readers: 18:36:15 INFO opendrift.models.basemodel.environment:232: x_sea_water_velocity: 0.000000 18:36:15 INFO opendrift.models.basemodel.environment:232: y_sea_water_velocity: 0.000000 18:36:15 INFO opendrift.models.basemodel.environment:232: sea_surface_height: 0.000000 18:36:15 INFO opendrift.models.basemodel.environment:232: x_wind: 0.000000 18:36:15 INFO opendrift.models.basemodel.environment:232: y_wind: 0.000000 18:36:15 INFO opendrift.models.basemodel.environment:232: upward_sea_water_velocity: 0.000000 18:36:15 INFO opendrift.models.basemodel.environment:232: ocean_vertical_diffusivity: 0.000000 18:36:15 INFO opendrift.models.basemodel.environment:232: sea_surface_wave_significant_height: 0.000000 18:36:15 INFO opendrift.models.basemodel.environment:232: sea_surface_wave_stokes_drift_x_velocity: 0.000000 18:36:15 INFO opendrift.models.basemodel.environment:232: sea_surface_wave_stokes_drift_y_velocity: 0.000000 18:36:15 INFO opendrift.models.basemodel.environment:232: sea_surface_wave_period_at_variance_spectral_density_maximum: 0.000000 18:36:15 INFO opendrift.models.basemodel.environment:232: sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000 18:36:15 INFO opendrift.models.basemodel.environment:232: sea_surface_swell_wave_to_direction: 0.000000 18:36:15 INFO opendrift.models.basemodel.environment:232: sea_surface_swell_wave_peak_period_from_variance_spectral_density: 0.000000 18:36:15 INFO opendrift.models.basemodel.environment:232: sea_surface_swell_wave_significant_height: 0.000000 18:36:15 INFO opendrift.models.basemodel.environment:232: sea_surface_wind_wave_to_direction: 0.000000 18:36:15 INFO opendrift.models.basemodel.environment:232: sea_surface_wind_wave_mean_period: 0.000000 18:36:15 INFO opendrift.models.basemodel.environment:232: sea_surface_wind_wave_significant_height: 0.000000 18:36:15 INFO opendrift.models.basemodel.environment:232: ocean_mixed_layer_thickness: 50.000000 18:36:15 INFO opendrift.models.basemodel.environment:232: sea_floor_depth_below_sea_level: 10000.000000 =========================== Model: OceanDrift (OpenDrift version 1.14.2) 0 active Lagrangian3DArray particles (0 deactivated, 2000 scheduled) ------------------- Environment variables: ----- land_binary_mask 1) global_landmask ----- Readers not added for the following variables: ocean_mixed_layer_thickness ocean_vertical_diffusivity sea_floor_depth_below_sea_level sea_surface_height sea_surface_swell_wave_peak_period_from_variance_spectral_density sea_surface_swell_wave_significant_height sea_surface_swell_wave_to_direction sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment sea_surface_wave_period_at_variance_spectral_density_maximum sea_surface_wave_significant_height sea_surface_wave_stokes_drift_x_velocity sea_surface_wave_stokes_drift_y_velocity sea_surface_wind_wave_mean_period sea_surface_wind_wave_significant_height sea_surface_wind_wave_to_direction upward_sea_water_velocity x_sea_water_velocity x_wind y_sea_water_velocity y_wind --- Lazy readers: LazyReader: https://thredds.met.no/thredds/dodsC/sea/norkyst800m/1h/aggregate_be Discarded readers: =========================== .. GENERATED FROM PYTHON SOURCE LINES 31-32 Running model .. GENERATED FROM PYTHON SOURCE LINES 32-34 .. code-block:: Python o.run(duration=timedelta(hours=24), time_step=1800) .. rst-class:: sphx-glr-script-out .. code-block:: none 18:36:15 INFO opendrift:1825: Skipping environment variable ocean_vertical_diffusivity because of condition ['drift:vertical_mixing', 'is', False] 18:36:15 INFO opendrift:889: Using existing reader for land_binary_mask 18:36:15 INFO opendrift:918: All points are in ocean 18:36:15 INFO opendrift:2051: Storing previous position of elements for coastline interaction 18:36:15 INFO opendrift:2112: 2025-06-30 18:36:10.747339 - step 1 of 48 - 2000 active elements (0 deactivated) 18:36:15 INFO opendrift.readers:61: Opening file with xr.open_dataset 18:36:16 INFO opendrift.readers.reader_netCDF_CF_generic:332: Detected dimensions: {'x': 'X', 'y': 'Y', 'z': 'depth', 'time': 'time'} 18:36:19 INFO opendrift:2112: 2025-06-30 19:06:10.747339 - step 2 of 48 - 2000 active elements (0 deactivated) 18:36:20 INFO opendrift:2112: 2025-06-30 19:36:10.747339 - step 3 of 48 - 2000 active elements (0 deactivated) 18:36:20 INFO opendrift:2112: 2025-06-30 20:06:10.747339 - step 4 of 48 - 2000 active elements (0 deactivated) 18:36:21 INFO opendrift:2112: 2025-06-30 20:36:10.747339 - step 5 of 48 - 2000 active elements (0 deactivated) 18:36:21 INFO opendrift:2112: 2025-06-30 21:06:10.747339 - step 6 of 48 - 2000 active elements (0 deactivated) 18:36:22 INFO opendrift:2112: 2025-06-30 21:36:10.747339 - step 7 of 48 - 2000 active elements (0 deactivated) 18:36:22 INFO opendrift:2112: 2025-06-30 22:06:10.747339 - step 8 of 48 - 2000 active elements (0 deactivated) 18:36:24 INFO opendrift:2112: 2025-06-30 22:36:10.747339 - step 9 of 48 - 2000 active elements (0 deactivated) 18:36:24 INFO opendrift:2112: 2025-06-30 23:06:10.747339 - step 10 of 48 - 2000 active elements (0 deactivated) 18:36:25 INFO opendrift:2112: 2025-06-30 23:36:10.747339 - step 11 of 48 - 2000 active elements (0 deactivated) 18:36:25 INFO opendrift:2112: 2025-07-01 00:06:10.747339 - step 12 of 48 - 2000 active elements (0 deactivated) 18:36:26 INFO opendrift:2112: 2025-07-01 00:36:10.747339 - step 13 of 48 - 2000 active elements (0 deactivated) 18:36:26 INFO opendrift:2112: 2025-07-01 01:06:10.747339 - step 14 of 48 - 2000 active elements (0 deactivated) 18:36:27 INFO opendrift:2112: 2025-07-01 01:36:10.747339 - step 15 of 48 - 2000 active elements (0 deactivated) 18:36:27 INFO opendrift:2112: 2025-07-01 02:06:10.747339 - step 16 of 48 - 2000 active elements (0 deactivated) 18:36:29 INFO opendrift:2112: 2025-07-01 02:36:10.747339 - step 17 of 48 - 2000 active elements (0 deactivated) 18:36:29 INFO opendrift:2112: 2025-07-01 03:06:10.747339 - step 18 of 48 - 2000 active elements (0 deactivated) 18:36:30 INFO opendrift:2112: 2025-07-01 03:36:10.747339 - step 19 of 48 - 2000 active elements (0 deactivated) 18:36:30 INFO opendrift:2112: 2025-07-01 04:06:10.747339 - step 20 of 48 - 2000 active elements (0 deactivated) 18:36:31 INFO opendrift:2112: 2025-07-01 04:36:10.747339 - step 21 of 48 - 2000 active elements (0 deactivated) 18:36:31 INFO opendrift:2112: 2025-07-01 05:06:10.747339 - step 22 of 48 - 2000 active elements (0 deactivated) 18:36:33 INFO opendrift:2112: 2025-07-01 05:36:10.747339 - step 23 of 48 - 2000 active elements (0 deactivated) 18:36:33 INFO opendrift:2112: 2025-07-01 06:06:10.747339 - step 24 of 48 - 2000 active elements (0 deactivated) 18:36:35 INFO opendrift:2112: 2025-07-01 06:36:10.747339 - step 25 of 48 - 2000 active elements (0 deactivated) 18:36:35 INFO opendrift:2112: 2025-07-01 07:06:10.747339 - step 26 of 48 - 2000 active elements (0 deactivated) 18:36:36 INFO opendrift:2112: 2025-07-01 07:36:10.747339 - step 27 of 48 - 2000 active elements (0 deactivated) 18:36:36 INFO opendrift:2112: 2025-07-01 08:06:10.747339 - step 28 of 48 - 2000 active elements (0 deactivated) 18:36:38 INFO opendrift:2112: 2025-07-01 08:36:10.747339 - step 29 of 48 - 2000 active elements (0 deactivated) 18:36:38 INFO opendrift:2112: 2025-07-01 09:06:10.747339 - step 30 of 48 - 2000 active elements (0 deactivated) 18:36:39 INFO opendrift:2112: 2025-07-01 09:36:10.747339 - step 31 of 48 - 2000 active elements (0 deactivated) 18:36:39 INFO opendrift:2112: 2025-07-01 10:06:10.747339 - step 32 of 48 - 2000 active elements (0 deactivated) 18:36:40 INFO opendrift:2112: 2025-07-01 10:36:10.747339 - step 33 of 48 - 2000 active elements (0 deactivated) 18:36:40 INFO opendrift:2112: 2025-07-01 11:06:10.747339 - step 34 of 48 - 2000 active elements (0 deactivated) 18:36:42 INFO opendrift:2112: 2025-07-01 11:36:10.747339 - step 35 of 48 - 2000 active elements (0 deactivated) 18:36:42 INFO opendrift:2112: 2025-07-01 12:06:10.747339 - step 36 of 48 - 2000 active elements (0 deactivated) 18:36:43 INFO opendrift:2112: 2025-07-01 12:36:10.747339 - step 37 of 48 - 2000 active elements (0 deactivated) 18:36:43 INFO opendrift:2112: 2025-07-01 13:06:10.747339 - step 38 of 48 - 2000 active elements (0 deactivated) 18:36:44 INFO opendrift:2112: 2025-07-01 13:36:10.747339 - step 39 of 48 - 2000 active elements (0 deactivated) 18:36:44 INFO opendrift:2112: 2025-07-01 14:06:10.747339 - step 40 of 48 - 2000 active elements (0 deactivated) 18:36:46 INFO opendrift:2112: 2025-07-01 14:36:10.747339 - step 41 of 48 - 2000 active elements (0 deactivated) 18:36:46 INFO opendrift:2112: 2025-07-01 15:06:10.747339 - step 42 of 48 - 2000 active elements (0 deactivated) 18:36:47 INFO opendrift:2112: 2025-07-01 15:36:10.747339 - step 43 of 48 - 2000 active elements (0 deactivated) 18:36:47 INFO opendrift:2112: 2025-07-01 16:06:10.747339 - step 44 of 48 - 2000 active elements (0 deactivated) 18:36:48 INFO opendrift:2112: 2025-07-01 16:36:10.747339 - step 45 of 48 - 2000 active elements (0 deactivated) 18:36:48 INFO opendrift:2112: 2025-07-01 17:06:10.747339 - step 46 of 48 - 2000 active elements (0 deactivated) 18:36:50 INFO opendrift:2112: 2025-07-01 17:36:10.747339 - step 47 of 48 - 2000 active elements (0 deactivated) 18:36:50 INFO opendrift:2112: 2025-07-01 18:06:10.747339 - step 48 of 48 - 2000 active elements (0 deactivated) .. raw:: html
<xarray.Dataset> Size: 12MB
    Dimensions:                                                                              (
                                                                                              trajectory: 2000,
                                                                                              time: 49)
    Coordinates:
      * trajectory                                                                           (trajectory) int64 16kB ...
      * time                                                                                 (time) datetime64[ns] 392B ...
    Data variables: (12/30)
        status                                                                               (trajectory, time) float32 392kB ...
        moving                                                                               (trajectory, time) float32 392kB ...
        age_seconds                                                                          (trajectory, time) float32 392kB ...
        origin_marker                                                                        (trajectory, time) float32 392kB ...
        lon                                                                                  (trajectory, time) float32 392kB ...
        lat                                                                                  (trajectory, time) float32 392kB ...
        ...                                                                                   ...
        sea_surface_wind_wave_to_direction                                                   (trajectory, time) float32 392kB ...
        sea_surface_wind_wave_mean_period                                                    (trajectory, time) float32 392kB ...
        sea_surface_wind_wave_significant_height                                             (trajectory, time) float32 392kB ...
        ocean_mixed_layer_thickness                                                          (trajectory, time) float32 392kB ...
        sea_floor_depth_below_sea_level                                                      (trajectory, time) float32 392kB ...
        land_binary_mask                                                                     (trajectory, time) float32 392kB ...
    Attributes: (12/142)
        Conventions:                                                             ...
        standard_name_vocabulary:                                                ...
        featureType:                                                             ...
        title:                                                                   ...
        summary:                                                                 ...
        keywords:                                                                ...
        ...                                                                                                               ...
        geospatial_lon_units:                                                    ...
        geospatial_lon_resolution:                                               ...
        runtime:                                                                 ...
        geospatial_vertical_min:                                                 ...
        geospatial_vertical_max:                                                 ...
        geospatial_vertical_positive:                                            ...


.. GENERATED FROM PYTHON SOURCE LINES 35-36 Plot results with lines and particles colored by depth .. GENERATED FROM PYTHON SOURCE LINES 36-40 .. code-block:: Python print(o) o.plot(linecolor='z', buffer=.1, show_elements=False) o.animation(color='z', buffer=.1) .. image-sg:: /gallery/images/sphx_glr_example_depth_001.png :alt: OpenDrift - OceanDrift 2025-06-30 18:36 to 2025-07-01 18:36 UTC (49 steps) :srcset: /gallery/images/sphx_glr_example_depth_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none =========================== -------------------- Reader performance: -------------------- global_landmask 0:00:00.0 total 0:00:00.0 preparing 0:00:00.0 reading 0:00:00.0 masking -------------------- https://thredds.met.no/thredds/dodsC/sea/norkyst800m/1h/aggregate_be 0:00:32.5 total 0:00:00.0 preparing 0:00:32.1 reading 0:00:00.5 interpolation 0:00:00.0 interpolation_time 0:00:00.3 rotating vectors 0:00:00.0 masking -------------------- Performance: 40.8 total time 4.3 configuration 0.0 preparing main loop 0.0 moving elements to ocean 36.3 main loop 0.1 updating elements 0.0 cleaning up -------------------- =========================== Model: OceanDrift (OpenDrift version 1.14.2) 2000 active Lagrangian3DArray particles (0 deactivated, 0 scheduled) ------------------- Environment variables: ----- land_binary_mask 1) global_landmask ----- sea_floor_depth_below_sea_level sea_surface_height upward_sea_water_velocity x_sea_water_velocity x_wind y_sea_water_velocity y_wind 1) https://thredds.met.no/thredds/dodsC/sea/norkyst800m/1h/aggregate_be ----- Readers not added for the following variables: ocean_mixed_layer_thickness sea_surface_swell_wave_peak_period_from_variance_spectral_density sea_surface_swell_wave_significant_height sea_surface_swell_wave_to_direction sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment sea_surface_wave_period_at_variance_spectral_density_maximum sea_surface_wave_significant_height sea_surface_wave_stokes_drift_x_velocity sea_surface_wave_stokes_drift_y_velocity sea_surface_wind_wave_mean_period sea_surface_wind_wave_significant_height sea_surface_wind_wave_to_direction Discarded readers: Time: Start: 2025-06-30 18:36:10.747339 UTC Present: 2025-07-01 18:36:10.747339 UTC Calculation steps: 48 * 0:30:00 - total time: 1 day, 0:00:00 Output steps: 49 * 0:30:00 =========================== 18:37:52 INFO opendrift:4630: Saving animation to /root/project/docs/source/gallery/animations/example_depth_0.gif... 18:38:20 INFO opendrift:3071: Time to make animation: 0:00:29.798700 .. GENERATED FROM PYTHON SOURCE LINES 41-41 .. image:: /gallery/animations/example_depth_0.gif .. rst-class:: sphx-glr-timing **Total running time of the script:** (2 minutes 18.039 seconds) .. _sphx_glr_download_gallery_example_depth.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_depth.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_depth.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: example_depth.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_