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 2024-04-12 13:21 to 2024-04-14 01:21 UTC (73 steps)
===========================
--------------------
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.0  total
 0:00:00.0  preparing
 0:00:00.0  reading
 0:00:00.0  masking
--------------------
Performance:
    7.3 total time
    5.7 configuration
    0.0 preparing main loop
      0.0 moving elements to ocean
    1.5 main loop
      0.0 updating elements
    0.0 cleaning up
--------------------
===========================
Model:  OceanDrift     (OpenDrift version 1.11.2)
        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_mixed_layer_thickness
  ocean_vertical_diffusivity
  sea_floor_depth_below_sea_level
  sea_surface_height
  sea_surface_swell_wave_peak_period_from_variance_spectral_density
  sea_surface_swell_wave_significant_height
  sea_surface_swell_wave_to_direction
  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
  sea_surface_wind_wave_mean_period
  sea_surface_wind_wave_significant_height
  sea_surface_wind_wave_to_direction
  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

Discarded readers:

Time:
        Start: 2024-04-12 13:21:12.560500 UTC
        Present: 2024-04-14 01:21:12.560500 UTC
        Calculation steps: 144 * 0:15:00 - total time: 1 day, 12:00:00
        Output steps: 73 * 0:30:00
===========================

/opt/conda/envs/opendrift/lib/python3.11/site-packages/cartopy/mpl/geoaxes.py:1696: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
  result = super().scatter(*args, **kwargs)

(<GeoAxes: title={'center': 'OpenDrift - OceanDrift\n2024-04-12 13:21 to 2024-04-14 01:21 UTC (73 steps)'}>, <Figure size 1100x861.384 with 1 Axes>)
../_images/example_coastline_options_0.gif

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

Gallery generated by Sphinx-Gallery