Skip to content

Commit

Permalink
Merge pull request #526 from aodn/2.5.41
Browse files Browse the repository at this point in the history
2.5.41
  • Loading branch information
ggalibert authored Dec 14, 2018
2 parents a324086 + dbd5869 commit 959c4a0
Show file tree
Hide file tree
Showing 23 changed files with 214 additions and 122 deletions.
11 changes: 8 additions & 3 deletions Graph/TimeSeries/graphTimeSeriesTimeDepth.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,19 @@

h = pcolor(ax, double(xPcolor), double(yPcolor), double(var.data'));
set(h, 'FaceColor', 'flat', 'EdgeColor', 'none');
cb = colorbar('peer', ax);
% 'peer' input is not recommended starting in R2014b
if verLessThan('matlab', '8.4')
cb = colorbar('peer', ax);
else
cb = colorbar(ax);
end

% reset position to what it was without the colorbar so that it aligns with
% 1D datasets
set(ax, 'Position', posWithoutCb);

% Attach the context menu to colorbar
hMenu = setTimeSerieColorbarContextMenu(var);
hMenu = setTimeSeriesColorbarContextMenu(ax, var);
set(cb, 'uicontextmenu', hMenu);

% Let's redefine properties after pcolor to make sure grid lines appear
Expand All @@ -96,7 +101,7 @@
'Layer', 'top', ...
'Tag', 'axis2D');

if all(all(colormap == rkbwr))
if all(all(colormap(ax) == rkbwr))
set(cb, 'YLim', [0 360], 'YTick', [0 90 180 270 360]);
end

Expand Down
11 changes: 8 additions & 3 deletions Graph/TimeSeries/graphTimeSeriesTimeFrequency.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,20 @@

h = pcolor(ax, double(xPcolor), double(yPcolor), double(var.data'));
set(h, 'FaceColor', 'flat', 'EdgeColor', 'none');
cb = colorbar('peer', ax);
% 'peer' input is not recommended starting in R2014b
if verLessThan('matlab', '8.4')
cb = colorbar('peer', ax);
else
cb = colorbar(ax);
end

% reset position to what it was without the colorbar so that it aligns with
% 1D datasets
set(ax, 'Position', posWithoutCb);

% Attach the context menu to colorbar
hMenu = setTimeSerieColorbarContextMenu(var);
set(cb,'uicontextmenu',hMenu);
hMenu = setTimeSeriesColorbarContextMenu(ax, var);
set(cb, 'uicontextmenu', hMenu);

% Let's redefine properties after pcolor to make sure grid lines appear
% above color data and XTick and XTickLabel haven't changed
Expand Down
11 changes: 8 additions & 3 deletions Graph/TimeSeries/graphTimeSeriesTimeFrequencyDirection.m
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,16 @@
'Position' , posUi2(mainPanel, 50, 1, 50, 1, 0), ...
'String' ,'Time cursor');

cb = colorbar('peer',ax);
% 'peer' input is not recommended starting in R2014b
if verLessThan('matlab', '8.4')
cb = colorbar('peer', ax);
else
cb = colorbar(ax);
end

% Attach the context menu to colorbar
hMenu = setTimeSerieColorbarContextMenu(myVar);
set(cb,'uicontextmenu',hMenu);
hMenu = setTimeSeriesColorbarContextMenu(ax, myVar);
set(cb, 'uicontextmenu', hMenu);

cbLabel = imosParameters(myVar.name, 'uom');
cbLabel = [myVar.name ' (' cbLabel ')'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
function hMenu = setTimeSerieColorbarContextMenu(var)
%SETTIMESERIECOLORBARCONTEXTMENU returns a context menu for colorbar
% specific to variables.
function hMenu = setTimeSeriesColorbarContextMenu(ax, var)
%SETTIMESERIESCOLORBARCONTEXTMENU sets a colorbar uicontextmenu and returns its handle
% specific to an axes and a variable.
%
% This function is used for defining the colorbar context menus of each
% axis 2D displayed.
%
% Inputs:
% ax - The handle of the targeted axes.
% var - The variable structure from sample_data.variables{k} if
% it is the k_th variable.
%
Expand All @@ -32,8 +33,9 @@
% along with this program.
% If not, see <https://www.gnu.org/licenses/gpl-3.0.en.html>.
%
narginchk(1, 1);
narginchk(2, 2);

if ~ishandle(ax), error('ax must be a graphic object handle'); end
if ~isstruct(var), error('var must be a struct'); end

hMenu = [];
Expand All @@ -52,8 +54,8 @@

switch upper(var.name(1:4))
case {'UCUR', 'VCUR', 'WCUR', 'ECUR', 'VEL1', 'VEL2', 'VEL3', 'VEL4'} % 0 centred parameters
colormap(r_b);
cbCLimRange('', '', 'full, 0 centred', var.data); % full is chosen to attract attention on any potential outlier
colormap(ax, r_b);
cbCLimRange('', '', ax, 'full, 0 centred', var.data); % full is chosen to attract attention on any potential outlier

% Define a context menu
hMenu = uicontextmenu;
Expand All @@ -68,13 +70,13 @@
uimenu(mainItem1, 'Label', 'other', 'Callback', hcb13);

mainItem2 = uimenu(hMenu, 'Label', 'Color range');
uimenu(mainItem2, 'Label', 'full, 0 centred (default)', 'Callback', {@cbCLimRange, 'full, 0 centred', var.data});
uimenu(mainItem2, 'Label', 'auto, 0 centred [0 +/-2*stdDev]', 'Callback', {@cbCLimRange, 'auto, 0 centred', var.data});
uimenu(mainItem2, 'Label', 'manual', 'Callback', {@cbCLimRange, 'manual', var.data});
uimenu(mainItem2, 'Label', 'full, 0 centred (default)', 'Callback', {@cbCLimRange, ax, 'full, 0 centred', var.data});
uimenu(mainItem2, 'Label', 'auto, 0 centred [0 +/-2*stdDev]', 'Callback', {@cbCLimRange, ax, 'auto, 0 centred', var.data});
uimenu(mainItem2, 'Label', 'manual', 'Callback', {@cbCLimRange, ax, 'manual', var.data});

case {'CDIR', 'SSWD'} % directions
colormap(rkbwr);
cbCLimRange('', '', 'direction [0; 360]', var.data);
colormap(ax, rkbwr);
cbCLimRange('', '', ax, 'direction [0; 360]', var.data);

% Define a context menu
hMenu = uicontextmenu;
Expand All @@ -89,12 +91,12 @@
uimenu(mainItem1, 'Label', 'other', 'Callback', hcb13);

mainItem2 = uimenu(hMenu, 'Label', 'Color range');
uimenu(mainItem2, 'Label', 'direction [0; 360] (default)', 'Callback', {@cbCLimRange, 'direction [0; 360]', var.data});
uimenu(mainItem2, 'Label', 'manual', 'Callback', {@cbCLimRange, 'manual', var.data});
uimenu(mainItem2, 'Label', 'direction [0; 360] (default)', 'Callback', {@cbCLimRange, ax, 'direction [0; 360]', var.data});
uimenu(mainItem2, 'Label', 'manual', 'Callback', {@cbCLimRange, ax, 'manual', var.data});

case 'PERG' % percentages
colormap(parula);
cbCLimRange('', '', 'percent [0; 100]', var.data);
colormap(ax, parula);
cbCLimRange('', '', ax, 'percent [0; 100]', var.data);

% Define a context menu
hMenu = uicontextmenu;
Expand All @@ -111,12 +113,12 @@
uimenu(mainItem1, 'Label', 'other', 'Callback', hcb13);

mainItem2 = uimenu(hMenu, 'Label', 'Color range');
uimenu(mainItem2, 'Label', 'percent [0; 100] (default)', 'Callback', {@cbCLimRange, 'percent [0; 100]', var.data});
uimenu(mainItem2, 'Label', 'manual', 'Callback', {@cbCLimRange, 'manual', var.data});
uimenu(mainItem2, 'Label', 'percent [0; 100] (default)', 'Callback', {@cbCLimRange, ax, 'percent [0; 100]', var.data});
uimenu(mainItem2, 'Label', 'manual', 'Callback', {@cbCLimRange, ax, 'manual', var.data});

case {'CSPD', 'VDEN', 'VDEV', 'VDEP', 'VDES'} % [0; oo[ paremeters
colormap(parula);
cbCLimRange('', '', 'full', var.data); % full is chosen to attract attention on any potential outlier
colormap(ax, parula);
cbCLimRange('', '', ax, 'full', var.data); % full is chosen to attract attention on any potential outlier

% Define a context menu
hMenu = uicontextmenu;
Expand All @@ -133,17 +135,17 @@
uimenu(mainItem1, 'Label', 'other', 'Callback', hcb13);

mainItem2 = uimenu(hMenu, 'Label', 'Color range');
uimenu(mainItem2, 'Label', 'full', 'Callback', {@cbCLimRange, 'full', var.data});
uimenu(mainItem2, 'Label', 'full from 0 (default)', 'Callback', {@cbCLimRange, 'full from 0', var.data});
uimenu(mainItem2, 'Label', 'auto [mean +/-2*stdDev]', 'Callback', {@cbCLimRange, 'auto', var.data});
uimenu(mainItem2, 'Label', 'auto from 0 [0; mean +2*stdDev]', 'Callback', {@cbCLimRange, 'auto from 0', var.data});
uimenu(mainItem2, 'Label', 'manual', 'Callback', {@cbCLimRange, 'manual', var.data});
uimenu(mainItem2, 'Label', 'full', 'Callback', {@cbCLimRange, ax, 'full', var.data});
uimenu(mainItem2, 'Label', 'full from 0 (default)', 'Callback', {@cbCLimRange, ax, 'full from 0', var.data});
uimenu(mainItem2, 'Label', 'auto [mean +/-2*stdDev]', 'Callback', {@cbCLimRange, ax, 'auto', var.data});
uimenu(mainItem2, 'Label', 'auto from 0 [0; mean +2*stdDev]', 'Callback', {@cbCLimRange, ax, 'auto from 0', var.data});
uimenu(mainItem2, 'Label', 'manual', 'Callback', {@cbCLimRange, ax, 'manual', var.data});

case {'SSWV'} % [0; oo[ paremeter with special jet_w colormap
% let's apply a colormap like jet but starting from white
load('jet_w.mat', '-mat', 'jet_w');
colormap(jet_w);
cbCLimRange('', '', 'full', var.data); % full is chosen to attract attention on any potential outlier
colormap(ax, jet_w);
cbCLimRange('', '', ax, 'full', var.data); % full is chosen to attract attention on any potential outlier

% Define a context menu
hMenu = uicontextmenu;
Expand All @@ -162,15 +164,15 @@
uimenu(mainItem1, 'Label', 'other', 'Callback', hcb14);

mainItem2 = uimenu(hMenu, 'Label', 'Color range');
uimenu(mainItem2, 'Label', 'full', 'Callback', {@cbCLimRange, 'full', var.data});
uimenu(mainItem2, 'Label', 'full from 0 (default)', 'Callback', {@cbCLimRange, 'full from 0', var.data});
uimenu(mainItem2, 'Label', 'auto [mean +/-2*stdDev]', 'Callback', {@cbCLimRange, 'auto', var.data});
uimenu(mainItem2, 'Label', 'auto from 0 [0; mean +2*stdDev]', 'Callback', {@cbCLimRange, 'auto from 0', var.data});
uimenu(mainItem2, 'Label', 'manual', 'Callback', {@cbCLimRange, 'manual', var.data});
uimenu(mainItem2, 'Label', 'full', 'Callback', {@cbCLimRange, ax, 'full', var.data});
uimenu(mainItem2, 'Label', 'full from 0 (default)', 'Callback', {@cbCLimRange, ax, 'full from 0', var.data});
uimenu(mainItem2, 'Label', 'auto [mean +/-2*stdDev]', 'Callback', {@cbCLimRange, ax, 'auto', var.data});
uimenu(mainItem2, 'Label', 'auto from 0 [0; mean +2*stdDev]', 'Callback', {@cbCLimRange, ax, 'auto from 0', var.data});
uimenu(mainItem2, 'Label', 'manual', 'Callback', {@cbCLimRange, ax, 'manual', var.data});

otherwise
colormap(parula);
cbCLimRange('', '', 'full', var.data); % full is chosen to attract attention on any potential outlier
colormap(ax, parula);
cbCLimRange('', '', ax, 'full', var.data); % full is chosen to attract attention on any potential outlier

% Define a context menu
hMenu = uicontextmenu;
Expand All @@ -189,20 +191,20 @@
uimenu(mainItem1, 'Label', 'other', 'Callback', hcb14);

mainItem2 = uimenu(hMenu, 'Label', 'Color range');
uimenu(mainItem2, 'Label', 'full (default)', 'Callback', {@cbCLimRange, 'full', var.data});
uimenu(mainItem2, 'Label', 'full from 0', 'Callback', {@cbCLimRange, 'full from 0', var.data});
uimenu(mainItem2, 'Label', 'full, 0 centred', 'Callback', {@cbCLimRange, 'full, 0 centred', var.data});
uimenu(mainItem2, 'Label', 'auto [mean +/-2*stdDev]', 'Callback', {@cbCLimRange, 'auto', var.data});
uimenu(mainItem2, 'Label', 'auto from 0 [0; mean +2*stdDev]', 'Callback', {@cbCLimRange, 'auto from 0', var.data});
uimenu(mainItem2, 'Label', 'auto, 0 centred [0 +/-2*stdDev]', 'Callback', {@cbCLimRange, 'auto, 0 centred', var.data});
uimenu(mainItem2, 'Label', 'manual', 'Callback', {@cbCLimRange, 'manual', var.data});
uimenu(mainItem2, 'Label', 'full (default)', 'Callback', {@cbCLimRange, ax, 'full', var.data});
uimenu(mainItem2, 'Label', 'full from 0', 'Callback', {@cbCLimRange, ax, 'full from 0', var.data});
uimenu(mainItem2, 'Label', 'full, 0 centred', 'Callback', {@cbCLimRange, ax, 'full, 0 centred', var.data});
uimenu(mainItem2, 'Label', 'auto [mean +/-2*stdDev]', 'Callback', {@cbCLimRange, ax, 'auto', var.data});
uimenu(mainItem2, 'Label', 'auto from 0 [0; mean +2*stdDev]', 'Callback', {@cbCLimRange, ax, 'auto from 0', var.data});
uimenu(mainItem2, 'Label', 'auto, 0 centred [0 +/-2*stdDev]', 'Callback', {@cbCLimRange, ax, 'auto, 0 centred', var.data});
uimenu(mainItem2, 'Label', 'manual', 'Callback', {@cbCLimRange, ax, 'manual', var.data});

end

end

% Callback function for CLim range
function cbCLimRange(src,eventdata, cLimMode, data)
function cbCLimRange(src,eventdata, ax, cLimMode, data)

CLim = NaN(1, 2);

Expand Down Expand Up @@ -253,7 +255,7 @@ function cbCLimRange(src,eventdata, cLimMode, data)
CLim = [-2*stdDev, 2*stdDev];

case 'manual'
CLimCurr = get(gca, 'CLim');
CLimCurr = get(ax, 'CLim');
prompt = {['{\bf', sprintf('Colorbar range :}\n\nmin value :')],...
'max value :'};
def = {num2str(CLimCurr(1)), num2str(CLimCurr(2))};
Expand All @@ -278,6 +280,6 @@ function cbCLimRange(src,eventdata, cLimMode, data)

if CLim(1) == CLim(2), CLim(2) = CLim(1) + 1; end % CLim must be increasing

set(gca, 'CLim', CLim);
set(ax, 'CLim', CLim);

end
7 changes: 6 additions & 1 deletion Graph/diagramMooring1DVarAgainstOther.m
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,12 @@ function diagramMooring1DVarAgainstOther(sample_data, varName, yAxisVarName, isQ

if ~strcmpi(yAxisVarName, 'DEPTH')
% colorbar not needed when Y axis is already DEPTH
hCBar = colorbar('peer', hAxMooringVar);
% 'peer' input is not recommended starting in R2014b
if verLessThan('matlab', '8.4')
hCBar = colorbar('peer', hAxMooringVar);
else
hCBar = colorbar(hAxMooringVar);
end
set(get(hCBar, 'Title'), 'String', 'DEPTH (m)', 'Interpreter', 'none');
end

Expand Down
8 changes: 7 additions & 1 deletion Graph/diagramMooring2DVarAgainstOther.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ function diagramMooring2DVarAgainstOther(sample_data, varName, yAxisVarName, isQ
iHeight = getVar(sample_data{iSort(i)}.dimensions, 'HEIGHT_ABOVE_SENSOR');
if iHeight == 0, iHeight = getVar(sample_data{iSort(i)}.dimensions, 'DIST_ALONG_BEAMS'); end % is equivalent when tilt is negligeable
iVar = getVar(sample_data{iSort(i)}.variables, varName);
iYAxisVar = getVar(sample_data{iSort(i)}.variables, yAxisVarName);

if iVar && iYAxisVar && iHeight && ...
size(sample_data{iSort(i)}.variables{iVar}.data, 2) > 1 && ...
Expand Down Expand Up @@ -305,7 +306,12 @@ function diagramMooring2DVarAgainstOther(sample_data, varName, yAxisVarName, isQ

if ~strcmpi(yAxisVarName, 'DEPTH')
% colorbar not needed when Y axis is already DEPTH
hCBar = colorbar('peer', hAxMooringVar);
% 'peer' input is not recommended starting in R2014b
if verLessThan('matlab', '8.4')
hCBar = colorbar('peer', hAxMooringVar);
else
hCBar = colorbar(hAxMooringVar);
end
set(get(hCBar, 'Title'), 'String', 'DEPTH (m)', 'Interpreter', 'none');
end

Expand Down
7 changes: 6 additions & 1 deletion Graph/lineMooring1DVar.m
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,12 @@ function lineMooring1DVar(sample_data, varName, isQC, saveToFile, exportDir)

% Let's add a fake colorbar to have consistent display with or
% without colorbar
cb = colorbar('peer', hAxMooringVar);
% 'peer' input is not recommended starting in R2014b
if verLessThan('matlab', '8.4')
cb = colorbar('peer', hAxMooringVar);
else
cb = colorbar(hAxMooringVar);
end
set(get(cb, 'YLabel'), 'String', 'TEST');
pos_with_colorbar = get(hAxMooringVar, 'Position');
colorbar(cb, 'off');
Expand Down
25 changes: 21 additions & 4 deletions Graph/pcolorMooring2DVar.m
Original file line number Diff line number Diff line change
Expand Up @@ -208,21 +208,38 @@ function pcolorMooring2DVar(sample_data, varName, isQC, saveToFile, exportDir)
'YDir', 'normal', ...
'Layer', 'top');

hCBar = colorbar('peer', hAxMooringVar);
% 'peer' input is not recommended starting in R2014b
if verLessThan('matlab', '8.4')
hCBar = colorbar('peer', hAxMooringVar);
else
hCBar = colorbar(hAxMooringVar);
end
colormap(hAxMooringVar, cMap);

switch cType
case 'direction'
hCBar = colorbar('peer', hAxMooringVar, 'YLim', [0 360], 'YTick', [0 90 180 270 360]);
if verLessThan('matlab', '8.4')
hCBar = colorbar('peer', hAxMooringVar, 'YLim', [0 360], 'YTick', [0 90 180 270 360]);
else
hCBar = colorbar(hAxMooringVar, 'YLim', [0 360], 'YTick', [0 90 180 270 360]);
end
set(hAxMooringVar, 'CLim', [0 360]);
set(hCBar, 'YTick', [0 90 180 270 360]);
case 'centeredOnZero'
yLimMax = max(max(dataVar));
hCBar = colorbar('peer', hAxMooringVar, 'YLim', [-yLimMax yLimMax]);
if verLessThan('matlab', '8.4')
hCBar = colorbar('peer', hAxMooringVar, 'YLim', [-yLimMax yLimMax]);
else
hCBar = colorbar(hAxMooringVar, 'YLim', [-yLimMax yLimMax]);
end
set(hAxMooringVar, 'CLim', [-yLimMax yLimMax]);
case 'positiveFromZero'
yLimMax = max(max(dataVar));
hCBar = colorbar('peer', hAxMooringVar, 'YLim', [0 yLimMax]);
if verLessThan('matlab', '8.4')
hCBar = colorbar('peer', hAxMooringVar, 'YLim', [0 yLimMax]);
else
hCBar = colorbar(hAxMooringVar, 'YLim', [0 yLimMax]);
end
set(hAxMooringVar, 'CLim', [0 yLimMax]);
end

Expand Down
7 changes: 6 additions & 1 deletion Graph/scatterMooring1DVarAgainstDepth.m
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,12 @@ function scatterMooring1DVarAgainstDepth(sample_data, varName, isQC, saveToFile,
cMap = colormap(hAxMooringVar, parula(nColors));
end

hCBar = colorbar('peer', hAxMooringVar);
% 'peer' input is not recommended starting in R2014b
if verLessThan('matlab', '8.4')
hCBar = colorbar('peer', hAxMooringVar);
else
hCBar = colorbar(hAxMooringVar);
end
set(get(hCBar, 'Title'), 'String', [varName ' (' varUnit ')'], 'Interpreter', 'none');

initiateFigure = false;
Expand Down
7 changes: 6 additions & 1 deletion Graph/scatterMooring2DVarAgainstDepth.m
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,12 @@ function scatterMooring2DVarAgainstDepth(sample_data, varName, isQC, saveToFile,
set(zoomH,'ActionPostCallback',{@zoomDateTick, hAxMooringVar});
set(panH,'ActionPostCallback',{@zoomDateTick, hAxMooringVar});

hCBar = colorbar('peer', hAxMooringVar, 'YLim', CLim);
% 'peer' input is not recommended starting in R2014b
if verLessThan('matlab', '8.4')
hCBar = colorbar('peer', hAxMooringVar, 'YLim', CLim);
else
hCBar = colorbar(hAxMooringVar, 'YLim', CLim);
end
colormap(hAxMooringVar, cMap);
set(hAxMooringVar, 'CLim', CLim);

Expand Down
Loading

0 comments on commit 959c4a0

Please sign in to comment.