Seeding from GeoJSON string

from datetime import datetime, timedelta
from opendrift.models.leeway import Leeway
from opendrift.models.openoil import OpenOil

Polygon

o = OpenOil(loglevel=50)
o.seed_from_geojson("""{
      "type": "Feature",
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [4.0, 60.0], [4.5, 60.0], [4.7, 60.1],
            [4.2, 60.1], [4.0, 60.0]
          ]
        ]
      },
      "properties": {
        "time": "2020-11-06T12:30:00Z",
        "number": 1000,
        "oil_type": "DVALIN 2020",
        "m3_per_hour": 50
      }
    }""")
o.plot(fast=True)
OpenDrift - OpenOil (DVALIN 2020) 1000 elements seeded at 2020-11-06 12:30 UTC

Out:

querying DB:
Oil.name ==  'DVALIN 2020'

(<GeoAxesSubplot:title={'center':'OpenDrift - OpenOil (DVALIN 2020)\n1000 elements seeded at 2020-11-06 12:30 UTC'}>, <module 'matplotlib.pyplot' from '/opt/conda/envs/opendrift/lib/python3.9/site-packages/matplotlib/pyplot.py'>)

Point release at seafloor

o = OpenOil(loglevel=50)
o.set_config('environment:constant:sea_floor_depth_below_sea_level', 200)
o.seed_from_geojson("""{
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [ 4.0, 60.0 ]
      },
      "properties": {
        "time": ["2020-11-06T12:30:00Z", "2020-11-06T18:30:00Z"],
        "number": 3000,
        "z": "seafloor"
      }
    }""")

for var in ['x_wind', 'y_wind', 'x_sea_water_velocity', 'y_sea_water_velocity']:
    o.set_config('environment:constant:' + var, 0)
o.run(duration=timedelta(hours=6), time_step=300)
o.animation_profile()

Out:

querying DB:
Oil.name ==  'AASGARD A 2003'
MovieWriter imagemagick unavailable; using Pillow instead.
../_images/example_seed_geojson_0.gif

Cone

from (position1, radius1, time1) to (position2, radius2, time2)

o = Leeway(loglevel=50)
o.seed_from_geojson("""{
      "type": "Feature",
      "geometry": {
        "type": "LineString",
        "coordinates": [
            [4.0, 60.0], [4.5, 60.1]
        ]
      },
      "properties": {
        "time": ["2020-11-06T12:30:00Z", "2020-11-06T18:30:00Z"],
        "radius": [0, 2000],
        "number": 3000
      }
    }""")

for var in ['x_wind', 'y_wind', 'x_sea_water_velocity', 'y_sea_water_velocity']:
    o.set_config('environment:constant:' + var, 0)
o.run(duration=timedelta(hours=6))
o.animation(fast=True)

Out:

MovieWriter imagemagick unavailable; using Pillow instead.
../_images/example_seed_geojson_1.gif

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

Gallery generated by Sphinx-Gallery