.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/example_current_from_drifter.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_current_from_drifter.py: Current from drifter ==================== .. GENERATED FROM PYTHON SOURCE LINES 6-15 .. code-block:: Python from datetime import datetime, timedelta from opendrift.readers import reader_current_from_drifter from opendrift.models.oceandrift import OceanDrift o = OceanDrift(loglevel=20) o.set_config('environment:fallback:land_binary_mask', 0) .. rst-class:: sphx-glr-script-out .. code-block:: none 17:12:49 INFO opendrift:513: OpenDriftSimulation initialised (version 1.14.2 / v1.14.2-88-gf09b7bd) .. GENERATED FROM PYTHON SOURCE LINES 16-20 We make a reader which reconstructs the ocean current from observed time series of a drifter This is actual data of SLDMB/Code drifter as used in this study: Jones, C.E., Dagestad, K.-F., Breivik, O., Holt, B., Rohrs, J., Christensen, K.H., Espeseth, M.M., Brekke, C., Skrunes, S. (2016): Measurement and modeling of oil slick transport. Journal of Geophysical Research - Oceans, Volume 121, Issue 10, October 2016, Pages 7759-7775. DOI: 10.1002/2016JC012113. .. GENERATED FROM PYTHON SOURCE LINES 20-32 .. code-block:: Python drifterlons = [2.407376, 2.405140, 2.403248, 2.401872, 2.400152, 2.398518, 2.397056, 2.395766, 2.394476, 2.393358, 2.392584, 2.391810, 2.390606, 2.389316, 2.388628, 2.388370, 2.387940, 2.387510, 2.387338, 2.387166, 2.387252, 2.387338, 2.387682, 2.387854, 2.388284, 2.388628, 2.389230, 2.390004, 2.390434, 2.390692, 2.391380, 2.391896, 2.392068, 2.392154, 2.392068, 2.391896, 2.391896, 2.391896, 2.391638, 2.391380, 2.391208, 2.391036, 2.390692, 2.390090, 2.389660, 2.389058, 2.388628] drifterlats = [60.034740, 60.033880, 60.033106, 60.032246, 60.031300, 60.030182, 60.028892, 60.027602, 60.026656, 60.025538, 60.024420, 60.023388, 60.022442, 60.021496, 60.020378, 60.019346, 60.018572, 60.017626, 60.016852, 60.016164, 60.015734, 60.015304, 60.014616, 60.014100, 60.013670, 60.013412, 60.013240, 60.013068, 60.013154, 60.013412, 60.013584, 60.013842, 60.014186, 60.014616, 60.015218, 60.015820, 60.016594, 60.017454, 60.018400, 60.019346, 60.020464, 60.021410, 60.022442, 60.023474, 60.024678, 60.025882, 60.026914] drifterlats = drifterlats[::-1] drifterlons = drifterlons[::-1] driftertimes = [datetime(2015, 6, 10, 5, 50) + timedelta(minutes=10)*i for i in range(len(drifterlons))] r = reader_current_from_drifter.Reader( lons=drifterlons, lats=drifterlats, times=driftertimes) o.add_reader(r) .. GENERATED FROM PYTHON SOURCE LINES 33-35 We seed elements within polygon, as could have been extracted from remote sensing imagery .. GENERATED FROM PYTHON SOURCE LINES 35-40 .. code-block:: Python lons = [2.39, 2.391, 2.392, 2.393, 2.394, 2.393, 2.392, 2.391, 2.39] lats = [60.02, 60.02, 60.019, 60.02, 60.021, 60.022, 60.021, 60.021, 60.02] o.seed_within_polygon(lons=lons, lats=lats, number=2000, time=r.start_time) .. rst-class:: sphx-glr-script-out .. code-block:: none 17:12:50 INFO opendrift.models.basemodel.environment:206: Adding a global landmask from GSHHG 17:12:54 INFO opendrift.models.basemodel.environment:229: Fallback values will be used for the following variables which have no readers: 17:12:54 INFO opendrift.models.basemodel.environment:232: sea_surface_height: 0.000000 17:12:54 INFO opendrift.models.basemodel.environment:232: x_wind: 0.000000 17:12:54 INFO opendrift.models.basemodel.environment:232: y_wind: 0.000000 17:12:54 INFO opendrift.models.basemodel.environment:232: upward_sea_water_velocity: 0.000000 17:12:54 INFO opendrift.models.basemodel.environment:232: ocean_vertical_diffusivity: 0.000000 17:12:54 INFO opendrift.models.basemodel.environment:232: sea_surface_wave_significant_height: 0.000000 17:12:54 INFO opendrift.models.basemodel.environment:232: sea_surface_wave_stokes_drift_x_velocity: 0.000000 17:12:54 INFO opendrift.models.basemodel.environment:232: sea_surface_wave_stokes_drift_y_velocity: 0.000000 17:12:54 INFO opendrift.models.basemodel.environment:232: ocean_mixed_layer_thickness: 50.000000 17:12:54 INFO opendrift.models.basemodel.environment:232: sea_floor_depth_below_sea_level: 10000.000000 .. GENERATED FROM PYTHON SOURCE LINES 41-42 Finally running simulation .. GENERATED FROM PYTHON SOURCE LINES 42-48 .. code-block:: Python o.run(end_time=r.end_time, time_step=r.time_step) drifter={'time': driftertimes, 'lon': drifterlons, 'lat': drifterlats, 'label': 'CODE Drifter', 'color': 'b', 'linewidth': 2, 'markersize': 40} o.animation(buffer=.01, fast=True, drifter=drifter) .. rst-class:: sphx-glr-script-out .. code-block:: none 17:12:54 INFO opendrift:1732: Skipping environment variable ocean_vertical_diffusivity because of condition ['drift:vertical_mixing', 'is', False] 17:12:54 INFO opendrift:1732: Skipping environment variable ocean_mixed_layer_thickness because of condition ['drift:vertical_mixing', 'is', False] 17:12:54 INFO opendrift:1743: Storing previous values of element property lon because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous'])) 17:12:54 INFO opendrift:1743: Storing previous values of element property lat because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous'])) 17:12:54 INFO opendrift:1751: Storing previous values of environment variable sea_surface_height because of condition ['drift:vertical_advection', 'is', True] 17:12:54 INFO opendrift:899: Using existing reader for land_binary_mask 17:12:54 INFO opendrift:928: All points are in ocean 17:12:54 INFO opendrift:2035: 2015-06-10 05:50:00 - step 1 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 06:00:00 - step 2 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 06:10:00 - step 3 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 06:20:00 - step 4 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 06:30:00 - step 5 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 06:40:00 - step 6 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 06:50:00 - step 7 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 07:00:00 - step 8 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 07:10:00 - step 9 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 07:20:00 - step 10 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 07:30:00 - step 11 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 07:40:00 - step 12 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 07:50:00 - step 13 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 08:00:00 - step 14 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 08:10:00 - step 15 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 08:20:00 - step 16 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 08:30:00 - step 17 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 08:40:00 - step 18 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 08:50:00 - step 19 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 09:00:00 - step 20 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 09:10:00 - step 21 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 09:20:00 - step 22 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 09:30:00 - step 23 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 09:40:00 - step 24 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 09:50:00 - step 25 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 10:00:00 - step 26 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 10:10:00 - step 27 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 10:20:00 - step 28 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 10:30:00 - step 29 of 45 - 2000 active elements (0 deactivated) 17:12:54 INFO opendrift:2035: 2015-06-10 10:40:00 - step 30 of 45 - 2000 active elements (0 deactivated) 17:12:55 INFO opendrift:2035: 2015-06-10 10:50:00 - step 31 of 45 - 2000 active elements (0 deactivated) 17:12:55 INFO opendrift:2035: 2015-06-10 11:00:00 - step 32 of 45 - 2000 active elements (0 deactivated) 17:12:55 INFO opendrift:2035: 2015-06-10 11:10:00 - step 33 of 45 - 2000 active elements (0 deactivated) 17:12:55 INFO opendrift:2035: 2015-06-10 11:20:00 - step 34 of 45 - 2000 active elements (0 deactivated) 17:12:55 INFO opendrift:2035: 2015-06-10 11:30:00 - step 35 of 45 - 2000 active elements (0 deactivated) 17:12:55 INFO opendrift:2035: 2015-06-10 11:40:00 - step 36 of 45 - 2000 active elements (0 deactivated) 17:12:55 INFO opendrift:2035: 2015-06-10 11:50:00 - step 37 of 45 - 2000 active elements (0 deactivated) 17:12:55 INFO opendrift:2035: 2015-06-10 12:00:00 - step 38 of 45 - 2000 active elements (0 deactivated) 17:12:55 INFO opendrift:2035: 2015-06-10 12:10:00 - step 39 of 45 - 2000 active elements (0 deactivated) 17:12:55 INFO opendrift:2035: 2015-06-10 12:20:00 - step 40 of 45 - 2000 active elements (0 deactivated) 17:12:55 INFO opendrift:2035: 2015-06-10 12:30:00 - step 41 of 45 - 2000 active elements (0 deactivated) 17:12:55 INFO opendrift:2035: 2015-06-10 12:40:00 - step 42 of 45 - 2000 active elements (0 deactivated) 17:12:55 INFO opendrift:2035: 2015-06-10 12:50:00 - step 43 of 45 - 2000 active elements (0 deactivated) 17:12:55 INFO opendrift:2035: 2015-06-10 13:00:00 - step 44 of 45 - 2000 active elements (0 deactivated) 17:12:55 INFO opendrift:2035: 2015-06-10 13:10:00 - step 45 of 45 - 2000 active elements (0 deactivated) 17:12:55 WARNING opendrift:2391: Plotting fast. This will make your plots less accurate. 17:12:56 INFO opendrift:4553: Saving animation to /root/project/docs/source/gallery/animations/example_current_from_drifter_0.gif... 17:13:21 INFO opendrift:2994: Time to make animation: 0:00:25.822650 .. GENERATED FROM PYTHON SOURCE LINES 49-50 .. image:: /gallery/animations/example_current_from_drifter_0.gif .. GENERATED FROM PYTHON SOURCE LINES 52-53 Drifter track is shown in red, and simulated trajectories are shown in gray. Oil spill is displaced relative to drifter, but drifter current is assumed to be spatially homogeneous. .. GENERATED FROM PYTHON SOURCE LINES 53-55 .. code-block:: Python o.plot(buffer=.01, fast=True, drifter=drifter) .. image-sg:: /gallery/images/sphx_glr_example_current_from_drifter_001.png :alt: OpenDrift - OceanDrift 2015-06-10 05:50 to 2015-06-10 13:20 UTC (46 steps) :srcset: /gallery/images/sphx_glr_example_current_from_drifter_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none 17:13:21 WARNING opendrift:2391: Plotting fast. This will make your plots less accurate. (,
) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 44.188 seconds) .. _sphx_glr_download_gallery_example_current_from_drifter.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_current_from_drifter.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_current_from_drifter.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: example_current_from_drifter.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_