Coastline interaction

Example to illustrate stranding options using an artificial east-west oscillating current field Knut-Frode Dagestad, Feb 2017

from datetime import datetime
from opendrift.readers import reader_oscillating
from opendrift.models.oceandrift import OceanDrift

o = OceanDrift(loglevel=50)  # Set loglevel to 0 for debug information

reader_osc = reader_oscillating.Reader('x_sea_water_velocity', amplitude=1,
                                       zero_time=datetime.utcnow())
o.add_reader([reader_osc])  # Oscillating east-west current component

o.set_config('environment:fallback:y_sea_water_velocity', .2)  # Adding northwards drift

Try different options: ‘previous’, ‘stranding’, ‘none’

o.set_config('general:coastline_action', 'previous')

o.seed_elements(lon=12.2, lat=67.7, radius=5000, number=25, time=reader_osc.zero_time)

o.run(steps=36*4, time_step=900, time_step_output=1800)

Print and plot results

print(o)
o.animation()
o.plot()
OpenDrift - OceanDrift 2021-09-24 13:47 to 2021-09-26 01:47 UTC (73 steps)

Out:

===========================
--------------------
Reader performance:
--------------------
oscillating_reader
 0:00:00.0  total
 0:00:00.0  preparing
 0:00:00.0  reading
 0:00:00.0  masking
--------------------
global_landmask
 0:00:00.1  total
 0:00:00.0  preparing
 0:00:00.1  reading
 0:00:00.0  masking
--------------------
Performance:
    3.7 total time
    0.2 configuration
    2.4 preparing main loop
      2.4 making dynamical landmask
      0.0 moving elements to ocean
      0.6 readers
        0.1 global_landmask
        0.2 postprocessing
    0.9 main loop
        0.0 oscillating_reader
      0.0 updating elements
    0.0 cleaning up
--------------------
===========================
Model:  OceanDrift     (OpenDrift version 1.7.1)
        25 active Lagrangian3DArray particles  (0 deactivated, 0 scheduled)
-------------------
Environment variables:
  -----
  x_sea_water_velocity
     1) oscillating_reader
  -----
  land_binary_mask
     1) global_landmask
  -----
Readers not added for the following variables:
  ocean_vertical_diffusivity
  sea_floor_depth_below_sea_level
  sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment
  sea_surface_wave_period_at_variance_spectral_density_maximum
  sea_surface_wave_significant_height
  sea_surface_wave_stokes_drift_x_velocity
  sea_surface_wave_stokes_drift_y_velocity
  surface_downward_x_stress
  surface_downward_y_stress
  turbulent_generic_length_scale
  turbulent_kinetic_energy
  upward_sea_water_velocity
  x_wind
  y_sea_water_velocity
  y_wind

Time:
        Start: 2021-09-24 13:47:22.678791
        Present: 2021-09-26 01:47:22.678791
        Calculation steps: 144 * 0:15:00 - total time: 1 day, 12:00:00
        Output steps: 73 * 0:30:00
===========================

MovieWriter imagemagick unavailable; using Pillow instead.

(<GeoAxesSubplot:title={'center':'OpenDrift - OceanDrift\n2021-09-24 13:47 to 2021-09-26 01:47 UTC (73 steps)'}>, <module 'matplotlib.pyplot' from '/opt/conda/envs/opendrift/lib/python3.9/site-packages/matplotlib/pyplot.py'>)
../_images/example_coastline_options_0.gif

Total running time of the script: ( 0 minutes 18.995 seconds)

Gallery generated by Sphinx-Gallery