{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# SHYFEM: Using model input from unstructured grid\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from datetime import timedelta\nimport numpy as np\nfrom opendrift.readers.unstructured import shyfem\nfrom opendrift.models.oceandrift import OceanDrift\n\no = OceanDrift(loglevel=20) # Set loglevel to 0 for debug information\n\no.set_config('general:coastline_action', 'previous')\n\nshyfem = shyfem.Reader('https://iws.ismar.cnr.it/thredds/dodsC/emerge/shyfem_unstructured_adriatic.nc')\no.add_reader(shyfem)\nprint(shyfem)\n\n# Seed elements at defined positions, depth and time\nN = 1000\nz = -15*np.random.uniform(0, 1, N)\no.seed_elements(lon=12.4, lat=45.25, radius=1000, number=N,\n z=z, time=shyfem.start_time)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Running model\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"o.run(time_step=1800, duration=timedelta(hours=12))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Print and plot results\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"print(o)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Animations\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"o.animation(color='z', markersize=5, corners=[12.2, 12.6, 45.1, 45.5])\n\no.animation_profile(color='z', markersize=5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"o.plot(fast=True, buffer = 1., corners=[12.2, 12.6, 45.1, 45.5])"
]
}
],
"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
}