-
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 #738 from aodn/fix_imos_compliance_bug
Fix imos compliance bug, fixes #737
- Loading branch information
Showing
4 changed files
with
71 additions
and
29 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
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -1,40 +1,84 @@ | ||
classdef testadcpBinMappingPP < matlab.unittest.TestCase | ||
|
||
% Test adcpBinMappingPP refactored code. | ||
% | ||
% The largest code change | ||
% | ||
% The largest code change | ||
% | ||
% by [email protected] | ||
% | ||
properties (TestParameter) | ||
rdi_file = {[toolboxRootPath 'data/testfiles/Teledyne/workhorse/v000/beam/1759001.000.reduced'], }; | ||
enu_file = {[toolboxRootPath 'data/testfiles/Teledyne/workhorse/v000/enu/16072000.000'], }; | ||
|
||
end | ||
|
||
methods (Test) | ||
|
||
function test_mapping_RDI_beam_velocity(test) | ||
s = workhorseParse(test.rdi_file,''); | ||
bs = adcpBinMappingPP({s},''); | ||
bs = bs{1}; | ||
|
||
bin_mapping_string = 'has been vertically bin-mapped to HEIGHT_ABOVE_SENSOR using tilt information'; | ||
dim_removed_string = 'DIST_ALONG_BEAMS is not used by any variable left and has been removed'; | ||
|
||
assert(isfield(bs,'history')) | ||
assert(contains(bs.history,bin_mapping_string)) | ||
assert(contains(bs.history,dim_removed_string)) | ||
|
||
vars_to_check = {'VEL1','VEL2','VEL3','VEL4'}; | ||
mapped = IMOS.as_named_struct(bs.variables); | ||
raw = IMOS.as_named_struct(s.variables); | ||
for k=1:length(vars_to_check) | ||
vname = vars_to_check{k}; | ||
assert(isfield(mapped.(vname),'comment')) | ||
assert(contains(mapped.(vname).comment,bin_mapping_string)); | ||
[~,~,p] = isequal_tol(raw.(vname).data,mapped.(vname).data); | ||
assert(p<0.1,'Data similiary larger than 10% - Data is possible not beam mapped') | ||
end | ||
end | ||
function test_dont_remove_dist_along_beams_when_perg_and_data_is_enu(test) | ||
s = workhorseParse(test.enu_file, ''); | ||
bs = adcpBinMappingPP({s}, ''); | ||
bs = bs{1}; | ||
dims = IMOS.as_named_struct(bs.dimensions); | ||
vars = IMOS.as_named_struct(bs.variables); | ||
assert(isfield(dims, 'DIST_ALONG_BEAMS')) | ||
assert(isfield(dims, 'HEIGHT_ABOVE_SENSOR')) | ||
expected_coords = 'TIME LATITUDE LONGITUDE DIST_ALONG_BEAMS'; | ||
|
||
for k = 1:4 | ||
varname = ['PERG' num2str(k)]; | ||
assert(isfield(vars, varname)) | ||
assert(strcmpi(expected_coords, vars.(varname).coordinates)) | ||
end | ||
|
||
end | ||
|
||
function test_mapping_RDI_beam_velocity(test) | ||
s = workhorseParse(test.rdi_file, ''); | ||
bs = adcpBinMappingPP({s}, ''); | ||
bs = bs{1}; | ||
|
||
bin_mapping_string = 'has been vertically bin-mapped to HEIGHT_ABOVE_SENSOR using tilt information'; | ||
dim_removed_string = 'DIST_ALONG_BEAMS is not used by any variable left and has been removed'; | ||
|
||
assert(isfield(bs, 'history')) | ||
assert(contains(bs.history, bin_mapping_string)) | ||
assert(~contains(bs.history, dim_removed_string)) | ||
|
||
vars_to_check = {'VEL1', 'VEL2', 'VEL3', 'VEL4'}; | ||
mapped = IMOS.as_named_struct(bs.variables); | ||
raw = IMOS.as_named_struct(s.variables); | ||
|
||
for k = 1:length(vars_to_check) | ||
vname = vars_to_check{k}; | ||
assert(isfield(mapped.(vname), 'comment')) | ||
assert(contains(mapped.(vname).comment, bin_mapping_string)); | ||
[~, ~, p] = isequal_tol(raw.(vname).data, mapped.(vname).data); | ||
assert(p < 0.1, 'Data similiary larger than 10% - Data is possible not beam mapped') | ||
end | ||
|
||
end | ||
|
||
function test_removal_of_dangling_dist_along_beams_dims(test) | ||
s = workhorseParse(test.rdi_file, ''); | ||
%remove perg variables | ||
perg1_ind = IMOS.find(s.variables, 'PERG1'); | ||
perg2_ind = IMOS.find(s.variables, 'PERG2'); | ||
perg3_ind = IMOS.find(s.variables, 'PERG3'); | ||
perg4_ind = IMOS.find(s.variables, 'PERG4'); | ||
inds = 1:length(s.variables); | ||
no_dab_inds = setxor(inds, [perg1_ind, perg2_ind, perg3_ind, perg4_ind]); | ||
s.variables = s.variables(no_dab_inds); | ||
|
||
bs = adcpBinMappingPP({s}, ''); | ||
bs = bs{1}; | ||
|
||
bin_mapping_string = 'has been vertically bin-mapped to HEIGHT_ABOVE_SENSOR using tilt information'; | ||
dim_removed_string = 'DIST_ALONG_BEAMS is not used by any variable left and has been removed'; | ||
|
||
assert(isfield(bs, 'history')) | ||
assert(contains(bs.history, bin_mapping_string)) | ||
assert(contains(bs.history, dim_removed_string)) | ||
end | ||
|
||
function testRDI_old_mapping_to_new_mapping_code(test) | ||
base_file = load([toolboxRootPath 'data/testfiles/Teledyne/workhorse/v000/beam/1759001.000.reduced.old_mapping.mat']); | ||
|