Macondo

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

This is a highly simplified 2D simulation, for illustration purpose only

o = OpenOil(loglevel=20)  # Set loglevel to 0 for debug information

Out:

13:44:54 INFO    opendrift.models.basemodel: OpenDriftSimulation initialised (version 1.7.1 / v1.7.1-87-g074c1d2)

For this datasource which does not contain standard_name, we impose a variable mapping

reader_globcurrent = None

try:
    reader_globcurrent = reader_netCDF_CF_generic.Reader(
        'http://tds0.ifremer.fr/thredds/dodsC/GLOBCURRENT-L4-CUREUL_HS-ALT_SUM-V03.0',
        standard_name_mapping={'eastward_eulerian_current_velocity': 'x_sea_water_velocity',
                               'northward_eulerian_current_velocity': 'y_sea_water_velocity'})
except:
    print('Thredds server not available, cannot run example')

if reader_globcurrent is not None:
    reader_oceanwind = reader_netCDF_CF_generic.Reader('https://tds0.ifremer.fr/thredds/dodsC/CERSAT-GLO-CLIM_WIND_L4-OBS_FULL_TIME_SERIE')

    # Add readers
    o.add_reader([reader_globcurrent, reader_oceanwind])

    # Seed some particles
    lon = -88.387161; lat = 28.736669  # Macondo location
    starttime = datetime(2010, 4, 21, 6, 0, 0)  # 4 hours after explosion
    time = [starttime, starttime + timedelta(hours=24*30)]
    o.seed_elements(lon, lat, radius=0, number=15000, time=time, oil_type='LIGHT LOUISIANNA SWEET, BP')

    # Run model
    print(o)
    o.run(duration=timedelta(days=30),
        time_step=timedelta(hours=3),
        time_step_output=timedelta(hours=6))

    # Print and plot results
    print(o)
    o.plot(fast=True)
    o.plot_oil_budget()
    o.animation(fast=True)

Out:

13:44:54 INFO    opendrift.readers.reader_netCDF_CF_generic: Opening dataset: http://tds0.ifremer.fr/thredds/dodsC/GLOBCURRENT-L4-CUREUL_HS-ALT_SUM-V03.0
Thredds server not available, cannot run example
gallery/animations/example_macondo_0.gif

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

Gallery generated by Sphinx-Gallery