From fcfb83be0a1b4f3feeabda6622d1cfaaa7ac2da5 Mon Sep 17 00:00:00 2001 From: Guillaume Galibert Date: Wed, 20 Sep 2017 18:26:40 +1000 Subject: [PATCH] checkMooringPlannedDepths has been added to the default diagnostic plots produced when exporting NetCDFs. In batch mode it considers the first quarter of the deployment for its analysis. --- FlowManager/exportManager.m | 52 ++++++++-------- Graph/checkMooringPlannedDepths.m | 98 +++++++++++++++++++++++-------- 2 files changed, 99 insertions(+), 51 deletions(-) diff --git a/FlowManager/exportManager.m b/FlowManager/exportManager.m index abb336734..544e4cfc0 100644 --- a/FlowManager/exportManager.m +++ b/FlowManager/exportManager.m @@ -234,42 +234,38 @@ function exportQCPlots(sample_data, exportDir, mode, auto, progress) paramsName = unique(paramsName); -switch mode - case 'timeSeries' - % we get rid of specific parameters - notNeededParams = {'TIMESERIES', 'PROFILE', 'TRAJECTORY', 'LATITUDE', 'LONGITUDE', 'NOMINAL_DEPTH'}; - for i=1:length(notNeededParams) - iNotNeeded = strcmpi(paramsName, notNeededParams{i}); - paramsName(iNotNeeded) = []; - end - - % timeseries specific plots - nParams = length(paramsName); - for i=1:nParams - if ~auto - waitbar(i / nParams, progress, ['Exporting ' paramsName{i} ' plots']); +try + switch mode + case 'timeSeries' + % we get rid of specific parameters + notNeededParams = {'TIMESERIES', 'PROFILE', 'TRAJECTORY', 'LATITUDE', 'LONGITUDE', 'NOMINAL_DEPTH'}; + for i=1:length(notNeededParams) + iNotNeeded = strcmpi(paramsName, notNeededParams{i}); + paramsName(iNotNeeded) = []; end - try + + % timeseries specific plots + checkMooringPlannedDepths(sample_data, true, true, exportDir); + nParams = length(paramsName); + for i=1:nParams + if ~auto + waitbar(i / nParams, progress, ['Exporting ' paramsName{i} ' plots']); + end lineMooring1DVar(sample_data, paramsName{i}, true, true, exportDir); scatterMooring1DVarAgainstDepth(sample_data, paramsName{i}, true, true, exportDir); scatterMooring2DVarAgainstDepth(sample_data, paramsName{i}, true, true, exportDir); - %pcolorMooring2DVar(sample_data, paramsName{i}, true, true, exportDir); diagramMooring1DVarAgainstOther(sample_data, paramsName{i}, 'DEPTH', true, true, exportDir); diagramMooring2DVarAgainstOther(sample_data, paramsName{i}, 'DEPTH', true, true, exportDir); - catch e - errorString = getErrorString(e); - fprintf('%s\n', ['Error says : ' errorString]); end - end - case 'profile' - % profile specific plots - try + + case 'profile' + % profile specific plots lineCastVar(sample_data, paramsName, true, true, exportDir); - catch e - errorString = getErrorString(e); - fprintf('%s\n', ['Error says : ' errorString]); - end -end + end +catch e + errorString = getErrorString(e); + fprintf('%s\n', ['Error says : ' errorString]); +end end diff --git a/Graph/checkMooringPlannedDepths.m b/Graph/checkMooringPlannedDepths.m index bc3e15337..f09616438 100644 --- a/Graph/checkMooringPlannedDepths.m +++ b/Graph/checkMooringPlannedDepths.m @@ -241,7 +241,14 @@ function checkMooringPlannedDepths(sample_data, isQC, saveToFile, exportDir) 'YGrid', 'on', ... 'Layer', 'top'); -if isPlottable +if isPlottable + % collect visualQC config + try + fastScatter = eval(readProperty('visualQC.fastScatter')); + catch e %#ok + fastScatter = true; + end + datetick(hAxPress, 'x', 'dd-mm-yy HH:MM:SS', 'keepticks'); % we try to split the legend, maximum 3 columns @@ -272,36 +279,81 @@ function checkMooringPlannedDepths(sample_data, isQC, saveToFile, exportDir) set(hAxPress, 'Position', posAx); end -%Ask for the user to select the region they would like to use for -%comparison -%This could be done better, with more finesse - could allow zooming in -%before going straight to the time period selection. For now, this will do. -hMsgbox = msgbox('Select (drag & drop) a time period on the top graph for comparison, preferably at the start of deployment, when the mooring is standing vertical', 'Time Period Selection', 'help', 'modal'); -uiwait(hMsgbox); - -%select the area to use for comparison -[x, ~] = select_points(hAxPress); +if saveToFile + % look for difference with nominal depth in the first quarter + % of the deployment + timeStart = min(min(timeVar)) + 1; + timeQuarter = timeStart + (max(max(timeVar)) - timeStart)/4; + yLim = get(hAxPress, 'YLim'); + x = [timeStart, timeQuarter, timeQuarter, timeStart, timeStart]; + y = [yLim(1), yLim(1), yLim(2), yLim(2), yLim(1)]; + plot(hAxPress, x, y); + + iGood = timeVar >= timeStart & timeVar <= timeQuarter; +else + %Ask for the user to select the region they would like to use for + %comparison + %This could be done better, with more finesse - could allow zooming in + %before going straight to the time period selection. For now, this will do. + hMsgbox = msgbox('Select (drag & drop) a time period on the top graph for comparison, preferably at the start of deployment, when the mooring is standing vertical', 'Time Period Selection', 'help', 'modal'); + uiwait(hMsgbox); + + %select the area to use for comparison + [x, ~] = select_points(hAxPress); + + iGood = timeVar >= x(1) & timeVar <= x(2); +end -%now plot the difference from planned depth data: -iGood = timeVar >= x(1) & timeVar <= x(2); +%now plot the difference from planned depth data dataVar(~iGood) = NaN; -minDep = min(dataVar,[],2); - -scatter(hAxDepthDiff, ... - metaDepth, ... - minDep - metaDepth, ... - 15, ... - cMap, ... - 'filled'); +iNaN = isnan(dataVar); +avgDep = NaN(lenMetaDepth, 1); +for i = 1:lenMetaDepth + avgDep(i) = median(dataVar(i, ~iNaN(i, :))); + + if fastScatter + % for performance, we use plot (1 single handle object + % returned) rather than scatter (as many handles returned as + % points to plot). We plot as many subsets of the total amount + % of points as we want colors to be displayed. This is + % performed by the function plotclr. + + % !!! The result is such that the overlapping of points is dictated by + % the order of the colors to be plotted and not by the X axis order (from + % first to last) of the total points given. We choose an ordering from + % centre to both ends of colorbar in order to keep extreme colors visible + % though. + + plotclr(hAxDepthDiff, ... + metaDepth(i), ... + avgDep(i) - metaDepth(i), ... + metaDepth(i), ... + 'o', ... + [min(metaDepth) max(metaDepth)], ... + 'Color', cMap(i, :), ... + 'MarkerFaceColor', cMap(i, :), ... + 'MarkerSize', 2.5); + else + % faster than scatter, but legend requires adjusting + fastScatterMesh(hAxDepthDiff, ... + metaDepth(i), ... + avgDep(i) - metaDepth(i), ... + metaDepth(i), ... + [min(metaDepth) max(metaDepth)], ... + 'Marker', 'o', ... + 'FaceColor', cMap(i, :), ... + 'MarkerSize', 2.5); + end +end instrumentDesc(1) = []; -text(metaDepth + 1, (minDep - metaDepth), instrumentDesc, ... +text(metaDepth + 1, (avgDep - metaDepth), instrumentDesc, ... 'Parent', hAxDepthDiff) if isPlottable if saveToFile - 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_'); + fileName = strrep(fileName, '_PARAM_', '_DEPTH_vs_NOMINAL_DEPTH_'); % IMOS_[sub-facility_code]_[site_code]_FV01_[deployment_code]_[PLOT-TYPE]_[PARAM]_C-[creation_date].png + fileName = strrep(fileName, '_PLOT-TYPE_', '_CHECK_'); fastSaveas(hFigPress, fullfile(exportDir, fileName));