-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #797 from aodn/FeatQcFlag
(Feat) Add failed QC tests information into new ancillary variable [*]_failed_tests
- Loading branch information
Showing
8 changed files
with
433 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
function value = imosQCTest( testName ) | ||
%imosQCTest Returns an appropriate QC flag_value (integer) | ||
% given a qc test routine (String) | ||
|
||
% The value returned by this function is the power of 2 of the qc routine | ||
% positional integer available in imosQCTests.txt. This is used to store | ||
% information in a variable in the form of integers | ||
% | ||
% | ||
% Inputs: | ||
% | ||
% testName - name of QC test | ||
% | ||
% Outputs: | ||
% value - integer | ||
% | ||
% Author: Laurent Besnard <[email protected]> | ||
% | ||
% Example: | ||
% | ||
% value = imosQCTest( 'userManualQC'); | ||
% | ||
% | ||
% assert(value==2) | ||
% | ||
|
||
narginchk(1, 1); | ||
if ~ischar(testName), error('field must be a string'); end | ||
|
||
value = ''; | ||
|
||
% open the IMOSQCFTests.txt file - it should be | ||
% in the same directory as this m-file | ||
path = ''; | ||
if ~isdeployed, [path, ~, ~] = fileparts(which('imosToolbox.m')); end | ||
if isempty(path), path = pwd; end | ||
path = fullfile(path, 'IMOS'); | ||
|
||
fidS = -1; | ||
try | ||
% read in the QC sets | ||
fidS = fopen([path filesep 'imosQCTests.txt'], 'rt'); | ||
if fidS == -1, return; end | ||
sets = textscan(fidS, '%s%f', 'delimiter', ',', 'commentStyle', '%'); | ||
fclose(fidS); | ||
|
||
[~, idx] = ismember(testName, sets{1,1}); | ||
|
||
value = int32(2^sets{1,2}(idx)); % return the | ||
|
||
|
||
catch e | ||
if fidS ~= -1, fclose(fidS); end | ||
rethrow(e); | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
function values = imosQCTests() | ||
%imosQCTests Returns a 1x2 cell array reading the info found in | ||
%ImosQCTests.txt | ||
% - the first one contains a list of QC routines | ||
% - the second cell returns a positional integer for each routine | ||
% | ||
% Inputs: | ||
% | ||
% N.A. | ||
% | ||
% Outputs: | ||
% 1x2 cell array | ||
% | ||
% Author: Laurent Besnard <[email protected]> | ||
% | ||
|
||
% | ||
% Copyright (C) 2023, Australian Ocean Data Network (AODN) and Integrated | ||
% Marine Observing System (IMOS). | ||
% | ||
% This program is free software: you can redistribute it and/or modify | ||
% it under the terms of the GNU General Public License as published by | ||
% the Free Software Foundation version 3 of the License. | ||
% | ||
% This program is distributed in the hope that it will be useful, | ||
% but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
% GNU General Public License for more details. | ||
|
||
% You should have received a copy of the GNU General Public License | ||
% along with this program. | ||
% If not, see <https://www.gnu.org/licenses/gpl-3.0.en.html>. | ||
% | ||
|
||
% open the IMOSQCFTests file - it should be | ||
% in the same directory as this m-file | ||
path = ''; | ||
if ~isdeployed, [path, ~, ~] = fileparts(which('imosToolbox.m')); end | ||
if isempty(path), path = pwd; end | ||
path = fullfile(path, 'IMOS'); | ||
|
||
fidS = -1; | ||
try | ||
% read in the QC sets | ||
fidS = fopen([path filesep 'imosQCTests.txt'], 'rt'); | ||
if fidS == -1, return; end | ||
sets = textscan(fidS, '%s%f', 'delimiter', ',', 'commentStyle', '%'); | ||
fclose(fidS); | ||
|
||
% rewrite sets with correct qc flag test values using the imosQCTest | ||
% function | ||
nQcFlags = length(sets{1}); | ||
for k = 1:nQcFlags | ||
sets{1,2}(k) = imosQCTest(sets{1,1}{k}); | ||
end | ||
|
||
values = sets; | ||
|
||
catch e | ||
if fidS ~= -1, fclose(fidS); end | ||
rethrow(e); | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
% | ||
% A list of all the toolbox QC routines flag values. This list is intended | ||
% to by used by the qcFilterMain.m function to tag, for each data point, | ||
% which QC test failed | ||
% | ||
% the positional integer value has to be strictly above 0 since 0 is used | ||
% as a _FillValue | ||
% | ||
% QC routine, positional integer | ||
userManualQC, 0 | ||
imosCorrMagVelocitySetQC, 1 | ||
imosDensityInversionSetQC, 2 | ||
imosEchoIntensitySetQC, 3 | ||
imosEchoIntensityVelocitySetQC, 4 | ||
imosEchoRangeSetQC, 5 | ||
imosErrorVelocitySetQC, 6 | ||
imosGlobalRangeQC, 7 | ||
imosHorizontalVelocitySetQC, 8 | ||
imosImpossibleDateQC, 10 | ||
imosImpossibleDepthQC, 11 | ||
imosImpossibleLocationSetQC, 12 | ||
imosInOutWaterQC, 13 | ||
imosPercentGoodVelocitySetQC, 14 | ||
imosRateOfChangeQC, 15 | ||
imosRegionalRangeQC, 16 | ||
imosSalinityFromPTQC, 17 | ||
imosSideLobeVelocitySetQC, 18 | ||
imosStationarityQC, 19 | ||
imosSurfaceDetectionByDepthSetQC, 20 | ||
imosTier2ProfileVelocitySetQC, 21 | ||
imosTiltVelocitySetQC_probably_good,22 | ||
imosTiltVelocitySetQC_bad, 23 | ||
imosTimeSeriesSpikeQC, 24 | ||
imosVerticalSpikeQC, 25 | ||
imosVerticalVelocityQC, 26 |
Oops, something went wrong.