Skip to content

Commit

Permalink
Merge pull request #427 from aodn/2.5.25
Browse files Browse the repository at this point in the history
2.5.25
  • Loading branch information
ggalibert authored Apr 6, 2017
2 parents c0f984a + c155307 commit d228ae1
Show file tree
Hide file tree
Showing 53 changed files with 1,250 additions and 837 deletions.
18 changes: 9 additions & 9 deletions AutomaticQC/imosEchoIntensityVelocitySetQC.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
idWcur = 0;
idCspd = 0;
idCdir = 0;
idABSI = cell(4, 1);
idABSIC = cell(4, 1);
for j=1:4
idABSI{j} = 0;
idABSIC{j} = 0;
end
lenVar = length(sample_data.variables);
for i=1:lenVar
Expand All @@ -80,21 +80,21 @@
if strncmpi(paramName, 'CDIR', 4), idCdir = i; end
for j=1:4
cc = int2str(j);
if strcmpi(paramName, ['ABSI' cc]), idABSI{j} = i; end
if strcmpi(paramName, ['ABSIC' cc]), idABSIC{j} = i; end
end
end

% check if the data is compatible with the QC algorithm
idMandatory = (idUcur | idVcur | idWcur | idCspd | idCdir);
for j=1:4
idMandatory = idMandatory & idABSI{j};
idMandatory = idMandatory & idABSIC{j};
end
if ~idMandatory, return; end

% let's get the associated vertical dimension
idVertDim = sample_data.variables{idABSI{1}}.dimensions(2);
idVertDim = sample_data.variables{idABSIC{1}}.dimensions(2);
if strcmpi(sample_data.dimensions{idVertDim}.name, 'DIST_ALONG_BEAMS')
disp(['Warning : imosEchoIntensityVelocitySetQC applied with a non tilt-corrected ABSIn (no bin mapping) on dataset ' sample_data.toolbox_input_file]);
disp(['Warning : imosEchoIntensityVelocitySetQC applied with a non tilt-corrected ABSICn (no bin mapping) on dataset ' sample_data.toolbox_input_file]);
end

qcSet = str2double(readProperty('toolbox.qc_set'));
Expand All @@ -103,10 +103,10 @@
rawFlag = imosQCFlag('raw', qcSet, 'flag');

%Pull out echo intensity
sizeData = size(sample_data.variables{idABSI{1}}.data);
sizeData = size(sample_data.variables{idABSIC{1}}.data);
ea = nan(4, sizeData(1), sizeData(2));
for j=1:4;
ea(j, :, :) = sample_data.variables{idABSI{j}}.data;
for j=1:4
ea(j, :, :) = sample_data.variables{idABSIC{j}}.data;
end

% read in filter parameters
Expand Down
25 changes: 24 additions & 1 deletion AutomaticQC/imosInOutWaterQC.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [data flags paramsLog] = imosInOutWaterQC( sample_data, data, k, type, auto )
function [data, flags, paramsLog] = imosInOutWaterQC( sample_data, data, k, type, auto )
%IMOSINOUTWATERQC Flags samples which were taken before and after the instrument was placed
% in the water.
%
Expand Down Expand Up @@ -110,6 +110,29 @@
end

case 'timeSeries'
% for test in display
sampleFile = sample_data.toolbox_input_file;

mWh = findobj('Tag', 'mainWindow');
qcParam = get(mWh, 'UserData');
p = 0;
if ~isempty(qcParam)
for i=1:length(qcParam)
if strcmp(qcParam(i).dataSet, sampleFile)
p = i;
break;
end
end
end
if p == 0
p = length(qcParam) + 1;
end
qcParam(p).dataSet = sampleFile;
qcParam(p).('inWater') = time_in_water;
qcParam(p).('outWater') = time_out_water;
% update qcParam for display
set(mWh, 'UserData', qcParam);

qcSet = str2double(readProperty('toolbox.qc_set'));
rawFlag = imosQCFlag('raw', qcSet, 'flag');
failFlag = imosQCFlag('bad', qcSet, 'flag');
Expand Down
5 changes: 4 additions & 1 deletion DDB/executeDDBQuery.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,13 @@

% execute the query - the java method returns
% an ArrayList of org.imos.ddb.schema.* objects.
source = '';
driver = '';
connection = '';
dbuser = '';
dbpassword = '';
try
source = readProperty('toolbox.ddb');
driver = readProperty('toolbox.ddb.driver');
connection = readProperty('toolbox.ddb.connection');
dbuser = readProperty('toolbox.ddb.user');
Expand All @@ -104,7 +107,7 @@
end

if isempty(connection)
ddb = org.imos.ddb.DDB.getDDB(readProperty('toolbox.ddb'));
ddb = org.imos.ddb.DDB.getDDB(source);
else
ddb = org.imos.ddb.DDB.getDDB(driver, connection, dbuser, dbpassword);
end
Expand Down
8 changes: 4 additions & 4 deletions FlowManager/displayManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ function rawDataCallback()
graphs = [];
try
graphFunc = getGraphFunc(graphType, 'graph', '');
[graphs lines vars] = graphFunc(panel, sample_data{setIdx}, vars);
[graphs, lines, vars] = graphFunc(panel, sample_data{setIdx}, vars);
catch e
errorString = getErrorString(e);
fprintf('%s\n', ['Error says : ' errorString]);
Expand All @@ -264,7 +264,7 @@ function rawDataCallback()
if ~isempty(graphs)
for k = 1:length(graphs)

set(graphs(k), 'UserData', {lines(k), k});
set(graphs(k), 'UserData', {lines(k,:), k});
end
end

Expand Down Expand Up @@ -330,7 +330,7 @@ function qcDataCallback()
flagFunc = [];
end

[graphs lines vars] = graphFunc(panel, sample_data{setIdx}, vars);
[graphs, lines, vars] = graphFunc(panel, sample_data{setIdx}, vars);

if isempty(flagFunc)
warning(['Cannot display QC flags using ' graphType ...
Expand All @@ -355,7 +355,7 @@ function qcDataCallback()
% so the data select callback can retrieve them
for k = 1:length(graphs)

set(graphs(k), 'UserData', {lines(k), k});
set(graphs(k), 'UserData', {lines(k,:), k});
end

% add data selection functionality
Expand Down
140 changes: 77 additions & 63 deletions GUI/mainWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -498,9 +498,10 @@ function zoomPostCallback(source,ev)
for i=1:length(graphs1D)
userData = get(graphs1D(i), 'UserData');
hData = userData{1};
iTickBox = userData{2};
iTickBox = userData{2}; % index into currently ticked boxes
iAllTickedBox = find(cell2mat(get(hTickBoxes, 'Value')) == 1);

varName = get(hTickBoxes(iTickBox), 'String');
varName = get(hTickBoxes(iAllTickedBox(iTickBox)), 'String');
iVar = getVar(sam.variables, varName);
flags = sam.variables{iVar}.flags;
iGood = ismember(flags, okFlags);
Expand Down Expand Up @@ -578,24 +579,21 @@ function displayLineMooringVar(source,ev, isQC)
stringQC = 'non QC';
if isQC, stringQC = 'QC'; end

% get all params that are in common in at least two datasets
lenSampleData = length(sample_data);
paramsName = {};
paramsCount = [];
paramsName{1} = 'diff(TIME)';
paramsCount(1) = lenSampleData;
% get all params that are in common in at least two datasets
for i=1:lenSampleData
lenParamsSample = length(sample_data{i}.variables);
for j=1:lenParamsSample
if i==1 && j==1
paramsName{1} = sample_data{1}.variables{1}.name;
paramsCount(1) = 1;
sameParam = strcmpi(paramsName, sample_data{i}.variables{j}.name);
if ~any(sameParam)
paramsName{end+1} = sample_data{i}.variables{j}.name;
paramsCount(end+1) = 1;
else
sameParam = strcmpi(paramsName, sample_data{i}.variables{j}.name);
if ~any(sameParam)
paramsName{end+1} = sample_data{i}.variables{j}.name;
paramsCount(end+1) = 1;
else
paramsCount(sameParam) = paramsCount(sameParam)+1;
end
paramsCount(sameParam) = paramsCount(sameParam)+1;
end
end
end
Expand All @@ -622,14 +620,14 @@ function displayLineMooringVar(source,ev, isQC)
iParam = strcmpi(paramsName, 'NOMINAL_DEPTH');
paramsName(iParam) = [];

% by default TEMP is selected
iTEMP = find(strcmpi(paramsName, 'TEMP'));
% by default diff(TIME) is selected
iDiffTIME = find(strcmpi(paramsName, 'diff(TIME)'));

[iSelection, ok] = listdlg(...
'ListString', paramsName, ...
'SelectionMode', 'single', ...
'ListSize', [150 150], ...
'InitialValue', iTEMP, ...
'InitialValue', iDiffTIME, ...
'Name', ['Plot a ' stringQC '''d variable accross all instruments in the mooring'], ...
'PromptString', 'Select a variable :');

Expand Down Expand Up @@ -949,68 +947,84 @@ function createVarPanel(sam, vars)
case 'profile'
% we don't want to plot TIME, PROFILE, DIRECTION, LATITUDE, LONGITUDE, BOT_DEPTH
varOffset = getVar(sam.variables, 'BOT_DEPTH');
dimLabel = 'DEPTH';
dimUnit = ' m';
dimFun = @num2str;

case 'timeSeries'
% we don't want to plot TIMESERIES, PROFILE, TRAJECTORY, LATITUDE, LONGITUDE, NOMINAL_DEPTH
varOffset = getVar(sam.variables, 'NOMINAL_DEPTH');
dimLabel = 'TIME';
dimUnit = ' UTC';
dimFun = @datestr;
end

% retrieve x/y click positions + data index
posClic = get(event_obj, 'Position');
I = get(event_obj, 'DataIndex');

switch graph
case 'Profile'
dimLabel = 'DEPTH';
dimUnit = ' m';
dimFun = @num2str;
case 'TimeSeries'
dimLabel = 'TIME';
dimUnit = ' UTC';
dimFun = @datestr;
otherwise
error(['graph type ' graph ' not supported']);
end

iDim = getVar(sam.dimensions, dimLabel);
nRecord = length(sam.dimensions{iDim}.data);

xLabel = get(get(gca, 'XLabel'), 'String');

nVar = length(vars);
txt = cell(1, nVar+1);
txt{1} = [dimLabel ': ' dimFun(posClic(1)) dimUnit];
for iVar=1:nVar
iVarCorr = vars(iVar)+varOffset;
varLabel = sam.variables{iVarCorr}.name;
varUnit = [' ' sam.variables{iVarCorr}.units];

nSample = numel(sam.variables{iVarCorr}.data);
iSample = I;
zInfo = '';
if I < nRecord && nSample > nRecord
% we've clicked on a 1D plot so don't want to display
% information from 2D plots
txt{iVar+1} = [];
continue;
else
% we've clicked on a 2D plot
nDim = sam.variables{iVarCorr}.dimensions;
if nDim==1
% and are dealing with a 1D info
iSample = sam.dimensions{iDim}.data == posClic(1);
else
% and are dealing with a 2D info
iZ = sam.variables{iVarCorr}.dimensions(2);
nZ = length(sam.dimensions{iZ}.data);
iSample = repmat(sam.dimensions{iDim}.data == posClic(1), 1, nZ) & repmat((sam.dimensions{iZ}.data == posClic(2))', nRecord, 1);
switch graph
case 'DepthProfile'
txt = cell(1, nVar+1);
% impossible to retrieve an exact TIME value, unfortunately
% DataIndex doesn't make sense
txt{1} = ['DEPTH: ' num2str(posClic(2)) ' m'];

for iVar=1:nVar
iVarCorr = vars(iVar)+varOffset;
varLabel = sam.variables{iVarCorr}.name;
varUnit = [' ' sam.variables{iVarCorr}.units];

varData = num2str(posClic(1));

zLabel = sam.dimensions{iZ}.name;
zUnit = [' ' sam.dimensions{iZ}.units];
zData = num2str(posClic(2));
zInfo = [' @' zLabel ': ' zData zUnit];
if ~isempty(strfind(xLabel, varLabel))
txt{iVar+1} = [varLabel ': ' varData varUnit];
end
end

case 'TimeSeries'
txt = cell(1, nVar+1);
txt{1} = [dimLabel ': ' dimFun(posClic(1)) dimUnit];

for iVar=1:nVar
iVarCorr = vars(iVar)+varOffset;
varLabel = sam.variables{iVarCorr}.name;
varUnit = [' ' sam.variables{iVarCorr}.units];

nSample = numel(sam.variables{iVarCorr}.data);
zInfo = '';
if strcmpi(get(gca, 'Tag'), 'axis1D') && nSample > nRecord
% we've clicked on a 1D plot and are dealing with 2D information
% we don't want to display
txt{iVar+1} = [];
continue;
else
nDim = length(sam.variables{iVarCorr}.dimensions);
if nDim == 1
% we've clicked on a 1D plot and are dealing with a 1D info
iSample = sam.dimensions{iDim}.data == posClic(1);
else
% we've clicked on a 2D plot and are dealing with a 2D info
iZ = sam.variables{iVarCorr}.dimensions(2);
nZ = length(sam.dimensions{iZ}.data);
iSample = repmat(sam.dimensions{iDim}.data == posClic(1), 1, nZ) & repmat((sam.dimensions{iZ}.data == posClic(2))', nRecord, 1);

zLabel = sam.dimensions{iZ}.name;
zUnit = [' ' sam.dimensions{iZ}.units];
zData = num2str(posClic(2));
zInfo = [' @' zLabel ': ' zData zUnit];
end
end
varData = num2str(sam.variables{iVarCorr}.data(iSample));

txt{iVar+1} = [varLabel ': ' varData varUnit zInfo];
end
end
varData = num2str(sam.variables{iVarCorr}.data(iSample));

txt{iVar+1} = [varLabel ': ' varData varUnit zInfo];
end

% clean up empty cells
Expand Down
6 changes: 5 additions & 1 deletion GUI/startDialog.m
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@
%

% dialog figure
f = figure('Name', 'Select Field Trip', ...
source = readProperty('toolbox.ddb');
if isempty(source)
source = readProperty('toolbox.ddb.connection');
end
f = figure('Name', ['Select Field Trip - ' source], ...
'Visible', 'off',...
'MenuBar', 'none',...
'Resize', 'off',...
Expand Down
15 changes: 13 additions & 2 deletions Graph/DepthProfile/flagDepthProfileGeneric.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
qcSet = str2double(readProperty('toolbox.qc_set'));
rawFlag = imosQCFlag('raw', qcSet, 'flag');

% get the toolbox execution mode
mode = readProperty('toolbox.mode');

% find the depth data, either a variable or dimension
depth = getVar(sample_data.variables, 'DEPTH');

Expand All @@ -70,9 +73,17 @@
depth = sample_data.dimensions{depth};
end

dim = depth.data;
fl = sample_data.variables{var}.flags;
data = sample_data.variables{var}.data;
fl = sample_data.variables{var}.flags;

[nSamples, nBins] = size(data);
if strcmpi(mode, 'timeSeries') && nBins > 1
% ADCP data, we look for vertical dimension
iVertDim = sample_data.variables{var}.dimensions(2);
dim = repmat(depth.data, 1, nBins) - repmat(sample_data.dimensions{iVertDim}.data', nSamples, 1);
else
dim = depth.data;
end

% get a list of the different flag types to be graphed
flagTypes = unique(fl);
Expand Down
Loading

0 comments on commit d228ae1

Please sign in to comment.