Oil budget

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

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

# Arome
reader_arome = reader_netCDF_CF_generic.Reader(o.test_data_folder() +
    '16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc')
#reader_arome = reader_netCDF_CF_generic.Reader('https://thredds.met.no/thredds/dodsC/mepslatest/meps_lagged_6_h_latest_2_5km_latest.nc')

# Norkyst
reader_norkyst = reader_netCDF_CF_generic.Reader(o.test_data_folder() +
    '16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc')
#reader_norkyst = reader_netCDF_CF_generic.Reader('https://thredds.met.no/thredds/dodsC/sea/norkyst800m/1h/aggregate_be')

o.add_reader([reader_norkyst, reader_arome])
#o.set_config('environment:fallback:x_wind', 9)
#o.set_config('environment:fallback:y_wind', 0)
#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)

Out:

13:47:35 INFO    opendrift.models.basemodel: OpenDriftSimulation initialised (version 1.7.1 / v1.7.1-87-g074c1d2)
13:47:35 INFO    opendrift.readers.reader_netCDF_CF_generic: Opening dataset: /root/project/tests/test_data/16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc
13:47:35 INFO    opendrift.readers.reader_netCDF_CF_generic: Opening dataset: /root/project/tests/test_data/16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc

Seed oil elements at defined position and time

oil_type = 'IFO-380LS 2014'
oil_type = 'IFO 300'
oil_type = 'IFO-180NS 2014'
oil_type = 'GENERIC LIGHT CRUDE'
oil_type = 'GENERIC HEAVY CRUDE'
o.seed_elements(lon=4.8, lat=60.0, z=0, radius=3000, number=1000,
                time=reader_arome.start_time, oil_type=oil_type)

Out:

querying DB:
Oil.name ==  'GENERIC HEAVY CRUDE'
/opt/conda/envs/opendrift/lib/python3.9/site-packages/scipy/optimize/minpack.py:833: OptimizeWarning: Covariance of the parameters could not be estimated
  warnings.warn('Covariance of the parameters could not be estimated',
13:47:35 INFO    opendrift.models.openoil: Using density 938.0670859538783 and viscosity 0.0010573364220196038 of oiltype GENERIC HEAVY CRUDE

Adjusting some configuration

o.set_config('processes:dispersion', True)
o.set_config('processes:evaporation', True)
o.set_config('processes:emulsification', True)
o.set_config('drift:vertical_mixing', True)
o.set_config('vertical_mixing:timestep', 20.) # seconds

Running model

o.run(duration=timedelta(hours=24), time_step=1800)

o.plot_oil_budget(show_density_viscosity=True, show_wind_and_current=True)

o.animation(color='viscosity')
GENERIC HEAVY CRUDE (938.1 kg/m3) - 2015-11-16 00:00 to 2015-11-17 00:00

Out:

13:47:35 INFO    opendrift.models.basemodel: Fallback values will be used for the following variables which have no readers:
13:47:35 INFO    opendrift.models.basemodel:    upward_sea_water_velocity: 0.000000
13:47:35 INFO    opendrift.models.basemodel:    sea_surface_wave_significant_height: 0.000000
13:47:35 INFO    opendrift.models.basemodel:    sea_surface_wave_stokes_drift_x_velocity: 0.000000
13:47:35 INFO    opendrift.models.basemodel:    sea_surface_wave_stokes_drift_y_velocity: 0.000000
13:47:35 INFO    opendrift.models.basemodel:    sea_surface_wave_period_at_variance_spectral_density_maximum: 0.000000
13:47:35 INFO    opendrift.models.basemodel:    sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000
13:47:35 INFO    opendrift.models.basemodel:    sea_ice_area_fraction: 0.000000
13:47:35 INFO    opendrift.models.basemodel:    sea_ice_x_velocity: 0.000000
13:47:35 INFO    opendrift.models.basemodel:    sea_ice_y_velocity: 0.000000
13:47:35 INFO    opendrift.models.basemodel:    sea_water_temperature: 10.000000
13:47:35 INFO    opendrift.models.basemodel:    sea_water_salinity: 34.000000
13:47:35 INFO    opendrift.models.basemodel:    sea_floor_depth_below_sea_level: 10000.000000
13:47:35 INFO    opendrift.models.basemodel:    ocean_vertical_diffusivity: 0.020000
13:47:35 INFO    opendrift.models.basemodel: Adding a dynamical landmask with max. priority based on assumed maximum speed of 1.3 m/s. Adding a customised landmask may be faster...
13:47:37 INFO    opendrift.models.basemodel: Using existing reader for land_binary_mask
13:47:37 INFO    opendrift.models.basemodel: All points are in ocean
13:47:37 INFO    opendrift.models.openoil: Oil-water surface tension is 0.033937 Nm
13:47:37 INFO    opendrift.models.basemodel: 2015-11-16 00:00:00 - step 1 of 48 - 1000 active elements (0 deactivated)
13:47:38 INFO    opendrift.models.basemodel: 2015-11-16 00:30:00 - step 2 of 48 - 1000 active elements (0 deactivated)
13:47:38 INFO    opendrift.models.basemodel: 2015-11-16 01:00:00 - step 3 of 48 - 1000 active elements (0 deactivated)
13:47:38 INFO    opendrift.models.basemodel: 2015-11-16 01:30:00 - step 4 of 48 - 1000 active elements (0 deactivated)
13:47:38 INFO    opendrift.models.basemodel: 2015-11-16 02:00:00 - step 5 of 48 - 1000 active elements (0 deactivated)
13:47:38 INFO    opendrift.models.basemodel: 2015-11-16 02:30:00 - step 6 of 48 - 1000 active elements (0 deactivated)
13:47:39 INFO    opendrift.models.basemodel: 2015-11-16 03:00:00 - step 7 of 48 - 1000 active elements (0 deactivated)
13:47:39 INFO    opendrift.models.basemodel: 2015-11-16 03:30:00 - step 8 of 48 - 1000 active elements (0 deactivated)
13:47:39 INFO    opendrift.models.basemodel: 2015-11-16 04:00:00 - step 9 of 48 - 1000 active elements (0 deactivated)
13:47:39 INFO    opendrift.models.basemodel: 2015-11-16 04:30:00 - step 10 of 48 - 1000 active elements (0 deactivated)
13:47:39 INFO    opendrift.models.basemodel: 2015-11-16 05:00:00 - step 11 of 48 - 1000 active elements (0 deactivated)
13:47:39 INFO    opendrift.models.basemodel: 2015-11-16 05:30:00 - step 12 of 48 - 1000 active elements (0 deactivated)
13:47:40 INFO    opendrift.models.basemodel: 2015-11-16 06:00:00 - step 13 of 48 - 1000 active elements (0 deactivated)
13:47:40 INFO    opendrift.models.basemodel: 2015-11-16 06:30:00 - step 14 of 48 - 1000 active elements (0 deactivated)
13:47:40 INFO    opendrift.models.basemodel: 2015-11-16 07:00:00 - step 15 of 48 - 1000 active elements (0 deactivated)
13:47:40 INFO    opendrift.models.basemodel: 2015-11-16 07:30:00 - step 16 of 48 - 1000 active elements (0 deactivated)
13:47:40 INFO    opendrift.models.basemodel: 2015-11-16 08:00:00 - step 17 of 48 - 1000 active elements (0 deactivated)
13:47:40 INFO    opendrift.models.basemodel: 2015-11-16 08:30:00 - step 18 of 48 - 1000 active elements (0 deactivated)
13:47:40 INFO    opendrift.models.basemodel: 2015-11-16 09:00:00 - step 19 of 48 - 1000 active elements (0 deactivated)
13:47:41 INFO    opendrift.models.basemodel: 2015-11-16 09:30:00 - step 20 of 48 - 1000 active elements (0 deactivated)
13:47:41 INFO    opendrift.models.basemodel: 2015-11-16 10:00:00 - step 21 of 48 - 1000 active elements (0 deactivated)
13:47:41 INFO    opendrift.models.basemodel: 2015-11-16 10:30:00 - step 22 of 48 - 1000 active elements (0 deactivated)
13:47:41 WARNING opendrift.readers.basereader.structured: 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`.
13:47:41 INFO    opendrift.models.basemodel: 2015-11-16 11:00:00 - step 23 of 48 - 1000 active elements (0 deactivated)
13:47:41 INFO    opendrift.models.basemodel: 2015-11-16 11:30:00 - step 24 of 48 - 1000 active elements (0 deactivated)
13:47:41 INFO    opendrift.models.basemodel: 2015-11-16 12:00:00 - step 25 of 48 - 1000 active elements (0 deactivated)
13:47:42 INFO    opendrift.models.basemodel: 2015-11-16 12:30:00 - step 26 of 48 - 1000 active elements (0 deactivated)
13:47:42 INFO    opendrift.models.basemodel: 2015-11-16 13:00:00 - step 27 of 48 - 1000 active elements (0 deactivated)
13:47:42 INFO    opendrift.models.basemodel: 2015-11-16 13:30:00 - step 28 of 48 - 1000 active elements (0 deactivated)
13:47:42 INFO    opendrift.models.basemodel: 2015-11-16 14:00:00 - step 29 of 48 - 1000 active elements (0 deactivated)
13:47:42 INFO    opendrift.models.basemodel: 2015-11-16 14:30:00 - step 30 of 48 - 1000 active elements (0 deactivated)
13:47:43 INFO    opendrift.models.basemodel: 2015-11-16 15:00:00 - step 31 of 48 - 999 active elements (1 deactivated)
13:47:43 INFO    opendrift.models.basemodel: 2015-11-16 15:30:00 - step 32 of 48 - 998 active elements (2 deactivated)
13:47:43 INFO    opendrift.models.basemodel: 2015-11-16 16:00:00 - step 33 of 48 - 996 active elements (4 deactivated)
13:47:43 INFO    opendrift.models.basemodel: 2015-11-16 16:30:00 - step 34 of 48 - 991 active elements (9 deactivated)
13:47:43 INFO    opendrift.models.basemodel: 2015-11-16 17:00:00 - step 35 of 48 - 988 active elements (12 deactivated)
13:47:44 INFO    opendrift.models.basemodel: 2015-11-16 17:30:00 - step 36 of 48 - 986 active elements (14 deactivated)
13:47:44 INFO    opendrift.models.basemodel: 2015-11-16 18:00:00 - step 37 of 48 - 985 active elements (15 deactivated)
13:47:44 INFO    opendrift.models.basemodel: 2015-11-16 18:30:00 - step 38 of 48 - 981 active elements (19 deactivated)
13:47:44 INFO    opendrift.models.basemodel: 2015-11-16 19:00:00 - step 39 of 48 - 974 active elements (26 deactivated)
13:47:44 INFO    opendrift.models.basemodel: 2015-11-16 19:30:00 - step 40 of 48 - 964 active elements (36 deactivated)
13:47:44 INFO    opendrift.models.basemodel: 2015-11-16 20:00:00 - step 41 of 48 - 930 active elements (70 deactivated)
13:47:45 INFO    opendrift.models.basemodel: 2015-11-16 20:30:00 - step 42 of 48 - 892 active elements (108 deactivated)
13:47:45 INFO    opendrift.models.basemodel: 2015-11-16 21:00:00 - step 43 of 48 - 852 active elements (148 deactivated)
13:47:45 INFO    opendrift.models.basemodel: 2015-11-16 21:30:00 - step 44 of 48 - 828 active elements (172 deactivated)
13:47:45 INFO    opendrift.models.basemodel: 2015-11-16 22:00:00 - step 45 of 48 - 769 active elements (231 deactivated)
13:47:45 INFO    opendrift.models.basemodel: 2015-11-16 22:30:00 - step 46 of 48 - 720 active elements (280 deactivated)
13:47:45 INFO    opendrift.models.basemodel: 2015-11-16 23:00:00 - step 47 of 48 - 667 active elements (333 deactivated)
13:47:46 INFO    opendrift.models.basemodel: 2015-11-16 23:30:00 - step 48 of 48 - 599 active elements (401 deactivated)
13:48:07 INFO    opendrift.models.basemodel: Saving animation to /root/project/docs/source/gallery/animations/example_oil_budget_0.gif...
13:48:07 INFO    opendrift.models.basemodel: Making animated gif...
MovieWriter imagemagick unavailable; using Pillow instead.
../_images/example_oil_budget_0.gif

Total running time of the script: ( 1 minutes 21.426 seconds)

Gallery generated by Sphinx-Gallery