Skip to content
Snippets Groups Projects
Verified Commit dde75955 authored by Thomas Lambert's avatar Thomas Lambert :helicopter:
Browse files

fix(plots): better range, better annotations

parent 51939229
No related branches found
No related tags found
No related merge requests found
...@@ -21,33 +21,39 @@ function plotcf(ResData) ...@@ -21,33 +21,39 @@ function plotcf(ResData)
OFFSET_STEPS = 20; OFFSET_STEPS = 20;
CHORD = 0.05; CHORD = 0.05;
INTERESTING_PLOTS = [ INTERESTING_PLOTS = [
0.03, 2, 7.7
0.03, 2, 7.7
0.03, 3, 2.5
0.03, 3, 4.6 0.03, 3, 4.6
0.03, 3.5, 2.5
0.03, 3.5, 4.6 0.03, 3.5, 4.6
0.03, 3.5, 7.7 0.03, 3, 7.7
0.10, 3, 7.7
% 0.05, 1.25, 4.6 % DRIFT ON INERTIA
0.05, 2, 7.7 % 0.03, 2, 7.7
0.05, 3, 7.7 % 0.03, 2, 7.7
0.05, 3.5, 2.5 % 0.03, 3, 2.5
0.05, 3.5, 7.7 % 0.03, 3.5, 2.5
% 0.03, 3.5, 7.7
0.10, 2.5, 4.6 %
0.10, 2.5, 7.7 % % 0.05, 1.25, 4.6 % DRIFT ON INERTIA
0.10, 3.5, 2.5 % 0.05, 2, 7.7
0.10, 3.5, 4.6 % 0.05, 3, 7.7
0.10, 3.5, 7.7 % 0.05, 3.5, 2.5
% 0.05, 3.5, 7.7
%
% 0.10, 2.5, 4.6
% 0.10, 2.5, 7.7
% 0.10, 3.5, 2.5
% 0.10, 3.5, 4.6
% 0.10, 3.5, 7.7
]; ];
SAVE_TIKZ_PARAM = [0, 0, 0]; % Points to save ([0,0,0] to make sur nothing is save) SAVE_TIKZ_PARAM = []; % Points to save ([0,0,0] to make sur nothing is save)
for i = 1:size(ResData, 1) for j = 1:size(ResData, 2)
for j = 1:size(ResData, 2) for i = 1:size(ResData, 1)
if isinteresting(ResData(i, j), INTERESTING_PLOTS) if isinteresting(ResData(i, j), INTERESTING_PLOTS) && ...
~(ResData(i, j).Testcase.dx == 0.05 && ResData(i, j).Testcase.freq <= 2) && ...
~(ResData(i, j).Testcase.dx == 0.03 && ResData(i, j).Testcase.freq == 1.25)
trueF = ResData(i, j).Front.trueFreq; trueF = ResData(i, j).Front.trueFreq;
...@@ -55,12 +61,13 @@ function plotcf(ResData) ...@@ -55,12 +61,13 @@ function plotcf(ResData)
expParam = sprintf('d = %0.2f, f = %0.2f, V = %0.1f (k = %0.02f)', ... expParam = sprintf('d = %0.2f, f = %0.2f, V = %0.1f (k = %0.02f)', ...
ResData(i, j).Testcase.dx, ... ResData(i, j).Testcase.dx, ...
ResData(i, j).Testcase.freq, ... ResData(i, j).Front.trueFreq, ...
ResData(i, j).Testcase.airspeed, ... ResData(i, j).Testcase.airspeed, ...
redFreq); redFreq);
offsets = ResData(i, j).AllPhases.offsets; offsets = ResData(i, j).AllPhases.offsets;
cleanOffsets = -175:OFFSET_STEPS:175; offsets = wrapTo360(offsets); % Wrap offsets in [0,360];
cleanOffsets = OFFSET_STEPS / 2:OFFSET_STEPS:360 - OFFSET_STEPS / 2;
meanOffset = nan(size(cleanOffsets)); meanOffset = nan(size(cleanOffsets));
stdOffset = nan(size(cleanOffsets)); stdOffset = nan(size(cleanOffsets));
for iOff = 1:length(cleanOffsets) for iOff = 1:length(cleanOffsets)
...@@ -91,15 +98,16 @@ function plotcf(ResData) ...@@ -91,15 +98,16 @@ function plotcf(ResData)
plot(ResData(i, j).AllPhases.offsets, ... plot(ResData(i, j).AllPhases.offsets, ...
ResData(i, j).AllPhases.Front.cF(:, [1, 3]), 'o'); ResData(i, j).AllPhases.Front.cF(:, [1, 3]), 'o');
end end
errorbar(cleanOffsets, meanF(:, 3), yposF(:, 3), 'o', 'Capsize', ERR_CAPSIZE); e1 = errorbar(cleanOffsets, meanF(:, 3), yposF(:, 3), 's', 'Capsize', ERR_CAPSIZE);
errorbar(cleanOffsets, meanF(:, 1), yposF(:, 1), 'o', 'Capsize', ERR_CAPSIZE); e2 = errorbar(cleanOffsets, meanF(:, 1), yposF(:, 1), 'o', 'Capsize', ERR_CAPSIZE);
e1.MarkerFaceColor = e1.Color;
e2.MarkerFaceColor = e2.Color;
hold off; hold off;
setgca('XTickLabel', [], ... setgca('XTickLabel', [], ...
'XLabel', []); 'XLabel', []);
legend({'\cl', '\cd'}, 'Location', 'SouthWest'); legend({'\cl', '\cd'}, 'Location', 'SouthWest');
legend('boxoff'); legend('boxoff');
ax1.Position(3) = 1.25 * ax1.Position(3); % ax1.Position(3) = 1.25 * ax1.Position(3);
title('Front');
ax2 = subplot(212); ax2 = subplot(212);
setcolormap(); setcolormap();
...@@ -108,17 +116,28 @@ function plotcf(ResData) ...@@ -108,17 +116,28 @@ function plotcf(ResData)
plot(ResData(i, j).AllPhases.offsets, ... plot(ResData(i, j).AllPhases.offsets, ...
ResData(i, j).AllPhases.Aft.cF(:, [1, 3]), 'o'); ResData(i, j).AllPhases.Aft.cF(:, [1, 3]), 'o');
end end
errorbar(cleanOffsets, meanA(:, 3), yposA(:, 3), 'o', 'Capsize', ERR_CAPSIZE); e3 = errorbar(cleanOffsets, meanA(:, 3), yposA(:, 3), 's', 'Capsize', ERR_CAPSIZE);
errorbar(cleanOffsets, meanA(:, 1), yposA(:, 1), 'o', 'Capsize', ERR_CAPSIZE); e4 = errorbar(cleanOffsets, meanA(:, 1), yposA(:, 1), 'o', 'Capsize', ERR_CAPSIZE);
e3.MarkerFaceColor = e3.Color;
e4.MarkerFaceColor = e4.Color;
hold off; hold off;
title(ax2, 'Aft');
setgca(); setgca();
linkaxes([ax1 ax2], 'xy'); linkaxes([ax1 ax2], 'xy');
ax2.Position(3) = ax1.Position(3); ax2.Position(3) = ax1.Position(3);
title('Aft');
% Add annotations
% Increase axes Y lim by 10% of the data range before writing text
FACTOR = 0.1;
yDiff = diff(ax1.YLim);
ax1.YLim = [ax1.YLim(1), ax1.YLim(2) + FACTOR * yDiff];
addtxt(ax1, '\bf Front', ax1.YLim(2));
addtxt(ax2, '\bf Aft', ax2.YLim(2));
if isinteresting(ResData(i, j), SAVE_TIKZ_PARAM) if isinteresting(ResData(i, j), SAVE_TIKZ_PARAM)
pause(1);
figdir = 'figures/results/'; figdir = 'figures/results/';
filename = sprintf('flapWindOn-Dx%0.2f_F%0.2f_V%0.1f.tex', ... filename = sprintf('flapWindOn-Dx%0.2f_F%0.2f_V%0.1f.tex', ...
ResData(i, j).Testcase.dx, ... ResData(i, j).Testcase.dx, ...
...@@ -142,37 +161,78 @@ function plotcf(ResData) ...@@ -142,37 +161,78 @@ function plotcf(ResData)
end end
% Plot aft wings only for different spacing conditions % Plot aft wings only for different spacing conditions
for j = 26 for j = 24
figure('Name', 'Dx'); figure('Name', 'Dx');
ax1 = subplot(211); ax1 = subplot(221);
setcolormap(); setcolormap();
hold on; hold on;
errorbar(Tmp(2, j).cleanOffsets, Tmp(2, j).meanA(:, 3), Tmp(2, j).stdA(:, 3), 'o', ... e11 = errorbar(Tmp(2, j).cleanOffsets, Tmp(2, j).meanF(:, 3), Tmp(2, j).stdF(:, 3), 'o', ...
'Capsize', ERR_CAPSIZE); 'Capsize', ERR_CAPSIZE);
errorbar(Tmp(2, j).cleanOffsets, Tmp(2, j).meanA(:, 1), Tmp(2, j).stdA(:, 1), 'o', ... e12 = errorbar(Tmp(2, j).cleanOffsets, Tmp(2, j).meanF(:, 1), Tmp(2, j).stdF(:, 1), 'o', ...
'Capsize', ERR_CAPSIZE); 'Capsize', ERR_CAPSIZE);
e11.MarkerFaceColor = e11.Color;
e12.MarkerFaceColor = e12.Color;
hold off; hold off;
setgca('XTickLabel', [], ... setgca('XTickLabel', [], ...
'XLabel', []); 'XLabel', []);
title('$\dx = 0.03 \unit{\m}$');
legend({'\cl', '\cd'}, 'Location', 'NorthEast'); legend({'\cl', '\cd'}, 'Location', 'SouthWest');
legend('boxoff'); legend('boxoff');
ax1.Position(3) = 1.25 * ax1.Position(3);
ax2 = subplot(212); ax2 = subplot(222);
setcolormap();
hold on;
e21 = errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanF(:, 3), Tmp(1, j).stdF(:, 3), 'o', ...
'Capsize', ERR_CAPSIZE);
e22 = errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanF(:, 1), Tmp(1, j).stdF(:, 1), 'o', ...
'Capsize', ERR_CAPSIZE);
e21.MarkerFaceColor = e21.Color;
e22.MarkerFaceColor = e22.Color;
hold off;
setgca('XTickLabel', [], ...
'XLabel', [], ...
'YTickLabel', [], ...
'YLabel', []);
ax3 = subplot(223);
setcolormap(); setcolormap();
hold on; hold on;
errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 3), Tmp(1, j).stdA(:, 3), 'o', ... e31 = errorbar(Tmp(1, j).cleanOffsets, Tmp(2, j).meanA(:, 3), Tmp(2, j).stdA(:, 3), 'o', ...
'Capsize', ERR_CAPSIZE); 'Capsize', ERR_CAPSIZE);
errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 1), Tmp(1, j).stdA(:, 1), 'o', ... e32 = errorbar(Tmp(1, j).cleanOffsets, Tmp(2, j).meanA(:, 1), Tmp(2, j).stdA(:, 1), 'o', ...
'Capsize', ERR_CAPSIZE); 'Capsize', ERR_CAPSIZE);
e31.MarkerFaceColor = e31.Color;
e32.MarkerFaceColor = e32.Color;
hold off; hold off;
setgca(); setgca();
title('$\dx = 0.10 \unit{\m}$');
linkaxes([ax1 ax2], 'xy');
ax2.Position(3) = ax1.Position(3);
ax4 = subplot(224);
setcolormap();
hold on;
e41 = errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 3), Tmp(1, j).stdA(:, 3), 'o', ...
'Capsize', ERR_CAPSIZE);
e42 = errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 1), Tmp(1, j).stdA(:, 1), 'o', ...
'Capsize', ERR_CAPSIZE);
e41.MarkerFaceColor = e41.Color;
e42.MarkerFaceColor = e42.Color;
hold off;
setgca('YTickLabel', [], ...
'YLabel', []);
linkaxes([ax1 ax2 ax3 ax4], 'xy');
% Add annotations
% Increase axes Y lim by 10% of the data range before writing text
FACTOR = 0.1;
yDiff = diff(ax1.YLim);
ax1.YLim = [ax1.YLim(1), ax1.YLim(2) + FACTOR * yDiff];
addtxt(ax1, '$\mathbf{\dx}$ = 0.03 m (Front)', ax1.YLim(2));
addtxt(ax2, '$\mathbf{\dx}$ = 0.10 m (Aft)', ax2.YLim(2));
addtxt(ax3, '$\mathbf{\dx}$ = 0.03 m (Front)', ax3.YLim(2));
addtxt(ax4, '$\mathbf{\dx}$ = 0.10 m (Aft)', ax4.YLim(2));
pause(1);
figdir = 'figures/results/'; figdir = 'figures/results/';
filename = sprintf('flapWindOn-DxCompa-F%0.2f_V%0.1f.tex', ... filename = sprintf('flapWindOn-DxCompa-F%0.2f_V%0.1f.tex', ...
ResData(i, j).Testcase.freq, ... ResData(i, j).Testcase.freq, ...
...@@ -181,53 +241,95 @@ function plotcf(ResData) ...@@ -181,53 +241,95 @@ function plotcf(ResData)
end end
% Plot aft wings only for diff frequencies % % Plot aft wings only for different spacing conditions
j = 20; % for j = 26
figure('Name', 'K'); %
ax1 = subplot(211); % figure('Name', 'Dx');
setcolormap(); % ax1 = subplot(211);
hold on; % setcolormap();
errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 3), Tmp(1, j).stdA(:, 3), 'o', ... % hold on;
'Capsize', ERR_CAPSIZE); % errorbar(Tmp(2, j).cleanOffsets, Tmp(2, j).meanA(:, 3), Tmp(2, j).stdA(:, 3), 'o', ...
errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 1), Tmp(1, j).stdA(:, 1), 'o', ... % 'Capsize', ERR_CAPSIZE);
'Capsize', ERR_CAPSIZE); % errorbar(Tmp(2, j).cleanOffsets, Tmp(2, j).meanA(:, 1), Tmp(2, j).stdA(:, 1), 'o', ...
hold off; % 'Capsize', ERR_CAPSIZE);
setgca('XTickLabel', [], ... % hold off;
'XLabel', []); % setgca('XTickLabel', [], ...
title('$\redFreq = 0.05$'); % 'XLabel', []);
legend({'\cl', '\cd'}, 'Location', 'NorthEast'); % title('$\dx = 0.03 \unit{\m}$');
legend('boxoff'); % legend({'\cl', '\cd'}, 'Location', 'NorthEast');
ax1.Position(3) = 1.25 * ax1.Position(3); % legend('boxoff');
% ax1.Position(3) = 1.25 * ax1.Position(3);
j = 28; %
ax2 = subplot(212); % ax2 = subplot(212);
setcolormap(); % setcolormap();
hold on; % hold on;
errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 3), Tmp(1, j).stdA(:, 3), 'o', ... % errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 3), Tmp(1, j).stdA(:, 3), 'o', ...
'Capsize', ERR_CAPSIZE); % 'Capsize', ERR_CAPSIZE);
errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 1), Tmp(1, j).stdA(:, 1), 'o', ... % errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 1), Tmp(1, j).stdA(:, 1), 'o', ...
'Capsize', ERR_CAPSIZE); % 'Capsize', ERR_CAPSIZE);
hold off; % hold off;
setgca(); % setgca();
title('$\redFreq = 0.07$'); % title('$\dx = 0.10 \unit{\m}$');
linkaxes([ax1 ax2], 'x'); % linkaxes([ax1 ax2], 'xy');
ax2.Position(3) = ax1.Position(3); % ax2.Position(3) = ax1.Position(3);
%
figdir = 'figures/results/'; % figdir = 'figures/results/';
filename = sprintf('flapWindOn-kCompa-Dx%0.2f_V%0.1f.tex', ... % filename = sprintf('flapWindOn-DxCompa-F%0.2f_V%0.1f.tex', ...
ResData(i, j).Testcase.dx, ... % ResData(i, j).Testcase.freq, ...
ResData(i, j).Testcase.airspeed); % ResData(i, j).Testcase.airspeed);
save2tikz([figdir, filename], '\small'); % save2tikz([figdir, filename], '\small');
%
% end
%
% % Plot aft wings only for diff frequencies
% j = 20;
% figure('Name', 'K');
% ax1 = subplot(211);
% setcolormap();
% hold on;
% errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 3), Tmp(1, j).stdA(:, 3), 'o', ...
% 'Capsize', ERR_CAPSIZE);
% errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 1), Tmp(1, j).stdA(:, 1), 'o', ...
% 'Capsize', ERR_CAPSIZE);
% hold off;
% setgca('XTickLabel', [], ...
% 'XLabel', []);
% title('$\redFreq = 0.05$');
% legend({'\cl', '\cd'}, 'Location', 'NorthEast');
% legend('boxoff');
% ax1.Position(3) = 1.25 * ax1.Position(3);
%
% j = 28;
% ax2 = subplot(212);
% setcolormap();
% hold on;
% errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 3), Tmp(1, j).stdA(:, 3), 'o', ...
% 'Capsize', ERR_CAPSIZE);
% errorbar(Tmp(1, j).cleanOffsets, Tmp(1, j).meanA(:, 1), Tmp(1, j).stdA(:, 1), 'o', ...
% 'Capsize', ERR_CAPSIZE);
% hold off;
% setgca();
% title('$\redFreq = 0.07$');
% linkaxes([ax1 ax2], 'x');
% ax2.Position(3) = ax1.Position(3);
%
% figdir = 'figures/results/';
% filename = sprintf('flapWindOn-kCompa-Dx%0.2f_V%0.1f.tex', ...
% ResData(i, j).Testcase.dx, ...
% ResData(i, j).Testcase.airspeed);
% save2tikz([figdir, filename], '\small');
end end
function setgca(varargin) function setgca(varargin)
xlim([-180, 180]); % xlim([-180, 180]);
xlim([0, 360]);
xlabel('Phase offset [deg]'); xlabel('Phase offset [deg]');
ylabel('\cl and \cd [-]'); ylabel('\cl and \cd [-]');
xticks([-180:90:180]); % xticks([-180:90:180]);
xticks([0:90:360]);
set(gca, ... set(gca, ...
'Box', 'off', ... 'Box', 'off', ...
...@@ -251,3 +353,10 @@ function setgca(varargin) ...@@ -251,3 +353,10 @@ function setgca(varargin)
end end
end end
function addtxt(ax, txt, ypos)
text(ax, 10, ypos, ...
txt, ...
'HorizontalAlignment', 'left', 'VerticalAlignment', 'top', 'FontWeight', 'bold');
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment