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])
20:12:34 INFO    opendrift.models.basemodel:515: OpenDriftSimulation initialised (version 1.12.0 / v1.12.0-26-g390e945)
20:12:34 INFO    opendrift.readers:58: Opening file with xr.open_dataset
20:12:34 INFO    opendrift.readers.reader_netCDF_CF_generic:337: Detected dimensions: {'time': 'time', 'x': 'x', 'y': 'y'}
20:12:34 INFO    opendrift.readers:58: Opening file with xr.open_dataset
20:12:34 INFO    opendrift.readers.reader_netCDF_CF_generic:337: Detected dimensions: {'x': 'X', 'y': 'Y', 'z': 'depth', 'time': 'time'}

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
#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)

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)
20:12:34 INFO    opendrift.models.openoil.adios.dirjs:86: Querying ADIOS database for oil: GENERIC HEAVY CRUDE
20:12:34 INFO    opendrift.models.openoil.openoil:1715: Using density 963.50937 and viscosity 0.007984481780964631 of oiltype GENERIC HEAVY CRUDE
20:12:34 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...
20:12:37 INFO    opendrift.models.basemodel.environment:245: Fallback values will be used for the following variables which have no readers:
20:12:37 INFO    opendrift.models.basemodel.environment:248:    sea_surface_height: 0.000000
20:12:37 INFO    opendrift.models.basemodel.environment:248:    upward_sea_water_velocity: 0.000000
20:12:37 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_significant_height: 0.000000
20:12:37 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_stokes_drift_x_velocity: 0.000000
20:12:37 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_stokes_drift_y_velocity: 0.000000
20:12:37 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_period_at_variance_spectral_density_maximum: 0.000000
20:12:37 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000
20:12:37 INFO    opendrift.models.basemodel.environment:248:    sea_ice_area_fraction: 0.000000
20:12:37 INFO    opendrift.models.basemodel.environment:248:    sea_ice_x_velocity: 0.000000
20:12:37 INFO    opendrift.models.basemodel.environment:248:    sea_ice_y_velocity: 0.000000
20:12:37 INFO    opendrift.models.basemodel.environment:248:    sea_water_temperature: 10.000000
20:12:37 INFO    opendrift.models.basemodel.environment:248:    sea_water_salinity: 34.000000
20:12:37 INFO    opendrift.models.basemodel.environment:248:    sea_floor_depth_below_sea_level: 10000.000000
20:12:37 INFO    opendrift.models.basemodel.environment:248:    ocean_vertical_diffusivity: 0.020000
20:12:37 INFO    opendrift.models.basemodel.environment:248:    ocean_mixed_layer_thickness: 50.000000

Running model

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

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

o.animation(color='viscosity')
GENERIC HEAVY CRUDE (963.5 kg/m3) - 2015-11-16 00:00 to 2015-11-17 00:00
20:12:38 INFO    opendrift.models.basemodel:935: Using existing reader for land_binary_mask
20:12:38 INFO    opendrift.models.basemodel:946: All points are in ocean
20:12:38 INFO    opendrift.models.openoil.openoil:684: Oil-water surface tension is 0.035048 Nm
20:12:38 INFO    opendrift.models.openoil.openoil:697: Max water fraction not available for GENERIC HEAVY CRUDE, using default
20:12:38 INFO    opendrift.models.basemodel:2035: 2015-11-16 00:00:00 - step 1 of 48 - 1000 active elements (0 deactivated)
20:12:38 INFO    opendrift.models.basemodel:2035: 2015-11-16 00:30:00 - step 2 of 48 - 1000 active elements (0 deactivated)
20:12:38 INFO    opendrift.models.basemodel:2035: 2015-11-16 01:00:00 - step 3 of 48 - 1000 active elements (0 deactivated)
20:12:38 INFO    opendrift.models.basemodel:2035: 2015-11-16 01:30:00 - step 4 of 48 - 1000 active elements (0 deactivated)
20:12:39 INFO    opendrift.models.basemodel:2035: 2015-11-16 02:00:00 - step 5 of 48 - 1000 active elements (0 deactivated)
20:12:39 INFO    opendrift.models.basemodel:2035: 2015-11-16 02:30:00 - step 6 of 48 - 1000 active elements (0 deactivated)
20:12:39 INFO    opendrift.models.basemodel:2035: 2015-11-16 03:00:00 - step 7 of 48 - 1000 active elements (0 deactivated)
20:12:39 INFO    opendrift.models.basemodel:2035: 2015-11-16 03:30:00 - step 8 of 48 - 1000 active elements (0 deactivated)
20:12:39 INFO    opendrift.models.basemodel:2035: 2015-11-16 04:00:00 - step 9 of 48 - 1000 active elements (0 deactivated)
20:12:39 INFO    opendrift.models.basemodel:2035: 2015-11-16 04:30:00 - step 10 of 48 - 1000 active elements (0 deactivated)
20:12:39 INFO    opendrift.models.basemodel:2035: 2015-11-16 05:00:00 - step 11 of 48 - 1000 active elements (0 deactivated)
20:12:39 INFO    opendrift.models.basemodel:2035: 2015-11-16 05:30:00 - step 12 of 48 - 1000 active elements (0 deactivated)
20:12:40 INFO    opendrift.models.basemodel:2035: 2015-11-16 06:00:00 - step 13 of 48 - 1000 active elements (0 deactivated)
20:12:40 INFO    opendrift.models.basemodel:2035: 2015-11-16 06:30:00 - step 14 of 48 - 1000 active elements (0 deactivated)
20:12:40 INFO    opendrift.models.basemodel:2035: 2015-11-16 07:00:00 - step 15 of 48 - 1000 active elements (0 deactivated)
20:12:40 INFO    opendrift.models.basemodel:2035: 2015-11-16 07:30:00 - step 16 of 48 - 1000 active elements (0 deactivated)
20:12:40 INFO    opendrift.models.basemodel:2035: 2015-11-16 08:00:00 - step 17 of 48 - 1000 active elements (0 deactivated)
20:12:40 INFO    opendrift.models.basemodel:2035: 2015-11-16 08:30:00 - step 18 of 48 - 1000 active elements (0 deactivated)
20:12:40 INFO    opendrift.models.basemodel:2035: 2015-11-16 09:00:00 - step 19 of 48 - 1000 active elements (0 deactivated)
20:12:41 INFO    opendrift.models.basemodel:2035: 2015-11-16 09:30:00 - step 20 of 48 - 1000 active elements (0 deactivated)
20:12:41 INFO    opendrift.models.basemodel:2035: 2015-11-16 10:00:00 - step 21 of 48 - 1000 active elements (0 deactivated)
20:12:41 INFO    opendrift.models.basemodel:2035: 2015-11-16 10:30:00 - step 22 of 48 - 1000 active elements (0 deactivated)
20:12:41 INFO    opendrift.models.basemodel:2035: 2015-11-16 11:00:00 - step 23 of 48 - 1000 active elements (0 deactivated)
20:12:41 INFO    opendrift.models.basemodel:2035: 2015-11-16 11:30:00 - step 24 of 48 - 1000 active elements (0 deactivated)
20:12:41 INFO    opendrift.models.basemodel:2035: 2015-11-16 12:00:00 - step 25 of 48 - 1000 active elements (0 deactivated)
20:12:41 INFO    opendrift.models.basemodel:2035: 2015-11-16 12:30:00 - step 26 of 48 - 1000 active elements (0 deactivated)
20:12:41 INFO    opendrift.models.basemodel:2035: 2015-11-16 13:00:00 - step 27 of 48 - 1000 active elements (0 deactivated)
20:12:42 INFO    opendrift.models.basemodel:2035: 2015-11-16 13:30:00 - step 28 of 48 - 1000 active elements (0 deactivated)
20:12:42 INFO    opendrift.models.basemodel:2035: 2015-11-16 14:00:00 - step 29 of 48 - 1000 active elements (0 deactivated)
20:12:42 INFO    opendrift.models.basemodel:2035: 2015-11-16 14:30:00 - step 30 of 48 - 1000 active elements (0 deactivated)
20:12:42 INFO    opendrift.models.basemodel:2035: 2015-11-16 15:00:00 - step 31 of 48 - 1000 active elements (0 deactivated)
20:12:44 INFO    opendrift.models.basemodel:2035: 2015-11-16 15:30:00 - step 32 of 48 - 1000 active elements (0 deactivated)
20:12:45 INFO    opendrift.models.basemodel:2035: 2015-11-16 16:00:00 - step 33 of 48 - 998 active elements (2 deactivated)
20:12:45 INFO    opendrift.models.basemodel:2035: 2015-11-16 16:30:00 - step 34 of 48 - 995 active elements (5 deactivated)
20:12:46 INFO    opendrift.models.basemodel:2035: 2015-11-16 17:00:00 - step 35 of 48 - 995 active elements (5 deactivated)
20:12:46 INFO    opendrift.models.basemodel:2035: 2015-11-16 17:30:00 - step 36 of 48 - 993 active elements (7 deactivated)
20:12:46 INFO    opendrift.models.basemodel:2035: 2015-11-16 18:00:00 - step 37 of 48 - 992 active elements (8 deactivated)
20:12:46 INFO    opendrift.models.basemodel:2035: 2015-11-16 18:30:00 - step 38 of 48 - 991 active elements (9 deactivated)
20:12:46 INFO    opendrift.models.basemodel:2035: 2015-11-16 19:00:00 - step 39 of 48 - 989 active elements (11 deactivated)
20:12:46 INFO    opendrift.models.basemodel:2035: 2015-11-16 19:30:00 - step 40 of 48 - 969 active elements (31 deactivated)
20:12:46 INFO    opendrift.models.basemodel:2035: 2015-11-16 20:00:00 - step 41 of 48 - 936 active elements (64 deactivated)
20:12:46 INFO    opendrift.models.basemodel:2035: 2015-11-16 20:30:00 - step 42 of 48 - 900 active elements (100 deactivated)
20:12:47 INFO    opendrift.models.basemodel:2035: 2015-11-16 21:00:00 - step 43 of 48 - 861 active elements (139 deactivated)
20:12:47 INFO    opendrift.models.basemodel:2035: 2015-11-16 21:30:00 - step 44 of 48 - 829 active elements (171 deactivated)
20:12:47 INFO    opendrift.models.basemodel:2035: 2015-11-16 22:00:00 - step 45 of 48 - 789 active elements (211 deactivated)
20:12:47 INFO    opendrift.models.basemodel:2035: 2015-11-16 22:30:00 - step 46 of 48 - 749 active elements (251 deactivated)
20:12:47 INFO    opendrift.models.basemodel:2035: 2015-11-16 23:00:00 - step 47 of 48 - 673 active elements (327 deactivated)
20:12:47 INFO    opendrift.models.basemodel:2035: 2015-11-16 23:30:00 - step 48 of 48 - 605 active elements (395 deactivated)
20:13:09 INFO    opendrift.models.basemodel:4613: Saving animation to /root/project/docs/source/gallery/animations/example_oil_budget_0.gif...
20:15:36 INFO    opendrift.models.basemodel:3037: Time to make animation: 0:02:47.915341
../_images/example_oil_budget_0.gif

Total running time of the script: (3 minutes 6.866 seconds)

Gallery generated by Sphinx-Gallery