diff --git a/tsg_util/minSpeedQC.m b/tsg_util/minSpeedQC.m new file mode 100644 index 0000000000000000000000000000000000000000..901674bd6daddf53c0f74e6ed5520d58edb33ece --- /dev/null +++ b/tsg_util/minSpeedQC.m @@ -0,0 +1,46 @@ +function minSpeedQC(hMainFig) +% +% This function is called after option/preferences menu has been activated +% and flag salinity data where ship speed < min as HARBOUR if test is on +% +% Input +% ----- +% hMainFig ............ Handle to the main user interface +% +% problem: the QC flag counter in 'Validation Codes' window +% is not updated after the test is applied +% + + +% Get the data from the application GUI +% ------------------------------------- +tsg = getappdata( hMainFig, 'tsg_data'); + +% Get HARBOUR code value +% ---------------------- +harbourCode = tsg.qc.hash.HARBOUR.code; + +% get preference choice for ship speed test +% ----------------------------------------- +test = tsg.preference.ship_speed_test; + +if (test==2) + + speed_min_string = tsg.preference.ship_speed_min_string; + speed_min_choice = tsg.preference.ship_speed_min; + speed_min=str2double(speed_min_string(speed_min_choice)); + + % Set salinity QC to HARBOUR for ship speed < speed_min + % ----------------------------------------------------- + ind = find(tsg.SPDC < speed_min); + if ~isempty( ind ) + tsg.SSPS_QC(ind) = castByteQC( harbourCode, ind ); + end + +end + +% Save tsg structure +% ------------------ +setappdata( hMainFig, 'tsg_data', tsg); + +end diff --git a/tsg_util/preferencesForm.m b/tsg_util/preferencesForm.m index b9370e6fec28bb176860af98ada6fa7d4f7c0b1e..0bb270bd69078a4a5e0e8acc4a16129d18070b2c 100644 --- a/tsg_util/preferencesForm.m +++ b/tsg_util/preferencesForm.m @@ -108,6 +108,70 @@ if bottom < .1 left = left + inc_x; end +% display ship speed test text +% ---------------------------- +uicontrol(... + 'Parent', hPreferencesFig, ... + 'Units', 'normalized', ... + 'Style', 'Text', ... + 'Fontsize', tsg.fontSize-1, ... + 'HorizontalAlignment', 'left', ... + 'Position',[left, bottom, length, height], ... + 'TooltipString', 'enable/disable ship speed test', ... + 'String', 'Ship Speed Test'); + +% display ship speed test uicontrol +% --------------------------------- +uicontrol(... + 'Parent', hPreferencesFig, ... + 'Units', 'normalized', ... + 'BackgroundColor', 'w', ... + 'Style', 'popupmenu', ... + 'Fontsize', tsg.fontSize-2, ... + 'HorizontalAlignment', 'right', ... + 'Position', [left + length, bottom, length, height], ... + 'String', tsg.preference.ship_speed_test_string, ... + 'Value', tsg.preference.ship_speed_test, ... + 'Tag', 'PREFERENCES_SHIP_SPEED_TEST'); + +bottom = bottom - inc_y - height; +if bottom < .1 + bottom = 0.95; + left = left + inc_x; +end + +% display ship speed min text +% ----------------------------- +uicontrol(... + 'Parent', hPreferencesFig, ... + 'Units', 'normalized', ... + 'Style', 'Text', ... + 'Fontsize', tsg.fontSize-1, ... + 'HorizontalAlignment', 'left', ... + 'Position',[left, bottom, length, height], ... + 'TooltipString', 'select ship speed min (knots)', ... + 'String', 'Ship Speed Min'); + +% display ship speed min uicontrol +% -------------------------------- +uicontrol(... + 'Parent', hPreferencesFig, ... + 'Units', 'normalized', ... + 'BackgroundColor', 'w', ... + 'Style', 'popupmenu', ... + 'Fontsize', tsg.fontSize-2, ... + 'HorizontalAlignment', 'right', ... + 'Position', [left + length, bottom, length, height], ... + 'String', tsg.preference.ship_speed_min_string, ... + 'Value', tsg.preference.ship_speed_min, ... + 'Tag', 'PREFERENCES_SHIP_SPEED_MIN'); + +bottom = bottom - inc_y - height; +if bottom < .1 + bottom = 0.95; + left = left + inc_x; +end + % display connected line text % ------------------------- uicontrol(... @@ -152,8 +216,8 @@ if bottom < .1 left = left + inc_x; end -% display connected line text -% ------------------------- +% display coefficient type text +% ----------------------------- uicontrol(... 'Parent', hPreferencesFig, ... 'Units', 'normalized', ... @@ -164,8 +228,8 @@ uicontrol(... 'TooltipString', 'select coefficients type', ... 'String', 'Coefficients type'); -% display connected line uicontrol -% -------------------------------- +% display coefficient type uicontrol +% ---------------------------------- uicontrol(... 'Parent', hPreferencesFig, ... 'Units', 'normalized', ... @@ -244,6 +308,10 @@ uiwait(hPreferencesFig); get(prefs.PREFERENCES_LEVITUS_VALUE, 'value'); tsg.preference.levitus_depth_value = ... get(prefs.PREFERENCES_LEVITUS_DEPTH, 'value'); + tsg.preference.ship_speed_test = ... + get(prefs.PREFERENCES_SHIP_SPEED_TEST, 'value'); + tsg.preference.ship_speed_min = ... + get(prefs.PREFERENCES_SHIP_SPEED_MIN, 'value'); tsg.preference.plot_connected_value = ... get(prefs.PREFERENCES_PLOT_CONNECTED_LINE, 'value'); tsg.preference.coeff_type_value = ... @@ -257,7 +325,11 @@ uiwait(hPreferencesFig); % ------------------------------ updateTsgStructWithCalCoeff(hTsgGUI); + % apply ship speed QC + % ------------------- + minSpeedQC(hTsgGUI); + % close windows (replace call to uiresume(hHeaderFig)) % ---------------------------------------------------- close(hPreferencesFig); diff --git a/tsg_util/tsg_preferences.m b/tsg_util/tsg_preferences.m index 8d3e6957e05d1e4ea8ed9eba9147860e24aaaeb9..456edd2738e1ec02352b00d73512721871c5f78d 100644 --- a/tsg_util/tsg_preferences.m +++ b/tsg_util/tsg_preferences.m @@ -135,7 +135,10 @@ end preference.levitus_value = 2; % WOA05 preference.levitus_depth_string = {'0','10'}; preference.levitus_depth_value = 1; - preference.ship_speed = 1; + preference.ship_speed_test_string= {'none','automatic'}; + preference.ship_speed_test = 1; % no test on ship speed + preference.ship_speed_min_string = {'1','3','5'}; + preference.ship_speed_min = 1; preference.plot_connected_string = {'none', '-', '--', ':', '-.'}; preference.plot_connected_value = 1; % 0, line not connected preference.coeff_type_string = {'use A-D', 'use G-J'};