.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/example_macondo.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_example_macondo.py: Macondo ================================== .. GENERATED FROM PYTHON SOURCE LINES 6-11 .. code-block:: Python from datetime import datetime, timedelta from opendrift.readers import reader_netCDF_CF_generic from opendrift.models.openoil import OpenOil .. GENERATED FROM PYTHON SOURCE LINES 12-13 This is a highly simplified 2D simulation, for illustration purpose only .. GENERATED FROM PYTHON SOURCE LINES 13-16 .. code-block:: Python o = OpenOil(loglevel=20) # Set loglevel to 0 for debug information .. rst-class:: sphx-glr-script-out .. code-block:: none 13:55:06 INFO opendrift:576: OpenDriftSimulation initialised (version 1.14.7 / v1.14.7-15-g2988cd4) .. GENERATED FROM PYTHON SOURCE LINES 17-18 For this datasource which does not contain standard_name, we impose a variable mapping .. GENERATED FROM PYTHON SOURCE LINES 18-53 .. code-block:: Python reader_globcurrent = None try: reader_globcurrent = reader_netCDF_CF_generic.Reader( 'https://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) o.animation(fast=True, frames = range(0, 120, 4), fps = 1) .. rst-class:: sphx-glr-script-out .. code-block:: none 13:55:06 INFO opendrift.readers:63: Opening file with xr.open_dataset Thredds server not available, cannot run example .. GENERATED FROM PYTHON SOURCE LINES 54-55 .. image:: /gallery/animations/example_macondo_0.gif .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 6.145 seconds) .. _sphx_glr_download_gallery_example_macondo.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_macondo.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_macondo.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: example_macondo.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_