Normalized Wind Rose Plot help

5 次查看(过去 30 天)
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 个评论
Douglas Leaffer
Douglas Leaffer 2023-6-24
移动:VBBV 2023-6-25
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 2023-6-25
For the direction with meteorological conventions, you can simply give a new direction newD = 90-oldD

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2023-6-23
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 个评论
Douglas Leaffer
Douglas Leaffer 2023-6-24
Excellent. It worked fine. Thank you

请先登录,再进行评论。

更多回答(1 个)

Douglas Leaffer
Douglas Leaffer 2023-12-22
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 个评论
Douglas Leaffer
Douglas Leaffer 2023-12-22
That seems to be more of what I need. Thanks again

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Geographic Plots 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by