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