Oil budget (NOAA)

from datetime import datetime
from opendrift.readers import reader_netCDF_CF_generic
from opendrift.models.openoil import OpenOil

o = OpenOil(loglevel=20, weathering_model='noaa')

# Using constand wind and current
#o.set_config('environment:fallback:x_wind', 7)
#o.set_config('environment:fallback:x_sea_water_velocity', .7)
#o.set_config('environment:fallback:y_sea_water_velocity', .3)
#o.set_config('environment:fallback:land_binary_mask', 0)

# Arome atmospheric model
reader_arome = reader_netCDF_CF_generic.Reader(o.test_data_folder() + '16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc')
# Norkyst ocean model
reader_norkyst = reader_netCDF_CF_generic.Reader(o.test_data_folder() + '16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc')

o.add_reader([reader_arome, reader_norkyst])
09:37:46 INFO    opendrift.models.basemodel:515: OpenDriftSimulation initialised (version 1.11.13 / v1.11.13-48-g5bea84b)
09:37:46 INFO    opendrift.readers.reader_netCDF_CF_generic:102: Opening dataset: /root/project/tests/test_data/16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc
09:37:47 INFO    opendrift.readers.reader_netCDF_CF_generic:325: Detected dimensions: {'time': 'time', 'x': 'x', 'y': 'y'}
09:37:47 INFO    opendrift.readers.reader_netCDF_CF_generic:102: Opening dataset: /root/project/tests/test_data/16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc
09:37:47 INFO    opendrift.readers.reader_netCDF_CF_generic:325: Detected dimensions: {'x': 'X', 'y': 'Y', 'z': 'depth', 'time': 'time'}

Adjusting some configuration

o.set_config('processes:dispersion', False)
o.set_config('processes:evaporation', True)
o.set_config('processes:emulsification', True)
o.set_config('drift:vertical_mixing', True)

Seeding some oil particles

oil_type='MARTIN LINGE CRUDE 2016'
o.seed_elements(lon=4.88, lat=60.1, z=0, radius=3000, number=500,
                time=reader_norkyst.start_time, oil_type=oil_type)
09:37:47 INFO    opendrift.models.openoil.adios.dirjs:90: Querying ADIOS database for oil: MARTIN LINGE CRUDE 2016
09:37:47 INFO    opendrift.models.openoil.openoil:1719: Using density 930.00252 and viscosity 0.0003426469471271408 of oiltype MARTIN LINGE CRUDE 2016
09:37:47 INFO    opendrift.models.basemodel.environment:218: Adding a dynamical landmask with max. priority based on assumed maximum speed of 1.3 m/s. Adding a customised landmask may be faster...
09:37:53 INFO    opendrift.models.basemodel.environment:245: Fallback values will be used for the following variables which have no readers:
09:37:53 INFO    opendrift.models.basemodel.environment:248:    sea_surface_height: 0.000000
09:37:53 INFO    opendrift.models.basemodel.environment:248:    upward_sea_water_velocity: 0.000000
09:37:53 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_significant_height: 0.000000
09:37:53 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_stokes_drift_x_velocity: 0.000000
09:37:53 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_stokes_drift_y_velocity: 0.000000
09:37:53 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_period_at_variance_spectral_density_maximum: 0.000000
09:37:53 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000
09:37:53 INFO    opendrift.models.basemodel.environment:248:    sea_ice_area_fraction: 0.000000
09:37:53 INFO    opendrift.models.basemodel.environment:248:    sea_ice_x_velocity: 0.000000
09:37:53 INFO    opendrift.models.basemodel.environment:248:    sea_ice_y_velocity: 0.000000
09:37:53 INFO    opendrift.models.basemodel.environment:248:    sea_water_temperature: 10.000000
09:37:53 INFO    opendrift.models.basemodel.environment:248:    sea_water_salinity: 34.000000
09:37:53 INFO    opendrift.models.basemodel.environment:248:    sea_floor_depth_below_sea_level: 10000.000000
09:37:53 INFO    opendrift.models.basemodel.environment:248:    ocean_vertical_diffusivity: 0.020000
09:37:53 INFO    opendrift.models.basemodel.environment:248:    ocean_mixed_layer_thickness: 50.000000

Running model

o.run(steps=4*24, time_step=900, time_step_output=3600)
09:37:54 INFO    opendrift.models.basemodel:936: Using existing reader for land_binary_mask
09:37:54 INFO    opendrift.models.basemodel:947: All points are in ocean
09:37:54 INFO    opendrift.models.openoil.openoil:687: Oil-water surface tension is 0.033729 Nm
09:37:54 INFO    opendrift.models.openoil.openoil:696: Using max water fractions [0.72, 0.78] for temperatures [5.0, 15.0] for oiltype MARTIN LINGE CRUDE 2016
09:37:54 INFO    opendrift.models.openoil.openoil:697: Corresponding max water fraction from GNOME is 0.731347796266117
09:37:54 INFO    opendrift.models.basemodel:2038: 2015-11-16 00:00:00 - step 1 of 96 - 500 active elements (0 deactivated)
/root/project/opendrift/readers/interpolation/interpolators.py:17: RuntimeWarning: overflow encountered in cast
  data[mask] = np.finfo(np.float64).min
09:37:54 INFO    opendrift.models.basemodel:2038: 2015-11-16 00:15:00 - step 2 of 96 - 500 active elements (0 deactivated)
09:37:54 INFO    opendrift.models.basemodel:2038: 2015-11-16 00:30:00 - step 3 of 96 - 500 active elements (0 deactivated)
09:37:54 INFO    opendrift.models.basemodel:2038: 2015-11-16 00:45:00 - step 4 of 96 - 500 active elements (0 deactivated)
09:37:54 INFO    opendrift.models.basemodel:2038: 2015-11-16 01:00:00 - step 5 of 96 - 500 active elements (0 deactivated)
09:37:54 INFO    opendrift.models.basemodel:2038: 2015-11-16 01:15:00 - step 6 of 96 - 500 active elements (0 deactivated)
09:37:54 INFO    opendrift.models.basemodel:2038: 2015-11-16 01:30:00 - step 7 of 96 - 500 active elements (0 deactivated)
09:37:54 INFO    opendrift.models.basemodel:2038: 2015-11-16 01:45:00 - step 8 of 96 - 500 active elements (0 deactivated)
09:37:54 INFO    opendrift.models.basemodel:2038: 2015-11-16 02:00:00 - step 9 of 96 - 500 active elements (0 deactivated)
09:37:54 INFO    opendrift.models.basemodel:2038: 2015-11-16 02:15:00 - step 10 of 96 - 500 active elements (0 deactivated)
09:37:54 INFO    opendrift.models.basemodel:2038: 2015-11-16 02:30:00 - step 11 of 96 - 500 active elements (0 deactivated)
09:37:54 INFO    opendrift.models.basemodel:2038: 2015-11-16 02:45:00 - step 12 of 96 - 500 active elements (0 deactivated)
09:37:54 INFO    opendrift.models.basemodel:2038: 2015-11-16 03:00:00 - step 13 of 96 - 500 active elements (0 deactivated)
09:37:54 INFO    opendrift.models.basemodel:2038: 2015-11-16 03:15:00 - step 14 of 96 - 500 active elements (0 deactivated)
09:37:55 INFO    opendrift.models.basemodel:2038: 2015-11-16 03:30:00 - step 15 of 96 - 500 active elements (0 deactivated)
09:37:55 INFO    opendrift.models.basemodel:2038: 2015-11-16 03:45:00 - step 16 of 96 - 500 active elements (0 deactivated)
09:37:55 INFO    opendrift.models.basemodel:2038: 2015-11-16 04:00:00 - step 17 of 96 - 500 active elements (0 deactivated)
09:37:55 INFO    opendrift.models.basemodel:2038: 2015-11-16 04:15:00 - step 18 of 96 - 500 active elements (0 deactivated)
09:37:55 INFO    opendrift.models.basemodel:2038: 2015-11-16 04:30:00 - step 19 of 96 - 500 active elements (0 deactivated)
09:37:55 INFO    opendrift.models.basemodel:2038: 2015-11-16 04:45:00 - step 20 of 96 - 500 active elements (0 deactivated)
09:37:55 INFO    opendrift.models.basemodel:2038: 2015-11-16 05:00:00 - step 21 of 96 - 500 active elements (0 deactivated)
09:37:55 INFO    opendrift.models.basemodel:2038: 2015-11-16 05:15:00 - step 22 of 96 - 500 active elements (0 deactivated)
09:37:55 INFO    opendrift.models.basemodel:2038: 2015-11-16 05:30:00 - step 23 of 96 - 500 active elements (0 deactivated)
09:37:55 INFO    opendrift.models.basemodel:2038: 2015-11-16 05:45:00 - step 24 of 96 - 500 active elements (0 deactivated)
09:37:55 INFO    opendrift.models.basemodel:2038: 2015-11-16 06:00:00 - step 25 of 96 - 500 active elements (0 deactivated)
09:37:55 INFO    opendrift.models.basemodel:2038: 2015-11-16 06:15:00 - step 26 of 96 - 500 active elements (0 deactivated)
09:37:55 INFO    opendrift.models.basemodel:2038: 2015-11-16 06:30:00 - step 27 of 96 - 500 active elements (0 deactivated)
09:37:55 INFO    opendrift.models.basemodel:2038: 2015-11-16 06:45:00 - step 28 of 96 - 500 active elements (0 deactivated)
09:37:55 INFO    opendrift.models.basemodel:2038: 2015-11-16 07:00:00 - step 29 of 96 - 500 active elements (0 deactivated)
09:37:56 INFO    opendrift.models.basemodel:2038: 2015-11-16 07:15:00 - step 30 of 96 - 500 active elements (0 deactivated)
09:37:56 INFO    opendrift.models.basemodel:2038: 2015-11-16 07:30:00 - step 31 of 96 - 500 active elements (0 deactivated)
09:37:56 INFO    opendrift.models.basemodel:2038: 2015-11-16 07:45:00 - step 32 of 96 - 500 active elements (0 deactivated)
09:37:56 INFO    opendrift.models.basemodel:2038: 2015-11-16 08:00:00 - step 33 of 96 - 500 active elements (0 deactivated)
09:37:56 INFO    opendrift.models.basemodel:2038: 2015-11-16 08:15:00 - step 34 of 96 - 500 active elements (0 deactivated)
09:37:56 INFO    opendrift.models.basemodel:2038: 2015-11-16 08:30:00 - step 35 of 96 - 500 active elements (0 deactivated)
09:37:56 INFO    opendrift.models.basemodel:2038: 2015-11-16 08:45:00 - step 36 of 96 - 500 active elements (0 deactivated)
09:37:56 INFO    opendrift.models.basemodel:2038: 2015-11-16 09:00:00 - step 37 of 96 - 500 active elements (0 deactivated)
09:37:56 INFO    opendrift.models.basemodel:2038: 2015-11-16 09:15:00 - step 38 of 96 - 500 active elements (0 deactivated)
09:37:56 INFO    opendrift.models.basemodel:2038: 2015-11-16 09:30:00 - step 39 of 96 - 500 active elements (0 deactivated)
09:37:56 INFO    opendrift.models.basemodel:2038: 2015-11-16 09:45:00 - step 40 of 96 - 500 active elements (0 deactivated)
09:37:56 INFO    opendrift.models.basemodel:2038: 2015-11-16 10:00:00 - step 41 of 96 - 500 active elements (0 deactivated)
09:37:56 INFO    opendrift.models.basemodel:2038: 2015-11-16 10:15:00 - step 42 of 96 - 500 active elements (0 deactivated)
09:37:56 INFO    opendrift.models.basemodel:2038: 2015-11-16 10:30:00 - step 43 of 96 - 500 active elements (0 deactivated)
09:37:56 INFO    opendrift.models.basemodel:2038: 2015-11-16 10:45:00 - step 44 of 96 - 500 active elements (0 deactivated)
09:37:56 WARNING opendrift.readers.basereader.structured:324: Data block from /root/project/tests/test_data/16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc not large enough to cover element positions within timestep. Buffer size (4) must be increased. See `Variables.set_buffer_size`.
09:37:57 INFO    opendrift.models.basemodel:2038: 2015-11-16 11:00:00 - step 45 of 96 - 500 active elements (0 deactivated)
09:37:57 INFO    opendrift.models.basemodel:2038: 2015-11-16 11:15:00 - step 46 of 96 - 500 active elements (0 deactivated)
09:37:57 INFO    opendrift.models.basemodel:2038: 2015-11-16 11:30:00 - step 47 of 96 - 500 active elements (0 deactivated)
09:37:57 INFO    opendrift.models.basemodel:2038: 2015-11-16 11:45:00 - step 48 of 96 - 500 active elements (0 deactivated)
09:37:57 INFO    opendrift.models.basemodel:2038: 2015-11-16 12:00:00 - step 49 of 96 - 500 active elements (0 deactivated)
09:37:57 INFO    opendrift.models.basemodel:2038: 2015-11-16 12:15:00 - step 50 of 96 - 499 active elements (1 deactivated)
09:37:57 INFO    opendrift.models.basemodel:2038: 2015-11-16 12:30:00 - step 51 of 96 - 499 active elements (1 deactivated)
09:37:57 INFO    opendrift.models.basemodel:2038: 2015-11-16 12:45:00 - step 52 of 96 - 499 active elements (1 deactivated)
09:37:57 WARNING opendrift.readers.basereader.structured:324: Data block from /root/project/tests/test_data/16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc not large enough to cover element positions within timestep. Buffer size (4) must be increased. See `Variables.set_buffer_size`.
09:37:57 INFO    opendrift.models.basemodel:2038: 2015-11-16 13:00:00 - step 53 of 96 - 499 active elements (1 deactivated)
09:37:57 INFO    opendrift.models.basemodel:2038: 2015-11-16 13:15:00 - step 54 of 96 - 498 active elements (2 deactivated)
09:37:57 INFO    opendrift.models.basemodel:2038: 2015-11-16 13:30:00 - step 55 of 96 - 498 active elements (2 deactivated)
09:37:57 INFO    opendrift.models.basemodel:2038: 2015-11-16 13:45:00 - step 56 of 96 - 498 active elements (2 deactivated)
09:37:57 INFO    opendrift.models.basemodel:2038: 2015-11-16 14:00:00 - step 57 of 96 - 498 active elements (2 deactivated)
09:37:57 INFO    opendrift.models.basemodel:2038: 2015-11-16 14:15:00 - step 58 of 96 - 498 active elements (2 deactivated)
09:37:57 INFO    opendrift.models.basemodel:2038: 2015-11-16 14:30:00 - step 59 of 96 - 498 active elements (2 deactivated)
09:37:57 INFO    opendrift.models.basemodel:2038: 2015-11-16 14:45:00 - step 60 of 96 - 498 active elements (2 deactivated)
09:37:57 INFO    opendrift.models.basemodel:2038: 2015-11-16 15:00:00 - step 61 of 96 - 498 active elements (2 deactivated)
09:37:58 INFO    opendrift.models.basemodel:2038: 2015-11-16 15:15:00 - step 62 of 96 - 498 active elements (2 deactivated)
09:37:58 INFO    opendrift.models.basemodel:2038: 2015-11-16 15:30:00 - step 63 of 96 - 498 active elements (2 deactivated)
09:37:58 INFO    opendrift.models.basemodel:2038: 2015-11-16 15:45:00 - step 64 of 96 - 498 active elements (2 deactivated)
09:37:58 INFO    opendrift.models.basemodel:2038: 2015-11-16 16:00:00 - step 65 of 96 - 497 active elements (3 deactivated)
09:37:58 INFO    opendrift.models.basemodel:2038: 2015-11-16 16:15:00 - step 66 of 96 - 496 active elements (4 deactivated)
09:37:58 INFO    opendrift.models.basemodel:2038: 2015-11-16 16:30:00 - step 67 of 96 - 496 active elements (4 deactivated)
09:37:58 INFO    opendrift.models.basemodel:2038: 2015-11-16 16:45:00 - step 68 of 96 - 495 active elements (5 deactivated)
09:37:58 INFO    opendrift.models.basemodel:2038: 2015-11-16 17:00:00 - step 69 of 96 - 494 active elements (6 deactivated)
09:37:58 INFO    opendrift.models.basemodel:2038: 2015-11-16 17:15:00 - step 70 of 96 - 493 active elements (7 deactivated)
09:37:58 INFO    opendrift.models.basemodel:2038: 2015-11-16 17:30:00 - step 71 of 96 - 490 active elements (10 deactivated)
09:37:58 INFO    opendrift.models.basemodel:2038: 2015-11-16 17:45:00 - step 72 of 96 - 487 active elements (13 deactivated)
09:37:58 INFO    opendrift.models.basemodel:2038: 2015-11-16 18:00:00 - step 73 of 96 - 479 active elements (21 deactivated)
09:37:58 INFO    opendrift.models.basemodel:2038: 2015-11-16 18:15:00 - step 74 of 96 - 474 active elements (26 deactivated)
09:37:58 INFO    opendrift.models.basemodel:2038: 2015-11-16 18:30:00 - step 75 of 96 - 467 active elements (33 deactivated)
09:37:58 INFO    opendrift.models.basemodel:2038: 2015-11-16 18:45:00 - step 76 of 96 - 459 active elements (41 deactivated)
09:37:59 INFO    opendrift.models.basemodel:2038: 2015-11-16 19:00:00 - step 77 of 96 - 455 active elements (45 deactivated)
09:37:59 INFO    opendrift.models.basemodel:2038: 2015-11-16 19:15:00 - step 78 of 96 - 447 active elements (53 deactivated)
09:37:59 INFO    opendrift.models.basemodel:2038: 2015-11-16 19:30:00 - step 79 of 96 - 438 active elements (62 deactivated)
09:37:59 INFO    opendrift.models.basemodel:2038: 2015-11-16 19:45:00 - step 80 of 96 - 434 active elements (66 deactivated)
09:37:59 INFO    opendrift.models.basemodel:2038: 2015-11-16 20:00:00 - step 81 of 96 - 424 active elements (76 deactivated)
09:37:59 INFO    opendrift.models.basemodel:2038: 2015-11-16 20:15:00 - step 82 of 96 - 417 active elements (83 deactivated)
09:37:59 INFO    opendrift.models.basemodel:2038: 2015-11-16 20:30:00 - step 83 of 96 - 408 active elements (92 deactivated)
09:37:59 INFO    opendrift.models.basemodel:2038: 2015-11-16 20:45:00 - step 84 of 96 - 403 active elements (97 deactivated)
09:37:59 INFO    opendrift.models.basemodel:2038: 2015-11-16 21:00:00 - step 85 of 96 - 401 active elements (99 deactivated)
09:37:59 INFO    opendrift.models.basemodel:2038: 2015-11-16 21:15:00 - step 86 of 96 - 399 active elements (101 deactivated)
09:37:59 INFO    opendrift.models.basemodel:2038: 2015-11-16 21:30:00 - step 87 of 96 - 394 active elements (106 deactivated)
09:37:59 WARNING opendrift.readers.basereader.structured:324: Data block from /root/project/tests/test_data/16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc not large enough to cover element positions within timestep. Buffer size (4) must be increased. See `Variables.set_buffer_size`.
09:37:59 INFO    opendrift.models.basemodel:2038: 2015-11-16 21:45:00 - step 88 of 96 - 393 active elements (107 deactivated)
09:37:59 WARNING opendrift.readers.basereader.structured:324: Data block from /root/project/tests/test_data/16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc not large enough to cover element positions within timestep. Buffer size (4) must be increased. See `Variables.set_buffer_size`.
09:37:59 WARNING opendrift.readers.basereader.structured:324: Data block from /root/project/tests/test_data/16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:37:59 INFO    opendrift.models.basemodel:2038: 2015-11-16 22:00:00 - step 89 of 96 - 389 active elements (111 deactivated)
09:37:59 INFO    opendrift.models.basemodel:2038: 2015-11-16 22:15:00 - step 90 of 96 - 384 active elements (116 deactivated)
09:37:59 INFO    opendrift.models.basemodel:2038: 2015-11-16 22:30:00 - step 91 of 96 - 378 active elements (122 deactivated)
09:38:00 INFO    opendrift.models.basemodel:2038: 2015-11-16 22:45:00 - step 92 of 96 - 375 active elements (125 deactivated)
09:38:00 WARNING opendrift.readers.basereader.structured:324: Data block from /root/project/tests/test_data/16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.
09:38:00 INFO    opendrift.models.basemodel:2038: 2015-11-16 23:00:00 - step 93 of 96 - 374 active elements (126 deactivated)
09:38:00 INFO    opendrift.models.basemodel:2038: 2015-11-16 23:15:00 - step 94 of 96 - 371 active elements (129 deactivated)
09:38:00 INFO    opendrift.models.basemodel:2038: 2015-11-16 23:30:00 - step 95 of 96 - 358 active elements (142 deactivated)
09:38:00 INFO    opendrift.models.basemodel:2038: 2015-11-16 23:45:00 - step 96 of 96 - 348 active elements (152 deactivated)
09:38:00 WARNING opendrift.readers.basereader.structured:324: Data block from /root/project/tests/test_data/16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc not large enough to cover element positions within timestep. Buffer size (8) must be increased. See `Variables.set_buffer_size`.

Print and plot results

o.plot_oil_budget()
o.plot(fast=True)
o.animation(fast=True)
#o.plot_oil_budget('oil_budget_MartinLingeCrude.png')
  • MARTIN LINGE CRUDE 2016 (930.0 kg/m3) - 2015-11-16 00:00 to 2015-11-17 00:00
  • OpenDrift - OpenOil (MARTIN LINGE CRUDE 2016) 2015-11-16 00:00 to 2015-11-17 00:00 UTC (25 steps)
09:38:00 WARNING opendrift.models.basemodel:2411: Plotting fast. This will make your plots less accurate.
09:38:03 WARNING opendrift.models.basemodel:2411: Plotting fast. This will make your plots less accurate.
/opt/conda/envs/opendrift/lib/python3.11/site-packages/cartopy/mpl/geoaxes.py:1683: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  result = super().scatter(*args, **kwargs)
09:38:05 INFO    opendrift.models.basemodel:4608: Saving animation to /root/project/docs/source/gallery/animations/example_oil_budget_noaa_0.gif...
09:38:17 INFO    opendrift.models.basemodel:3037: Time to make animation: 0:00:14.186046
../_images/example_oil_budget_noaa_0.gif
o.plot_property('fraction_evaporated')
o.plot_property('density')
o.plot_property('water_fraction')
o.plot_property('viscosity')
o.plot_property('interfacial_area')
o.plot_property('z')
  • fraction_evaporated
  • density
  • water_fraction
  • viscosity
  • interfacial_area
  • z

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

Gallery generated by Sphinx-Gallery