diff --git a/FlowManager/displayManager.m b/FlowManager/displayManager.m index 5abf03902..63ba8a899 100644 --- a/FlowManager/displayManager.m +++ b/FlowManager/displayManager.m @@ -640,7 +640,7 @@ function exportNetCDFCallback() callbacks.exportNetCDFRequestCallback(); stateSelectCallback('', panel, updateCallback, lastState, ... - sample_data, graphType, setIdx, vars, extraSetIdx); + sample_data, graphType, setIdx, vars, extraSetIdx, isFlagVisible); state = lastState; end @@ -651,7 +651,7 @@ function exportRawCallback() callbacks.exportRawRequestCallback(); stateSelectCallback('', panel, updateCallback, lastState, ... - sample_data, graphType, setIdx, vars, extraSetIdx); + sample_data, graphType, setIdx, vars, extraSetIdx, isFlagVisible); state = lastState; end end diff --git a/FlowManager/exportManager.m b/FlowManager/exportManager.m index 9bdbd8937..9b992d5c3 100644 --- a/FlowManager/exportManager.m +++ b/FlowManager/exportManager.m @@ -53,14 +53,17 @@ function exportManager(dataSets, levelNames, output, auto) if length(dataSets{k}) ~= numSets, error('data set length mismatch'); end end - suffix = ''; + extension = ''; varOpts = false; switch (output) - case 'raw', suffix = 'txt'; - case 'netcdf' - varOpts = true; - suffix = 'nc'; - otherwise, error(['unknown output type: ' output]); + case 'raw' + + case 'netcdf' + varOpts = true; + extension = '.nc'; + + otherwise + error(['unknown output type: ' output]); end % get the toolbox execution mode @@ -68,7 +71,7 @@ function exportManager(dataSets, levelNames, output, auto) setNames = cell(numSets, 1); for k = 1:numSets - setNames{k} = genIMOSFileName(dataSets{1}{k}, suffix); + setNames{k} = genIMOSFileName(dataSets{1}{k}, extension); end % prompt user for export directory, and data sets to export diff --git a/Graph/TimeSeries/setTimeSerieColorbarContextMenu.m b/Graph/TimeSeries/setTimeSerieColorbarContextMenu.m index 92abc4308..ed68a1c6e 100644 --- a/Graph/TimeSeries/setTimeSerieColorbarContextMenu.m +++ b/Graph/TimeSeries/setTimeSerieColorbarContextMenu.m @@ -68,9 +68,9 @@ uimenu(mainItem1, 'Label', 'other', 'Callback', hcb13); mainItem2 = uimenu(hMenu, 'Label', 'Color range'); - uimenu(mainItem2, 'Label', 'full, 0 centred', 'Callback', {@cbCLimRange, 'full, 0 centred', var.data}); - uimenu(mainItem2, 'Label', 'auto, 0 centred [0 +/-2*stdDev] (default)', 'Callback', {@cbCLimRange, 'auto, 0 centred', var.data}); - uimenu(mainItem2, 'Label', 'manual', 'Callback', {@cbCLimRange, 'manual', var.data}); + uimenu(mainItem2, 'Label', 'full, 0 centred (default)', 'Callback', {@cbCLimRange, 'full, 0 centred', var.data}); + uimenu(mainItem2, 'Label', 'auto, 0 centred [0 +/-2*stdDev]', 'Callback', {@cbCLimRange, 'auto, 0 centred', var.data}); + uimenu(mainItem2, 'Label', 'manual', 'Callback', {@cbCLimRange, 'manual', var.data}); case {'CDIR', 'SSWD'} % directions colormap(rkbwr); @@ -133,11 +133,11 @@ uimenu(mainItem1, 'Label', 'other', 'Callback', hcb13); mainItem2 = uimenu(hMenu, 'Label', 'Color range'); - uimenu(mainItem2, 'Label', 'full', 'Callback', {@cbCLimRange, 'full', var.data}); - uimenu(mainItem2, 'Label', 'full from 0', 'Callback', {@cbCLimRange, 'full from 0', var.data}); - uimenu(mainItem2, 'Label', 'auto [mean +/-2*stdDev]', 'Callback', {@cbCLimRange, 'auto', var.data}); - uimenu(mainItem2, 'Label', 'auto from 0 [0; mean +2*stdDev] (default)', 'Callback', {@cbCLimRange, 'auto from 0', var.data}); - uimenu(mainItem2, 'Label', 'manual', 'Callback', {@cbCLimRange, 'manual', var.data}); + uimenu(mainItem2, 'Label', 'full', 'Callback', {@cbCLimRange, 'full', var.data}); + uimenu(mainItem2, 'Label', 'full from 0 (default)', 'Callback', {@cbCLimRange, 'full from 0', var.data}); + uimenu(mainItem2, 'Label', 'auto [mean +/-2*stdDev]', 'Callback', {@cbCLimRange, 'auto', var.data}); + uimenu(mainItem2, 'Label', 'auto from 0 [0; mean +2*stdDev]', 'Callback', {@cbCLimRange, 'auto from 0', var.data}); + uimenu(mainItem2, 'Label', 'manual', 'Callback', {@cbCLimRange, 'manual', var.data}); case {'SSWV'} % [0; oo[ paremeter with special jet_w colormap % let's apply a colormap like jet but starting from white @@ -162,11 +162,11 @@ uimenu(mainItem1, 'Label', 'other', 'Callback', hcb14); mainItem2 = uimenu(hMenu, 'Label', 'Color range'); - uimenu(mainItem2, 'Label', 'full', 'Callback', {@cbCLimRange, 'full', var.data}); - uimenu(mainItem2, 'Label', 'full from 0', 'Callback', {@cbCLimRange, 'full from 0', var.data}); - uimenu(mainItem2, 'Label', 'auto [mean +/-2*stdDev]', 'Callback', {@cbCLimRange, 'auto', var.data}); - uimenu(mainItem2, 'Label', 'auto from 0 [0; mean +2*stdDev] (default)', 'Callback', {@cbCLimRange, 'auto from 0', var.data}); - uimenu(mainItem2, 'Label', 'manual', 'Callback', {@cbCLimRange, 'manual', var.data}); + uimenu(mainItem2, 'Label', 'full', 'Callback', {@cbCLimRange, 'full', var.data}); + uimenu(mainItem2, 'Label', 'full from 0 (default)', 'Callback', {@cbCLimRange, 'full from 0', var.data}); + uimenu(mainItem2, 'Label', 'auto [mean +/-2*stdDev]', 'Callback', {@cbCLimRange, 'auto', var.data}); + uimenu(mainItem2, 'Label', 'auto from 0 [0; mean +2*stdDev]', 'Callback', {@cbCLimRange, 'auto from 0', var.data}); + uimenu(mainItem2, 'Label', 'manual', 'Callback', {@cbCLimRange, 'manual', var.data}); otherwise colormap(parula); diff --git a/Graph/checkMooringPlannedDepths.m b/Graph/checkMooringPlannedDepths.m index 58a5770bc..8c714a5a9 100644 --- a/Graph/checkMooringPlannedDepths.m +++ b/Graph/checkMooringPlannedDepths.m @@ -177,7 +177,7 @@ function checkMooringPlannedDepths(sample_data, isQC, saveToFile, exportDir) %now plot all the calculated depths on one plot to choose region for comparison: %plot -fileName = genIMOSFileName(sample_data{1}, 'png'); +fileName = genIMOSFileName(sample_data{1}, '.png'); visible = 'on'; if saveToFile, visible = 'off'; end hFigPress = figure(... diff --git a/Graph/checkMooringPresDiffs.m b/Graph/checkMooringPresDiffs.m index c3e328f70..5d3134678 100644 --- a/Graph/checkMooringPresDiffs.m +++ b/Graph/checkMooringPresDiffs.m @@ -128,7 +128,7 @@ function checkMooringPresDiffs(sample_data, iSampleMenu, isQC, saveToFile, expor backgroundColor = [1 1 1]; % white %plot -fileName = genIMOSFileName(sample_data{iCurrSam}, 'png'); +fileName = genIMOSFileName(sample_data{iCurrSam}, '.png'); visible = 'on'; if saveToFile, visible = 'off'; end hFigPressDiff = figure(... diff --git a/Graph/diagramMooring1DVarAgainstOther.m b/Graph/diagramMooring1DVarAgainstOther.m index 64aaa725b..5767e28a0 100644 --- a/Graph/diagramMooring1DVarAgainstOther.m +++ b/Graph/diagramMooring1DVarAgainstOther.m @@ -203,7 +203,7 @@ function diagramMooring1DVarAgainstOther(sample_data, varName, yAxisVarName, isQ if isPlottable(i) if initiateFigure - fileName = genIMOSFileName(sample_data{iSort(i)}, 'png'); + fileName = genIMOSFileName(sample_data{iSort(i)}, '.png'); visible = 'on'; if saveToFile, visible = 'off'; end hFigMooringVar = figure(... diff --git a/Graph/diagramMooring2DVarAgainstOther.m b/Graph/diagramMooring2DVarAgainstOther.m index 711cf4ae2..6a8bd600f 100644 --- a/Graph/diagramMooring2DVarAgainstOther.m +++ b/Graph/diagramMooring2DVarAgainstOther.m @@ -273,7 +273,7 @@ function diagramMooring2DVarAgainstOther(sample_data, varName, yAxisVarName, isQ if isPlottable(i) if initiateFigure - fileName = genIMOSFileName(sample_data{iSort(i)}, 'png'); + fileName = genIMOSFileName(sample_data{iSort(i)}, '.png'); visible = 'on'; if saveToFile, visible = 'off'; end hFigMooringVar = figure(... diff --git a/Graph/lineCastVar.m b/Graph/lineCastVar.m index 37398ff82..f69a89713 100644 --- a/Graph/lineCastVar.m +++ b/Graph/lineCastVar.m @@ -115,7 +115,7 @@ function lineCastVar(sample_data, varNames, isQC, saveToFile, exportDir) if iVar > 0 if initiateFigure - fileName = genIMOSFileName(sample_data{i}, 'png'); + fileName = genIMOSFileName(sample_data{i}, '.png'); visible = 'on'; if saveToFile, visible = 'off'; end hFigCastVar = figure(... diff --git a/Graph/lineMooring1DVar.m b/Graph/lineMooring1DVar.m index d7f83963c..991e1f6a0 100644 --- a/Graph/lineMooring1DVar.m +++ b/Graph/lineMooring1DVar.m @@ -145,7 +145,7 @@ function lineMooring1DVar(sample_data, varName, isQC, saveToFile, exportDir) if iVar > 0 && size(sample_data{iSort(i)}.(typeVar){iVar}.data, 2) == 1 && ... % we're only plotting 1D variables but no current all(~strncmpi(sample_data{iSort(i)}.(typeVar){iVar}.name, {'UCUR', 'VCUR', 'WCUR', 'CDIR', 'CSPD', 'VEL1', 'VEL2', 'VEL3', 'VEL4'}, 4)) if initiateFigure - fileName = genIMOSFileName(sample_data{iSort(i)}, 'png'); + fileName = genIMOSFileName(sample_data{iSort(i)}, '.png'); visible = 'on'; if saveToFile, visible = 'off'; end hFigMooringVar = figure(... diff --git a/Graph/lineMooring2DVarSection.m b/Graph/lineMooring2DVarSection.m index e61513f6e..eb5bf1526 100644 --- a/Graph/lineMooring2DVarSection.m +++ b/Graph/lineMooring2DVarSection.m @@ -100,7 +100,7 @@ function lineMooring2DVarSection(sample_data, varName, timeValue, isQC, saveToFi if iVar > 0 if initiateFigure - fileName = genIMOSFileName(sample_data, 'png'); + fileName = genIMOSFileName(sample_data, '.png'); visible = 'on'; if saveToFile, visible = 'off'; end hFigVarSection = figure(... diff --git a/Graph/pcolorMooring2DVar.m b/Graph/pcolorMooring2DVar.m index d57bcb097..b8ab53d4f 100644 --- a/Graph/pcolorMooring2DVar.m +++ b/Graph/pcolorMooring2DVar.m @@ -140,7 +140,7 @@ function pcolorMooring2DVar(sample_data, varName, isQC, saveToFile, exportDir) size(sample_data{iSort(i)}.variables{iVar}.data, 2) > 1 && ... size(sample_data{iSort(i)}.variables{iVar}.data, 3) == 1 % we're only plotting ADCP 2D variables if initiateFigure - fileName = genIMOSFileName(sample_data{iSort(i)}, 'png'); + fileName = genIMOSFileName(sample_data{iSort(i)}, '.png'); visible = 'on'; if saveToFile, visible = 'off'; end hFigMooringVar = figure(... diff --git a/Graph/scatterMooring1DVarAgainstDepth.m b/Graph/scatterMooring1DVarAgainstDepth.m index a1dec4db7..479967938 100644 --- a/Graph/scatterMooring1DVarAgainstDepth.m +++ b/Graph/scatterMooring1DVarAgainstDepth.m @@ -182,7 +182,7 @@ function scatterMooring1DVarAgainstDepth(sample_data, varName, isQC, saveToFile, if isPlottable(i) if initiateFigure - fileName = genIMOSFileName(sample_data{iSort(i)}, 'png'); + fileName = genIMOSFileName(sample_data{iSort(i)}, '.png'); visible = 'on'; if saveToFile, visible = 'off'; end hFigMooringVar = figure(... diff --git a/Graph/scatterMooring2DVarAgainstDepth.m b/Graph/scatterMooring2DVarAgainstDepth.m index ed608e6bd..0b3d0176d 100644 --- a/Graph/scatterMooring2DVarAgainstDepth.m +++ b/Graph/scatterMooring2DVarAgainstDepth.m @@ -240,7 +240,7 @@ function scatterMooring2DVarAgainstDepth(sample_data, varName, isQC, saveToFile, if isPlottable(i) if initiateFigure - fileName = genIMOSFileName(sample_data{iSort(i)}, 'png'); + fileName = genIMOSFileName(sample_data{iSort(i)}, '.png'); visible = 'on'; if saveToFile, visible = 'off'; end hFigMooringVar = figure(... diff --git a/IMOS/genIMOSFileName.m b/IMOS/genIMOSFileName.m index 8de61643b..8d062416a 100644 --- a/IMOS/genIMOSFileName.m +++ b/IMOS/genIMOSFileName.m @@ -1,15 +1,15 @@ -function filename = genIMOSFileName( sample_data, suffix ) +function filename = genIMOSFileName( sample_data, extension ) %GENIMOSFILENAME Generates an IMOS file name for the given data set. % % Generates a file name for the given data set. The file name is generated -% according to the IMOS NetCDF File Naming Convention, version 1.3. Values +% according to the IMOS NetCDF File Naming Convention, version 1.4. Values % for each field are retrieved from the imosFileName.txt configuration % file. Any fields which are not present, or not set in this file are given % a default value. % % Inputs: % sample_data - the data set to generate a file name for. -% suffix - file name suffix to use. +% extension - file extension to use. % % Outputs: % filename - the generated file name. @@ -39,7 +39,7 @@ narginchk(2,2); if ~isstruct(sample_data), error('sample_data must be a struct'); end - if ~ischar(suffix), error('suffix must be a string'); end + if ~ischar(extension), error('extension must be a string'); end % % all dates should be in ISO 8601 format @@ -56,7 +56,7 @@ switch mode case 'profile' % build the file name - if strcmpi(suffix, 'png') + if strcmpi(extension, '.png') filename = [sample_data.naming_authority '_']; filename = [filename getVal(fileCfg, defCfg, 'facility_code') '_']; filename = [filename getVal(fileCfg, defCfg, 'site_code') '_']; @@ -75,7 +75,7 @@ end case 'timeSeries' % build the file name - if strcmpi(suffix, 'png') + if strcmpi(extension, '.png') filename = [sample_data.naming_authority '_']; filename = [filename getVal(fileCfg, defCfg, 'facility_code') '_']; filename = [filename getVal(fileCfg, defCfg, 'platform_code') '_']; @@ -104,10 +104,13 @@ end % it is assumed that the suffix is valid - filename = [filename '.' suffix]; + if isempty(extension) % for export of raw datasets, we retain the original suffix + [~, ~, extension] = fileparts(sample_data.toolbox_input_file); + end + filename = [filename extension]; % we handle the case when the source file is a NetCDF file. - if isfield(sample_data.meta, 'file_name') && strcmpi(suffix, 'nc') + if isfield(sample_data.meta, 'file_name') && strcmpi(extension, '.nc') filename = sample_data.meta.file_name; % we need to update the creation_date diff --git a/NetCDF/exportNetCDF.m b/NetCDF/exportNetCDF.m index de6c1440a..5a0007702 100644 --- a/NetCDF/exportNetCDF.m +++ b/NetCDF/exportNetCDF.m @@ -47,7 +47,7 @@ end % generate the filename - filename = genIMOSFileName(sample_data, 'nc'); + filename = genIMOSFileName(sample_data, '.nc'); filename = [dest filesep filename]; compressionLevel = 1; % it seems the compression level 1 gives the best ration size/cpu diff --git a/Parser/aquadoppProfilerParse.m b/Parser/aquadoppProfilerParse.m index 3a0af17b6..3d7746ecd 100644 --- a/Parser/aquadoppProfilerParse.m +++ b/Parser/aquadoppProfilerParse.m @@ -293,7 +293,6 @@ 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 % velocity has been processed iDimVel = nDims-1; @@ -302,14 +301,28 @@ iDimVel = nDims; iDimDiag = nDims; end +switch user.CoordSystem + case 0 % ENU + vel2Name = 'VCUR_MAG'; % we assume no correction for magnetic declination has been applied + vel1Name = 'UCUR_MAG'; + vel3Name = 'WCUR'; + + case 2 % Beam + vel2Name = 'VEL2'; + vel1Name = 'VEL1'; + vel3Name = 'VEL3'; + + otherwise + error([mfilename ' only supports ENU and Beam coordinate systems']); +end vars = { 'TIMESERIES', [], 1;... 'LATITUDE', [], NaN; ... 'LONGITUDE', [], NaN; ... 'NOMINAL_DEPTH', [], NaN; ... - 'VCUR_MAG', [1 iDimVel], velocity2; ... % V - 'UCUR_MAG', [1 iDimVel], velocity1; ... % U - 'WCUR', [1 iDimVel], velocity3; ... + vel2Name, [1 iDimVel], velocity2; ... + vel1Name, [1 iDimVel], velocity1; ... + vel3Name, [1 iDimVel], velocity3; ... 'ABSIC1', [1 iDimDiag], backscatter1; ... 'ABSIC2', [1 iDimDiag], backscatter2; ... 'ABSIC3', [1 iDimDiag], backscatter3; ... diff --git a/Parser/aquadoppVelocityParse.m b/Parser/aquadoppVelocityParse.m index c3ac578ec..27561c381 100644 --- a/Parser/aquadoppVelocityParse.m +++ b/Parser/aquadoppVelocityParse.m @@ -151,15 +151,28 @@ 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 +switch user.CoordSystem + case 0 % ENU + vel2Name = 'VCUR_MAG'; % we assume no correction for magnetic declination has been applied + vel1Name = 'UCUR_MAG'; + vel3Name = 'WCUR'; + + case 2 % Beam + vel2Name = 'VEL2'; + vel1Name = 'VEL1'; + vel3Name = 'VEL3'; + + otherwise + error([mfilename ' only supports ENU and Beam coordinate systems']); +end vars = { 'TIMESERIES', [], 1;... 'LATITUDE', [], NaN; ... 'LONGITUDE', [], NaN; ... 'NOMINAL_DEPTH', [], NaN; ... - 'VCUR_MAG', 1, velocity2; ... % V - 'UCUR_MAG', 1, velocity1; ... % U - 'WCUR', 1, velocity3; ... + vel2Name, 1, velocity2; ... + vel1Name, 1, velocity1; ... + vel3Name, 1, velocity3; ... 'ABSIC1', 1, backscatter1; ... 'ABSIC2', 1, backscatter2; ... 'ABSIC3', 1, backscatter3; ... diff --git a/Parser/awacParse.m b/Parser/awacParse.m index 05fdb4101..67b755b81 100644 --- a/Parser/awacParse.m +++ b/Parser/awacParse.m @@ -261,7 +261,6 @@ 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 % velocity has been processed iDimVel = nDims-1; @@ -270,14 +269,28 @@ iDimVel = nDims; iDimDiag = nDims; end +switch user.CoordSystem + case 0 % ENU + vel2Name = 'VCUR_MAG'; % we assume no correction for magnetic declination has been applied + vel1Name = 'UCUR_MAG'; + vel3Name = 'WCUR'; + + case 2 % Beam + vel2Name = 'VEL2'; + vel1Name = 'VEL1'; + vel3Name = 'VEL3'; + + otherwise + error([mfilename ' only supports ENU and Beam coordinate systems']); +end vars = { 'TIMESERIES', [], 1; ... 'LATITUDE', [], NaN; ... 'LONGITUDE', [], NaN; ... 'NOMINAL_DEPTH', [], NaN; ... - 'VCUR_MAG', [1 iDimVel], velocity2; ... % V - 'UCUR_MAG', [1 iDimVel], velocity1; ... % U - 'WCUR', [1 iDimVel], velocity3; ... + vel2Name, [1 iDimVel], velocity2; ... + vel1Name, [1 iDimVel], velocity1; ... + vel3Name, [1 iDimVel], velocity3; ... 'ABSIC1', [1 iDimDiag], backscatter1; ... 'ABSIC2', [1 iDimDiag], backscatter2; ... 'ABSIC3', [1 iDimDiag], backscatter3; ... diff --git a/Parser/continentalParse.m b/Parser/continentalParse.m index 6b4252f39..d5cda2ec2 100644 --- a/Parser/continentalParse.m +++ b/Parser/continentalParse.m @@ -260,7 +260,6 @@ 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 % velocity has been processed iDimVel = nDims-1; @@ -269,14 +268,28 @@ iDimVel = nDims; iDimDiag = nDims; end +switch user.CoordSystem + case 0 % ENU + vel2Name = 'VCUR_MAG'; % we assume no correction for magnetic declination has been applied + vel1Name = 'UCUR_MAG'; + vel3Name = 'WCUR'; + + case 2 % Beam + vel2Name = 'VEL2'; + vel1Name = 'VEL1'; + vel3Name = 'VEL3'; + + otherwise + error([mfilename ' only supports ENU and Beam coordinate systems']); +end vars = { 'TIMESERIES', [], 1; ... 'LATITUDE', [], NaN; ... 'LONGITUDE', [], NaN; ... 'NOMINAL_DEPTH', [], NaN; ... - 'VCUR_MAG', [1 iDimVel], velocity2; ... % V - 'UCUR_MAG', [1 iDimVel], velocity1; ... % U - 'WCUR', [1 iDimVel], velocity3; ... + vel2Name, [1 iDimVel], velocity2; ... + vel1Name, [1 iDimVel], velocity1; ... + vel3Name, [1 iDimVel], velocity3; ... 'ABSIC1', [1 iDimDiag], backscatter1; ... 'ABSIC2', [1 iDimDiag], backscatter2; ... 'ABSIC3', [1 iDimDiag], backscatter3; ... diff --git a/Preprocessing/adcpNortekVelocityEnu2BeamPP.m b/Preprocessing/adcpNortekVelocityEnu2BeamPP.m index 3dca0401e..60d5800a3 100644 --- a/Preprocessing/adcpNortekVelocityEnu2BeamPP.m +++ b/Preprocessing/adcpNortekVelocityEnu2BeamPP.m @@ -76,7 +76,7 @@ % do not process if more than 3 beams absic4Idx = getVar(sample_data{k}.variables, 'ABSIC4'); - if absic4Idx continue; end + if absic4Idx, continue; end ucur = sample_data{k}.variables{ucurIdx}.data; vcur = sample_data{k}.variables{vcurIdx}.data; diff --git a/Preprocessing/magneticDeclinationPP.m b/Preprocessing/magneticDeclinationPP.m index dbe4bd0dc..dca011d23 100644 --- a/Preprocessing/magneticDeclinationPP.m +++ b/Preprocessing/magneticDeclinationPP.m @@ -212,9 +212,7 @@ % we apply the modifications to the data and metadata paramName = sample_data{iMagDataSet(i)}.variables{j}.name(1:end-4); sample_data{iMagDataSet(i)}.variables{j}.name = paramName; - sample_data{iMagDataSet(i)}.variables{j}.standard_name = ''; - sample_data{iMagDataSet(i)}.variables{j}.long_name = ''; - sample_data{iMagDataSet(i)}.variables{j}.units = ''; + sample_data{iMagDataSet(i)}.variables{j}.reference_datum = ''; % will be updated by makeNetCDFCompliant sample_data{iMagDataSet(i)}.variables{j}.data = data; sample_data{iMagDataSet(i)}.variables{j}.magnetic_declination = geomagDeclin(i); sample_data{iMagDataSet(i)}.variables{j}.compass_correction_applied = geomagDeclin(i); diff --git a/Preprocessing/salinityPP.m b/Preprocessing/salinityPP.m index eb9c4b6ef..6356eb934 100644 --- a/Preprocessing/salinityPP.m +++ b/Preprocessing/salinityPP.m @@ -77,7 +77,7 @@ psal = gsw_SP_from_R(R, temp, presRel); dimensions = sam.variables{tempIdx}.dimensions; - salinityComment = ['salinityPP.m: derived from CNDC, TEMP and ' zName ' ' zComment ' using the Gibbs-SeaWater toolbox (TEOS-10) v3.06']; + salinityComment = ['salinityPP.m: derived from CNDC, TEMP and ' zName ' ' zComment ' using the Gibbs-SeaWater toolbox (TEOS-10) v3.06.']; if isfield(sam.variables{tempIdx}, 'coordinates') coordinates = sam.variables{tempIdx}.coordinates; diff --git a/Preprocessing/velocityMagDirPP.m b/Preprocessing/velocityMagDirPP.m new file mode 100644 index 000000000..136aaad0f --- /dev/null +++ b/Preprocessing/velocityMagDirPP.m @@ -0,0 +1,107 @@ +function sample_data = velocityMagDirPP( sample_data, qcLevel, auto ) +%VELOCITYMAGDIRPP Adds CSPD and CDIR variables to the given data sets, if they +% contain UCUR and VCUR variables. +% +% This function uses trigonometry functions to derive the sea water +% velocity direction and speed data from the meridional and zonal sea water +% velocity speed. It adds the sea water velocity magnitude and direction data +% as new variables in the data sets. Data sets which do not contain +% UCUR and VCUR variables or which already contain CSPD and CDIR are left unmodified. +% +% Inputs: +% sample_data - cell array of data sets, ideally with UCUR and VCUR. +% qcLevel - string, 'raw' or 'qc'. Some pp not applied when 'raw'. +% auto - logical, run pre-processing in batch mode. +% +% Outputs: +% sample_data - the same data sets, with CSPD and CDIR variables added. +% +% Author: Guillaume Galibert +% + +% +% Copyright (C) 2017, 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 . +% +narginchk(2, 3); + +if ~iscell(sample_data), error('sample_data must be a cell array'); end +if isempty(sample_data), return; end + +% no modification of data is performed on the raw FV00 dataset except +% local time to UTC conversion +if strcmpi(qcLevel, 'raw'), return; end + +% auto logical in input to enable running under batch processing +if nargin<3, auto=false; end + +for k = 1:length(sample_data) + + sam = sample_data{k}; + + % data set already contains CSPD or CDIR + if getVar(sam.variables, 'CSPD') || getVar(sam.variables, 'CDIR'), continue; end + + ucurIdx = getVar(sam.variables, 'UCUR'); + vcurIdx = getVar(sam.variables, 'VCUR'); + + % UCUR or VCUR not present in data set + if ~(ucurIdx && vcurIdx), continue; end + + ucur = sam.variables{ucurIdx}.data; + vcur = sam.variables{vcurIdx}.data; + + % calculate magnitude + cspd = sqrt(ucur.^2 + vcur.^2); + + % calculate direction + cdir = atan2(vcur, ucur) * 180/pi; % atan2 goes positive anti-clockwise with 0 on the right side + cdir = -cdir + 90; % we want to go positive clockwise with 0 on the top side + cdir = cdir + 360*(cdir < 0); % we shift +360 for whatever is left negative + + dimensions = sam.variables{ucurIdx}.dimensions; + comment = 'velocityMagDirPP.m: CSPD and CDIR were derived from UCUR and VCUR.'; + + if isfield(sam.variables{ucurIdx}, 'coordinates') + coordinates = sam.variables{ucurIdx}.coordinates; + else + coordinates = ''; + end + + % add CSPD and CDIR data as new variable in data set + sample_data{k} = addVar(... + sample_data{k}, ... + 'CSPD', ... + cspd, ... + dimensions, ... + comment, ... + coordinates); + + sample_data{k} = addVar(... + sample_data{k}, ... + 'CDIR', ... + cdir, ... + dimensions, ... + comment, ... + coordinates); + + history = sample_data{k}.history; + if isempty(history) + sample_data{k}.history = sprintf('%s - %s', datestr(now_utc, readProperty('exportNetCDF.dateFormat')), comment); + else + sample_data{k}.history = sprintf('%s\n%s - %s', history, datestr(now_utc, readProperty('exportNetCDF.dateFormat')), comment); + end +end diff --git a/imosToolbox.m b/imosToolbox.m index 4119fe728..512c99282 100644 --- a/imosToolbox.m +++ b/imosToolbox.m @@ -37,7 +37,7 @@ function imosToolbox(auto, varargin) % % Set current toolbox version -toolboxVersion = ['2.5.39 - ' computer]; +toolboxVersion = ['2.5.40 - ' computer]; if nargin == 0, auto = 'manual'; end diff --git a/imosToolbox_Linux64.bin b/imosToolbox_Linux64.bin index a57abb5ac..1c9f38d69 100755 Binary files a/imosToolbox_Linux64.bin and b/imosToolbox_Linux64.bin differ diff --git a/imosToolbox_Win32.exe b/imosToolbox_Win32.exe index e1b7c349e..09b09ccae 100644 Binary files a/imosToolbox_Win32.exe and b/imosToolbox_Win32.exe differ diff --git a/imosToolbox_Win64.exe b/imosToolbox_Win64.exe index 015468a14..95ca8337a 100644 Binary files a/imosToolbox_Win64.exe and b/imosToolbox_Win64.exe differ diff --git a/toolboxProperties.txt b/toolboxProperties.txt index 5c236c85a..1f39e3f0d 100644 --- a/toolboxProperties.txt +++ b/toolboxProperties.txt @@ -48,11 +48,11 @@ autoQCManager.autoQCChain.profile = imosImpossibleDateQC imosImpossibleLocationS preprocessManager.preprocessPrompt = true % default set of preprocessing routines -preprocessManager.preprocessDefaultChain.timeSeries = depthPP salinityPP oxygenPP magneticDeclinationPP absiDecibelBasicPP adcpNortekVelocityEnu2BeamPP adcpBinMappingPP adcpNortekVelocityBeam2EnuPP +preprocessManager.preprocessDefaultChain.timeSeries = depthPP salinityPP oxygenPP absiDecibelBasicPP adcpNortekVelocityEnu2BeamPP adcpBinMappingPP adcpNortekVelocityBeam2EnuPP magneticDeclinationPP velocityMagDirPP preprocessManager.preprocessDefaultChain.profile = depthPP salinityPP oxygenPP % last selected set of preprocessing routines -preprocessManager.preprocessChain.timeSeries = depthPP salinityPP oxygenPP magneticDeclinationPP absiDecibelBasicPP adcpNortekVelocityEnu2BeamPP adcpBinMappingPP adcpNortekVelocityBeam2EnuPP +preprocessManager.preprocessChain.timeSeries = depthPP salinityPP oxygenPP absiDecibelBasicPP adcpNortekVelocityEnu2BeamPP adcpBinMappingPP adcpNortekVelocityBeam2EnuPP magneticDeclinationPP velocityMagDirPP preprocessManager.preprocessChain.profile = depthPP salinityPP oxygenPP % file status dialog formatting styles