How do you plot a wave rose/polarhistogram?
40 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
So I am relatively new to matlab and am still trying to figure out how it works. What I am trying to do currently is see if I can use (ocean) wave data to plot a windrose/waverose diagram showing annual wave direction (Direction (deg)) and wave power (P (kW/m2)). I am using a FOR LOOP to produce figures and graphs for 5 years, with each year being a separate data file. I have tried to look into using the functions rose and polarhistogram but I am struggling to understand how to input the data in the commands when looking at doc polarhistogram for example. I have attached one of the data files to this question and have input my current code below.
close all
clear all
clc
%Load in the data
fpath=uigetdir;
files=dir([fpath '\*.csv']);
files=char(files.name);
%for loop to go through the variable files, creating variables for wave
%height (Hmax [H])), wave power (P kW/m2), max period (Tmax [T]), and geographical direction in
%degrees (Directiondeg [direction]). Using textscan function to read the
%data files.
for n=1:size(files,1)
fid=fopen([fpath '\' files(n,:)]);
data{n}=textscan(fid, ['%s' repmat('%f', 1,34)],'Delimiter',',','CollectOutput',1, 'Headerlines',1);
fclose(fid);
%readtable to set datetime array for first column in the data.
T1=readtable([fpath '\' files(n,:)], 'VariableNamingRule','preserve');
VN=T1.Properties.VariableNames;
DT=T1.('Date/Time (GMT)');
T1.('Date/Time (GMT)').TimeZone='UTC';
T1.('Date/Time (GMT)').TimeZone;
%Identify and generate wave parameter variables suitable to portray the wave climate of the
%chosen sites. This identifies wave height (H), wave period (T), wave
%direction (direction), wave power (power), and time (time).
H=T1.("Hmax (m)");
T=T1.("Tmax (s)");
direction=T1.("Direction (deg)");
time=T1.("Date/Time (GMT)");
power=T1.("P (kW/m2");
%Identify and replace anomalous data with NaN.
bad=9999;
ind=find(H==bad);
H(ind)=NaN;
T(ind)=NaN;
direction(ind)=NaN;
%Plot the figures. This plots wave height against time.
figure(n);
plot(time,H,'b','LineWidth',1)
xlabel('Time','FontSize',12)
ylabel('Wave Height (m)','FontSize',12)
title(['n=' num2str(n) ' ' files(n,:)],'FontSize',12)
%Plot wave rose diagram with wave power (power) and wave direction
%(direction).
end
1 commentaire
Réponses (2)
William Rose
le 29 Nov 2022
Here is a script that plots a regular histogram of wind direction and the same data in polar form. Data is from NOAA Buoy SJSN4, quality controlled, Sept 2022. This buoy does not have wave data but it does have wind speed and direction , so that is what I used. There were 7066 valid data points in the month, out of 7200 possible (every 6 minutes).
The script makes a histogram of the good data (i.e. data for which WDIR is not 999). The top and bottom panels of the figure below are the same data, in two formats. Wind speed is not taken into account in this plot - only direction matters.
Good luck wiht your work.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1211908/image.png)
4 commentaires
Javier Leon
le 29 Mar 2023
Modifié(e) : Javier Leon
le 29 Mar 2023
Is there a way to take into account the wave power as well?
William Rose
le 30 Mar 2023
I was using available wind data to illustrate the concept. If you have wave power-by-direction data, then you can use the ideas illustrated by my script to make polar plots of wave power as a function of direction.
You, as the investigator, must decide is how you want to present and analyze the power-by-direction data. One option is to plot mean power (where the mean is taken over a sutable time period, which you determine) from each direction, as a polar plot. Another option is to plot peak power (measured over some suitable time period) as a funciton of direction. This could be important if you are trying to design to wave resitance and you want to know where the biggest threat is coming from.
Voir également
Catégories
En savoir plus sur Polar Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!