{ "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\nproj = \"+proj=utm +zone=33 +north +ellps=WGS84 +datum=WGS84 +units=m +no_defs\"\nfvcom = 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)\no.add_reader(fvcom)\nprint(fvcom)\n\n# Seed elements at defined positions, depth and time\nN = 1000\nz = -10*np.random.uniform(0, 1, N)\no.seed_elements(lon=18.0, lat=69.8, radius=2000, number=N,\n z=z, time=fvcom.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": [ "Animation (current as background not yet working).\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.animation(color='z')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "o.plot(fast=True, buffer = 1.)" ] } ], "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 }