diff --git a/Preprocessing/depthPP.m b/Preprocessing/depthPP.m index d6d76ff65..e1b6442d9 100644 --- a/Preprocessing/depthPP.m +++ b/Preprocessing/depthPP.m @@ -568,6 +568,12 @@ dimensions, ... computedDepthComment, ... coordinates); + + % update vertical min/max from new computed DEPTH + sample_data{k}.geospatial_vertical_min = min(computedDepth); + sample_data{k}.geospatial_vertical_max = max(computedDepth); + sample_data{k}.comment = strrep(sample_data{k}.comment, 'NOMINAL_DEPTH', 'DEPTH min and max'); + clear computedDepth; history = sample_data{k}.history; @@ -591,8 +597,6 @@ end end - - % update vertical min/max from new computed DEPTH - sample_data{k} = populateMetadata(sample_data{k}); + clear curSam; end diff --git a/Preprocessing/salinityPP.m b/Preprocessing/salinityPP.m index 7399f3c8d..4ec5a3d6c 100644 --- a/Preprocessing/salinityPP.m +++ b/Preprocessing/salinityPP.m @@ -125,6 +125,10 @@ presName = 'instrument_nominal_depth'; end + % any depth values <= -5 are discarded (reminder, depth is + % positive down), this allow use of gsw_p_from_z without error. + depth(depth <= -5) = NaN; + % pressure information needed for Salinity computation is either % retrieved from gsw_p_from_z when latitude is available or by % simply assuming 1dbar ~= 1m diff --git a/Util/populateMetadata.m b/Util/populateMetadata.m index c92dd6913..5f5e57eb7 100644 --- a/Util/populateMetadata.m +++ b/Util/populateMetadata.m @@ -143,159 +143,26 @@ metadataChanged = true; else - % Update from PRES if available - if ivPres > 0 || ivPresRel > 0 - if ivPresRel == 0 - % update from a relative pressure like SeaBird computes - % it in its processed files, substracting a constant value - % 10.1325 dbar for nominal atmospheric pressure - relPres = sample_data.variables{ivPres}.data - gsw_P0/10^4; - presComment = ['absolute '... - 'pressure measurements to which a nominal '... - 'value for atmospheric pressure (10.1325 dbar) '... - 'has been substracted']; - iNanRelPres = isnan(relPres); - else - % update from a relative measured pressure - relPres = sample_data.variables{ivPresRel}.data; - presComment = ['relative '... - 'pressure measurements (calibration offset '... - 'usually performed to balance current '... - 'atmospheric pressure and acute sensor '... - 'precision at a deployed depth)']; - iNanRelPres = isnan(relPres); - end - if ~isempty(sample_data.geospatial_lat_min) && ~isempty(sample_data.geospatial_lat_max) - % compute vertical min/max with Gibbs-SeaWater toolbox (TEOS-10) - if sample_data.geospatial_lat_min == sample_data.geospatial_lat_max - computedDepth = - gsw_z_from_p(relPres, ... - sample_data.geospatial_lat_min); - computedMinDepth = - gsw_z_from_p(min(relPres(~iNanRelPres)), ... - sample_data.geospatial_lat_min); - computedMaxDepth = - gsw_z_from_p(max(relPres(~iNanRelPres)), ... - sample_data.geospatial_lat_min); - computedDepthComment = ['depthPP: Depth computed using the '... - 'Gibbs-SeaWater toolbox (TEOS-10) v3.05 from latitude and '... - presComment '.']; - else - meanLat = sample_data.geospatial_lat_min + ... - (sample_data.geospatial_lat_max - sample_data.geospatial_lat_min)/2; - - computedDepth = - gsw_z_from_p(relPres, meanLat); - computedMinDepth = - gsw_z_from_p(min(relPres(~iNanRelPres)), meanLat); - computedMaxDepth = - gsw_z_from_p(max(relPres(~iNanRelPres)), meanLat); - computedDepthComment = ['depthPP: Depth computed using the '... - 'Gibbs-SeaWater toolbox (TEOS-10) v3.05 from mean latitude and '... - presComment '.']; - end - else - % without latitude information, we assume 1dbar ~= 1m - computedDepth = relPres; - computedMinDepth = min(relPres(~iNanRelPres)); - computedMaxDepth = max(relPres(~iNanRelPres)); - computedDepthComment = ['depthPP: Depth computed from '... - presComment ', assuming 1dbar ~= 1m.']; - end + % Update from NOMINAL_DEPTH if available + if ivNomDepth > 0 + % Update from NOMINAL_DEPTH data + dataNominalDepth = sample_data.variables{ivNomDepth}.data; + iNan = isnan(dataNominalDepth); + dataNominalDepth = dataNominalDepth(~iNan); - if idHeight > 0 - % ADCP - if all(sample_data.dimensions{idHeight}.data >= 0) % upward looking configuration - maxDistance = max(sample_data.dimensions{idHeight}.data); % HEIGHT_ABOVE_SENSOR is positive when upward - % update vertical min/max metadata from data - % we assume that depth data is reliable - if isempty(sample_data.geospatial_vertical_min) && isempty(sample_data.geospatial_vertical_max) - - sample_data.geospatial_vertical_min = computedMinDepth - maxDistance; - sample_data.geospatial_vertical_max = computedMaxDepth; - comment = computedDepthComment; - - if isempty(sample_data.comment) - sample_data.comment = comment; - elseif ~strcmpi(sample_data.comment, comment) - sample_data.comment = [sample_data.comment ' ' comment]; - end - - metadataChanged = true; - end - else % downward looking configuration - maxDistance = - min(sample_data.dimensions{idHeight}.data); % HEIGHT_ABOVE_SENSOR is negative when downward - % update vertical min/max metadata from data - % we assume that depth data is reliable - if isempty(sample_data.geospatial_vertical_min) && isempty(sample_data.geospatial_vertical_max) - - sample_data.geospatial_vertical_min = computedMinDepth; - sample_data.geospatial_vertical_max = computedMaxDepth + maxDistance; - comment = computedDepthComment; - - if isempty(sample_data.comment) - sample_data.comment = comment; - elseif ~strcmpi(sample_data.comment, comment) - sample_data.comment = [sample_data.comment ' ' comment]; - end - - metadataChanged = true; - end - end - else - % Not an ADCP, so we can update existing DEPTH dimension/variable from PRES data - if idDepth > 0 - sample_data.dimensions{idDepth}.data = sample_data.dimensions{idDepth}.typeCastFunc(computedDepth); - comment = sample_data.dimensions{idDepth}.comment; - if isempty(comment) - sample_data.dimensions{idDepth}.comment = computedDepthComment; - elseif ~strcmpi(computedDepthComment, comment) - sample_data.dimensions{idDepth}.comment = [comment ' ' computedDepthComment]; - end - metadataChanged = true; - end - if ivDepth > 0 - sample_data.variables{ivDepth}.data = sample_data.variables{ivDepth}.typeCastFunc(computedDepth); - comment = sample_data.variables{ivDepth}.comment; - if isempty(comment) - sample_data.variables{ivDepth}.comment = computedDepthComment; - elseif ~strcmpi(computedDepthComment, comment) - sample_data.variables{ivDepth}.comment = [comment ' ' computedDepthComment]; - end - metadataChanged = true; - end + verticalComment = ['Geospatial vertical min/max information has '... + 'been filled using the NOMINAL_DEPTH.']; - if isempty(sample_data.geospatial_vertical_min) && isempty(sample_data.geospatial_vertical_max) - - sample_data.geospatial_vertical_min = computedMinDepth; - sample_data.geospatial_vertical_max = computedMaxDepth; - comment = computedDepthComment; - - metadataChanged = true; - - if isempty(sample_data.comment) - sample_data.comment = comment; - elseif ~strcmpi(sample_data.comment, comment) - sample_data.comment = [sample_data.comment ' ' comment]; - end - end - end - else - % Update from NOMINAL_DEPTH if available - if ivNomDepth > 0 - % Update from NOMINAL_DEPTH data - dataNominalDepth = sample_data.variables{ivNomDepth}.data; - iNan = isnan(dataNominalDepth); - dataNominalDepth = dataNominalDepth(~iNan); - - verticalComment = ['Geospatial vertical min/max information has '... - 'been filled using the NOMINAL_DEPTH.']; - - sample_data.geospatial_vertical_min = dataNominalDepth; - sample_data.geospatial_vertical_max = dataNominalDepth; - - if isempty(sample_data.comment) - sample_data.comment = verticalComment; - elseif ~strcmpi(sample_data.comment, verticalComment) - sample_data.comment = [sample_data.comment ' ' verticalComment]; - end - - metadataChanged = true; + sample_data.geospatial_vertical_min = dataNominalDepth; + sample_data.geospatial_vertical_max = dataNominalDepth; + + if isempty(sample_data.comment) + sample_data.comment = verticalComment; + elseif ~strcmpi(sample_data.comment, verticalComment) + sample_data.comment = [sample_data.comment ' ' verticalComment]; end + + metadataChanged = true; end end diff --git a/imosToolbox.m b/imosToolbox.m index c81683d3f..922b950ec 100644 --- a/imosToolbox.m +++ b/imosToolbox.m @@ -73,7 +73,7 @@ function imosToolbox(auto, varargin) end % Set current toolbox version -toolboxVersion = ['2.5.18 - ' computer]; +toolboxVersion = ['2.5.19 - ' computer]; switch auto case 'auto', autoIMOSToolbox(toolboxVersion, varargin{:}); diff --git a/imosToolbox_Linux64.bin b/imosToolbox_Linux64.bin index a756223ec..daca016a4 100755 Binary files a/imosToolbox_Linux64.bin and b/imosToolbox_Linux64.bin differ diff --git a/imosToolbox_Win32.exe b/imosToolbox_Win32.exe index fad15ad1d..d383b00d3 100644 Binary files a/imosToolbox_Win32.exe and b/imosToolbox_Win32.exe differ diff --git a/imosToolbox_Win64.exe b/imosToolbox_Win64.exe index b75ffcbad..3776a3ad6 100644 Binary files a/imosToolbox_Win64.exe and b/imosToolbox_Win64.exe differ