#!/usr/bin/env python # coding: utf-8 # Reading meteo data from Poseidon database. Yannis Karyotakis January 2023 # I am uing Anaconda and Jupyter notebook # In[6]: # The package netCDF4 reads meteo data and must be installed import pandas as pd import numpy as np import matplotlib.pyplot as plt from matplotlib import rcParams from matplotlib import colors from matplotlib.dates import DateFormatter import seaborn as sns import warnings import netCDF4 as nc import os.path from os import path # In[8]: fn = 'D:/temp/TS_TG_PaleaFokea_20220930-20221003_20230112102048.nc' file_exists = path.exists(fn) print (file_exists) ds = nc.Dataset(fn) wsp = ds.variables['WSPD'][:]*3600/1852 time = ds.variables['TIME'][:] time_units = ds.variables['TIME'].units from netCDF4 import num2date dates = num2date(time[:], units=time_units, only_use_cftime_datetimes=False) sns.set_context("paper") sns.set(font_scale = 2) fig = plt.figure(figsize=(15,15)) ax = plt.subplot() ax.plot(dates,wsp,lw=2.0, ms=9, color='tab:blue') ax.set_title('Wind speed') ax.set_ylabel('Wind speed [Kts]') fig.autofmt_xdate() fig.tight_layout() date_form = DateFormatter("%d-%b-%y %H:%M") ax.xaxis.set_major_formatter(date_form) plt.show() fig.savefig('D:/temp/FiguresFleet/Wind-DH', dpi=300)