function updateTsgStructWithSmoothVars(hMainFig)
%
% This function is called after change option/parameter from preferenceForm
% or tsg_preference
%
% Input
% -----
% hMainFig ............ Handle to the main user interface
%
% $Id$


% Get the data from the application GUI
% -------------------------------------
tsg = getappdata( hMainFig, 'tsg_data');

% use in tsg-average by tsg.cst.TSG_DT_SMOOTH
% convert this value minute with datenum
% ---------------------------------------------
hour = floor(str2double(tsg.preference.dt_smooth)/60);
min = mod(str2double(tsg.preference.dt_smooth), 60);
smooth = datenum(0, 0, 0, hour, min , 0);
tsg.cst.TSG_DT_SMOOTH = smooth;

% Salinity, in 1 hour interval, should not depart the average for more
% than SAL_STD_MAX standard deviation
% -------------------------------------
tsg.SSPS_STDMAX = str2double(tsg.preference.ssps_stdmax);

% Maximum time difference between tsg data and water sample used to
% compute the difference 
% convert this value minute with datenum
% ------------------------------------
hour = floor(str2double(tsg.preference.ws_timediff)/60);
min = mod(str2double(tsg.preference.ws_timediff), 60);
timediff = datenum(0, 0, 0, hour, min , 0);
tsg.cst.TSG_WS_TIMEDIFF = timediff;

% uncomment for debug
% -------------------
% tsg.cst
% tsg.SSPS_STDMAX

% Save tsg structure
% ------------------
setappdata( hMainFig, 'tsg_data', tsg);

end