Newer
Older
function updateTsgStruct(hTsgGUI)
%
% This function is called after reading data and update tsg structure
% with common values
%
% Input
% -----
% hTsgGUI ............ Handel to the main user interface
%
% $Id$
% Get the data from the application GUI
% -------------------------------------
tsg = getappdata( hTsgGUI, 'tsg_data');
% get min and max values for position and set to globals attributes
% -----------------------------------------------------------------
tsg.SOUTH_LATX = min(tsg.LATX);
tsg.NORTH_LATX = max(tsg.LATX);
tsg.WEST_LONX = min(tsg.LONX);
tsg.EAST_LONX = max(tsg.LONX);
% get date start and end value and set to globals attributes
% -----------------------------------------------------------------
date = datestr(min(tsg.DAYD),30);
date = datestr(max(tsg.DAYD),30);
tsg.DATE_END = [date(1:8) date(10:15)];
% Compute ship velocity from positions if sog not available
% ---------------------------------------------------------
if isempty(tsg.SPDC)
range = m_lldist(tsg.LONX,tsg.LATX);
ind = size(tsg.DAYD);
for i=1:length(tsg.DAYD)-1
tsg.SPDC(i) = range(i) / ((tsg.DAYD(i+1)-tsg.DAYD(i)) * 24 * 1.854);
end
tsg.SPDC = [tsg.SPDC';0];
end
% Initialise ADJUSTED variables if empty
% --------------------------------------
if isempty( tsg.SSPS_ADJUSTED ) && ~isempty( tsg.SSPS )
tsg.SSPS_ADJUSTED = tsg.SSPS;
tsg.SSPS_ADJUSTED_QC = tsg.SSPS_QC;
tsg.SSPS_ADJUSTED_ERROR = NaN * ones( size( tsg.SSPS ));
elseif isempty( tsg.SSPS )
msgbox('You must initialise the tsg.SSPS variable',...
'function ''updateTsgStruct''', ....
'warn', 'modal');
end
if isempty( tsg.SSJT_ADJUSTED ) && ~isempty( tsg.SSJT )
tsg.SSJT_ADJUSTED = tsg.SSJT;
tsg.SSJT_ADJUSTED_QC = tsg.SSJT_QC;
tsg.SSJT_ADJUSTED_ERROR = NaN * ones( size( tsg.SSJT ));
elseif isempty( tsg.SSJT )
msgbox('You must initialise the tsg.SSJT variable',...
'function ''updateTsgStruct''', ....
'warn', 'modal');
end
if isempty( tsg.SSPS_ADJUSTED ) && ~isempty( tsg.SSPS )
tsg.SSPT_ADJUSTED = tsg.SSPT;
tsg.SSPT_ADJUSTED_QC = tsg.SSPT_QC;
tsg.SSPT_ADJUSTED_ERROR = NaN * ones( size( tsg.SSPS ));
end
% Save tsg structure
% ------------------
setappdata( hTsgGUI, 'tsg_data', tsg);