Skip to content

Commit

Permalink
Merge pull request #458 from aodn/2.5.30
Browse files Browse the repository at this point in the history
2.5.30
  • Loading branch information
ggalibert authored Jul 18, 2017
2 parents 0db75fe + 3d01a96 commit 16fdf84
Show file tree
Hide file tree
Showing 22 changed files with 164 additions and 1,046 deletions.
9 changes: 7 additions & 2 deletions FlowManager/displayManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,13 @@ function importCallback()

for k = 1:length(sample_data), updateCallback(sample_data{k}); end

stateSelectCallback('state', panel, updateCallback, lastState, ...
sample_data, graphType, setIdx, vars);
switch(lastState)
case 'Metadata', metadataCallback();
case 'Raw data', rawDataCallback();
case 'QC data', qcDataCallback();
case 'QC stats', qcStatsCallback();
otherwise, rawDataCallback();
end
state = lastState;
end

Expand Down
108 changes: 54 additions & 54 deletions FlowManager/flowManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -78,68 +78,73 @@ function flowManager(toolboxVersion)
function importRequestCallback()
%IMPORTREQUESTCALLBACK Called when the user wishes to import more data.
% Prompts the user to import more data, then adds the new data to the
% data sets. Forces a run of the auto QC routines over the new data if
% data sets. Forces a run of the PP and QC routines over the new data if
% necessary.
%

% prompt user to import more data
importedData = importManager(toolboxVersion);
importedNonUTCRawData = importManager(toolboxVersion);

if isempty(importedData), return; end
if isempty(importedNonUTCRawData), return; end

% check for and remove duplicates
remove = [];
for k = 1:length(importedData)
for i = 1:length(importedNonUTCRawData)
for m = 1:length(rawData)
if strcmp( rawData{m}.meta.raw_data_file,...
importedData{k}.meta.raw_data_file)
remove(end+1) = k;
importedNonUTCRawData{i}.meta.raw_data_file)
remove(end+1) = i;
end
end
end

if ~isempty(remove)
uiwait(msgbox('Duplicate data sets were removed during the import', ...
'Duplicate data sets removed', 'non-modal'));
importedData(remove) = [];
importedNonUTCRawData(remove) = [];
end


% add index to the newly imported data
for k = 1:length(importedData)
importedData{k}.meta.index = k + length(rawData);
for i = 1:length(importedNonUTCRawData)
importedNonUTCRawData{i}.meta.index = i + length(rawData);
end

% preprocess new data
importedRawData = preprocessManager(importedData, mode, 'raw');
importedQCData = preprocessManager(importedData, mode, 'qc');
[importedAutoQCData, importedCancel] = preprocessManager(importedNonUTCRawData, 'qc', mode, false);
if importedCancel
importedRawData = importedNonUTCRawData;
else
importedRawData = preprocessManager(importedNonUTCRawData, 'raw', mode, true); % only apply TIME to UTC conversion pre-processing routines, auto is true so that GUI only appears once
end
clear importedNonUTCRawData;

% insert the new data into the rawData array, and run QC if necessary
startIdx = (length(rawData)+1);
endIdx = startIdx + length(importedData) - 1;
startIdx = length(rawData) + 1;
endIdx = startIdx + length(importedRawData) - 1;
rawData = [rawData importedRawData];
autoQCData = [autoQCData importedQCData];
clear importedRawData importedQCData;
autoQCData = [autoQCData importedAutoQCData];
clear importedAutoQCData;

if autoQCData{end}.meta.level == 1 % previously imported datasets have been QC'd already
if autoQCData{startIdx - 1}.meta.level == 1 % previously imported datasets have been QC'd already
autoQCRequestCallback(startIdx:endIdx, 0);

% if user cancelled auto QC process, the autoQCData and rawData arrays
% will be out of sync; this is bad, so the following is a dirty hack
% which ensures that the arrays will stay synced.
if length(autoQCData) ~= length(rawData)

autoQCData(startIdx:endIdx) = importedData;
autoQCData(startIdx:endIdx) = importedRawData;

for k = startIdx:endIdx
autoQCData{k}.meta.level = 1;
autoQCData{k}.file_version = imosFileVersion(1, 'name');
autoQCData{k}.file_version_quality_control = ...
for i = startIdx:endIdx
autoQCData{i}.meta.level = 1;
autoQCData{i}.file_version = imosFileVersion(1, 'name');
autoQCData{i}.file_version_quality_control = ...
imosFileVersion(1, 'desc');
end
end
end
clear importedData;
clear importedRawData;
end

function metadataUpdateCallback(sample_data)
Expand Down Expand Up @@ -284,44 +289,39 @@ function metadataRepCallback(location, fields, values)
sample_data = autoQCData;

% save data set selection
lastSetIdx = lastAutoQCSetIdx;
lastAutoQCSetIdx = setIdx;

% if QC has not been run before, run QC over every data set
if autoQCData{1}.meta.level == 0

setIdx = 1:length(sample_data);
qcLevel = cellfun(@(x) x(:).meta.level, autoQCData, 'UniformOutput', false);
qcLevel = [qcLevel{:}];

% if just a state change, return previous QC data
% if QC has not been run before, run QC over every data set
if all(qcLevel == 0)

setIdx = 1:length(sample_data);

% if just a state change, return previous QC data
elseif stateChange, return;

% if QC has already been executed, passed-in set index is the same as
% that which was previoously passed, and state has not changed, prompt

% if QC has already been executed, prompt
% user if they want to keep old QC data, or redo QC, for this set only
elseif lastSetIdx == setIdx

response = questdlg(...
['Re-run auto-QC routines '...
'(existing flags/mods will be discarded)?'],...
'Re-run QC Routines?', ...
'No', ...
'Re-run for this data set',...
'Re-run for all data sets',...
'No');

if ~strncmp(response, 'Re-run', 6), return; end

if strcmp(response, 'Re-run for all data sets')
setIdx = 1:length(sample_data);
end

% otherwise if no new data sets, return the existing auto QC data
elseif ~any(setIdx > length(sample_data))
return;
elseif all(qcLevel == 1)

response = questdlg(...
['Re-run auto-QC routines '...
'(existing flags/mods will be discarded)?'],...
'Re-run QC Routines?', ...
'No', ...
'Re-run for this data set',...
'Re-run for all data sets',...
'No');

if ~strncmp(response, 'Re-run', 6), return; end

if strcmp(response, 'Re-run for all data sets')
setIdx = 1:length(sample_data);
end

end

% save data set selection
lastSetIdx = setIdx;

% run QC routines over raw data
aqc = autoQCManager(sample_data(setIdx));
Expand Down
2 changes: 1 addition & 1 deletion FlowManager/preprocessManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
% routine names, but must be provided to the list selection dialog
% as indices
ppChainIdx = cellfun(@(x)(find(ismember(ppRoutines,x))),ppChain);
[ppChain, cancel] = listSelectionDialog('Select Preprocess routines', ...
[ppChain, cancel] = listSelectionDialog('Select Preprocessing routines', ...
ppRoutines, ppChainIdx, ...
{@routineConfig, 'Configure routine';
@setDefaultRoutines, 'Default set'});
Expand Down
7 changes: 7 additions & 0 deletions Graph/TimeSeries/highlightTimeSeriesTimeDepth.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@
if ~ishandle(data), error('data must be a graphics handle'); end
if ~isstruct(variable), error('variable must be a struct'); end
if ~ischar(type), error('type must be a string'); end

if any(size(variable.data) == 1)
% we actually deal with a single point in depth instrument (ex.:
% current metre)
highlight = highlightTimeSeriesGeneric(region, data, variable, type);
return;
end

xdata = get(data, 'XData');
ydata = get(data, 'YData');
Expand Down
22 changes: 10 additions & 12 deletions Graph/checkMooringPlannedDepths.m
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,16 @@ function checkMooringPlannedDepths(sample_data, isQC, saveToFile, exportDir)
%now plot all the calculated depths on one plot to choose region for comparison:
%plot
fileName = genIMOSFileName(sample_data{1}, 'png');
visible = 'on';
if saveToFile, visible = 'off'; end
hFigPress = figure(...
'Name', title, ...
'NumberTitle','off', ...
'OuterPosition', monitorRect(iBigMonitor, :));
'Name', title, ...
'NumberTitle', 'off', ...
'Visible', visible, ...
'OuterPosition', monitorRect(iBigMonitor, :));

% create uipanel within figure so that screencapture can be
% used on the plot only and without capturing all of the figure
% (including buttons, menus...)
hPanelMooringVar = uipanel('Parent', hFigPress);
hAxPress = subplot(2,1,1,'Parent', hPanelMooringVar);
hAxDepthDiff = subplot(2,1,2,'Parent', hPanelMooringVar);
hAxPress = subplot(2,1,1,'Parent', hFigPress);
hAxDepthDiff = subplot(2,1,2,'Parent', hFigPress);

%depth plot for selecting region to compare depth to planned depth
set(hAxPress, 'YDir', 'reverse')
Expand Down Expand Up @@ -277,8 +276,7 @@ function checkMooringPlannedDepths(sample_data, isQC, saveToFile, exportDir)
'buffer', [0 -hYBuffer], ...
'ncol', nCols,...
'FontSize', fontSizeAx,...
'xscale', xscale, ...
'parent', hPanelMooringVar);
'xscale', xscale);
posAx = get(hAxPress, 'Position');
set(hLegend, 'Units', 'Normalized', 'color', backgroundColor);

Expand Down Expand Up @@ -318,7 +316,7 @@ function checkMooringPlannedDepths(sample_data, isQC, saveToFile, exportDir)
fileName = strrep(fileName, '_PARAM_', ['_', varName, '_']); % IMOS_[sub-facility_code]_[site_code]_FV01_[deployment_code]_[PLOT-TYPE]_[PARAM]_C-[creation_date].png
fileName = strrep(fileName, '_PLOT-TYPE_', '_LINE_');

fastSaveas(hFigPress, hPanelMooringVar, fullfile(exportDir, fileName));
fastSaveas(hFigPress, fullfile(exportDir, fileName));

close(hFigPress);
end
Expand Down
23 changes: 10 additions & 13 deletions Graph/checkMooringPresDiffs.m
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,16 @@ function checkMooringPresDiffs(sample_data, iSampleMenu, isQC, saveToFile, expor

%plot
fileName = genIMOSFileName(sample_data{iCurrSam}, 'png');
visible = 'on';
if saveToFile, visible = 'off'; end
hFigPressDiff = figure(...
'Name', title, ...
'NumberTitle','off', ...
'OuterPosition', monitorRect(iBigMonitor, :));

% create uipanel within figure so that screencapture can be
% used on the plot only and without capturing all of the figure
% (including buttons, menus...)
hPanelMooringVar = uipanel('Parent', hFigPressDiff);
'Name', title, ...
'NumberTitle', 'off', ...
'Visible', visible, ...
'OuterPosition', monitorRect(iBigMonitor, :));

%pressure plot
hAxPress = subplot(2,1,1,'Parent', hPanelMooringVar);
hAxPress = subplot(2,1,1,'Parent', hFigPressDiff);
set(hAxPress, 'YDir', 'reverse')
set(get(hAxPress, 'XLabel'), 'String', 'Time');
set(get(hAxPress, 'YLabel'), 'String', [presRelCode ' (' varUnit ')'], 'Interpreter', 'none');
Expand All @@ -162,7 +160,7 @@ function checkMooringPresDiffs(sample_data, iSampleMenu, isQC, saveToFile, expor
hold(hAxPress, 'on');

%Pressure diff plot
hAxPressDiff = subplot(2,1,2,'Parent', hPanelMooringVar);
hAxPressDiff = subplot(2,1,2,'Parent', hFigPressDiff);
set(get(hAxPressDiff, 'XLabel'), 'String', 'Time');
set(get(hAxPressDiff, 'YLabel'), 'String', ['Pressure differences (' varUnit ')'], 'Interpreter', 'none');
set(get(hAxPressDiff, 'Title'), 'String', ...
Expand Down Expand Up @@ -332,8 +330,7 @@ function checkMooringPresDiffs(sample_data, iSampleMenu, isQC, saveToFile, expor
'buffer', [0 -hYBuffer], ...
'ncol', nCols,...
'FontSize', fontSizeAx,...
'xscale', xscale, ...
'parent', hPanelMooringVar);
'xscale', xscale);
posAx = get(hAxPress, 'Position');
set(hLegend, 'Units', 'Normalized', 'color', backgroundColor);

Expand All @@ -345,7 +342,7 @@ function checkMooringPresDiffs(sample_data, iSampleMenu, isQC, saveToFile, expor
fileName = strrep(fileName, '_PARAM_', ['_', varName, '_']); % IMOS_[sub-facility_code]_[site_code]_FV01_[deployment_code]_[PLOT-TYPE]_[PARAM]_C-[creation_date].png
fileName = strrep(fileName, '_PLOT-TYPE_', '_LINE_');

fastSaveas(hFigPressDiff, hPanelMooringVar, fullfile(exportDir, fileName));
fastSaveas(hFigPressDiff, fullfile(exportDir, fileName));

close(hFigPressDiff);
end
Expand Down
18 changes: 8 additions & 10 deletions Graph/lineCastVar.m
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,19 @@ function lineCastVar(sample_data, varNames, isQC, saveToFile, exportDir)
if iVar > 0
if initiateFigure
fileName = genIMOSFileName(sample_data{i}, 'png');
visible = 'on';
if saveToFile, visible = 'off'; end
hFigCastVar = figure(...
'Name', title, ...
'NumberTitle','off', ...
'OuterPosition', monitorRect(iBigMonitor, :));

% create uipanel within figure so that screencapture can be
% used on the plot only and without capturing all of the figure
% (including buttons, menus...)
hPanelCastVar = uipanel('Parent', hFigCastVar);
'Name', title, ...
'NumberTitle', 'off', ...
'Visible', visible, ...
'OuterPosition', monitorRect(iBigMonitor, :));

initiateFigure = false;
end

if i==1
hAxCastVar = subplot(1, lenVarNames, k, 'Parent', hPanelCastVar);
hAxCastVar = subplot(1, lenVarNames, k);
set(hAxCastVar, 'YDir', 'reverse');
set(get(hAxCastVar, 'Title'), 'String', title, 'Interpreter', 'none');
set(get(hAxCastVar, 'XLabel'), 'String', varName, 'Interpreter', 'none');
Expand Down Expand Up @@ -307,7 +305,7 @@ function lineCastVar(sample_data, varNames, isQC, saveToFile, exportDir)
if saveToFile
fileName = strrep(fileName, '_PLOT-TYPE_', '_LINE_'); % IMOS_[sub-facility_code]_[platform_code]_FV01_[time_coverage_start]_[PLOT-TYPE]_C-[creation_date].png

fastSaveas(hFigCastVar, hPanelCastVar, fullfile(exportDir, fileName));
fastSaveas(hFigCastVar, fullfile(exportDir, fileName));

close(hFigCastVar);
end
Expand Down
20 changes: 9 additions & 11 deletions Graph/lineMooring1DVar.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,15 @@ function lineMooring1DVar(sample_data, varName, isQC, saveToFile, exportDir)
all(~strncmpi(sample_data{iSort(i)}.(typeVar){iVar}.name, {'UCUR', 'VCUR', 'WCUR', 'CDIR', 'CSPD', 'VEL1', 'VEL2', 'VEL3'}, 4))
if initiateFigure
fileName = genIMOSFileName(sample_data{iSort(i)}, 'png');
visible = 'on';
if saveToFile, visible = 'off'; end
hFigMooringVar = figure(...
'Name', title, ...
'NumberTitle','off', ...
'OuterPosition', monitorRect(iBigMonitor, :));
'Name', title, ...
'NumberTitle', 'off', ...
'Visible', visible, ...
'OuterPosition', monitorRect(iBigMonitor, :));

% create uipanel within figure so that screencapture can be
% used on the plot only and without capturing all of the figure
% (including buttons, menus...)
hPanelMooringVar = uipanel('Parent', hFigMooringVar);
hAxMooringVar = axes('Parent', hPanelMooringVar);
hAxMooringVar = axes('Parent', hFigMooringVar);

if any(strcmpi(varName, {'DEPTH', 'PRES', 'PRES_REL'})), set(hAxMooringVar, 'YDir', 'reverse'); end
set(get(hAxMooringVar, 'XLabel'), 'String', 'Time');
Expand Down Expand Up @@ -332,8 +331,7 @@ function lineMooring1DVar(sample_data, varName, isQC, saveToFile, exportDir)
'buffer', [0 -hYBuffer], ...
'ncol', nCols,...
'FontSize', fontSizeAx,...
'xscale', xscale, ...
'parent', hPanelMooringVar);
'xscale', xscale);
posAx = get(hAxMooringVar, 'Position');
set(hLegend, 'Units', 'Normalized', 'color', backgroundColor);
posLh = get(hLegend, 'Position');
Expand All @@ -348,7 +346,7 @@ function lineMooring1DVar(sample_data, varName, isQC, saveToFile, exportDir)
fileName = strrep(fileName, '_PARAM_', ['_', varName, '_']); % IMOS_[sub-facility_code]_[site_code]_FV01_[deployment_code]_[PLOT-TYPE]_[PARAM]_C-[creation_date].png
fileName = strrep(fileName, '_PLOT-TYPE_', '_LINE_');

fastSaveas(hFigMooringVar, hPanelMooringVar, fullfile(exportDir, fileName));
fastSaveas(hFigMooringVar, fullfile(exportDir, fileName));

close(hFigMooringVar);
end
Expand Down
Loading

0 comments on commit 16fdf84

Please sign in to comment.