Skip to content
Snippets Groups Projects
Commit 88eb57bd authored by jacques.grelet_ird.fr's avatar jacques.grelet_ird.fr
Browse files

Gael Alory

- correction d'un bug qui apparaissait lors de la lecture des fichiers bouteilles de petite taille
- gestion dans le calcul de vitesse des valeurs trop grandes apparaissant lors d'un shift brutal en lon/lat 
parent ff253b83
No related branches found
No related tags found
No related merge requests found
...@@ -19,9 +19,9 @@ switch nPlot ...@@ -19,9 +19,9 @@ switch nPlot
if ~isempty( tsg.([SAMPLE '_EXT']) ) if ~isempty( tsg.([SAMPLE '_EXT']) )
% Plot circle for WS data % Plot squares for WS data
% ----------------------- % -----------------------
ind = 1: length( tsg.([SAMPLE '_EXT_TYPE'])); ind = 1: size( tsg.([SAMPLE '_EXT_TYPE']),1);
indWS = strmatch( 'WS', tsg.([SAMPLE '_EXT_TYPE']), 'exact'); indWS = strmatch( 'WS', tsg.([SAMPLE '_EXT_TYPE']), 'exact');
if ~isempty(ind) if ~isempty(ind)
plot_Tsg( hMainFig, hPlotAxes, 1,... plot_Tsg( hMainFig, hPlotAxes, 1,...
...@@ -30,7 +30,7 @@ switch nPlot ...@@ -30,7 +30,7 @@ switch nPlot
[SAMPLE '_EXT_1'],'','none','square',5); [SAMPLE '_EXT_1'],'','none','square',5);
end end
% Plot squares for CTD, ARGO, etc. data % Plot circles for CTD, ARGO, etc. data
% ------------------------------------- % -------------------------------------
indEXT = setxor(ind, indWS); indEXT = setxor(ind, indWS);
if ~isempty(indEXT) if ~isempty(indEXT)
......
...@@ -14,55 +14,75 @@ tsg = getappdata( hMainFig, 'tsg_data'); ...@@ -14,55 +14,75 @@ tsg = getappdata( hMainFig, 'tsg_data');
tsgNames = fieldnames(tsg); tsgNames = fieldnames(tsg);
nbFieldNames = length( tsgNames ); nbFieldNames = length( tsgNames );
% Record number
% -------------
tsgLength = length(tsg.DAYD);
% Test for bad velocity. % Test for bad velocity.
% Suppress the bad records % Suppress the bad records
% ------------------------ % ------------------------
nBadVelocity = 0; nBadVelocity = 0;
indBadVelocity = 1; indBadVelocity = 1;
indStart = 1;
velocity = nan*ones(tsgLength,1);
while ~isempty( indBadVelocity ) while ~isempty( indBadVelocity )
% Record number % Spherical earth distance in km - Velocity in knots
% ------------- % --------------------------------------------------
tsgLength = length(tsg.DAYD); range = m_lldist(tsg.LONX(indStart:tsgLength),tsg.LATX(indStart:tsgLength));
velocity(indStart:tsgLength) = [range;0] ./ ((circshift(tsg.DAYD(indStart:tsgLength),-1)...
% Spherical earth distance in km - Velocity in knots -tsg.DAYD(indStart:tsgLength)) * 24 * 1.854);
% --------------------------------------------------
range = m_lldist(tsg.LONX,tsg.LATX); % Find velocity > 50 knots
ind = size(tsg.DAYD); % ------------------------
velocity = zeros(size(ind)); indBadVelocity = find( velocity(indStart:tsgLength) > 50 );
for i = 1:tsgLength-1
velocity(i) = range(i) / ((tsg.DAYD(i+1)-tsg.DAYD(i)) * 24 * 1.854); if ~isempty( indBadVelocity )
end
velocity = [velocity';0]; nextBad=circshift(indBadVelocity,-1)-indBadVelocity;
% Find velocity > 50 knots if (nextBad(1)==1)
% ------------------------
indBadVelocity = find( velocity > 50 ); % Case when one bad position lead to 2 bad velocities
% ---------------------------------------------------
if ~isempty( indBadVelocity ) indBadVelocity = indBadVelocity(1) + 1;
% Keep only the first indice. One bad position lead to 2 bad velocities % Delete bad record
% --------------------------------------------------------------------- % -----------------
indBadVelocity = indBadVelocity(1) + 1; for i = 1 : nbFieldNames
% Store the number of bad Velocity para = char( tsgNames{i} );
% --------------------------------
nBadVelocity = nBadVelocity + 1; % Find array of length DAYD in the TSG structure
% ----------------------------------------------
% Delete bad record if length( tsg.(para) ) == tsgLength
% ----------------- tsg.(para)(indStart+indBadVelocity-1,:) = [];
for i = 1 : nbFieldNames end
para = char( tsgNames{i} ); end
% Find array of length DAYD in the TSG structure tsgLength=tsgLength-1;
% ---------------------------------------------- indStart=indStart+indBadVelocity-2;
if length( tsg.(para) ) == tsgLength
tsg.(para)(indBadVelocity,:) = []; else
end
% Case when sudden shift in position: apply NaN to velocity
% ---------------------------------------------------------
indBadVelocity = indBadVelocity(1);
velocity(indStart+indBadVelocity-1)=nan;
indStart=indStart+indBadVelocity;
end
% Store the number of bad Velocity
% --------------------------------
nBadVelocity = nBadVelocity + 1;
end end
end
end end
% Keep the number of data not in increasing date % Keep the number of data not in increasing date
...@@ -72,7 +92,7 @@ tsg.report.badvelocity = nBadVelocity; ...@@ -72,7 +92,7 @@ tsg.report.badvelocity = nBadVelocity;
% Keep ship velocity from positions if sog not available % Keep ship velocity from positions if sog not available
% ------------------------------------------------------ % ------------------------------------------------------
if isempty(tsg.SPDC) if isempty(tsg.SPDC)
tsg.SPDC = velocity; tsg.SPDC = velocity(1:tsgLength);
end end
% Save tsg structure % Save tsg structure
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment