{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Using wind measurements\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from datetime import datetime, timedelta, date\nfrom opendrift.readers import reader_netCDF_CF_generic\nfrom opendrift.models.openoil import OceanDrift\nfrom opendrift.readers import reader_timeseries\nfrom opendrift.readers.operators import ops\nimport opendrift.models.physics_methods as phy\nimport xarray as xr\nimport numpy as np\nimport pyproj\nimport matplotlib.pyplot as plt\nimport matplotlib as mpl\n\n# Preparation of figsize, dpi, fontsize and font style\n# Could also be done using mpl style sheet\n# https://matplotlib.org/stable/users/explain/customizing.html\nmpl.rcParams['figure.figsize'] = (5, 5)\nmpl.rcParams['savefig.dpi'] = 300\nmpl.rcParams['font.family'] = \"sans-serif\"\nmpl.rcParams['font.sans-serif'] = \"DejaVu Sans\"\nmpl.rcParams['font.size'] = 22\nmpl.rcParams['mathtext.fontset'] = \"dejavusans\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This example shows how to use wind or currents measurments \ncombined with an ocean model to improove the drift\ncalculation arround the measurment station.\n\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Fisrt, we import two times the same model, because one\nwill be used for the usual simulation, and one will\nbe used for the measurement combined simulation.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "reader_norkyst = reader_netCDF_CF_generic.Reader('https://thredds.met.no/thredds/dodsC/sea/norkyst800m/1h/aggregate_be')\nreader_norkyst2 = reader_netCDF_CF_generic.Reader('https://thredds.met.no/thredds/dodsC/sea/norkyst800m/1h/aggregate_be')\n\n#Verification\nprint(reader_norkyst)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We then import wind measurement data,\nthat will be stored in a timeserie reader.\nDon't forget to give the lon and lat of the \nmeasurement station.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "time_list = [datetime(2024, 5, 27, 6, 00, 00) + i*timedelta(minutes=10) for i in range(7)] # Manual import for this example\nwind_speed_array = np.array([1.9, 3.0, 3.5, 3.4, 3.9, 2.8, 2.5])\nwind_speed_angle = np.array([22, 25, 24, 19, 17, 30, 16])\n\n\n\n# Alternative if data are in a csv file\n\n# data_wind_bridge = np.genfromtxt(\"Simulation_data/data_wind_21_mai_2024.txt\", dtype = '