.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/example_seed_geojson.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_seed_geojson.py: Seeding from GeoJSON string =========================== .. GENERATED FROM PYTHON SOURCE LINES 6-11 .. code-block:: Python from datetime import datetime, timedelta from opendrift.models.leeway import Leeway from opendrift.models.openoil import OpenOil .. GENERATED FROM PYTHON SOURCE LINES 12-14 Polygon -------- .. GENERATED FROM PYTHON SOURCE LINES 14-39 .. code-block:: Python o = OpenOil(loglevel=50) for var in ['x_wind', 'y_wind', 'x_sea_water_velocity', 'y_sea_water_velocity']: o.set_config('environment:constant:' + var, 0) 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) .. image-sg:: /gallery/images/sphx_glr_example_seed_geojson_001.png :alt: OpenDrift - OpenOil (DVALIN 2020) 1000 elements seeded at 2020-11-06 12:30 UTC :srcset: /gallery/images/sphx_glr_example_seed_geojson_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none (,
) .. GENERATED FROM PYTHON SOURCE LINES 40-42 Point release at seafloor -------------------------- .. GENERATED FROM PYTHON SOURCE LINES 42-63 .. code-block:: Python o = OpenOil(loglevel=50) o.set_config('environment:constant:sea_floor_depth_below_sea_level', 200) for var in ['x_wind', 'y_wind', 'x_sea_water_velocity', 'y_sea_water_velocity']: o.set_config('environment:constant:' + var, 0) 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" } }""") o.run(duration=timedelta(hours=6), time_step=300) o.animation_profile() .. rst-class:: sphx-glr-script-out .. code-block:: none /root/project/opendrift/models/basemodel/__init__.py:3122: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored points = ax.scatter([], [], .. GENERATED FROM PYTHON SOURCE LINES 64-65 .. image:: /gallery/animations/example_seed_geojson_0.gif .. GENERATED FROM PYTHON SOURCE LINES 68-71 Cone ----- from (position1, radius1, time1) to (position2, radius2, time2) .. GENERATED FROM PYTHON SOURCE LINES 71-93 .. code-block:: Python o = Leeway(loglevel=50) for var in ['x_wind', 'y_wind', 'x_sea_water_velocity', 'y_sea_water_velocity']: o.set_config('environment:constant:' + var, 0) 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 } }""") o.run(duration=timedelta(hours=6)) o.animation(fast=True) .. rst-class:: sphx-glr-script-out .. code-block:: none /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) .. GENERATED FROM PYTHON SOURCE LINES 94-95 .. image:: /gallery/animations/example_seed_geojson_1.gif .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 25.053 seconds) .. _sphx_glr_download_gallery_example_seed_geojson.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_seed_geojson.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_seed_geojson.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_