.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/example_oil_verticalmixing.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_oil_verticalmixing.py: Oil vertical mixing ================================== .. GENERATED FROM PYTHON SOURCE LINES 6-37 .. code-block:: Python import os from datetime import timedelta from opendrift.readers import reader_netCDF_CF_generic from opendrift.models.openoil import OpenOil o = OpenOil(loglevel=20) # Set loglevel to 0 for debug information ncfile = 'oilmixing.nc' import_file = False # Set to True to import previous run if import_file is True: o.io_import_file(ncfile) else: reader_arome = reader_netCDF_CF_generic.Reader('https://thredds.met.no/thredds/dodsC/mepslatest/meps_lagged_6_h_latest_2_5km_latest.nc') reader_norkyst = reader_netCDF_CF_generic.Reader('https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be') o.add_reader([reader_norkyst, reader_arome]) # Adjusting some configuration #o.set_config('vertical_mixing:diffusivitymodel', 'windspeed_Sundby1983') # Seed oil elements at defined position and time o.seed_elements(lon=4.9, lat=62.1, z=0, radius=1000, number=5000, time=reader_arome.start_time, oil_type='GENERIC DIESEL') # Running model o.run(end_time=reader_arome.start_time + timedelta(hours=12), time_step=900, time_step_output=1800, outfile=ncfile) .. rst-class:: sphx-glr-script-out .. code-block:: none 13:49:55 INFO opendrift:576: OpenDriftSimulation initialised (version 1.14.7 / v1.14.7-15-g2988cd4) 13:49:55 INFO opendrift.readers:63: Opening file with xr.open_dataset 13:49:57 INFO opendrift.readers.reader_netCDF_CF_generic:332: Detected dimensions: {'time': 'time', 'x': 'x', 'y': 'y'} 13:49:57 INFO opendrift.readers:63: Opening file with xr.open_dataset 13:50:00 INFO opendrift.readers.reader_netCDF_CF_generic:332: Detected dimensions: {'x': 'X', 'y': 'Y', 'z': 'depth', 'time': 'time'} 13:50:00 INFO opendrift.readers.basereader:176: Variable x_sea_water_velocity will be rotated from eastward_sea_water_velocity 13:50:00 INFO opendrift.readers.basereader:176: Variable y_sea_water_velocity will be rotated from northward_sea_water_velocity 13:50:00 INFO opendrift.readers.basereader:176: Variable x_wind will be rotated from eastward_wind 13:50:00 INFO opendrift.readers.basereader:176: Variable y_wind will be rotated from northward_wind 13:50:00 INFO opendrift.models.openoil.adios.dirjs:86: Querying ADIOS database for oil: GENERIC DIESEL 13:50:00 INFO opendrift.models.openoil.openoil:1717: Using density 855.84763 and viscosity 8.644570579524623e-06 of oiltype GENERIC DIESEL 13:50:00 INFO opendrift.models.basemodel.environment:203: Adding a global landmask from GSHHG 13:50:04 INFO opendrift.models.basemodel.environment:227: Fallback values will be used for the following variables which have no readers: 13:50:04 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_significant_height: 0.000000 13:50:04 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_stokes_drift_x_velocity: 0.000000 13:50:04 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_stokes_drift_y_velocity: 0.000000 13:50:04 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_period_at_variance_spectral_density_maximum: 0.000000 13:50:04 INFO opendrift.models.basemodel.environment:230: sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000 13:50:04 INFO opendrift.models.basemodel.environment:230: sea_ice_area_fraction: 0.000000 13:50:04 INFO opendrift.models.basemodel.environment:230: sea_ice_x_velocity: 0.000000 13:50:04 INFO opendrift.models.basemodel.environment:230: sea_ice_y_velocity: 0.000000 13:50:04 INFO opendrift.models.basemodel.environment:230: ocean_mixed_layer_thickness: 50.000000 13:50:04 INFO opendrift:1803: Skipping environment variable upward_sea_water_velocity because of condition ['drift:vertical_advection', 'is', False] 13:50:04 INFO opendrift:1814: Storing previous values of element property lon because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous'])) 13:50:04 INFO opendrift:1814: Storing previous values of element property lat because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous'])) 13:50:04 INFO opendrift:952: Using existing reader for land_binary_mask to move elements to ocean 13:50:04 INFO opendrift:982: All points are in ocean 13:50:04 INFO opendrift.models.openoil.openoil:692: Oil-water surface tension is 0.030314 Nm 13:50:04 INFO opendrift.models.openoil.openoil:705: Max water fraction not available for GENERIC DIESEL, using default 13:50:04 INFO opendrift:2111: 2025-12-16 11:00:00 - step 1 of 48 - 5000 active elements (0 deactivated) 13:50:07 INFO opendrift:2111: 2025-12-16 11:15:00 - step 2 of 48 - 5000 active elements (0 deactivated) 13:50:11 INFO opendrift:2111: 2025-12-16 11:30:00 - step 3 of 48 - 5000 active elements (0 deactivated) 13:50:11 INFO opendrift:2111: 2025-12-16 11:45:00 - step 4 of 48 - 5000 active elements (0 deactivated) 13:50:11 INFO opendrift:2111: 2025-12-16 12:00:00 - step 5 of 48 - 5000 active elements (0 deactivated) 13:50:12 INFO opendrift:2111: 2025-12-16 12:15:00 - step 6 of 48 - 5000 active elements (0 deactivated) 13:50:17 INFO opendrift:2111: 2025-12-16 12:30:00 - step 7 of 48 - 5000 active elements (0 deactivated) 13:50:17 INFO opendrift:2111: 2025-12-16 12:45:00 - step 8 of 48 - 5000 active elements (0 deactivated) 13:50:17 INFO opendrift:2111: 2025-12-16 13:00:00 - step 9 of 48 - 5000 active elements (0 deactivated) 13:50:17 INFO opendrift:2111: 2025-12-16 13:15:00 - step 10 of 48 - 5000 active elements (0 deactivated) 13:50:19 INFO opendrift:2111: 2025-12-16 13:30:00 - step 11 of 48 - 5000 active elements (0 deactivated) 13:50:19 INFO opendrift:2111: 2025-12-16 13:45:00 - step 12 of 48 - 5000 active elements (0 deactivated) 13:50:20 INFO opendrift:2111: 2025-12-16 14:00:00 - step 13 of 48 - 5000 active elements (0 deactivated) 13:50:20 INFO opendrift:2111: 2025-12-16 14:15:00 - step 14 of 48 - 5000 active elements (0 deactivated) 13:50:23 INFO opendrift:2111: 2025-12-16 14:30:00 - step 15 of 48 - 5000 active elements (0 deactivated) 13:50:24 INFO opendrift:2111: 2025-12-16 14:45:00 - step 16 of 48 - 5000 active elements (0 deactivated) 13:50:24 INFO opendrift:2111: 2025-12-16 15:00:00 - step 17 of 48 - 5000 active elements (0 deactivated) 13:50:24 INFO opendrift:2111: 2025-12-16 15:15:00 - step 18 of 48 - 5000 active elements (0 deactivated) 13:50:26 INFO opendrift:2111: 2025-12-16 15:30:00 - step 19 of 48 - 5000 active elements (0 deactivated) 13:50:27 INFO opendrift:2111: 2025-12-16 15:45:00 - step 20 of 48 - 5000 active elements (0 deactivated) 13:50:27 INFO opendrift:2111: 2025-12-16 16:00:00 - step 21 of 48 - 5000 active elements (0 deactivated) 13:50:27 INFO opendrift:2111: 2025-12-16 16:15:00 - step 22 of 48 - 5000 active elements (0 deactivated) 13:50:29 INFO opendrift:2111: 2025-12-16 16:30:00 - step 23 of 48 - 5000 active elements (0 deactivated) 13:50:30 INFO opendrift:2111: 2025-12-16 16:45:00 - step 24 of 48 - 5000 active elements (0 deactivated) 13:50:30 INFO opendrift:2111: 2025-12-16 17:00:00 - step 25 of 48 - 5000 active elements (0 deactivated) 13:50:30 INFO opendrift:2111: 2025-12-16 17:15:00 - step 26 of 48 - 5000 active elements (0 deactivated) 13:50:33 INFO opendrift:2111: 2025-12-16 17:30:00 - step 27 of 48 - 5000 active elements (0 deactivated) 13:50:33 INFO opendrift:2111: 2025-12-16 17:45:00 - step 28 of 48 - 5000 active elements (0 deactivated) 13:50:33 INFO opendrift:2111: 2025-12-16 18:00:00 - step 29 of 48 - 5000 active elements (0 deactivated) 13:50:34 INFO opendrift:2111: 2025-12-16 18:15:00 - step 30 of 48 - 5000 active elements (0 deactivated) 13:50:36 INFO opendrift:2111: 2025-12-16 18:30:00 - step 31 of 48 - 5000 active elements (0 deactivated) 13:50:36 INFO opendrift:2111: 2025-12-16 18:45:00 - step 32 of 48 - 5000 active elements (0 deactivated) 13:50:36 INFO opendrift:2111: 2025-12-16 19:00:00 - step 33 of 48 - 5000 active elements (0 deactivated) 13:50:36 INFO opendrift:2111: 2025-12-16 19:15:00 - step 34 of 48 - 5000 active elements (0 deactivated) 13:50:40 INFO opendrift:2111: 2025-12-16 19:30:00 - step 35 of 48 - 5000 active elements (0 deactivated) 13:50:40 INFO opendrift:2111: 2025-12-16 19:45:00 - step 36 of 48 - 5000 active elements (0 deactivated) 13:50:40 INFO opendrift:2111: 2025-12-16 20:00:00 - step 37 of 48 - 5000 active elements (0 deactivated) 13:50:41 INFO opendrift:2111: 2025-12-16 20:15:00 - step 38 of 48 - 5000 active elements (0 deactivated) 13:50:43 INFO opendrift:2111: 2025-12-16 20:30:00 - step 39 of 48 - 5000 active elements (0 deactivated) 13:50:43 INFO opendrift:2111: 2025-12-16 20:45:00 - step 40 of 48 - 5000 active elements (0 deactivated) 13:50:45 INFO opendrift:2111: 2025-12-16 21:00:00 - step 41 of 48 - 5000 active elements (0 deactivated) 13:50:45 INFO opendrift:2111: 2025-12-16 21:15:00 - step 42 of 48 - 5000 active elements (0 deactivated) 13:50:55 INFO opendrift:2111: 2025-12-16 21:30:00 - step 43 of 48 - 4999 active elements (1 deactivated) 13:50:55 INFO opendrift:2111: 2025-12-16 21:45:00 - step 44 of 48 - 4999 active elements (1 deactivated) 13:50:55 INFO opendrift:2111: 2025-12-16 22:00:00 - step 45 of 48 - 4999 active elements (1 deactivated) 13:50:55 INFO opendrift:2111: 2025-12-16 22:15:00 - step 46 of 48 - 4999 active elements (1 deactivated) 13:50:58 INFO opendrift:2111: 2025-12-16 22:30:00 - step 47 of 48 - 4999 active elements (1 deactivated) 13:50:58 INFO opendrift:2111: 2025-12-16 22:45:00 - step 48 of 48 - 4999 active elements (1 deactivated) .. GENERATED FROM PYTHON SOURCE LINES 38-39 Print and plot results .. GENERATED FROM PYTHON SOURCE LINES 39-49 .. code-block:: Python print(o) o.plot(linecolor='z', fast=True) o.plot_property('z') o.plot_oil_budget() o.animation(fast=True) o.animate_vertical_distribution() os.remove(ncfile) # cleaning up .. rst-class:: sphx-glr-horizontal * .. image-sg:: /gallery/images/sphx_glr_example_oil_verticalmixing_001.png :alt: OpenDrift - OpenOil (GENERIC DIESEL) 2025-12-16 11:00 to 2025-12-16 23:00 UTC (25 steps) :srcset: /gallery/images/sphx_glr_example_oil_verticalmixing_001.png :class: sphx-glr-multi-img * .. image-sg:: /gallery/images/sphx_glr_example_oil_verticalmixing_002.png :alt: z :srcset: /gallery/images/sphx_glr_example_oil_verticalmixing_002.png :class: sphx-glr-multi-img * .. image-sg:: /gallery/images/sphx_glr_example_oil_verticalmixing_003.png :alt: GENERIC DIESEL (855.8 kg/m3) - 2025-12-16 11:00 to 2025-12-16 23:00 :srcset: /gallery/images/sphx_glr_example_oil_verticalmixing_003.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none =========================== -------------------- Reader performance: -------------------- https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be 0:00:40.2 total 0:00:00.0 preparing 0:00:39.3 reading 0:00:02.6 interpolation 0:00:00.0 interpolation_time 0:00:00.8 rotating vectors 0:00:00.0 masking -------------------- https://thredds.met.no/thredds/dodsC/mepslatest/meps_lagged_6_h_latest_2_5km_latest.nc -------------------- global_landmask 0:00:01.7 total 0:00:00.0 preparing 0:00:01.7 reading 0:00:00.0 masking -------------------- Performance: 1:03.0 total time 9.0 configuration 0.0 preparing main loop 0.0 moving elements to ocean 53.9 main loop 7.5 updating elements 0.3 oil weathering 0.0 updating viscosities 0.0 updating densities 0.2 evaporation 0.0 emulsification 0.0 dispersion 6.7 vertical mixing 0.0 cleaning up -------------------- =========================== Model: OpenOil (OpenDrift version 1.14.7) 4999 active Oil particles (1 deactivated, 0 scheduled) ------------------- Environment variables: ----- ocean_vertical_diffusivity sea_floor_depth_below_sea_level sea_surface_height sea_water_salinity sea_water_temperature x_sea_water_velocity y_sea_water_velocity 1) https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be ----- x_wind y_wind 1) https://thredds.met.no/thredds/dodsC/fou-hi/norkystv3_800m_m00_be 2) https://thredds.met.no/thredds/dodsC/mepslatest/meps_lagged_6_h_latest_2_5km_latest.nc ----- land_binary_mask 1) global_landmask ----- Readers not added for the following variables: ocean_mixed_layer_thickness sea_ice_area_fraction sea_ice_x_velocity sea_ice_y_velocity 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 Discarded readers: Time: Start: 2025-12-16 11:00:00 UTC Present: 2025-12-16 23:00:00 UTC Calculation steps: 48 * 0:15:00 - total time: 12:00:00 Output steps: 25 * 0:30:00 =========================== 13:51:00 WARNING opendrift:2473: Plotting fast. This will make your plots less accurate. 13:52:07 WARNING opendrift:2473: Plotting fast. This will make your plots less accurate. 13:52:08 INFO opendrift:4660: Saving animation to /root/project/docs/source/gallery/animations/example_oil_verticalmixing_0.gif... 13:52:23 INFO opendrift:3094: Time to make animation: 0:00:16.623334 13:52:24 INFO opendrift:4660: Saving animation to /root/project/docs/source/gallery/animations/example_oil_verticalmixing_1.gif... 13:52:30 INFO opendrift.models.oceandrift:643: Time to make animation: 0:00:06.828020 .. GENERATED FROM PYTHON SOURCE LINES 50-52 .. image:: /gallery/animations/example_oil_verticalmixing_0.gif .. image:: /gallery/animations/example_oil_verticalmixing_1.gif .. rst-class:: sphx-glr-timing **Total running time of the script:** (2 minutes 49.676 seconds) .. _sphx_glr_download_gallery_example_oil_verticalmixing.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_oil_verticalmixing.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_oil_verticalmixing.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: example_oil_verticalmixing.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_