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])
12:24:31 INFO    opendrift.models.basemodel:532: OpenDriftSimulation initialised (version 1.10.5 / v0.10.5-2-g8025fe7)
12:24:31 INFO    opendrift.readers.reader_netCDF_CF_generic:129: Opening dataset: /root/project/tests/test_data/16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc
12:24:31 INFO    opendrift.readers.reader_netCDF_CF_generic:129: Opening dataset: /root/project/tests/test_data/16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc

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)
12:24:31 INFO    opendrift.models.openoil.openoil:1423: setting oil_type to: MARTIN LINGE CRUDE 2016
12:24:31 INFO    opendrift.models.openoil.adios.dirjs:71: Querying ADIOS database for oil: MARTIN LINGE CRUDE 2016
12:24:31 INFO    opendrift.models.openoil.openoil:1580: Using density 930.00252 and viscosity 0.000342646948441439 of oiltype MARTIN LINGE CRUDE 2016

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)

Running model

o.run(steps=4*24, time_step=900, time_step_output=3600)
12:24:31 INFO    opendrift.models.basemodel:2574: Fallback values will be used for the following variables which have no readers:
12:24:31 INFO    opendrift.models.basemodel:2577:       upward_sea_water_velocity: 0.000000
12:24:31 INFO    opendrift.models.basemodel:2577:       sea_surface_wave_significant_height: 0.000000
12:24:31 INFO    opendrift.models.basemodel:2577:       sea_surface_wave_stokes_drift_x_velocity: 0.000000
12:24:31 INFO    opendrift.models.basemodel:2577:       sea_surface_wave_stokes_drift_y_velocity: 0.000000
12:24:31 INFO    opendrift.models.basemodel:2577:       sea_surface_wave_period_at_variance_spectral_density_maximum: 0.000000
12:24:31 INFO    opendrift.models.basemodel:2577:       sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000
12:24:31 INFO    opendrift.models.basemodel:2577:       sea_ice_area_fraction: 0.000000
12:24:31 INFO    opendrift.models.basemodel:2577:       sea_ice_x_velocity: 0.000000
12:24:31 INFO    opendrift.models.basemodel:2577:       sea_ice_y_velocity: 0.000000
12:24:31 INFO    opendrift.models.basemodel:2577:       sea_water_temperature: 10.000000
12:24:31 INFO    opendrift.models.basemodel:2577:       sea_water_salinity: 34.000000
12:24:31 INFO    opendrift.models.basemodel:2577:       sea_floor_depth_below_sea_level: 10000.000000
12:24:31 INFO    opendrift.models.basemodel:2577:       ocean_vertical_diffusivity: 0.020000
12:24:31 INFO    opendrift.models.basemodel:2577:       ocean_mixed_layer_thickness: 50.000000
12:24:31 INFO    opendrift.models.basemodel:2736: Adding a dynamical landmask with max. priority based on assumed maximum speed of 1.3 m/s. Adding a customised landmask may be faster...
12:24:37 INFO    opendrift.models.basemodel:1689: Using existing reader for land_binary_mask
12:24:37 INFO    opendrift.models.basemodel:1701: All points are in ocean
12:24:37 INFO    opendrift.models.openoil.openoil:607: Oil-water surface tension is 0.033729 Nm
12:24:37 INFO    opendrift.models.basemodel:2865: 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
12:24:37 INFO    opendrift.models.basemodel:2865: 2015-11-16 00:15:00 - step 2 of 96 - 500 active elements (0 deactivated)
12:24:37 INFO    opendrift.models.basemodel:2865: 2015-11-16 00:30:00 - step 3 of 96 - 500 active elements (0 deactivated)
12:24:37 INFO    opendrift.models.basemodel:2865: 2015-11-16 00:45:00 - step 4 of 96 - 500 active elements (0 deactivated)
12:24:37 INFO    opendrift.models.basemodel:2865: 2015-11-16 01:00:00 - step 5 of 96 - 500 active elements (0 deactivated)
12:24:37 INFO    opendrift.models.basemodel:2865: 2015-11-16 01:15:00 - step 6 of 96 - 500 active elements (0 deactivated)
12:24:37 INFO    opendrift.models.basemodel:2865: 2015-11-16 01:30:00 - step 7 of 96 - 500 active elements (0 deactivated)
12:24:38 INFO    opendrift.models.basemodel:2865: 2015-11-16 01:45:00 - step 8 of 96 - 500 active elements (0 deactivated)
12:24:38 INFO    opendrift.models.basemodel:2865: 2015-11-16 02:00:00 - step 9 of 96 - 500 active elements (0 deactivated)
12:24:38 INFO    opendrift.models.basemodel:2865: 2015-11-16 02:15:00 - step 10 of 96 - 500 active elements (0 deactivated)
12:24:38 INFO    opendrift.models.basemodel:2865: 2015-11-16 02:30:00 - step 11 of 96 - 500 active elements (0 deactivated)
12:24:38 INFO    opendrift.models.basemodel:2865: 2015-11-16 02:45:00 - step 12 of 96 - 500 active elements (0 deactivated)
12:24:38 INFO    opendrift.models.basemodel:2865: 2015-11-16 03:00:00 - step 13 of 96 - 500 active elements (0 deactivated)
12:24:38 INFO    opendrift.models.basemodel:2865: 2015-11-16 03:15:00 - step 14 of 96 - 500 active elements (0 deactivated)
12:24:38 INFO    opendrift.models.basemodel:2865: 2015-11-16 03:30:00 - step 15 of 96 - 500 active elements (0 deactivated)
12:24:38 INFO    opendrift.models.basemodel:2865: 2015-11-16 03:45:00 - step 16 of 96 - 500 active elements (0 deactivated)
12:24:38 INFO    opendrift.models.basemodel:2865: 2015-11-16 04:00:00 - step 17 of 96 - 500 active elements (0 deactivated)
12:24:38 INFO    opendrift.models.basemodel:2865: 2015-11-16 04:15:00 - step 18 of 96 - 500 active elements (0 deactivated)
12:24:38 INFO    opendrift.models.basemodel:2865: 2015-11-16 04:30:00 - step 19 of 96 - 500 active elements (0 deactivated)
12:24:38 INFO    opendrift.models.basemodel:2865: 2015-11-16 04:45:00 - step 20 of 96 - 500 active elements (0 deactivated)
12:24:38 INFO    opendrift.models.basemodel:2865: 2015-11-16 05:00:00 - step 21 of 96 - 500 active elements (0 deactivated)
12:24:39 INFO    opendrift.models.basemodel:2865: 2015-11-16 05:15:00 - step 22 of 96 - 500 active elements (0 deactivated)
12:24:39 INFO    opendrift.models.basemodel:2865: 2015-11-16 05:30:00 - step 23 of 96 - 500 active elements (0 deactivated)
12:24:39 INFO    opendrift.models.basemodel:2865: 2015-11-16 05:45:00 - step 24 of 96 - 500 active elements (0 deactivated)
12:24:39 INFO    opendrift.models.basemodel:2865: 2015-11-16 06:00:00 - step 25 of 96 - 500 active elements (0 deactivated)
12:24:39 INFO    opendrift.models.basemodel:2865: 2015-11-16 06:15:00 - step 26 of 96 - 500 active elements (0 deactivated)
12:24:39 INFO    opendrift.models.basemodel:2865: 2015-11-16 06:30:00 - step 27 of 96 - 500 active elements (0 deactivated)
12:24:39 INFO    opendrift.models.basemodel:2865: 2015-11-16 06:45:00 - step 28 of 96 - 500 active elements (0 deactivated)
12:24:39 INFO    opendrift.models.basemodel:2865: 2015-11-16 07:00:00 - step 29 of 96 - 500 active elements (0 deactivated)
12:24:39 INFO    opendrift.models.basemodel:2865: 2015-11-16 07:15:00 - step 30 of 96 - 500 active elements (0 deactivated)
12:24:39 INFO    opendrift.models.basemodel:2865: 2015-11-16 07:30:00 - step 31 of 96 - 500 active elements (0 deactivated)
12:24:39 INFO    opendrift.models.basemodel:2865: 2015-11-16 07:45:00 - step 32 of 96 - 500 active elements (0 deactivated)
12:24:39 INFO    opendrift.models.basemodel:2865: 2015-11-16 08:00:00 - step 33 of 96 - 500 active elements (0 deactivated)
12:24:39 INFO    opendrift.models.basemodel:2865: 2015-11-16 08:15:00 - step 34 of 96 - 500 active elements (0 deactivated)
12:24:40 INFO    opendrift.models.basemodel:2865: 2015-11-16 08:30:00 - step 35 of 96 - 500 active elements (0 deactivated)
12:24:40 INFO    opendrift.models.basemodel:2865: 2015-11-16 08:45:00 - step 36 of 96 - 500 active elements (0 deactivated)
12:24:40 INFO    opendrift.models.basemodel:2865: 2015-11-16 09:00:00 - step 37 of 96 - 500 active elements (0 deactivated)
12:24:40 INFO    opendrift.models.basemodel:2865: 2015-11-16 09:15:00 - step 38 of 96 - 500 active elements (0 deactivated)
12:24:40 INFO    opendrift.models.basemodel:2865: 2015-11-16 09:30:00 - step 39 of 96 - 500 active elements (0 deactivated)
12:24:40 INFO    opendrift.models.basemodel:2865: 2015-11-16 09:45:00 - step 40 of 96 - 500 active elements (0 deactivated)
12:24:40 INFO    opendrift.models.basemodel:2865: 2015-11-16 10:00:00 - step 41 of 96 - 500 active elements (0 deactivated)
12:24:40 INFO    opendrift.models.basemodel:2865: 2015-11-16 10:15:00 - step 42 of 96 - 500 active elements (0 deactivated)
12:24:40 INFO    opendrift.models.basemodel:2865: 2015-11-16 10:30:00 - step 43 of 96 - 500 active elements (0 deactivated)
12:24:40 INFO    opendrift.models.basemodel:2865: 2015-11-16 10:45:00 - step 44 of 96 - 500 active elements (0 deactivated)
12:24:40 WARNING opendrift.readers.basereader.structured:286: 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`.
12:24:40 INFO    opendrift.models.basemodel:2865: 2015-11-16 11:00:00 - step 45 of 96 - 500 active elements (0 deactivated)
12:24:40 INFO    opendrift.models.basemodel:2865: 2015-11-16 11:15:00 - step 46 of 96 - 500 active elements (0 deactivated)
12:24:40 INFO    opendrift.models.basemodel:2865: 2015-11-16 11:30:00 - step 47 of 96 - 500 active elements (0 deactivated)
12:24:40 INFO    opendrift.models.basemodel:2865: 2015-11-16 11:45:00 - step 48 of 96 - 500 active elements (0 deactivated)
12:24:40 INFO    opendrift.models.basemodel:2865: 2015-11-16 12:00:00 - step 49 of 96 - 500 active elements (0 deactivated)
12:24:41 INFO    opendrift.models.basemodel:2865: 2015-11-16 12:15:00 - step 50 of 96 - 499 active elements (1 deactivated)
12:24:41 INFO    opendrift.models.basemodel:2865: 2015-11-16 12:30:00 - step 51 of 96 - 499 active elements (1 deactivated)
12:24:41 INFO    opendrift.models.basemodel:2865: 2015-11-16 12:45:00 - step 52 of 96 - 499 active elements (1 deactivated)
12:24:41 WARNING opendrift.readers.basereader.structured:286: 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`.
12:24:41 INFO    opendrift.models.basemodel:2865: 2015-11-16 13:00:00 - step 53 of 96 - 499 active elements (1 deactivated)
12:24:41 INFO    opendrift.models.basemodel:2865: 2015-11-16 13:15:00 - step 54 of 96 - 498 active elements (2 deactivated)
12:24:41 INFO    opendrift.models.basemodel:2865: 2015-11-16 13:30:00 - step 55 of 96 - 498 active elements (2 deactivated)
12:24:41 INFO    opendrift.models.basemodel:2865: 2015-11-16 13:45:00 - step 56 of 96 - 498 active elements (2 deactivated)
12:24:41 INFO    opendrift.models.basemodel:2865: 2015-11-16 14:00:00 - step 57 of 96 - 498 active elements (2 deactivated)
12:24:41 INFO    opendrift.models.basemodel:2865: 2015-11-16 14:15:00 - step 58 of 96 - 498 active elements (2 deactivated)
12:24:41 INFO    opendrift.models.basemodel:2865: 2015-11-16 14:30:00 - step 59 of 96 - 498 active elements (2 deactivated)
12:24:41 INFO    opendrift.models.basemodel:2865: 2015-11-16 14:45:00 - step 60 of 96 - 498 active elements (2 deactivated)
12:24:41 INFO    opendrift.models.basemodel:2865: 2015-11-16 15:00:00 - step 61 of 96 - 498 active elements (2 deactivated)
12:24:41 INFO    opendrift.models.basemodel:2865: 2015-11-16 15:15:00 - step 62 of 96 - 498 active elements (2 deactivated)
12:24:41 INFO    opendrift.models.basemodel:2865: 2015-11-16 15:30:00 - step 63 of 96 - 498 active elements (2 deactivated)
12:24:42 INFO    opendrift.models.basemodel:2865: 2015-11-16 15:45:00 - step 64 of 96 - 498 active elements (2 deactivated)
12:24:42 INFO    opendrift.models.basemodel:2865: 2015-11-16 16:00:00 - step 65 of 96 - 497 active elements (3 deactivated)
12:24:42 INFO    opendrift.models.basemodel:2865: 2015-11-16 16:15:00 - step 66 of 96 - 496 active elements (4 deactivated)
12:24:42 INFO    opendrift.models.basemodel:2865: 2015-11-16 16:30:00 - step 67 of 96 - 496 active elements (4 deactivated)
12:24:42 INFO    opendrift.models.basemodel:2865: 2015-11-16 16:45:00 - step 68 of 96 - 495 active elements (5 deactivated)
12:24:42 INFO    opendrift.models.basemodel:2865: 2015-11-16 17:00:00 - step 69 of 96 - 494 active elements (6 deactivated)
12:24:42 INFO    opendrift.models.basemodel:2865: 2015-11-16 17:15:00 - step 70 of 96 - 493 active elements (7 deactivated)
12:24:42 INFO    opendrift.models.basemodel:2865: 2015-11-16 17:30:00 - step 71 of 96 - 490 active elements (10 deactivated)
12:24:42 INFO    opendrift.models.basemodel:2865: 2015-11-16 17:45:00 - step 72 of 96 - 487 active elements (13 deactivated)
12:24:42 INFO    opendrift.models.basemodel:2865: 2015-11-16 18:00:00 - step 73 of 96 - 479 active elements (21 deactivated)
12:24:42 INFO    opendrift.models.basemodel:2865: 2015-11-16 18:15:00 - step 74 of 96 - 474 active elements (26 deactivated)
12:24:42 INFO    opendrift.models.basemodel:2865: 2015-11-16 18:30:00 - step 75 of 96 - 467 active elements (33 deactivated)
12:24:42 INFO    opendrift.models.basemodel:2865: 2015-11-16 18:45:00 - step 76 of 96 - 459 active elements (41 deactivated)
12:24:42 INFO    opendrift.models.basemodel:2865: 2015-11-16 19:00:00 - step 77 of 96 - 455 active elements (45 deactivated)
12:24:43 INFO    opendrift.models.basemodel:2865: 2015-11-16 19:15:00 - step 78 of 96 - 447 active elements (53 deactivated)
12:24:43 INFO    opendrift.models.basemodel:2865: 2015-11-16 19:30:00 - step 79 of 96 - 438 active elements (62 deactivated)
12:24:43 INFO    opendrift.models.basemodel:2865: 2015-11-16 19:45:00 - step 80 of 96 - 434 active elements (66 deactivated)
12:24:43 INFO    opendrift.models.basemodel:2865: 2015-11-16 20:00:00 - step 81 of 96 - 424 active elements (76 deactivated)
12:24:43 INFO    opendrift.models.basemodel:2865: 2015-11-16 20:15:00 - step 82 of 96 - 417 active elements (83 deactivated)
12:24:43 INFO    opendrift.models.basemodel:2865: 2015-11-16 20:30:00 - step 83 of 96 - 408 active elements (92 deactivated)
12:24:43 INFO    opendrift.models.basemodel:2865: 2015-11-16 20:45:00 - step 84 of 96 - 403 active elements (97 deactivated)
12:24:43 INFO    opendrift.models.basemodel:2865: 2015-11-16 21:00:00 - step 85 of 96 - 401 active elements (99 deactivated)
12:24:43 INFO    opendrift.models.basemodel:2865: 2015-11-16 21:15:00 - step 86 of 96 - 399 active elements (101 deactivated)
12:24:43 INFO    opendrift.models.basemodel:2865: 2015-11-16 21:30:00 - step 87 of 96 - 394 active elements (106 deactivated)
12:24:43 WARNING opendrift.readers.basereader.structured:286: 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`.
12:24:43 INFO    opendrift.models.basemodel:2865: 2015-11-16 21:45:00 - step 88 of 96 - 393 active elements (107 deactivated)
12:24:43 WARNING opendrift.readers.basereader.structured:286: 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`.
12:24:43 WARNING opendrift.readers.basereader.structured:286: 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`.
12:24:43 INFO    opendrift.models.basemodel:2865: 2015-11-16 22:00:00 - step 89 of 96 - 389 active elements (111 deactivated)
12:24:43 INFO    opendrift.models.basemodel:2865: 2015-11-16 22:15:00 - step 90 of 96 - 384 active elements (116 deactivated)
12:24:44 INFO    opendrift.models.basemodel:2865: 2015-11-16 22:30:00 - step 91 of 96 - 378 active elements (122 deactivated)
12:24:44 INFO    opendrift.models.basemodel:2865: 2015-11-16 22:45:00 - step 92 of 96 - 375 active elements (125 deactivated)
12:24:44 WARNING opendrift.readers.basereader.structured:286: 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`.
12:24:44 INFO    opendrift.models.basemodel:2865: 2015-11-16 23:00:00 - step 93 of 96 - 374 active elements (126 deactivated)
12:24:44 INFO    opendrift.models.basemodel:2865: 2015-11-16 23:15:00 - step 94 of 96 - 371 active elements (129 deactivated)
12:24:44 INFO    opendrift.models.basemodel:2865: 2015-11-16 23:30:00 - step 95 of 96 - 358 active elements (142 deactivated)
12:24:44 INFO    opendrift.models.basemodel:2865: 2015-11-16 23:45:00 - step 96 of 96 - 348 active elements (152 deactivated)
12:24:44 WARNING opendrift.readers.basereader.structured:286: 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)
12:24:44 WARNING opendrift.models.basemodel:3209: Plotting fast. This will make your plots less accurate.
12:24:47 WARNING opendrift.models.basemodel:3209: Plotting fast. This will make your plots less accurate.
/opt/conda/envs/opendrift/lib/python3.11/site-packages/cartopy/mpl/geoaxes.py:1700: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  result = super().scatter(*args, **kwargs)
12:24:48 INFO    opendrift.models.basemodel:5329: Saving animation to /root/project/docs/source/gallery/animations/example_oil_budget_noaa_0.gif...
12:24:52 INFO    opendrift.models.basemodel:3831: Time to make animation: 0:00:05.541522
../_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 26.175 seconds)

Gallery generated by Sphinx-Gallery