Skip to content

Commit

Permalink
Merge pull request #678 from aodn/fix_tilt_adcp
Browse files Browse the repository at this point in the history
feat(bugfix): correct ADCP tilt flag broadcasting, fixes #680
  • Loading branch information
lbesnard authored Jul 30, 2020
2 parents 142a9ee + 9a0d83c commit ed6c9b9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
5 changes: 2 additions & 3 deletions AutomaticQC/imosTiltVelocitySetQC.m
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,19 @@

% tilt test
iPass = tilt < secondTiltThreshold;
if ~isvector(flags)
if isvector(flags)
flags(iPass) = firstFlagThreshold;
else
flags(iPass,:) = firstFlagThreshold;
end

iPass = tilt < firstTiltThreshold;
if ~isvector(flags)
if isvector(flags)
flags(iPass) = goodFlag;
else
flags(iPass,:) = goodFlag;
end


if idWcur
sample_data.variables{idWcur}.flags = flags;
varChecked = [varChecked, {'WCUR'}];
Expand Down
24 changes: 14 additions & 10 deletions test/AutomaticQC/test_imosTiltVelocitySetQC.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
function test_load_nortek_current_meter_values(~)
ssize = [5, 1];
sample_data = create_sample_data(ssize);
sample_data.variables{end}.data(:, :) = 0.; %roll
sample_data.variables{end - 1}.data(:, :) = 90.; %pitch
sample_data.variables{end}.data = zeros(5,1); %roll
sample_data.variables{end - 1}.data = zeros(5,1)+90; %pitch
sample_data.instrument = 'Nortek Aquadopp Current Meter';
e_logentry = 'firstTiltThreshold=30, secondTiltThreshold=45';
v = sample_data.variables{1}.data * 0;
Expand Down Expand Up @@ -38,13 +38,17 @@ function test_load_nortek_current_meter_values(~)
function test_load_nortek_adcp(~)
ssize = [100, 6];
sample_data = create_sample_data(ssize);
sample_data.variables{end}.data(:, :) = 0.; %roll
sample_data.variables{end - 1}.data(:, :) = 90.; %pitch
sample_data.variables{end}.data = zeros(100,1); %roll
sample_data.variables{end - 1}.data = zeros(100,1)+90.; %pitch
sample_data.variables{end - 1}.data([1,99]) = 0;
sample_data.variables{end - 1}.data([2,98]) = 21;
sample_data.instrument = 'nortek';
e_logentry = 'firstTiltThreshold=20, secondTiltThreshold=30';
v = sample_data.variables{1}.data * 0;

v3 = v + 3;
v3([1,99],:) = 1;
v3([2,98],:) = 2;
[pdata, ~, logentry] = imosTiltVelocitySetQC(sample_data, true);
assert(isequal(pdata.variables{1}.flags, v3))
assert(isequal(e_logentry, logentry))
Expand All @@ -67,8 +71,8 @@ function test_load_nortek_adcp(~)
function test_load_sentinel(~)
ssize = [100, 33];
sample_data = create_sample_data(ssize);
sample_data.variables{end}.data(:, :) = 0.; %roll
sample_data.variables{end - 1}.data(:, :) = 90.; %pitch
sample_data.variables{end}.data = zeros(100,1); %roll
sample_data.variables{end - 1}.data = zeros(100,1)+90.; %pitch
sample_data.instrument = 'ADCP sentinel abcdefg';
e_logentry = 'firstTiltThreshold=15, secondTiltThreshold=22';
v = sample_data.variables{1}.data(:, :) * 0;
Expand Down Expand Up @@ -97,8 +101,8 @@ function test_below_secondThreshold_ui(testCase)
if testCase.testUI
ssize = [100, 33];
sample_data = create_sample_data(ssize);
sample_data.variables{end}.data(:, :) = 0.; %roll
sample_data.variables{end - 1}.data(:, :) = 90.; %pitch
sample_data.variables{end}.data = zeros(100,1); %roll
sample_data.variables{end - 1}.data = zeros(100,1) +90; %pitch
sample_data.instrument = 'ADCP sentinel abcdefg';
e_logentry = 'firstTiltThreshold=15, secondTiltThreshold=91';
disp('Set firstFlagThreshold to be 4 and SecondTiltThreshold to be 91 for this test to pass');
Expand All @@ -116,8 +120,8 @@ function test_above_secondThreshold_ui(testCase)
if testCase.testUI
ssize = [100, 33];
sample_data = create_sample_data(ssize);
sample_data.variables{end}.data(:, :) = 0.; %roll
sample_data.variables{end - 1}.data(:, :) = 81.; %pitch
sample_data.variables{end}.data = zeros(100,1); %roll
sample_data.variables{end - 1}.data = zeros(100,1)+81.; %pitch
sample_data.instrument = 'ADCP sentinel abcdefg';
e_logentry = 'firstTiltThreshold=15, secondTiltThreshold=80';
disp('Set SecondTiltThreshold to be 80 for this test to pass');
Expand Down

0 comments on commit ed6c9b9

Please sign in to comment.