Skip to content

Commit

Permalink
Merge pull request #342 from aodn/2.5.7
Browse files Browse the repository at this point in the history
2.5.7
  • Loading branch information
ggalibert committed Apr 26, 2016
2 parents c1187a6 + bc84d02 commit b39542c
Show file tree
Hide file tree
Showing 18 changed files with 436 additions and 155 deletions.
7 changes: 6 additions & 1 deletion AutomaticQC/imosTiltVelocitySetQC.m
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,12 @@
tilt = acos(sqrt(1 - sin(roll*pi/180).^2 - sin(pitch*pi/180).^2))*180/pi;

% initially everything is failing the tests
sizeCur = size(sample_data.variables{idWcur}.flags);
if idUcur
idVar = idUcur;
else
idVar = idCspd;
end
sizeCur = size(sample_data.variables{idVar}.flags);
flags = ones(sizeCur, 'int8')*secondFlagThreshold;

% tilt test
Expand Down
32 changes: 24 additions & 8 deletions Graph/scatterMooring1DVarAgainstDepth.m
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function scatterMooring1DVarAgainstDepth(sample_data, varName, isQC, saveToFile,
xMin = min(xMin);
xMax = max(xMax);

markerStyle = {'+', 'o', '*', '.', 'x', 's', 'd', '^', 'v', '>', '<', 'p', 'h'};
markerStyle = {'+', 'o', '*', 's', 'd', '^', 'v', '>', '<', 'p', 'h'};
lenMarkerStyle = length(markerStyle);

instrumentDesc = cell(lenSampleData + 1, 1);
Expand All @@ -128,17 +128,20 @@ function scatterMooring1DVarAgainstDepth(sample_data, varName, isQC, saveToFile,
iDepth = getVar(sample_data{iSort(i)}.variables, 'DEPTH');
izVar = getVar(sample_data{iSort(i)}.variables, varName);

if izVar > 0 && iDepth > 0 && ...
size(sample_data{iSort(i)}.variables{izVar}.data, 2) == 1 && ... % we're only plotting 1D variables with depth variable but no current
if izVar > 0 && size(sample_data{iSort(i)}.variables{izVar}.data, 2) == 1 && ... % we're only plotting 1D variables with depth variable but no current
all(~strcmpi(sample_data{iSort(i)}.variables{izVar}.name, {'UCUR', 'VCUR', 'WCUR', 'CDIR', 'CSPD', 'VEL1', 'VEL2', 'VEL3'}))
iGood = true(size(sample_data{iSort(i)}.variables{izVar}.data));
if isQC
%get time, depth and var QC information
timeFlags = sample_data{iSort(i)}.dimensions{iTime}.flags;
depthFlags = sample_data{iSort(i)}.variables{iDepth}.flags;
varFlags = sample_data{iSort(i)}.variables{izVar}.flags;

iGood = (timeFlags == 1 | timeFlags == 2) & (varFlags == 1 | varFlags == 2) & (depthFlags == 1 | depthFlags == 2);
iGood = (timeFlags == 1 | timeFlags == 2) & (varFlags == 1 | varFlags == 2);

if iDepth
depthFlags = sample_data{iSort(i)}.variables{iDepth}.flags;
iGood = iGood & (depthFlags == 1 | depthFlags == 2);
end
end

if any(iGood)
Expand Down Expand Up @@ -235,22 +238,35 @@ function scatterMooring1DVarAgainstDepth(sample_data, varName, isQC, saveToFile,
if isQC
%get time, depth and var QC information
timeFlags = sample_data{iSort(i)}.dimensions{iTime}.flags;
depthFlags = sample_data{iSort(i)}.variables{iDepth}.flags;
varFlags = sample_data{iSort(i)}.variables{izVar}.flags;
varValues = sample_data{iSort(i)}.variables{izVar}.data;

iGood = (timeFlags == 1 | timeFlags == 2) & ...
(varFlags == 1 | varFlags == 2) & ...
~isnan(varValues);
iGoodDepth = (depthFlags == 1 | depthFlags == 2);

if iDepth
depthFlags = sample_data{iSort(i)}.variables{iDepth}.flags;
iGoodDepth = (depthFlags == 1 | depthFlags == 2);
end
end

if all(~iGood) && isQC
fprintf('%s\n', ['Warning : in ' sample_data{iSort(i)}.toolbox_input_file ...
', there is not any ' varName ' data with good flags.']);
continue;
else
depth = sample_data{iSort(i)}.variables{iDepth}.data;
if iDepth
depth = sample_data{iSort(i)}.variables{iDepth}.data;
else
if isfield(sample_data{iSort(i)}, 'instrument_nominal_depth')
depth = sample_data{iSort(i)}.instrument_nominal_depth*ones(size(iGood));
else
fprintf('%s\n', ['Error : in ' sample_data{iSort(i)}.toolbox_input_file ...
', global attribute instrument_nominal_depth is not documented.']);
continue;
end
end
depth(~iGoodDepth) = metaDepth(i);
depth = depth(iGood);

Expand Down
26 changes: 19 additions & 7 deletions Graph/scatterMooring2DVarAgainstDepth.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function scatterMooring2DVarAgainstDepth(sample_data, varName, isQC, saveToFile,
return;
end

markerStyle = {'+', 'o', '*', '.', 'x', 's', 'd', '^', 'v', '>', '<', 'p', 'h'};
markerStyle = {'+', 'o', '*', 's', 'd', '^', 'v', '>', '<', 'p', 'h'};
lenMarkerStyle = length(markerStyle);

instrumentDesc = cell(lenSampleData + 1, 1);
Expand All @@ -139,10 +139,9 @@ function scatterMooring2DVarAgainstDepth(sample_data, varName, isQC, saveToFile,
iTime = getVar(sample_data{iSort(i)}.dimensions, 'TIME');
iHeight = getVar(sample_data{iSort(i)}.dimensions, 'HEIGHT_ABOVE_SENSOR');
if iHeight == 0, iHeight = getVar(sample_data{iSort(i)}.dimensions, 'DIST_ALONG_BEAMS'); end % is equivalent when tilt is negligeable
iDepth = getVar(sample_data{iSort(i)}.variables, 'DEPTH');
iVar = getVar(sample_data{iSort(i)}.variables, varName);

if iVar > 0 && iHeight > 0 && iDepth > 0 && ...
if iVar > 0 && iHeight > 0 && ...
size(sample_data{iSort(i)}.variables{iVar}.data, 2) > 1 && ...
size(sample_data{iSort(i)}.variables{iVar}.data, 3) == 1 % we're plotting ADCP 2D variables with DEPTH variable.
isPlottable(i) = true;
Expand All @@ -163,7 +162,7 @@ function scatterMooring2DVarAgainstDepth(sample_data, varName, isQC, saveToFile,
yLimMax = max(yLimMax, max(max(sample_data{iSort(i)}.variables{iVar}.data(iGood))));
end

elseif iVar > 0 && iDepth > 0 && ...
elseif iVar > 0 && ...
any(strcmpi(sample_data{iSort(i)}.variables{iVar}.name, {'UCUR', 'VCUR', 'WCUR', 'CDIR', 'CSPD', 'VEL1', 'VEL2', 'VEL3'})) && ...
size(sample_data{iSort(i)}.variables{iVar}.data, 2) == 1 % we're plotting current metre 1D variables with DEPTH variable.
iGood = true(size(sample_data{iSort(i)}.variables{iVar}.data));
Expand Down Expand Up @@ -307,11 +306,14 @@ function scatterMooring2DVarAgainstDepth(sample_data, varName, isQC, saveToFile,
if isQC
%get time and var QC information
timeFlags = sample_data{iSort(i)}.dimensions{iTime}.flags;
depthFlags = sample_data{iSort(i)}.variables{iDepth}.flags;
varFlags = sample_data{iSort(i)}.variables{iVar}.flags;
varValues = sample_data{iSort(i)}.variables{iVar}.data;

iGoodDepth = (depthFlags == 1 | depthFlags == 2);
if iDepth
depthFlags = sample_data{iSort(i)}.variables{iDepth}.flags;
iGoodDepth = (depthFlags == 1 | depthFlags == 2);
end

iGoodTime = (timeFlags == 1 | timeFlags == 2);

iGood = repmat(iGoodTime, [1, size(sample_data{iSort(i)}.variables{iVar}.data, 2)]);
Expand All @@ -337,7 +339,17 @@ function scatterMooring2DVarAgainstDepth(sample_data, varName, isQC, saveToFile,
yScatter = 0;
end

dataDepth = sample_data{iSort(i)}.variables{iDepth}.data;
if iDepth
dataDepth = sample_data{iSort(i)}.variables{iDepth}.data;
else
if isfield(sample_data{iSort(i)}, 'instrument_nominal_depth')
dataDepth = sample_data{iSort(i)}.instrument_nominal_depth*ones(size(iGoodTime));
else
fprintf('%s\n', ['Error : in ' sample_data{iSort(i)}.toolbox_input_file ...
', global attribute instrument_nominal_depth is not documented.']);
continue;
end
end
dataDepth(~iGoodTime) = NaN;
dataDepth(~iGoodDepth) = metaDepth(i);

Expand Down
1 change: 1 addition & 0 deletions NetCDF/template/global_attributes_timeSeries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ S, metadata =
S, sensorML =
S, instrument_serial_number = [mat updateIfEmpty('[ddb InstrumentID Instruments SerialNumber]', sample_data.meta.instrument_serial_no)]
N, instrument_sample_interval = [mat sample_data.meta.instrument_sample_interval]
N, instrument_average_interval = [mat sample_data.meta.instrument_average_interval]
N, instrument_beam_angle = [mat sample_data.meta.beam_angle]
N, instrument_burst_interval = [mat sample_data.meta.instrument_burst_interval]
N, instrument_burst_duration = [mat sample_data.meta.instrument_burst_duration]
Expand Down
6 changes: 5 additions & 1 deletion Parser/aquadoppProfilerParse.m
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
sample_data.meta.instrument_serial_no = hardware.SerialNo;
sample_data.meta.instrument_firmware = hardware.FWversion;
sample_data.meta.instrument_sample_interval = median(diff(time*24*3600));
sample_data.meta.instrument_average_interval= user.AvgInterval;
sample_data.meta.beam_angle = 25; % http://www.hydro-international.com/files/productsurvey_v_pdfdocument_19.pdf
sample_data.meta.beam_to_xyz_transform = head.TransformationMatrix;

Expand All @@ -255,7 +256,7 @@
end
iWellOriented = adcpOrientations == adcpOrientation; % we'll only keep data collected when ADCP is oriented as expected
dims = {
'TIME', time(iWellOriented), ''; ...
'TIME', time(iWellOriented), ['Time stamp corresponds to the start of the measurement which lasts ' num2str(user.AvgInterval) ' seconds.']; ...
'DIST_ALONG_BEAMS', distance, 'Nortek instrument data is not vertically bin-mapped (no tilt correction applied). Cells are lying parallel to the beams, at heights above sensor that vary with tilt.'
};
clear time distance;
Expand All @@ -277,6 +278,9 @@
end
clear dims;

% add information about the middle of the measurement period
sample_data.dimensions{1}.seconds_to_middle_of_measurement = user.AvgInterval/2;

% add variables with their dimensions and data mapped.
% we assume no correction for magnetic declination has been applied
if velocityProcessed
Expand Down
7 changes: 6 additions & 1 deletion Parser/aquadoppVelocityParse.m
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,13 @@
sample_data.meta.instrument_serial_no = hardware.SerialNo;
sample_data.meta.instrument_firmware = hardware.FWversion;
sample_data.meta.instrument_sample_interval = median(diff(time*24*3600));
sample_data.meta.instrument_average_interval= user.AvgInterval;
sample_data.meta.beam_angle = 45; % http://wiki.neptunecanada.ca/download/attachments/18022846/Nortek+Aquadopp+Current+Meter+User+Manual+-+Rev+C.pdf
sample_data.meta.featureType = mode;

% add dimensions with their data mapped
dims = {
'TIME', time
'TIME', time, ['Time stamp corresponds to the start of the measurement which lasts ' num2str(user.AvgInterval) ' seconds.']
};
clear time;

Expand All @@ -173,9 +174,13 @@
sample_data.dimensions{i}.name = dims{i, 1};
sample_data.dimensions{i}.typeCastFunc = str2func(netcdf3ToMatlabType(imosParameters(dims{i, 1}, 'type')));
sample_data.dimensions{i}.data = sample_data.dimensions{i}.typeCastFunc(dims{i, 2});
sample_data.dimensions{i}.comment = dims{i, 3};
end
clear dims;

% add information about the middle of the measurement period
sample_data.dimensions{1}.seconds_to_middle_of_measurement = user.AvgInterval/2;

% add variables with their dimensions and data mapped.
% we assume no correction for magnetic declination has been applied
vars = {
Expand Down
43 changes: 33 additions & 10 deletions Parser/awacParse.m
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@
sample_data.meta.instrument_model = 'AWAC';
sample_data.meta.instrument_serial_no = hardware.SerialNo;
sample_data.meta.instrument_sample_interval = median(diff(time*24*3600));
sample_data.meta.instrument_average_interval= user.AvgInterval;
sample_data.meta.instrument_firmware = hardware.FWversion;
sample_data.meta.beam_angle = 25; % http://www.hydro-international.com/files/productsurvey_v_pdfdocument_19.pdf
sample_data.meta.beam_to_xyz_transform = head.TransformationMatrix;
Expand All @@ -256,7 +257,7 @@
end
iWellOriented = adcpOrientations == adcpOrientation; % we'll only keep data collected when ADCP is oriented as expected
dims = {
'TIME', time(iWellOriented), ''; ...
'TIME', time(iWellOriented), ['Time stamp corresponds to the start of the measurement which lasts ' num2str(user.AvgInterval) ' seconds.']; ...
'DIST_ALONG_BEAMS', distance, 'Nortek instrument data is not vertically bin-mapped (no tilt correction applied). Cells are lying parallel to the beams, at heights above sensor that vary with tilt.'
};
clear time distance;
Expand All @@ -278,6 +279,9 @@
end
clear dims;

% add information about the middle of the measurement period
sample_data.dimensions{1}.seconds_to_middle_of_measurement = user.AvgInterval/2;

% add variables with their dimensions and data mapped.
% we assume no correction for magnetic declination has been applied
if velocityProcessed
Expand Down Expand Up @@ -370,20 +374,36 @@
[filePath, fileRadName, ~] = fileparts(filename);
filename = fullfile(filePath, [fileRadName '.wap']);

sample_data{2}.toolbox_input_file = filename;
sample_data{2}.meta.head = [];
sample_data{2}.meta.hardware = [];
sample_data{2}.meta.user = [];
sample_data{2}.meta.instrument_sample_interval = median(diff(waveData.Time*24*3600));
sample_data{2}.toolbox_input_file = filename;
sample_data{2}.meta.head = [];
sample_data{2}.meta.hardware = [];
sample_data{2}.meta.user = [];
sample_data{2}.meta.instrument_sample_interval = median(diff(waveData.Time*24*3600));

avgInterval = [];
if isfield(waveData, 'summary')
iMatch = ~cellfun(@isempty, regexp(waveData.summary, 'Wave - Number of samples [0-9]'));
if any(iMatch)
nSamples = textscan(waveData.summary{iMatch}, 'Wave - Number of samples %f');

iMatch = ~cellfun(@isempty, regexp(waveData.summary, 'Wave - Sampling rate [0-9\.] Hz'));
if any(iMatch)
samplingRate = textscan(waveData.summary{iMatch}, 'Wave - Sampling rate %f Hz');
avgInterval = nSamples{1}/samplingRate{1};
end
end
end
sample_data{2}.meta.instrument_average_interval = avgInterval;
if isempty(avgInterval), avgInterval = '?'; end

% we assume no correction for magnetic declination has been applied

% add dimensions with their data mapped
dims = {
'TIME', waveData.Time; ...
'FREQUENCY_1', waveData.pwrFrequency; ...
'FREQUENCY_2', waveData.dirFrequency; ...
'DIR_MAG', waveData.Direction
'TIME', waveData.Time, ['Time stamp corresponds to the start of the measurement which lasts ' num2str(avgInterval) ' seconds.']; ...
'FREQUENCY_1', waveData.pwrFrequency, ''; ...
'FREQUENCY_2', waveData.dirFrequency, ''; ...
'DIR_MAG', waveData.Direction, ''
};

nDims = size(dims, 1);
Expand All @@ -395,6 +415,9 @@
end
clear dims;

% add information about the middle of the measurement period
sample_data{2}.dimensions{1}.seconds_to_middle_of_measurement = sample_data{2}.meta.instrument_average_interval/2;

% add variables with their dimensions and data mapped
vars = {
'TIMESERIES', [], 1; ...
Expand Down
6 changes: 5 additions & 1 deletion Parser/continentalParse.m
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
sample_data.meta.instrument_model = 'Continental';
sample_data.meta.instrument_serial_no = hardware.SerialNo;
sample_data.meta.instrument_sample_interval = median(diff(time*24*3600));
sample_data.meta.instrument_average_interval= user.AvgInterval;
sample_data.meta.instrument_firmware = hardware.FWversion;
sample_data.meta.beam_angle = 25; % http://www.hydro-international.com/files/productsurvey_v_pdfdocument_19.pdf
sample_data.meta.beam_to_xyz_transform = head.TransformationMatrix;
Expand All @@ -258,7 +259,7 @@
end
iWellOriented = adcpOrientations == adcpOrientation; % we'll only keep data collected when ADCP is oriented as expected
dims = {
'TIME', time(iWellOriented), ''; ...
'TIME', time(iWellOriented), ['Time stamp corresponds to the start of the measurement which lasts ' num2str(user.AvgInterval) ' seconds.']; ...
'DIST_ALONG_BEAMS', distance, 'Nortek instrument data is not vertically bin-mapped (no tilt correction applied). Cells are lying parallel to the beams, at heights above sensor that vary with tilt.'
};
clear time distance;
Expand All @@ -280,6 +281,9 @@
end
clear dims;

% add information about the middle of the measurement period
sample_data.dimensions{1}.seconds_to_middle_of_measurement = user.AvgInterval/2;

% add variables with their dimensions and data mapped.
% we assume no correction for magnetic declination has been applied
if velocityProcessed
Expand Down
12 changes: 10 additions & 2 deletions Parser/readAWACWaveAscii.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
% transform the filename into processed wave data filenames
[path, name] = fileparts(filename);

summaryFile = fullfile(path, [name '.hdr']);
headerFile = fullfile(path, [name '.whd']);
waveFile = fullfile(path, [name '.wap']);
dirFreqFile = fullfile(path, [name '.wdr']);
Expand All @@ -170,6 +171,15 @@
end

try
waveData = struct;

if exist(summaryFile, 'file')
summaryFileID = fopen(summaryFile);
summary = textscan(summaryFileID, '%s', 'Delimiter', '');
waveData.summary = summary{1};
fclose(summaryFileID);
end

header = importdata(headerFile);
wave = importdata(waveFile);
dirFreq = importdata(dirFreqFile);
Expand Down Expand Up @@ -198,8 +208,6 @@
iWave = ismember(totalTime, waveTime);
clear headerTime waveTime;

waveData = struct;

% copy data over to struct
waveData.Time = totalTime;
nTime = length(totalTime);
Expand Down
12 changes: 11 additions & 1 deletion Parser/readWorkhorseWaveAscii.m
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,17 @@
waveData = struct;

% transform the filename into a path
filePath = fileparts(filename);
[filePath, name, ext] = fileparts(filename);

% read the summary file
summaryFile = fullfile(filePath, [name '.txt']);

if exist(summaryFile, 'file')
summaryFileID = fopen(summaryFile);
summary = textscan(summaryFileID, '%s', 'Delimiter', '');
waveData.summary = summary{1};
fclose(summaryFileID);
end

% Load the *_LOG9.TXT file
logFile = dir(fullfile(filePath, '*_LOG9.TXT'));
Expand Down
Loading

0 comments on commit b39542c

Please sign in to comment.