Skip to content

Commit

Permalink
Merge pull request #381 from aodn/2.5.18
Browse files Browse the repository at this point in the history
2.5.18
  • Loading branch information
ggalibert authored Oct 27, 2016
2 parents b97e0f9 + 27d2ae2 commit 65452f9
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 36 deletions.
2 changes: 1 addition & 1 deletion IMOS/imosParameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ DIR, 0, from_direction,
DIR_MAG, 0, from_direction, degree, clockwise, magnetic north, E, 999999.0, 0.0, 360.0, float
DIRECTION, 0, direction_of_the_profile, , , , , , , , char
DIRT, 0, to_direction, degree, clockwise, true north, E, 999999.0, 0.0, 360.0, float
DIST_ALONG_BEAMS, 0, distance_from_sensor_along_beams, m, up, sensor, Z, 999999.0, -12000.0, 12000.0, float
DIST_ALONG_BEAMS, 0, distance_from_sensor_along_beams, m, , sensor, Z, 999999.0, -12000.0, 12000.0, float
DOX1, 1, mole_concentration_of_dissolved_molecular_oxygen_in_sea_water, umol l-1, , , O, 999999.0, 0.0, 900000.0, float
DOX2, 1, moles_of_oxygen_per_unit_mass_in_sea_water, umol kg-1, , , O, 999999.0, 0.0, 880000.0, float
DOXS, 1, fractional_saturation_of_oxygen_in_sea_water, percent, , , O, 999999.0, , , float
Expand Down
2 changes: 1 addition & 1 deletion NetCDF/template/dist_along_beams_attributes.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
S, standard_name = [mat imosParameters('DIST_ALONG_BEAMS', 'standard_name')]
S, long_name = distance_from_sensor_along_beams
S, units = [mat imosParameters('DIST_ALONG_BEAMS', 'uom')]
S, axis = Z
S, axis =
S, positive = [mat imosParameters('DIST_ALONG_BEAMS', 'positive')]
S, reference_datum = [mat imosParameters('DIST_ALONG_BEAMS', 'reference_datum')]
N, valid_min = [mat imosParameters('DIST_ALONG_BEAMS', 'valid_min')]
Expand Down
5 changes: 4 additions & 1 deletion Preprocessing/CTDDepthBinPP.m
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@
zend = zbin(2:end);

z = (zstart + zend)/2; % depth of the actual centre of each bin
curSam.dimensions{iDepth}.data = z(:);

curSam.dimensions{iDepth}.data = z(:); % update dimension and global attribute values
curSam.geospatial_vertical_min = min(z(:));
curSam.geospatial_vertical_max = max(z(:));

[Z, ZSTART] = meshgrid(depth, zstart);
[~, ZEND] = meshgrid(depth, zend);
Expand Down
49 changes: 38 additions & 11 deletions Preprocessing/adcpBinMappingPP.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,10 @@
% impacted parameter
isBinMapApplied = false;
for j=1:length(sample_data{k}.variables)
if any(sample_data{k}.variables{j}.dimensions == distAlongBeamsIdx) ... % only process variables that are function of DIST_ALONG_BEAMS
if any(sample_data{k}.variables{j}.dimensions == distAlongBeamsIdx) % only process variables that are function of DIST_ALONG_BEAMS

beamNumber = sample_data{k}.variables{j}.name(end);
% only process variables that are in beam coordinates
beamNumber = sample_data{k}.variables{j}.long_name(end);
switch beamNumber
case '1'
nonMappedHeightAboveSensor = nonMappedHeightAboveSensorBeam1;
Expand Down Expand Up @@ -187,23 +188,26 @@
% mappedData(i,iLastGoodBin) = interp1(nonMappedHeightAboveSensor(i,:), nonMappedData(i,:), mappedHeightAboveSensor(i,iLastGoodBin), 'spline');
end

binMappingComment = ['adcpBinMappingPP.m: data in beam coordinates originally referenced to DISTANCE_ALONG_BEAMS ' ...
binMappingComment = ['adcpBinMappingPP.m: data in beam coordinates originally referenced to DIST_ALONG_BEAMS ' ...
'has been vertically bin-mapped to HEIGHT_ABOVE_SENSOR using tilt information.'];

% we create the HEIGHT_ABOVE_SENSOR dimension if needed
if ~heightAboveSensorIdx
sample_data{k}.dimensions{end+1} = sample_data{k}.dimensions{distAlongBeamsIdx};
sample_data{k}.dimensions{end}.name = 'HEIGHT_ABOVE_SENSOR';
sample_data{k}.dimensions{end}.long_name = 'height_above_sensor';
sample_data{k}.dimensions{end}.axis = 'Z';
sample_data{k}.dimensions{end}.positive = 'up';
sample_data{k}.dimensions{end}.comment = ['Data has been vertically bin-mapped using tilt information so that the cells ' ...
% we create the HEIGHT_ABOVE_SENSOR dimension if needed
sample_data{k}.dimensions{end+1} = sample_data{k}.dimensions{distAlongBeamsIdx};

% attributes units, reference_datum, valid_min/max and _FillValue are the same as with DIST_ALONG_BEAMS, the rest differs
sample_data{k}.dimensions{end}.name = 'HEIGHT_ABOVE_SENSOR';
sample_data{k}.dimensions{end}.long_name = 'height_above_sensor';
sample_data{k}.dimensions{end}.standard_name = imosParameters('HEIGHT_ABOVE_SENSOR', 'standard_name');
sample_data{k}.dimensions{end}.axis = 'Z';
sample_data{k}.dimensions{end}.positive = imosParameters('HEIGHT_ABOVE_SENSOR', 'positive');
sample_data{k}.dimensions{end}.comment = ['Data has been vertically bin-mapped using tilt information so that the cells ' ...
'have consistant heights above sensor in time.'];

heightAboveSensorIdx = getVar(sample_data{k}.dimensions, 'HEIGHT_ABOVE_SENSOR');
end

% we re-assign the parameter to this dimension
% we re-assign the parameter to the HEIGHT_ABOVE_SENSOR dimension
sample_data{k}.variables{j}.dimensions(sample_data{k}.variables{j}.dimensions == distAlongBeamsIdx) = heightAboveSensorIdx;

sample_data{k}.variables{j}.data = mappedData;
Expand All @@ -220,6 +224,29 @@
end

if isBinMapApplied
% let's look for remaining variables assigned to DIST_ALONG_BEAMS,
% if none we can remove this dimension (RDI for example)
isDistAlongBeamsUsed = false;
for j=1:length(sample_data{k}.variables)
if any(sample_data{k}.variables{j}.dimensions == distAlongBeamsIdx)
isDistAlongBeamsUsed = true;
break;
end
end
if ~isDistAlongBeamsUsed
if length(sample_data{k}.dimensions) > distAlongBeamsIdx
for j=1:length(sample_data{k}.variables)
dimToUpdate = sample_data{k}.variables{j}.dimensions > distAlongBeamsIdx;
if any(dimToUpdate)
sample_data{k}.variables{j}.dimensions(dimToUpdate) = sample_data{k}.variables{j}.dimensions(dimToUpdate) - 1;
end
end
end
sample_data{k}.dimensions(distAlongBeamsIdx) = [];

binMappingComment = [binMappingComment ' DIST_ALONG_BEAMS is not used by any variable left and has been removed.'];
end

history = sample_data{k}.history;
if isempty(history)
sample_data{k}.history = sprintf('%s - %s', datestr(now_utc, readProperty('exportNetCDF.dateFormat')), binMappingComment);
Expand Down
23 changes: 23 additions & 0 deletions Preprocessing/adcpNortekVelocityBeam2EnuPP.m
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,29 @@
end
end

% let's look for remaining variables assigned to DIST_ALONG_BEAMS,
% if none we can remove this dimension
isDistAlongBeamsUsed = false;
for j=1:length(sample_data{k}.variables)
if any(sample_data{k}.variables{j}.dimensions == distAlongBeamsIdx)
isDistAlongBeamsUsed = true;
break;
end
end
if ~isDistAlongBeamsUsed
if length(sample_data{k}.dimensions) > distAlongBeamsIdx
for j=1:length(sample_data{k}.variables)
dimToUpdate = sample_data{k}.variables{j}.dimensions > distAlongBeamsIdx;
if any(dimToUpdate)
sample_data{k}.variables{j}.dimensions(dimToUpdate) = sample_data{k}.variables{j}.dimensions(dimToUpdate) - 1;
end
end
end
sample_data{k}.dimensions(distAlongBeamsIdx) = [];

Beam2EnuComment = [Beam2EnuComment ' DIST_ALONG_BEAMS is not used by any variable left and has been removed.'];
end

if ~isfield(sample_data{k}, 'history')
sample_data{k}.history = sprintf('%s - %s', datestr(now_utc, readProperty('exportNetCDF.dateFormat')), Beam2EnuComment);
else
Expand Down
45 changes: 28 additions & 17 deletions Preprocessing/salinityPP.m
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@

cndc = sam.variables{cndcIdx}.data;
temp = sam.variables{tempIdx}.data;

% pressure information used for Salinity computation is from the
% PRES or PRES_REL variables in priority
if isPresVar
if presRelIdx > 0
presRel = sam.variables{presRelIdx}.data;
Expand All @@ -109,28 +112,36 @@
presName = 'PRES substracting a constant value 10.1325 dbar for nominal atmospheric pressure';
end
else
% when no pressure variable exists, we use depth information either
% from the DEPTH variable or from the instrument_nominal_depth
% global attribute
if depthIdx > 0
% with depth data
depth = sam.(depthType){depthIdx}.data;
if ~isempty(sam.geospatial_lat_min) && ~isempty(sam.geospatial_lat_max)
% compute depth with Gibbs-SeaWater toolbox
% relative_pressure ~= gsw_p_from_z(-depth, latitude)
if sam.geospatial_lat_min == sam.geospatial_lat_max
presRel = gsw_p_from_z(-depth, sam.geospatial_lat_min);
else
meanLat = sam.geospatial_lat_min + ...
(sam.geospatial_lat_max - sam.geospatial_lat_min)/2;
presRel = gsw_p_from_z(-depth, meanLat);
end
presName = 'DEPTH';
presName = 'DEPTH';
else
% with nominal depth information
depth = sam.instrument_nominal_depth*ones(size(temp));
presName = 'instrument_nominal_depth';
end

% pressure information needed for Salinity computation is either
% retrieved from gsw_p_from_z when latitude is available or by
% simply assuming 1dbar ~= 1m
if ~isempty(sam.geospatial_lat_min) && ~isempty(sam.geospatial_lat_max)
% compute depth with Gibbs-SeaWater toolbox
% relative_pressure ~= gsw_p_from_z(-depth, latitude)
if sam.geospatial_lat_min == sam.geospatial_lat_max
presRel = gsw_p_from_z(-depth, sam.geospatial_lat_min);
else
% without latitude information, we assume 1dbar ~= 1m
presRel = depth;
presName = 'DEPTH (assuming 1 m ~ 1 dbar)';
meanLat = sam.geospatial_lat_min + ...
(sam.geospatial_lat_max - sam.geospatial_lat_min)/2;
presRel = gsw_p_from_z(-depth, meanLat);
end

else
presRel = sam.instrument_nominal_depth*ones(size(temp));
presName = 'instrument_nominal_depth (assuming 1 m ~ 1 dbar)';
% without latitude information, we assume 1dbar ~= 1m
presRel = depth;
presName = [presName ' (assuming 1 m ~ 1 dbar)'];
end
end

Expand Down
17 changes: 13 additions & 4 deletions Util/fastSaveas.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,23 @@ function fastSaveas( hFig, hPanel, fileDestination )
%FASTSAVEAS is a faster alternative to saveas.
% It is used to save diagnostic plots when exporting netCDF files.

drawnow;

% preserve the color scheme
set(hFig, 'InvertHardcopy', 'off');

drawnow;

% force figure full screen
frame_h = get(handle(hFig), 'JavaFrame');
set(frame_h, 'Maximized', 1);
try
warning('off', 'MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');
frame_h = get(handle(hFig), 'JavaFrame');
set(frame_h, 'Maximized', 1);
catch
disp(['Warning : JavaFrame feature not supported. Figure is going full ' ...
'screen using normalised units which does not give best results.']);
oldUnits = get(hFig, 'Units');
set(hFig, 'Units', 'norm', 'Pos', [0, 0, 1, 1]);
set(hFig, 'Units', oldUnits);
end

% screencapture creates an image of what is really displayed on
% screen.
Expand Down
2 changes: 1 addition & 1 deletion imosToolbox.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function imosToolbox(auto, varargin)
end

% Set current toolbox version
toolboxVersion = ['2.5.17 - ' computer];
toolboxVersion = ['2.5.18 - ' computer];

switch auto
case 'auto', autoIMOSToolbox(toolboxVersion, varargin{:});
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 65452f9

Please sign in to comment.