Skip to content

Commit

Permalink
Merge pull request #476 from aodn/2.5.34
Browse files Browse the repository at this point in the history
2.5.34
  • Loading branch information
ggalibert authored Oct 5, 2017
2 parents 07f0f22 + af41045 commit 25470a1
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 53 deletions.
6 changes: 0 additions & 6 deletions Graph/diagramMooring2DVarAgainstOther.m
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,6 @@ function diagramMooring2DVarAgainstOther(sample_data, varName, yAxisVarName, isQ
xMin = min(xMin);
xMax = max(xMax);

% somehow could not get any data to plot, bail early
if all(isnan([xMin, xMax]))
fprintf('%s\n', ['Warning : there is not any ' varName ' data in this deployment with good flags.']);
return;
end

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

Expand Down
6 changes: 0 additions & 6 deletions Graph/scatterMooring2DVarAgainstDepth.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ function scatterMooring2DVarAgainstDepth(sample_data, varName, isQC, saveToFile,
xMin = min(xMin);
xMax = max(xMax);

% somehow could not get any data to plot, bail early
if any(isnan([xMin, xMax]))
fprintf('%s\n', ['Warning : there is not any ' varName ' data in this deployment with good flags.']);
return;
end

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

Expand Down
22 changes: 22 additions & 0 deletions Parser/readBB9raw.m
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,28 @@

sample_data.meta.instrument_sample_interval = 1;

% Let's find each start of bursts if any
dt = [0; diff(time)];
iBurst = [1; find(dt>(sample_data.meta.instrument_sample_interval/24/60)); length(time)+1];
nBurst = length(iBurst)-1;

if nBurst > 1
% let's read data burst by burst
firstTimeBurst = zeros(nBurst, 1);
sampleIntervalInBurst = zeros(nBurst, 1);
durationBurst = zeros(nBurst, 1);
for i=1:nBurst
timeBurst = time(iBurst(i):iBurst(i+1)-1);
sampleIntervalInBurst(i) = median(diff(timeBurst*24*3600));
firstTimeBurst(i) = timeBurst(1);
durationBurst(i) = (timeBurst(end) - timeBurst(1))*24*3600 + sampleIntervalInBurst(i);
end

sample_data.meta.instrument_sample_interval = round(median(sampleIntervalInBurst));
sample_data.meta.instrument_burst_interval = round(median(diff(firstTimeBurst*24*3600)));
sample_data.meta.instrument_burst_duration = round(median(durationBurst));
end

sample_data.dimensions{1}.name = 'TIME';
sample_data.dimensions{1}.typeCastFunc = str2func(netcdf3ToMatlabType(imosParameters(sample_data.dimensions{1}.name, 'type')));
sample_data.dimensions{1}.data = sample_data.dimensions{1}.typeCastFunc(time);
Expand Down
22 changes: 22 additions & 0 deletions Parser/readECOraw.m
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,28 @@

sample_data.meta.instrument_sample_interval = median(diff(time*24*3600));

% Let's find each start of bursts if any
dt = [0; diff(time)];
iBurst = [1; find(dt>(sample_data.meta.instrument_sample_interval/24/60)); length(time)+1];
nBurst = length(iBurst)-1;

if nBurst > 1
% let's read data burst by burst
firstTimeBurst = zeros(nBurst, 1);
sampleIntervalInBurst = zeros(nBurst, 1);
durationBurst = zeros(nBurst, 1);
for i=1:nBurst
timeBurst = time(iBurst(i):iBurst(i+1)-1);
sampleIntervalInBurst(i) = median(diff(timeBurst*24*3600));
firstTimeBurst(i) = timeBurst(1);
durationBurst(i) = (timeBurst(end) - timeBurst(1))*24*3600 + sampleIntervalInBurst(i);
end

sample_data.meta.instrument_sample_interval = round(median(sampleIntervalInBurst));
sample_data.meta.instrument_burst_interval = round(median(diff(firstTimeBurst*24*3600)));
sample_data.meta.instrument_burst_duration = round(median(durationBurst));
end

sample_data.dimensions{1}.name = 'TIME';
sample_data.dimensions{1}.typeCastFunc = str2func(netcdf3ToMatlabType(imosParameters(sample_data.dimensions{1}.name, 'type')));
sample_data.dimensions{1}.data = sample_data.dimensions{1}.typeCastFunc(time);
Expand Down
90 changes: 52 additions & 38 deletions Parser/workhorseParse.m
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
case 0
adcpFreq = 75;
model = 'Long Ranger';
xmitVoltScaleFactors = 2092719 / 10; % Long Ranger output is 10x larger, not sure why.
xmitVoltScaleFactors = 2092719;

case 1
adcpFreq = 150;
Expand Down Expand Up @@ -261,18 +261,31 @@
xmitVoltScaleFactors = 253765;
end
xmitVoltScaleFactors = xmitVoltScaleFactors / 1000000; %from p.136 of Workhorse Commands and Output Data Format PDF (RDI website - March 2016)

% xmit voltage conversion for diagnostics
% converting xmit voltage counts to volts , these are rough values

% converting xmit voltage counts to volts for diagnostics.
voltage = voltage * xmitVoltScaleFactors;

% set all NaN to the next available value after it (conservative approach)
voltComment = ['This parameter is actually the transmit voltage (ADC channel 1), which is NOT the same as battery voltage. ' ...
'The transmit voltage is sampled after a DC/DC converter and as such does not represent the true battery voltage. ' ...
'It does give a relative illustration of the battery voltage though which means that it will drop as the battery ' ...
'voltage drops. In addition, The circuit is not calibrated which means that the measurement is noisy and the values ' ...
'will vary between same frequency WH ADCPs.'];

% There are 8 ADC channels and this results in the following nuances:
% a. Only one ADC channel is sampled at a time per ping. This means it takes 8 pings in order to sample all 8 channels.
% b. Until 8 pings have happened the data in a given channel is not valid (NaN).
% c. Once 8 pings have happened the last value for each channel sampled will be stored into the leader data until the next sample is made.
% d. Only the last sample made is stored; there is no accumulation or averaging of the ADC channels.
% e. The ADC channels are stored over ensembles meaning the ADC channel is not reset until the instrument deployment is stopped.
% f. Examples:
% i. If you do 4 pings and then stop the deployment, only ADC channels 0-3 are valid.
% ii. If you do 12 pings and then stop the deployment, ADCP channels 0-3 will be updated with values from pings 9-12 respectively, and channels 4-7 will be updated with values from pings 4-7 respectively.
iNaNVoltage = isnan(voltage);
if iNaNVoltage(end) % we need to deal separately with the last value in case it's NaN
iLastGoodValue = find(~iNaNVoltage, 'last'); % in this case we have no choice but to look for the previous available value before it
iLastGoodValue = find(~iNaNVoltage, 1, 'last'); % in this case we have no choice but to look for the previous available value before it
voltage(end) = voltage(iLastGoodValue);
iNaNVoltage(end) = false;
end
% set any NaN to the next available value after it (conservative approach)
while any(iNaNVoltage)
iNextValue = [false; iNaNVoltage(1:end-1)];
voltage(iNaNVoltage) = voltage(iNextValue);
Expand Down Expand Up @@ -346,35 +359,35 @@

% add variables with their dimensions and data mapped
vars = {
'TIMESERIES', [], 1; ...
'LATITUDE', [], NaN; ...
'LONGITUDE', [], NaN; ...
'NOMINAL_DEPTH', [], NaN; ...
['VCUR' magExt], [1 2], vnrth; ...
['UCUR' magExt], [1 2], veast; ...
'WCUR', [1 2], wvel; ...
'CSPD', [1 2], speed; ...
['CDIR' magExt], [1 2], direction; ...
'ECUR', [1 2], evel; ...
'ABSIC1', [1 3], backscatter1; ...
'ABSIC2', [1 3], backscatter2; ...
'ABSIC3', [1 3], backscatter3; ...
'ABSIC4', [1 3], backscatter4; ...
'CMAG1', [1 3], correlation1; ...
'CMAG2', [1 3], correlation2; ...
'CMAG3', [1 3], correlation3; ...
'CMAG4', [1 3], correlation4; ...
'PERG1', [1 2], percentGood1; ...
'PERG2', [1 2], percentGood2; ...
'PERG3', [1 2], percentGood3; ...
'PERG4', [1 2], percentGood4; ...
'TEMP', 1, temperature; ...
'PRES_REL', 1, pressure; ...
'PSAL', 1, salinity; ...
'PITCH', 1, pitch; ...
'ROLL', 1, roll; ...
['HEADING' magExt], 1, heading; ...
'VOLT', 1, voltage
'TIMESERIES', [], 1, ''; ...
'LATITUDE', [], NaN, ''; ...
'LONGITUDE', [], NaN, ''; ...
'NOMINAL_DEPTH', [], NaN, ''; ...
['VCUR' magExt], [1 2], vnrth, magBiasComment; ...
['UCUR' magExt], [1 2], veast, magBiasComment; ...
'WCUR', [1 2], wvel, ''; ...
'CSPD', [1 2], speed, ''; ...
['CDIR' magExt], [1 2], direction, magBiasComment; ...
'ECUR', [1 2], evel, ''; ...
'ABSIC1', [1 3], backscatter1, ''; ...
'ABSIC2', [1 3], backscatter2, ''; ...
'ABSIC3', [1 3], backscatter3, ''; ...
'ABSIC4', [1 3], backscatter4, ''; ...
'CMAG1', [1 3], correlation1, ''; ...
'CMAG2', [1 3], correlation2, ''; ...
'CMAG3', [1 3], correlation3, ''; ...
'CMAG4', [1 3], correlation4, ''; ...
'PERG1', [1 2], percentGood1, ''; ...
'PERG2', [1 2], percentGood2, ''; ...
'PERG3', [1 2], percentGood3, ''; ...
'PERG4', [1 2], percentGood4, ''; ...
'TEMP', 1, temperature, ''; ...
'PRES_REL', 1, pressure, ''; ...
'PSAL', 1, salinity, ''; ...
'PITCH', 1, pitch, ''; ...
'ROLL', 1, roll, ''; ...
['HEADING' magExt], 1, heading, magBiasComment; ...
'VOLT', 1, voltage, voltComment
};

clear vnrth veast wvel evel speed direction backscatter1 ...
Expand All @@ -389,6 +402,8 @@
sample_data.variables{i}.name = vars{i, 1};
sample_data.variables{i}.typeCastFunc = str2func(netcdf3ToMatlabType(imosParameters(vars{i, 1}, 'type')));
sample_data.variables{i}.dimensions = vars{i, 2};
sample_data.variables{i}.data = sample_data.variables{i}.typeCastFunc(vars{i, 3});
sample_data.variables{i}.comment = vars{i, 4};

% we don't want coordinates attribute for LATITUDE, LONGITUDE and NOMINAL_DEPTH
if ~isempty(sample_data.variables{i}.dimensions)
Expand All @@ -402,13 +417,12 @@
end
end

sample_data.variables{i}.data = sample_data.variables{i}.typeCastFunc(vars{i, 3});
if strcmpi(vars{i, 1}, 'PRES_REL')
sample_data.variables{i}.applied_offset = sample_data.variables{i}.typeCastFunc(-gsw_P0/10^4); % (gsw_P0/10^4 = 10.1325 dbar)
end

if any(strcmpi(vars{i, 1}, {'VCUR', 'UCUR', 'CDIR', 'HEADING'}))
sample_data.variables{i}.compass_correction_applied = magDec;
sample_data.variables{i}.comment = magBiasComment;
end
end
clear vars;
Expand Down
19 changes: 18 additions & 1 deletion Preprocessing/rinkoDoPP.m
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,24 @@
end

else
presRel = sam.instrument_nominal_depth*ones(size(temp));
% get the toolbox execution mode
mode = readProperty('toolbox.mode');
switch mode
case 'profile'
dimIdx = getVar(sam.dimensions, 'DEPTH');
if dimIdx == 0
dimIdx = getVar(sam.dimensions, 'MAXZ');
end

case 'timeSeries'
dimIdx = getVar(sam.dimensions, 'TIME');

otherwise
return;

end

presRel = sam.instrument_nominal_depth * ones(size(sam.dimensions{dimIdx}.data));
presName = 'instrument_nominal_depth (assuming 1 m ~ 1 dbar)';
end
end
Expand Down
20 changes: 19 additions & 1 deletion Util/getPresRelForGSW.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,25 @@
presName = 'DEPTH';
else
% with nominal depth information
depth = sam.instrument_nominal_depth*ones(size(temp));

% get the toolbox execution mode
mode = readProperty('toolbox.mode');
switch mode
case 'profile'
dimIdx = getVar(sam.dimensions, 'DEPTH');
if dimIdx == 0
dimIdx = getVar(sam.dimensions, 'MAXZ');
end

case 'timeSeries'
dimIdx = getVar(sam.dimensions, 'TIME');

otherwise
return;

end

depth = sam.instrument_nominal_depth * ones(size(sam.dimensions{dimIdx}.data));
presName = 'instrument_nominal_depth';
end

Expand Down
2 changes: 1 addition & 1 deletion imosToolbox.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function imosToolbox(auto, varargin)
%

% Set current toolbox version
toolboxVersion = ['2.5.33 - ' computer];
toolboxVersion = ['2.5.34 - ' computer];

if nargin == 0, auto = 'manual'; end

Expand Down
Binary file modified imosToolbox_Linux64.bin
Binary file not shown.
Binary file modified imosToolbox_Win32.exe
Binary file not shown.
Binary file modified imosToolbox_Win64.exe
Binary file not shown.

0 comments on commit 25470a1

Please sign in to comment.