diff --git a/Graph/diagramMooring2DVarAgainstOther.m b/Graph/diagramMooring2DVarAgainstOther.m index 740c350a0..b4e5cc750 100644 --- a/Graph/diagramMooring2DVarAgainstOther.m +++ b/Graph/diagramMooring2DVarAgainstOther.m @@ -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); diff --git a/Graph/scatterMooring2DVarAgainstDepth.m b/Graph/scatterMooring2DVarAgainstDepth.m index 80d82cfde..2c23bb054 100644 --- a/Graph/scatterMooring2DVarAgainstDepth.m +++ b/Graph/scatterMooring2DVarAgainstDepth.m @@ -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); diff --git a/Parser/readBB9raw.m b/Parser/readBB9raw.m index 4a3460f88..b661b898c 100644 --- a/Parser/readBB9raw.m +++ b/Parser/readBB9raw.m @@ -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); diff --git a/Parser/readECOraw.m b/Parser/readECOraw.m index 1e987f0c7..fa756704e 100644 --- a/Parser/readECOraw.m +++ b/Parser/readECOraw.m @@ -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); diff --git a/Parser/workhorseParse.m b/Parser/workhorseParse.m index 2e4a21adc..5ab58e8a1 100644 --- a/Parser/workhorseParse.m +++ b/Parser/workhorseParse.m @@ -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; @@ -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); @@ -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 ... @@ -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) @@ -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; diff --git a/Preprocessing/rinkoDoPP.m b/Preprocessing/rinkoDoPP.m index 1cf342a58..dad6747de 100644 --- a/Preprocessing/rinkoDoPP.m +++ b/Preprocessing/rinkoDoPP.m @@ -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 diff --git a/Util/getPresRelForGSW.m b/Util/getPresRelForGSW.m index 0c0171399..65cbec41c 100644 --- a/Util/getPresRelForGSW.m +++ b/Util/getPresRelForGSW.m @@ -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 diff --git a/imosToolbox.m b/imosToolbox.m index eb8679d05..c3091c8c5 100644 --- a/imosToolbox.m +++ b/imosToolbox.m @@ -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 diff --git a/imosToolbox_Linux64.bin b/imosToolbox_Linux64.bin index 3d799104a..02cc016e1 100755 Binary files a/imosToolbox_Linux64.bin and b/imosToolbox_Linux64.bin differ diff --git a/imosToolbox_Win32.exe b/imosToolbox_Win32.exe index 3efc72af7..ef3ec6db0 100644 Binary files a/imosToolbox_Win32.exe and b/imosToolbox_Win32.exe differ diff --git a/imosToolbox_Win64.exe b/imosToolbox_Win64.exe index a4b99f1b6..080adf87a 100644 Binary files a/imosToolbox_Win64.exe and b/imosToolbox_Win64.exe differ