Effacer les filtres
Effacer les filtres

Normalized Wind Rose Plot help

12 vues (au cours des 30 derniers jours)
Douglas Leaffer
Douglas Leaffer le 22 Juin 2023
Commenté : Star Strider le 22 Déc 2023
I am trying to generate a normalized (to the max) wind rose plot of air pollutant concentration (UFP) by wind direction. See photo below. A data vector is attached. The simple code: polarplot(N.WD_Deg,N.UFPConc) doesn't generate what I want. Any help is appreciated. Thank you
load winddata.mat
polarplot(N.WD_Deg,N.UFPConc)
  4 commentaires
Douglas Leaffer
Douglas Leaffer le 24 Juin 2023
Déplacé(e) : VBBV le 25 Juin 2023
Thank you VBBV and Star Strider. Both of your suggested codes worked for me - but I can't seem to rotate the compass points to have 0 at the top and then clockwise ticks, with 90 deg at right, 180 at bottom and 270 at left. Is there a simple programmatic fix for this?
E. Cheynet
E. Cheynet le 25 Juin 2023
For the direction with meteorological conventions, you can simply give a new direction newD = 90-oldD

Connectez-vous pour commenter.

Réponse acceptée

Star Strider
Star Strider le 23 Juin 2023
Perhaps something like this —
LD = load('winddata.mat');
N = LD.N;
N.WD_Rad = deg2rad(N.WD_Deg) % Add Radian Variable (For Convenience, Since 'polarplot' Requires It)
N = 133872×4 table
WD_Deg WS UFPConc WD_Rad ______ ______ _______ ______ 30 25.927 0.11886 0.5236 30 25.927 0.13314 0.5236 30 25.927 0.16629 0.5236 30 25.927 0.15657 0.5236 30 25.927 0.15257 0.5236 30 25.927 0.15486 0.5236 30 25.927 0.12457 0.5236 30 25.927 0.12457 0.5236 30 25.927 0.15829 0.5236 30 25.927 0.13657 0.5236 30 25.927 0.124 0.5236 30 25.927 0.108 0.5236 30 25.927 0.10343 0.5236 30 25.927 0.12914 0.5236 30 25.927 0.18229 0.5236 30 25.927 0.19371 0.5236
[UDir,ix,iv] = unique(N.WD_Rad); % Unique Radian Values & Indices (Sorted)
Concv = accumarray(iv, (1:numel(iv)).', [], @(x)numel(N.UFPConc(x))); % Accumulate Count Values Of 'UFPConc' By Direction (Use 'numel' To Count Occurrences)
[sDir, sConc] = stairs(UDir, Concv); % Return 'stairs' Stepwise Result
figure
polarplot(sDir, sConc) % Plot 'stairs' Stepwise Result
figure
polarplot(UDir, Concv) % Plot Continuous Result
figure
polarhistogram(N.WD_Rad, UDir) % Plot Using 'polarhistogram'
Make appropriate changes to get the result you want.
Using the accumarray function, it is possible to get other parameters of the concentration, such as the mean or median values, as well as standard deviations (std and metrics derived from it, such as confidence intervals) and plot them also using the patch function (although that is more complicated and requires calculating them in polar coordinates and then using the pol2cart function first, and plotting them in Cartesian coordinates), not only the counts.
.
  4 commentaires
Douglas Leaffer
Douglas Leaffer le 24 Juin 2023
Excellent. It worked fine. Thank you
Star Strider
Star Strider le 24 Juin 2023
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (1)

Douglas Leaffer
Douglas Leaffer le 22 Déc 2023
Hello, it seems the plots generated from these suggested answers are not what I need. I need a normalized [0 1] wind rose of UFP (air pollution particle) by wind degree sector, as show in these 3 examples. My dataset is attached. The code I ran is given below. I could use some more help if anyone is able. Thank you.
load CR_1hr_wind.mat
NC = normalize(CT1,"norm",Inf,"DataVariables","UFPConc");
NC.WD_Rad = deg2rad(NC.WD_Deg) % Add Radian Variable (For Convenience, Since 'polarplot' Requires It)
[UDir,ix,iv] = unique(NC.WD_Rad); % Unique Radian Values & Indices (Sorted)
Concv = accumarray(iv, (1:numel(iv)).', [], @(x)numel(NC.UFPConc(x))); % Accumulate Count Values Of 'UFPConc' By Direction (Use 'numel' To Count Occurrences)
%[sDir, sConc] = stairs(UDir, Concv); % Return 'stairs' Stepwise Result
%figure
%polarplot(sDir, sConc)
figure
%subplot (121)
polarplot(UDir, Concv, 'LineWidth', 4) % Plot Continuous Result
Ax = gca;
Ax.ThetaZeroLocation = 'top';
Ax.ThetaDir = 'clockwise';
  3 commentaires
Douglas Leaffer
Douglas Leaffer le 22 Déc 2023
That seems to be more of what I need. Thanks again
Star Strider
Star Strider le 22 Déc 2023
As always, my pleasure!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Polar Plots dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by