function updateTsgStruct(hMainFig) % % This function is called after reading data and update tsg structure % with common values % % Input % ----- % hMainFig ............ Handel to the main user interface % % $Id$ % Compute ship velocity from positions if sog not available % Must be done first as we use getappdata and setappdata within % the function % --------------------------------------------------------- shipVelocity( hMainFig ); % Get the data from the application GUI % ------------------------------------- tsg = getappdata( hMainFig, 'tsg_data'); nPARA = 2; PARA = ['SSPS'; 'SSJT']; % Get NO_CONTROL and INTERPOLATED_VALUE codes % ------------------------------------------- NO_CONTROL = get(tsg.qc.hash, 'NO_CONTROL', 'code'); % 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); tsg.DATE_START = [date(1:8) date(10:15)]; date = datestr(max(tsg.DAYD),30); tsg.DATE_END = [date(1:8) date(10:15)]; % Variables must exists % --------------------- for i = 1: nPARA para1 = PARA(i,:); if ~isempty( tsg.(para1) ) && isempty( tsg.([para1 '_QC']) ) % If QC variables are emptied, fill them with NO_CONTROL code value % ----------------------------------------------------------------- tsg.([para1 '_QC']) = castByteQC( NO_CONTROL, tsg.DAYD ); end end % Empty variables filled with NaN % ------------------------------- names = fieldnames( tsg ); for i = 1: length(names) para = char( names(i) ); if ~isstruct( tsg.(para) ) && ~isempty( tsg.(para) ) A = tsg.(para); ind = find( isnan( A ) == 0 ); if isempty( ind ) tsg.(para) = []; end end end % Initialise 'variables_LINCOEF' % ------------------------------- if isempty(tsg.SSJT_LINCOEF) tsg.SSJT_LINCOEF(1) = 1; tsg.SSJT_LINCOEF(2) = 0; end if isempty(tsg.CNDC_LINCOEF) tsg.CNDC_LINCOEF(1) = 1; tsg.CNDC_LINCOEF(2) = 0; end if isempty(tsg.SSTP_LINCOEF) tsg.SSTP_LINCOEF(1) = 1; tsg.SSTP_LINCOEF(2) = 0; end % Save tsg structure % ------------------ setappdata( hMainFig, 'tsg_data', tsg); end