{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Seeding from GeoJSON string\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from datetime import datetime, timedelta\nfrom opendrift.models.leeway import Leeway\nfrom opendrift.models.openoil import OpenOil"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Polygon\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"o = OpenOil(loglevel=50)\nfor var in ['x_wind', 'y_wind', 'x_sea_water_velocity', 'y_sea_water_velocity']:\n o.set_config('environment:constant:' + var, 0)\no.seed_from_geojson(\"\"\"{\n \"type\": \"Feature\",\n \"geometry\": {\n \"type\": \"Polygon\",\n \"coordinates\": [\n [\n [4.0, 60.0], [4.5, 60.0], [4.7, 60.1],\n [4.2, 60.1], [4.0, 60.0]\n ]\n ]\n },\n \"properties\": {\n \"time\": \"2020-11-06T12:30:00Z\",\n \"number\": 1000,\n \"oil_type\": \"DVALIN 2020\",\n \"m3_per_hour\": 50\n }\n }\"\"\")\no.plot(fast=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Point release at seafloor\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"o = OpenOil(loglevel=50)\no.set_config('environment:constant:sea_floor_depth_below_sea_level', 200)\nfor var in ['x_wind', 'y_wind', 'x_sea_water_velocity', 'y_sea_water_velocity']:\n o.set_config('environment:constant:' + var, 0)\no.seed_from_geojson(\"\"\"{\n \"type\": \"Feature\",\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [ 4.0, 60.0 ]\n },\n \"properties\": {\n \"time\": [\"2020-11-06T12:30:00Z\", \"2020-11-06T18:30:00Z\"],\n \"number\": 3000,\n \"z\": \"seafloor\"\n }\n }\"\"\")\n\no.run(duration=timedelta(hours=6), time_step=300)\no.animation_profile()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Cone \n from (position1, radius1, time1) to (position2, radius2, time2)\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"o = Leeway(loglevel=50)\nfor var in ['x_wind', 'y_wind', 'x_sea_water_velocity', 'y_sea_water_velocity']:\n o.set_config('environment:constant:' + var, 0)\no.seed_from_geojson(\"\"\"{\n \"type\": \"Feature\",\n \"geometry\": {\n \"type\": \"LineString\",\n \"coordinates\": [\n [4.0, 60.0], [4.5, 60.1]\n ]\n },\n \"properties\": {\n \"time\": [\"2020-11-06T12:30:00Z\", \"2020-11-06T18:30:00Z\"],\n \"radius\": [0, 2000],\n \"number\": 3000\n }\n }\"\"\")\n\no.run(duration=timedelta(hours=6))\no.animation(fast=True)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}