{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# FVCOM: Using model input from unstructured grid\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from datetime import timedelta\nimport urllib.request as urllib_request\nimport numpy as np\nfrom opendrift.readers import reader_netCDF_CF_unstructured\nfrom opendrift.readers import reader_global_landmask\nfrom opendrift.models.oceandrift import OceanDrift\n\no = OceanDrift(loglevel=20) # Set loglevel to 0 for debug information\n\ntry:\n proj = \"+proj=utm +zone=33 +north +ellps=WGS84 +datum=WGS84 +units=m +no_defs\"\n fvcom = reader_netCDF_CF_unstructured.Reader(filename = 'https://thredds.met.no/thredds/dodsC/metusers/knutfd/thredds/netcdf_unstructured_samples/AkvaplanNiva_sample_lonlat_fixed.nc', proj4 = proj)\n o.add_reader(fvcom)\n print(fvcom)\nexcept:\n print('Thredds server not available, cannot run example')\n fvcom = None\n\nif fvcom is not None:\n # Seed elements at defined positions, depth and time\n N = 1000\n z = -10*np.random.uniform(0, 1, N)\n o.seed_elements(lon=18.0, lat=69.8, radius=2000, number=N,\n z=z, time=fvcom.start_time)\n\n #%%\n # Running model\n o.run(time_step=1800, duration=timedelta(hours=12))\n\n #%%\n # Print and plot results\n print(o)\n\n #%%\n # Animation (current as background not yet working).\n o.animation(color='z')\n\n o.plot(fast=True, buffer = 1.)" ] }, { "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.14.3" } }, "nbformat": 4, "nbformat_minor": 0 }